@openchambery/web 2.1.7-beta.8 → 2.1.7

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 (118) hide show
  1. package/dist/assets/{AgentAvatar-Ah1nMt7y.js → AgentAvatar-CAR4F5Sn.js} +1 -1
  2. package/dist/assets/AssistantView-DgjRT4M4.js +3 -0
  3. package/dist/assets/{DiagramView-CIrqRq87.js → DiagramView-Dd_3w4Hk.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-BssISEuf.js → FadeInOnReveal-CCVddfP5.js} +1 -1
  5. package/dist/assets/{Icon-DewMAW7N.js → Icon-DDB7S6Vz.js} +1 -1
  6. package/dist/assets/{ImageLoadingPlaceholder-CN2xfGIz.js → ImageLoadingPlaceholder-C6fDEcU1.js} +1 -1
  7. package/dist/assets/{LoadingImage-FfyUmEl3.js → LoadingImage-ByBH-5WW.js} +1 -1
  8. package/dist/assets/MarkdownRenderer-YbG78e0Y.js +2 -0
  9. package/dist/assets/{MarkdownRendererImpl-yNmDOCqY.js → MarkdownRendererImpl-BXgUthom.js} +1 -1
  10. package/dist/assets/{MarkstreamRendererImpl-K-0Id7Ku.js → MarkstreamRendererImpl-5W9P9U-w.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-ChIgOFsb.js → MobileDetailNavigation-Bk6C9i9l.js} +1 -1
  12. package/dist/assets/MobileShareBridge-B5nF-gT6.js +4 -0
  13. package/dist/assets/MobileTabPageHeader-D7r6pKco.js +2 -0
  14. package/dist/assets/{MultiRunWindow-ChzJsszv.js → MultiRunWindow-CpuFaAyG.js} +1 -1
  15. package/dist/assets/OnboardingScreen-DINUboLT.js +1 -0
  16. package/dist/assets/{OverlayScrollbar-C24-p2ns.js → OverlayScrollbar-BkxmoyYl.js} +1 -1
  17. package/dist/assets/{SettingsView-DcVf0omS.js → SettingsView--C3eizlJ.js} +9 -9
  18. package/dist/assets/{SettingsWindow-DJX-BguH.js → SettingsWindow-DYUvg92F.js} +1 -1
  19. package/dist/assets/{TerminalView-qHVQuT4W.js → TerminalView-BqAariXf.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-51bjEMV2.js → ToolOutputDialog-D6lPUZrN.js} +4 -4
  21. package/dist/assets/{appThemeRegistry-C2wlPLl2.js → appThemeRegistry-wWazoyp8.js} +1 -1
  22. package/dist/assets/{button-kJNzMb1G.js → button-DymteyMv.js} +1 -1
  23. package/dist/assets/{collapsible-MInYZ7dA.js → collapsible-Dzp5rO0Q.js} +1 -1
  24. package/dist/assets/{desktopHosts-BKeEWmL5.js → desktopHosts-DSBZ-9-L.js} +1 -1
  25. package/dist/assets/{desktopRelayRestore-FWm2fXr6.js → desktopRelayRestore-DK8TzHRx.js} +1 -1
  26. package/dist/assets/{diagram-BDSPghN-.js → diagram-CQs9px6y.js} +1 -1
  27. package/dist/assets/dialog-DfUeXqdE.js +1 -0
  28. package/dist/assets/dropdown-menu.styles-B6YMNOZz.js +1 -0
  29. package/dist/assets/{es-CLTWsqOO.js → es-2YvsazK2.js} +1 -1
  30. package/dist/assets/{fileMentionTouchSelection-BNeSAMGV.js → fileMentionTouchSelection-CEIhM6Ov.js} +1 -1
  31. package/dist/assets/{fileQueries-Dhgypzyl.js → fileQueries-BGE5l3Jd.js} +1 -1
  32. package/dist/assets/{fr-BNyfwida.js → fr-Cy0M48Gw.js} +1 -1
  33. package/dist/assets/{gitApi-BLVAlsm6.js → gitApi-BP68uLBQ.js} +1 -1
  34. package/dist/assets/{image-loading-DLh8WsH4.js → image-loading-qNtUCy69.js} +1 -1
  35. package/dist/assets/{input-02eTmC8w.js → input-BvpZiRHI.js} +1 -1
  36. package/dist/assets/{insertionBoundaries-CzI5suHn.js → insertionBoundaries-BywXllQ9.js} +1 -1
  37. package/dist/assets/{ja-D7MYkMo9.js → ja-1zLWWJ2R.js} +1 -1
  38. package/dist/assets/{ko-CFNLrmLm.js → ko-BLk_5Dhc.js} +1 -1
  39. package/dist/assets/main-DSY3-ZQZ.js +2 -0
  40. package/dist/assets/{main-CvS2IhaX.js → main-DdyFxokk.js} +21 -21
  41. package/dist/assets/{markdownHeightCache-CAVQhVdd.js → markdownHeightCache-MW1NYOaG.js} +1 -1
  42. package/dist/assets/{mcpQueries-CePnLorS.js → mcpQueries-BaQ2_bdm.js} +1 -1
  43. package/dist/assets/miniChat-B43ASec3.js +2 -0
  44. package/dist/assets/mobile-DloCio4f.js +2 -0
  45. package/dist/assets/{multirun-ovS4Bbm-.js → multirun-Blywdd6A.js} +1 -1
  46. package/dist/assets/{persistence-DUPZl7Oy.js → persistence-B7ORJ371.js} +1 -1
  47. package/dist/assets/{pl-aKpW58gt.js → pl-BE8MC0XQ.js} +1 -1
  48. package/dist/assets/{platform-z2erC6Bs.js → platform-CiBU2bCp.js} +2 -2
  49. package/dist/assets/{projectMeta-CbfH4yH1.js → projectMeta-BwPtPeMh.js} +1 -1
  50. package/dist/assets/{pt-BR-MliQk6-s.js → pt-BR-ubhNymyH.js} +1 -1
  51. package/dist/assets/rasterizePng-CpK-xCkB.js +1 -0
  52. package/dist/assets/renderElectronMiniChatApp-DCRctqrx.js +2 -0
  53. package/dist/assets/renderMobileApp-DuFdSBXi.js +28 -0
  54. package/dist/assets/{runtimeConfig-n6finZKu.js → runtimeConfig-CqpbN2lM.js} +1 -1
  55. package/dist/assets/runtimeEndpointReset-bWBhgTs_.js +149 -0
  56. package/dist/assets/scheduledTaskNavigation-BnKGGUlX.js +1 -0
  57. package/dist/assets/sessionChangeSummary-BlR9MyHu.js +2 -0
  58. package/dist/assets/{sessionLookup-t2PmDc5y.js → sessionLookup-6gcNEZnB.js} +1 -1
  59. package/dist/assets/{sortable-tabs-strip-DSGwZHAT.js → sortable-tabs-strip-CWR8KhJB.js} +1 -1
  60. package/dist/assets/{speechSettingsQueries-Db4bQEB3.js → speechSettingsQueries-Bp5LgcR7.js} +3 -3
  61. package/dist/assets/src-C9BNQK0O.css +2 -0
  62. package/dist/assets/{store-D5OeM4wB.js → store-n-H5RvRn.js} +1 -1
  63. package/dist/assets/{terminalApi-BnjU_lmF.js → terminalApi-bN5IYQau.js} +1 -1
  64. package/dist/assets/{textarea-yLPH5NYp.js → textarea-ClPlugKE.js} +1 -1
  65. package/dist/assets/{tooltip-B3eYZnNS.js → tooltip-D-1Pgmq1.js} +1 -1
  66. package/dist/assets/{uk-8Ovv1FvC.js → uk-BNyyigDo.js} +1 -1
  67. package/dist/assets/{url-DAyfGWPH.js → url-nbXEti6c.js} +1 -1
  68. package/dist/assets/{useAppFontEffects-DCTrzwyi.js → useAppFontEffects-8UJ5f0dG.js} +53 -53
  69. package/dist/assets/{useAssistantUIStore-Dt0l5AKe.js → useAssistantUIStore-Dlvb7P0q.js} +1 -1
  70. package/dist/assets/{useDesktopWindowControlsLayout-ke94Hv1g.js → useDesktopWindowControlsLayout-B_hNd3pD.js} +1 -1
  71. package/dist/assets/{useEffectiveDirectory-B4sVUjJq.js → useEffectiveDirectory-DISvoVLe.js} +1 -1
  72. package/dist/assets/{useFontPreferences-B4Cgu3bS.js → useFontPreferences-6LD7d7hP.js} +1 -1
  73. package/dist/assets/useMobileNavigationStore-BE_8Q8WJ.js +417 -0
  74. package/dist/assets/useUIStore-CDMI_Yzu.js +1 -0
  75. package/dist/assets/{useWorkerHighlightedLines-C5DNvAv7.js → useWorkerHighlightedLines-BFygybD8.js} +1 -1
  76. package/dist/assets/{zh-CN-DYC-d6-i.js → zh-CN-CNWzMPgL.js} +1 -1
  77. package/dist/assets/{zh-TW-OPu9_qbz.js → zh-TW-DrZ9S1yn.js} +1 -1
  78. package/dist/index.html +9 -9
  79. package/dist/mini-chat.html +9 -9
  80. package/dist/mobile.html +9 -9
  81. package/package.json +1 -1
  82. package/server/lib/assistants/DOCUMENTATION.md +39 -0
  83. package/server/lib/assistants/harness.js +20 -7
  84. package/server/lib/assistants/harness.test.js +21 -0
  85. package/server/lib/assistants/routes.js +2 -1
  86. package/server/lib/assistants/service.js +76 -13
  87. package/server/lib/assistants/service.test.js +53 -0
  88. package/server/lib/content-search/DOCUMENTATION.md +46 -0
  89. package/server/lib/content-search/routes.test.js +22 -0
  90. package/server/lib/content-search/runtime.js +17 -4
  91. package/server/lib/content-search/runtime.test.js +96 -0
  92. package/server/lib/content-search/service.js +25 -5
  93. package/server/lib/content-search/service.test.js +37 -0
  94. package/server/lib/notifications/DOCUMENTATION.md +5 -0
  95. package/server/lib/opencode/feature-routes-runtime.js +1 -0
  96. package/server/lib/scheduled-tasks/DOCUMENTATION.md +25 -0
  97. package/server/lib/scheduled-tasks/run-history-store.js +18 -5
  98. package/server/lib/scheduled-tasks/run-history-store.test.js +51 -0
  99. package/server/lib/scheduled-tasks/runtime.js +70 -12
  100. package/server/lib/scheduled-tasks/runtime.test.js +131 -0
  101. package/dist/assets/AssistantView-Bv_1jeEl.js +0 -3
  102. package/dist/assets/MarkdownRenderer-B-RZ-kvn.js +0 -2
  103. package/dist/assets/MobileShareBridge-BbSG8OWt.js +0 -4
  104. package/dist/assets/MobileTabPageHeader-DiqtKl1z.js +0 -2
  105. package/dist/assets/OnboardingScreen-BjikXNcy.js +0 -1
  106. package/dist/assets/context-menu-BYq0LM7H.js +0 -1
  107. package/dist/assets/dropdown-menu.styles-BXvVFEkh.js +0 -1
  108. package/dist/assets/main-Dn4VuT9V.js +0 -2
  109. package/dist/assets/miniChat-BukDq4rF.js +0 -2
  110. package/dist/assets/mobile-DkbzWKbi.js +0 -2
  111. package/dist/assets/rasterizePng-DCmIQQsI.js +0 -1
  112. package/dist/assets/renderElectronMiniChatApp-D-Xn6ChB.js +0 -2
  113. package/dist/assets/renderMobileApp-OK6onFU-.js +0 -28
  114. package/dist/assets/runtimeEndpointReset-N0qY25Cm.js +0 -148
  115. package/dist/assets/sessionChangeSummary-DWDoDbDo.js +0 -2
  116. package/dist/assets/src-BfNXhJ7m.css +0 -2
  117. package/dist/assets/useMobileNavigationStore-BsQYzG-5.js +0 -417
  118. package/dist/assets/useUIStore-pl39iO82.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Q as t,X as n,Y as r,Z as i,et as a,it as o,rt as s}from"./vendor-base-ui-CdzJ6My_.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{f as l,r as u}from"./button-kJNzMb1G.js";import{t as d}from"./SettingsView-DcVf0omS.js";var f=c(),p=e(o(),1),m=s(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(a,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(t,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(n,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(i,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(r,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Q as t,X as n,Y as r,Z as i,et as a,it as o,rt as s}from"./vendor-base-ui-CdzJ6My_.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{f as l,r as u}from"./button-DymteyMv.js";import{t as d}from"./SettingsView--C3eizlJ.js";var f=c(),p=e(o(),1),m=s(),h=e=>{let o=(0,f.c)(19),{open:s,onOpenChange:c}=e,{t:h}=l(),_=p.useId(),v=g,y;o[0]===c?y=o[1]:(y=e=>{!e&&v()||c(e)},o[0]=c,o[1]=y);let b;o[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(a,{className:u(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),o[2]=b):b=o[2];let x;o[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),o[3]=x):x=o[3];let S;o[4]===h?S=o[5]:(S=h(`settings.window.description`),o[4]=h,o[5]=S);let C;o[6]!==_||o[7]!==S?(C=(0,m.jsx)(t,{id:_,className:`sr-only`,children:S}),o[6]=_,o[7]=S,o[8]=C):C=o[8];let w;o[9]===c?w=o[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),o[9]=c,o[10]=w);let T;o[11]!==_||o[12]!==C||o[13]!==w?(T=(0,m.jsxs)(n,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(i,{"aria-describedby":_,className:x,children:[C,w]})})]}),o[11]=_,o[12]=C,o[13]=w,o[14]=T):T=o[14];let E;return o[15]!==s||o[16]!==y||o[17]!==T?(E=(0,m.jsx)(r,{open:s,onOpenChange:y,children:T}),o[15]=s,o[16]=y,o[17]=T,o[18]=E):E=o[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{on as n}from"./persistence-DUPZl7Oy.js";import{it as r,nt as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{c as o,l as s,n as c}from"./useUIStore-pl39iO82.js";import{o as l}from"./terminalApi-BnjU_lmF.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-DbBrwBII.js";import{d as p,f as m,r as h,t as g}from"./button-kJNzMb1G.js";import{d as _}from"./useMobileNavigationStore-BsQYzG-5.js";import{n as v}from"./useThemeSystem-8jhE4Zyk.js";import{n as y}from"./Icon-DewMAW7N.js";import{i as b,t as x}from"./OverlayScrollbar-C24-p2ns.js";import{n as ee}from"./useRuntimeAPIs-Cx8S1HLz.js";import{n as S}from"./useEffectiveDirectory-B4sVUjJq.js";import{t as C}from"./sortable-tabs-strip-DSGwZHAT.js";import{n as w,t as T}from"./useFontPreferences-B4Cgu3bS.js";import{r as E}from"./projectActions-CWvNGKfA.js";var D=e(r(),1);function te(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function ne(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var re=e(i(),1),O=a(),k=null;function A(){return k||=d.load(),k}function ie(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var ae=D.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},g)=>{let{t:_}=m(),v=D.useRef(null),y=D.useRef(null),b=D.useRef(null),ee=D.useRef(null),S=D.useRef(n),C=D.useRef(r),w=D.useRef(null),T=D.useRef(``),E=D.useRef(null),te=D.useRef(!1),k=D.useRef(null),ae=D.useRef(!0),j=D.useRef(null),M=D.useRef(null),oe=D.useRef(0),se=D.useRef(null),N=D.useRef(null),P=D.useRef(!1),F=D.useRef(!1),ce=D.useRef(null),le=D.useRef(null),ue=D.useRef(null),I=D.useRef(``),de=D.useRef(null),fe=D.useRef(!c),pe=D.useRef(d),[,me]=D.useReducer(e=>e+1,0),[he,ge]=D.useReducer(e=>e+1,0);S.current=n,C.current=r;let _e=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),L=!!c;D.useEffect(()=>{if(!c){fe.current=!0,pe.current=d;return}!pe.current&&d&&(fe.current=!1),pe.current=d},[c,d]);let ve=D.useCallback(()=>{if(!L)return;let e=v.current,t=se.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[L]),R=D.useCallback(e=>{if(de.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),de.current=e;return}t.options&&(t.options.cursorBlink=e,de.current=e)}catch{}},[]),z=L&&_e,B=D.useCallback((e,t)=>{let n=z?N.current:se.current,r=v.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[z]),V=D.useCallback(()=>{if(L){B(),R(!0);return}b.current?.focus(),R(!0)},[B,R,L]),H=D.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),U=D.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),ye=D.useCallback(e=>{if(typeof window>`u`||z)return;ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null);let t=0,n=()=>{ue.current=window.setTimeout(()=>{ue.current=null;let r=H(e);if(!r){if(t+=1,t<3){n();return}return}let i=I.current;I.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&S.current(a.replace(/\r\n|\r|\n/g,`\r`)),U(e),I.current=``},t===0?0:24)};n()},[U,H,z]);D.useEffect(()=>{let e=v.current;if(!L||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}B()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,L,B]);let W=D.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),be=D.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=v.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),xe=D.useCallback(async()=>{if(typeof document>`u`)return;let e=W()||be();e.trim()&&await p(e)},[be,W]),Se=D.useCallback(()=>W().trim()?!0:!!be().trim(),[be,W]);D.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Se()&&(e.preventDefault(),xe())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[xe,Se]);let G=D.useCallback(()=>{T.current=``,E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null,te.current=!1,k.current=null},[]),K=D.useCallback(()=>{let e=ee.current,t=b.current,n=v.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=w.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(w.current=n,C.current(n.cols,n.rows))}catch{}},[]),q=D.useCallback(()=>{if(te.current)return;let e=b.current;if(!e){G();return}if(!T.current)return;let t=T.current;T.current=``,te.current=!0,e.write(t,()=>{te.current=!1,T.current&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())})},[G]),Ce=D.useCallback(()=>{E.current===null&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())},[q]),J=D.useCallback(e=>{e&&(T.current+=e,Ce())},[Ce]),we=D.useCallback(()=>{if(j.current?.(),j.current=null,M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),!c){oe.current=0;return}let e=v.current;if(!e)return;let t=b.current;if(!t)return;oe.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,p=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},m=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){m(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){L?B(n.clientX,n.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=p(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){m(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let g=e.style.touchAction,_=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=g,e.style.overscrollBehaviorY=_};return}let g=e=>{e.touches.length===1&&(m(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,m();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),h=d*(n+Math.min(r,Math.abs(d)/25)),g=h/f;l.velocity=l.velocity*.75+g*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),p(h)},y=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];L?B(t?.clientX,t?.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=p(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){m(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,y,h),e.addEventListener(`touchcancel`,y,h);let x=e.style.touchAction,ee=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,y,h),e.removeEventListener(`touchcancel`,y,h),e.style.touchAction=x,e.style.overscrollBehaviorY=ee}},[c,L,B,o]);D.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,p=null,m=v.current;if(!m)return;if(m.tabIndex=L?-1:0,L){let e=m.focus.bind(m),t=m;t.focus=((...e)=>{B()}),p=()=>{t.focus=e}}let h=()=>{R(!0)},g=()=>{R(!1)},_=e=>{let t=e.target;if(t&&m.contains(t)){if(L&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),B()},0),R(!1);return}if(c&&!fe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),R(!1);return}R(!0);return}R(!1)},x=()=>{R(!1)},C=null;return(async()=>{try{let p=await A();if(e)return;let _=ne(a,o,i,p,!1),v=new u(_);ae.current=!0,L&&(v.focus=()=>{});let x=v;if(typeof x.scrollToBottom==`function`){let e=x.scrollToBottom.bind(x);x.scrollToBottom=()=>{ae.current&&e()},l=()=>{x.scrollToBottom=e}}let w=new f;if(t=v,b.current=v,ee.current=w,v.loadAddon(w),v.open(m),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}ge(),de.current=!1,C=v.textarea??m.querySelector(`textarea`),C&&(C.addEventListener(`focus`,h),C.addEventListener(`blur`,g)),ve(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ve()}),r.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let T=ie(m);T?(T.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),y.current=T,me()):y.current=null,K();let E=w;typeof E.observeResize==`function`&&E.observeResize(),we(),s=[v.onData(e=>{S.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();ae.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){ae.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;ae.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(m),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,x),()=>{e=!0,j.current?.(),j.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,x),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,C&&(C.removeEventListener(`focus`,h),C.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),p?.(),t?.dispose(),b.current=null,ee.current=null,y.current=null,w.current=null,de.current=null,G()}},[ve,c,K,B,a,o,we,i,G,R,L]),D.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),w.current=null,K())},[e,he,K,G]),D.useEffect(()=>{l&&b.current&&V()},[l,V,e,he]),D.useEffect(()=>(we(),()=>{j.current?.(),j.current=null}),[we,e]),D.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){k.current!==null&&(e.reset(),G(),K());return}let n=k.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&J(r.map(e=>e.data).join(``)),k.current=t[t.length-1].id},[t,he,J,K,G]),D.useImperativeHandle(g,()=>({focus:()=>{V()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[V,K,G]);let Y=D.useCallback(e=>{if(!L)return;let t=v.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[L]),X=D.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(le.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){P.current=!0;return}if(!n&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertText`&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertLineBreak`){if(P.current)return;e.preventDefault(),S.current(`\r`),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`deleteContentBackward`){if(P.current)return;e.preventDefault(),S.current(``),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0}},[]),Z=D.useCallback(e=>{let t=e.currentTarget;if(le.current=typeof performance<`u`?performance.now():Date.now(),P.current)return;if(F.current){let e=ce.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){F.current=!1,U(t);return}F.current=!1}let n=H(t);if(!n)return;I.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),I.current=``},[U,H]),Te=D.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Se()){e.preventDefault(),xe();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(String.fromCharCode(t.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(`\x1B`+e.key),U(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),S.current(i),U(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=ce.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),S.current(`\r`),U(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;H(a)||S.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=le.current;t&&s-t<50||(e.preventDefault(),S.current(e.key),F.current=!0,ce.current={type:`keydown-text`,at:s})}ye(a)},[U,xe,Se,H,ye]),Ee=D.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||ye(t)},[ye]),De=D.useCallback(e=>{let t=e.currentTarget;P.current=!1;let n=e.data||H(t);if(le.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),ce.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0},[U,H]),Oe=D.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;S.current(n)},[]),ke={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,O.jsxs)(`div`,{ref:v,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":L?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!L||c)&&!Se()){let t=e.touches?.[0];B(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(L){if(Se())return;B(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&Se()&&xe()},onTouchEnd:()=>{!c&&Se()&&xe()},children:[L&&typeof document<`u`?(0,re.createPortal)((0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{ref:N,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`block`:`none`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe}),(0,O.jsx)(`textarea`,{ref:se,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`none`:`block`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe})]}),document.body):null,y.current&&!c?(0,O.jsx)(x,{containerRef:y,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});ae.displayName=`TerminalViewport`;var j=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),M=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,oe=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,se=/Serving HTTP on .*? port (\d{2,5})/i,N=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),P=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(N.has(e)){t=t.slice(0,-1);continue}break}return t},F=e=>{let t=P(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},ce=e=>{if(!e)return null;let t=e.replace(j,``),n=t.match(se);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{on as n}from"./persistence-B7ORJ371.js";import{it as r,nt as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{c as o,l as s,n as c}from"./useUIStore-CDMI_Yzu.js";import{o as l}from"./terminalApi-bN5IYQau.js";import{n as u,r as d,t as f}from"./vendor-ghostty-web-DbBrwBII.js";import{d as p,f as m,r as h,t as g}from"./button-DymteyMv.js";import{d as _}from"./useMobileNavigationStore-BE_8Q8WJ.js";import{n as v}from"./useThemeSystem-8jhE4Zyk.js";import{n as y}from"./Icon-DDB7S6Vz.js";import{i as b,t as x}from"./OverlayScrollbar-BkxmoyYl.js";import{n as ee}from"./useRuntimeAPIs-Cx8S1HLz.js";import{n as S}from"./useEffectiveDirectory-DISvoVLe.js";import{t as C}from"./sortable-tabs-strip-CWR8KhJB.js";import{n as w,t as T}from"./useFontPreferences-6LD7d7hP.js";import{r as E}from"./projectActions-CWvNGKfA.js";var D=e(r(),1);function te(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function ne(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var re=e(i(),1),O=a(),k=null;function A(){return k||=d.load(),k}function ie(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var ae=D.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:d=!0},g)=>{let{t:_}=m(),v=D.useRef(null),y=D.useRef(null),b=D.useRef(null),ee=D.useRef(null),S=D.useRef(n),C=D.useRef(r),w=D.useRef(null),T=D.useRef(``),E=D.useRef(null),te=D.useRef(!1),k=D.useRef(null),ae=D.useRef(!0),j=D.useRef(null),M=D.useRef(null),oe=D.useRef(0),se=D.useRef(null),N=D.useRef(null),P=D.useRef(!1),F=D.useRef(!1),ce=D.useRef(null),le=D.useRef(null),ue=D.useRef(null),I=D.useRef(``),de=D.useRef(null),fe=D.useRef(!c),pe=D.useRef(d),[,me]=D.useReducer(e=>e+1,0),[he,ge]=D.useReducer(e=>e+1,0);S.current=n,C.current=r;let _e=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),L=!!c;D.useEffect(()=>{if(!c){fe.current=!0,pe.current=d;return}!pe.current&&d&&(fe.current=!1),pe.current=d},[c,d]);let ve=D.useCallback(()=>{if(!L)return;let e=v.current,t=se.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[L]),R=D.useCallback(e=>{if(de.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),de.current=e;return}t.options&&(t.options.cursorBlink=e,de.current=e)}catch{}},[]),z=L&&_e,B=D.useCallback((e,t)=>{let n=z?N.current:se.current,r=v.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[z]),V=D.useCallback(()=>{if(L){B(),R(!0);return}b.current?.focus(),R(!0)},[B,R,L]),H=D.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),U=D.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),ye=D.useCallback(e=>{if(typeof window>`u`||z)return;ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null);let t=0,n=()=>{ue.current=window.setTimeout(()=>{ue.current=null;let r=H(e);if(!r){if(t+=1,t<3){n();return}return}let i=I.current;I.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&S.current(a.replace(/\r\n|\r|\n/g,`\r`)),U(e),I.current=``},t===0?0:24)};n()},[U,H,z]);D.useEffect(()=>{let e=v.current;if(!L||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}B()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,L,B]);let W=D.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),be=D.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=v.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),xe=D.useCallback(async()=>{if(typeof document>`u`)return;let e=W()||be();e.trim()&&await p(e)},[be,W]),Se=D.useCallback(()=>W().trim()?!0:!!be().trim(),[be,W]);D.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{Se()&&(e.preventDefault(),xe())};return window.addEventListener(`openchamber:copy`,e),()=>{window.removeEventListener(`openchamber:copy`,e)}},[xe,Se]);let G=D.useCallback(()=>{T.current=``,E.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(E.current),E.current=null,te.current=!1,k.current=null},[]),K=D.useCallback(()=>{let e=ee.current,t=b.current,n=v.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=w.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(w.current=n,C.current(n.cols,n.rows))}catch{}},[]),q=D.useCallback(()=>{if(te.current)return;let e=b.current;if(!e){G();return}if(!T.current)return;let t=T.current;T.current=``,te.current=!0,e.write(t,()=>{te.current=!1,T.current&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())})},[G]),Ce=D.useCallback(()=>{E.current===null&&(typeof window<`u`?E.current=window.requestAnimationFrame(()=>{E.current=null,q()}):q())},[q]),J=D.useCallback(e=>{e&&(T.current+=e,Ce())},[Ce]),we=D.useCallback(()=>{if(j.current?.(),j.current=null,M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),!c){oe.current=0;return}let e=v.current;if(!e)return;let t=b.current;if(!t)return;oe.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,p=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},m=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){m(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){L?B(n.clientX,n.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=p(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){m(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let g=e.style.touchAction,_=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=g,e.style.overscrollBehaviorY=_};return}let g=e=>{e.touches.length===1&&(m(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,m();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),h=d*(n+Math.min(r,Math.abs(d)/25)),g=h/f;l.velocity=l.velocity*.75+g*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),p(h)},y=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];L?B(t?.clientX,t?.clientY):c&&!fe.current&&(fe.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=p(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){m(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,y,h),e.addEventListener(`touchcancel`,y,h);let x=e.style.touchAction,ee=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,j.current=()=>{m(),M.current!==null&&typeof window<`u`&&(window.clearTimeout(M.current),M.current=null),oe.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,y,h),e.removeEventListener(`touchcancel`,y,h),e.style.touchAction=x,e.style.overscrollBehaviorY=ee}},[c,L,B,o]);D.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,d=null,p=null,m=v.current;if(!m)return;if(m.tabIndex=L?-1:0,L){let e=m.focus.bind(m),t=m;t.focus=((...e)=>{B()}),p=()=>{t.focus=e}}let h=()=>{R(!0)},g=()=>{R(!1)},_=e=>{let t=e.target;if(t&&m.contains(t)){if(L&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),B()},0),R(!1);return}if(c&&!fe.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),R(!1);return}R(!0);return}R(!1)},x=()=>{R(!1)},C=null;return(async()=>{try{let p=await A();if(e)return;let _=ne(a,o,i,p,!1),v=new u(_);ae.current=!0,L&&(v.focus=()=>{});let x=v;if(typeof x.scrollToBottom==`function`){let e=x.scrollToBottom.bind(x);x.scrollToBottom=()=>{ae.current&&e()},l=()=>{x.scrollToBottom=e}}let w=new f;if(t=v,b.current=v,ee.current=w,v.loadAddon(w),v.open(m),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},d=()=>{e.renderScrollbar=t}}}ge(),de.current=!1,C=v.textarea??m.querySelector(`textarea`),C&&(C.addEventListener(`focus`,h),C.addEventListener(`blur`,g)),ve(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{ve()}),r.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let T=ie(m);T?(T.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),y.current=T,me()):y.current=null,K();let E=w;typeof E.observeResize==`function`&&E.observeResize(),we(),s=[v.onData(e=>{S.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();ae.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){ae.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;ae.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(m),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,x),()=>{e=!0,j.current?.(),j.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,x),s.forEach(e=>e.dispose()),l?.(),l=null,d?.(),d=null,C&&(C.removeEventListener(`focus`,h),C.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),p?.(),t?.dispose(),b.current=null,ee.current=null,y.current=null,w.current=null,de.current=null,G()}},[ve,c,K,B,a,o,we,i,G,R,L]),D.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),w.current=null,K())},[e,he,K,G]),D.useEffect(()=>{l&&b.current&&V()},[l,V,e,he]),D.useEffect(()=>(we(),()=>{j.current?.(),j.current=null}),[we,e]),D.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){k.current!==null&&(e.reset(),G(),K());return}let n=k.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&J(r.map(e=>e.data).join(``)),k.current=t[t.length-1].id},[t,he,J,K,G]),D.useImperativeHandle(g,()=>({focus:()=>{V()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[V,K,G]);let Y=D.useCallback(e=>{if(!L)return;let t=v.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[L]),X=D.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(le.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){P.current=!0;return}if(!n&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertText`&&r){if(P.current)return;e.preventDefault(),S.current(r),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`insertLineBreak`){if(P.current)return;e.preventDefault(),S.current(`\r`),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0;return}if(n===`deleteContentBackward`){if(P.current)return;e.preventDefault(),S.current(``),ce.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0}},[]),Z=D.useCallback(e=>{let t=e.currentTarget;if(le.current=typeof performance<`u`?performance.now():Date.now(),P.current)return;if(F.current){let e=ce.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){F.current=!1,U(t);return}F.current=!1}let n=H(t);if(!n)return;I.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),I.current=``},[U,H]),Te=D.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&Se()){e.preventDefault(),xe();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(String.fromCharCode(t.charCodeAt(0)-64)),U(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),S.current(`\x1B`+e.key),U(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),S.current(i),U(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=ce.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),S.current(`\r`),U(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;H(a)||S.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=le.current;t&&s-t<50||(e.preventDefault(),S.current(e.key),F.current=!0,ce.current={type:`keydown-text`,at:s})}ye(a)},[U,xe,Se,H,ye]),Ee=D.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||ye(t)},[ye]),De=D.useCallback(e=>{let t=e.currentTarget;P.current=!1;let n=e.data||H(t);if(le.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);S.current(r),U(t),ce.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},F.current=!0},[U,H]),Oe=D.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;S.current(n)},[]),ke={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,O.jsxs)(`div`,{ref:v,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":L?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!L||c)&&!Se()){let t=e.touches?.[0];B(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(L){if(Se())return;B(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&Se()&&xe()},onTouchEnd:()=>{!c&&Se()&&xe()},children:[L&&typeof document<`u`?(0,re.createPortal)((0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{ref:N,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`block`:`none`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe}),(0,O.jsx)(`textarea`,{ref:se,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":_(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...ke,display:z?`none`:`block`},onBlur:Y,onBeforeInput:X,onCompositionStart:()=>{P.current=!0},onInput:Z,onKeyDown:Te,onKeyUp:Ee,onCompositionEnd:De,onPaste:Oe})]}),document.body):null,y.current&&!c?(0,O.jsx)(x,{containerRef:y,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});ae.displayName=`TerminalViewport`;var j=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),M=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,oe=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,se=/Serving HTTP on .*? port (\d{2,5})/i,N=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),P=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(N.has(e)){t=t.slice(0,-1);continue}break}return t},F=e=>{let t=P(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},ce=e=>{if(!e)return null;let t=e.replace(j,``),n=t.match(se);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
2
2
  `);for(let e of r){if(!oe.test(e))continue;let t=Array.from(e.matchAll(M));if(t.length!==0)return F((t.find(e=>{try{return!!new URL(F(e[1])).port}catch{return!1}})??t[0])[1])}return null},le=async(e,n=1500)=>{if(!e||typeof window>`u`)return!1;let r;try{r=new URL(e)}catch{return!1}if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=r.hostname.toLowerCase();if(i!==`localhost`&&i!==`127.0.0.1`&&i!==`0.0.0.0`&&i!==`::1`&&i!==`::`)return!1;let a=new AbortController,o=window.setTimeout(()=>a.abort(),n);try{let e=await t(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:r.toString()}),cache:`no-store`,signal:a.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},ue={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},I={ctrl:`5`,cmd:`3`},de={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},fe={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},pe=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${I[t]}A`;case`arrow-down`:return`\u001b[1;${I[t]}B`;case`arrow-right`:return`\u001b[1;${I[t]}C`;case`arrow-left`:return`\u001b[1;${I[t]}D`}return ue[e]??null},me=()=>{let{t:e}=m(),{terminal:t,runtime:r}=ee(),{currentTheme:i}=v(),{monoFont:a}=T(),u=c(e=>e.terminalFontSize),d=c(e=>e.bottomTerminalHeight),f=c(e=>e.isBottomTerminalExpanded),{isMobile:p,isTablet:x,hasTouchOnlyPointer:ne}=b(),re=p||x,k=(re||ne)&&r.platform===`web`,A=r.platform!==`vscode`,ie=c(e=>e.showTerminalQuickKeysOnDesktop),j=!n()&&(re||ie),M=_(e=>e.currentSessionId),oe=_(e=>e.newSessionDraft),se=M!==null||oe?.open===!0,N=S()??null,P=w(e=>e.sessions),F=w(e=>e.hasHydrated),ue=w(e=>e.ensureDirectory),I=w(e=>e.createTab),me=w(e=>e.setActiveTab),he=w(e=>e.closeTab),ge=w(e=>e.setTabSessionId),_e=w(e=>e.setTabLifecycle),L=w(e=>e.setConnecting),ve=w(e=>e.appendToBuffer),R=w(e=>e.setTabPreviewUrl),z=w(e=>e.clearBuffer),B=c(e=>e.openContextPreview),V=D.useMemo(()=>{if(N)return P.get(N)},[P,N]),H=D.useMemo(()=>V?A?V.activeTabId??V.tabs[0]?.id??null:V.tabs[0]?.id??null:null,[V,A]),U=D.useMemo(()=>{if(V)return H?V.tabs.find(e=>e.id===H)??V.tabs[0]:V.tabs[0]},[V,H]),ye=D.useMemo(()=>(V?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?E[t.iconKey]??`terminal`:`terminal`;return(0,O.jsx)(y,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[V?.tabs,e]),W=U?.terminalSessionId??null,be=U?.lifecycle??`idle`,xe=U?.bufferChunks??[],Se=U?.isConnecting??!1,G=U?.previewUrl??null,[K,q]=D.useState(null),[Ce,J]=D.useState(!1),[we,Y]=D.useState(!1),[X,Z]=D.useState(null),[Te,Ee]=D.useState(!1),[De,Oe]=D.useState(0),ke=D.useRef(null),Ae=D.useRef(null),je=D.useRef(H),Me=D.useRef(W),Ne=D.useRef(N),Pe=D.useRef(null),Fe=D.useRef(null),Ie=D.useRef(!1),Le=D.useRef(!1),Re=D.useRef(null),ze=D.useRef(null),Be=D.useRef(new Set),Ve=D.useRef(!1),He=D.useRef(``),Ue=D.useRef(new Set),We=D.useRef(0),Ge=D.useCallback(()=>{He.current=``,Ue.current.clear(),We.current+=1},[]),Ke=D.useCallback(()=>{k||typeof document<`u`&&!document.hasFocus()||Pe.current?.focus()},[k]),qe=D.useCallback(()=>{k||Pe.current?.focus()},[k]);D.useEffect(()=>{if(!F||Ve.current)return;Ve.current=!0;let e=new Set;for(let[,t]of w.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Be.current=e},[F]);let Je=c(e=>e.activeMainTab),Ye=c(e=>e.isBottomTerminalOpen),Xe=c(e=>e.setBottomTerminalOpen),Ze=c(e=>e.setBottomTerminalExpanded),Qe=Je===`terminal`,Q=Qe||Ye,[$e,et]=D.useState(Q);D.useEffect(()=>{!Q||r.platform===`vscode`||l()},[Q,r.platform]),D.useEffect(()=>{Q&&et(!0)},[Q]),D.useEffect(()=>{Le.current=Q},[Q]),D.useEffect(()=>{Me.current=W},[W]),D.useEffect(()=>{je.current=H,Ge()},[H,Ge]),D.useEffect(()=>{Ne.current=N},[N]),D.useEffect(()=>{!j&&X!==null&&Z(null)},[j,X,Z]),D.useEffect(()=>{!W&&X!==null&&Z(null)},[W,X,Z]);let $=D.useCallback(()=>{ke.current?.(),ke.current=null,Ae.current=null,Re.current=null,Y(!1)},[]);D.useEffect(()=>()=>{$(),Me.current=null},[$]);let tt=D.useCallback((e,t,n)=>{if(!n)return;let r=`${He.current}${n}`.replace(/\r\n|\r/g,`
3
3
  `),i=r.split(`
4
4
  `),a=r.endsWith(`
@@ -1,10 +1,10 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{it as n,nt as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{_ as a}from"./useUIStore-pl39iO82.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as u,r as d,t as f}from"./button-kJNzMb1G.js";import{n as p,r as m}from"./rasterizePng-DCmIQQsI.js";import{n as h,t as g}from"./useThemeSystem-8jhE4Zyk.js";import{n as _}from"./Icon-DewMAW7N.js";import{s as v,v as y}from"./image-loading-DLh8WsH4.js";import{i as b,t as x}from"./appThemeRegistry-C2wlPLl2.js";import{n as S}from"./MarkdownRenderer-B-RZ-kvn.js";import{l as C}from"./markdown-worker-DFNZ3KJ_.js";import{n as w}from"./useEffectiveDirectory-B4sVUjJq.js";import{i as T,n as E}from"./markdownTheme-CV7_0QAL.js";import{t as D}from"./ImageLoadingPlaceholder-CN2xfGIz.js";import{_ as O,d as k,f as A,g as j,h as M,l as N,m as P,n as F,p as I,r as L,s as R,t as z,u as ee}from"./useWorkerHighlightedLines-C5DNvAv7.js";import{t as B}from"./vendor-tanstack-react-virtual-B_EO--9t.js";var V=o(),H=e(n(),1),U=i(),W=80,G=20,te=H.memo(e=>{let t=(0,V.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=h(),u;t[0]===l?u=t[1]:(u=E(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(ie).join(`
2
- `),t[2]=n,t[3]=f);let p=z(f,r);if(!(n.length>W)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==p||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==p||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,U.jsx)(re,{line:e,html:p?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=p,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=p,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,U.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let m;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(m=(0,U.jsx)(ne,{lines:n,highlighted:p,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=p,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=m):m=t[25],m});te.displayName=`VirtualizedCodeBlock`;var ne=H.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=H.useRef(null),s=`min(${e.length*G}px, ${r})`,c=B({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>G,overscan:20}),l=c.getVirtualItems();return(0,U.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,U.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,U.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,U.jsx)(re,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});ne.displayName=`VirtualizedRows`;var re=H.memo(e=>{let t=(0,V.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,U.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,U.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,U.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,U.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,U.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,U.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});re.displayName=`VirtualizedCodeBlock.Row`;function ie(e){return e.text}var ae=H.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=H.useRef(null),[o,s]=H.useState(null),c=H.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=H.useCallback(()=>{a.current?.expandAll()},[]),d=H.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,U.jsx)(`div`,{className:t,children:(0,U.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,U.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,U.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,U.jsxs)(`div`,{className:t,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,U.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(_,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,U.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(_,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,U.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,U.jsx)(L,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),oe=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},K=(e,t)=>new oe(e,t),se=e=>e instanceof oe,ce=e=>e+1,q=(e,t)=>e===t,J=e=>{let t=e.indexOf(`,`);if(t<0)throw K(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},le=e=>Promise.resolve().then(()=>J(e)),Y=1,ue=56,X=(e,t,n)=>Math.min(n,Math.max(t,e)),de=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=ue&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},fe=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},pe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=X(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:X(e.x,-a,a),y:X(e.y,-o,o)}},me=(e,t,n,r,i)=>{let a=X(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return pe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},he=(e,t,n)=>pe({...e,x:e.x+t.x,y:e.y+t.y},n),ge=(e,t,n,r,i,a)=>{let o=X(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return pe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Z=500,_e=24,ve=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Z,i=t.maxDistance??_e,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},ye=(e,t,n={})=>{ve(e,n),t()},be=e(r(),1);function xe(e,t,n,r,i){let a=e instanceof HTMLImageElement?e:e.querySelector(`img`);if(!a||!t.complete||!t.naturalWidth||!t.animate)return;let o=t.getBoundingClientRect(),s=a.getBoundingClientRect();if(!o.width||!o.height||!s.width||!s.height)return;let c=getComputedStyle(a),l=t.naturalWidth/t.naturalHeight,u=c.objectFit===`cover`?Math.max(s.width,s.height*l):Math.min(s.width,s.height*l),d=u/l,f=c.objectPosition.split(` `);if(!f.every(e=>e.endsWith(`%`)))return;let p=(s.width-u)*parseFloat(f[0])/100,m=(s.height-d)*parseFloat(f[1]??f[0])/100,h=s.left,g=s.top,_=s.right,v=s.bottom,y=c.borderRadius;for(let e=a.parentElement;e;e=e.parentElement){let t=getComputedStyle(e),n=e.getBoundingClientRect();[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowX)&&(h=Math.max(h,n.left),_=Math.min(_,n.right)),[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowY)&&(g=Math.max(g,n.top),v=Math.min(v,n.bottom)),n.width===s.width&&n.height===s.height&&t.borderRadius!==`0px`&&(y=t.borderRadius)}if(_<=h||v<=g)return;let b=document.createElement(`div`);b.dataset.mediaCropAnimation=``,b.setAttribute(`aria-hidden`,`true`),Object.assign(b.style,{position:`fixed`,left:`0`,top:`0`,overflow:`hidden`,pointerEvents:`none`,zIndex:`51`,contain:`paint`});let x=document.createElement(`img`);x.src=t.currentSrc||t.src,x.alt=``,Object.assign(x.style,{display:`block`,width:`${o.width}px`,height:`${o.height}px`,maxWidth:`none`,transformOrigin:`0 0`}),b.append(x),document.body.append(b);let S={transform:`translate(${o.left}px, ${o.top}px)`,width:`${o.width}px`,height:`${o.height}px`,borderRadius:`0px`},C={transform:`translate(${h}px, ${g}px)`,width:`${_-h}px`,height:`${v-g}px`,borderRadius:y},w={transform:`translate(0px, 0px) scale(1)`},T={transform:`translate(${s.left+p-h}px, ${s.top+m-g}px) scale(${u/o.width})`},E={duration:280,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`},D=t.style.visibility;t.style.visibility=`hidden`;let O=[b.animate(r?[S,C]:[C,S],E),x.animate(r?[w,T]:[T,w],E),n.animate({opacity:r?[1,0]:[0,1]},E)],k=!1,A=()=>{b.remove(),t.style.visibility=D,O.forEach(e=>e.cancel())};return Promise.all(O.map(e=>e.finished)).then(()=>{k||(i(),A())},()=>{k||(A(),i())}),()=>{k=!0,A()}}function Se(e,t,n,r,i=()=>{}){let a=e?.getBoundingClientRect(),o=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!o&&e?.isConnected&&t instanceof HTMLImageElement&&n&&a?.width&&a.height&&a.bottom>0&&a.top<window.innerHeight&&a.right>0&&a.left<window.innerWidth){let a=xe(e,t,n,r,i);if(a)return a}if(!document.startViewTransition||o||!e?.isConnected||!t||!n||!a?.width||!a.height||a.bottom<=0||a.top>=window.innerHeight||a.right<=0||a.left>=window.innerWidth){if(!n?.animate||o)return i(),()=>{};let e=n.animate({opacity:r?[1,0]:[0,1]},{duration:150,fill:`forwards`}),t=!1;return e.finished.then(()=>{t||i()},()=>{}),()=>{t=!0,e.cancel()}}let s=e.style.viewTransitionName,c=t.style.viewTransitionName,l=n.style.visibility,u=!1,d=`oc-media-preview`;e.style.viewTransitionName=r?`none`:d,t.style.viewTransitionName=r?d:`none`,r||(n.style.visibility=`hidden`);let f=document.startViewTransition(()=>{u||(e.style.viewTransitionName=r?d:`none`,t.style.viewTransitionName=r?`none`:d,n.style.visibility=r?`hidden`:l)}),p=()=>{e.style.viewTransitionName=s,t.style.viewTransitionName=c,n.style.visibility=l};f.ready.catch(()=>{});let m=()=>{u||(p(),i())};return f.finished.then(m,m),()=>{u=!0,f.skipTransition(),p()}}function Ce(e){let t=(0,V.c)(12),{onClose:n,isMobile:r,size:i}=e,{t:a}=u(),o;t[0]!==r||t[1]!==i?(o=r?{top:`calc(var(--oc-safe-area-top, 0px) + 0.5rem)`,right:`calc(var(--oc-safe-area-right, 0px) + 0.75rem)`}:{top:i?`calc(50% - ${i.height/2}px + 0.5rem)`:`0.5rem`,right:i?`calc(50% - ${i.width/2}px + 0.5rem)`:`0.5rem`},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a(`dialog.common.actions.close`),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,U.jsx)(_,{name:`close`,className:`size-5`}),t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==s?(l=(0,U.jsx)(f,{variant:`mobileGlass`,size:`mobileIcon`,"aria-label":s,onClick:n,children:c}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let d;return t[9]!==o||t[10]!==l?(d=(0,U.jsx)(`div`,{className:`absolute right-3 z-20`,style:o,children:l}),t[9]=o,t[10]=l,t[11]=d):d=t[11],d}function we(e){let t=(0,V.c)(25),{open:n,title:r,kind:i,source:a,isMobile:o,onOpenChange:s,children:c}=e,u=H.useRef(null),d=H.useRef(null),f=H.useRef(!1),[p,m]=H.useState(!1),h;t[0]!==s||t[1]!==a?(h=()=>{if(f.current)return;f.current=!0,d.current?.();let e=u.current?.querySelector(`[data-preview-transition-target]`)??null;d.current=Se(e?.dataset.previewReturn===`false`?void 0:a,e,u.current,!0,()=>{m(!0),s(!1)})},t[0]=s,t[1]=a,t[2]=h):h=t[2];let g=l(h),_=`${i}-preview`,v=n&&!p&&o,y;t[3]!==g||t[4]!==_||t[5]!==v?(y={id:_,active:v,layer:`overlay`,onBack:g,surfaceRef:u},t[3]=g,t[4]=_,t[5]=v,t[6]=y):y=t[6],b(y);let x,S;if(t[7]!==p||t[8]!==n||t[9]!==a?(x=()=>{if(!n){m(!1),f.current=!1;return}if(p)return;let e=u.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;return e?.querySelector(`button`)?.focus({preventScroll:!0}),d.current=Se(a,e?.querySelector(`[data-preview-transition-target]`)??null,e,!1),()=>{d.current?.(),d.current=null,f.current=!1,t?.isConnected&&t.focus({preventScroll:!0})}},S=[p,n,a],t[7]=p,t[8]=n,t[9]=a,t[10]=x,t[11]=S):(x=t[10],S=t[11]),H.useLayoutEffect(x,S),!n||p||typeof document>`u`)return null;let C=o?`var(--oc-media-preview-background)`:`color-mix(in srgb, var(--oc-media-preview-background) ${i===`mermaid`?90:70}%, transparent)`,w;t[12]===C?w=t[13]:(w={backgroundColor:C,color:`var(--oc-media-preview-foreground)`},t[12]=C,t[13]=w);let T;t[14]===g?T=t[15]:(T=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),g()),e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex="0"]`)),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},t[14]=g,t[15]=T);let E;t[16]!==c||t[17]!==g?(E=c(g),t[16]=c,t[17]=g,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==E||t[21]!==w||t[22]!==T||t[23]!==r?(D=(0,be.createPortal)((0,U.jsx)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,"data-media-preview":i,"data-page-scroll-lock":`true`,tabIndex:-1,className:`fixed inset-0 z-50 overflow-hidden select-none`,style:w,onClick:Te,onKeyDown:T,children:E}),document.body),t[19]=i,t[20]=E,t[21]=w,t[22]=T,t[23]=r,t[24]=D):D=t[24],D}function Te(e){e.preventDefault(),e.stopPropagation()}var Ee=500,De=400,Q=(e,t)=>new oe(e,t),Oe=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,U.jsx)(_,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,U.jsx)(_,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,U.jsx)(_,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,U.jsx)(_,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,U.jsx)(_,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,U.jsx)(_,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,U.jsx)(_,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,U.jsx)(_,{name:`search`,className:t}):n===`glob`?(0,U.jsx)(_,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,U.jsx)(_,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,U.jsx)(_,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,U.jsx)(_,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,U.jsx)(_,{name:`git-branch`,className:t}):(0,U.jsx)(_,{name:`tools`,className:t})},ke={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},Ae={download:!1,copy:!1,showPanZoomControls:!0},je=`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{it as n,nt as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{_ as a}from"./useUIStore-CDMI_Yzu.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as u,r as d,t as f}from"./button-DymteyMv.js";import{n as p,t as m}from"./useThemeSystem-8jhE4Zyk.js";import{n as h}from"./Icon-DDB7S6Vz.js";import{n as g,t as _}from"./dialog-DfUeXqdE.js";import{s as v,v as y}from"./image-loading-qNtUCy69.js";import{i as b,t as x}from"./appThemeRegistry-wWazoyp8.js";import{n as S}from"./MarkdownRenderer-YbG78e0Y.js";import{l as C}from"./markdown-worker-DFNZ3KJ_.js";import{n as w}from"./useEffectiveDirectory-DISvoVLe.js";import{i as T,n as E}from"./markdownTheme-CV7_0QAL.js";import{t as D}from"./ImageLoadingPlaceholder-C6fDEcU1.js";import{_ as O,d as k,f as A,g as j,h as M,l as N,m as P,n as F,p as I,r as L,s as R,t as z,u as ee}from"./useWorkerHighlightedLines-BFygybD8.js";import{t as B}from"./vendor-tanstack-react-virtual-B_EO--9t.js";var V=o(),H=e(n(),1),U=i(),W=80,G=20,te=H.memo(e=>{let t=(0,V.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=p(),u;t[0]===l?u=t[1]:(u=E(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(ie).join(`
2
+ `),t[2]=n,t[3]=f);let m=z(f,r);if(!(n.length>W)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==m||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==m||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,U.jsx)(re,{line:e,html:m?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=m,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=m,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,U.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let h;return t[19]!==m||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(h=(0,U.jsx)(ne,{lines:n,highlighted:m,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=m,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=h):h=t[25],h});te.displayName=`VirtualizedCodeBlock`;var ne=H.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=H.useRef(null),s=`min(${e.length*G}px, ${r})`,c=B({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>G,overscan:20}),l=c.getVirtualItems();return(0,U.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,U.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,U.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,U.jsx)(re,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});ne.displayName=`VirtualizedRows`;var re=H.memo(e=>{let t=(0,V.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,U.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,U.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,U.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,U.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,U.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,U.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});re.displayName=`VirtualizedCodeBlock.Row`;function ie(e){return e.text}var ae=H.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=H.useRef(null),[o,s]=H.useState(null),c=H.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=H.useCallback(()=>{a.current?.expandAll()},[]),d=H.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,U.jsx)(`div`,{className:t,children:(0,U.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,U.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,U.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,U.jsxs)(`div`,{className:t,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,U.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(h,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,U.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,U.jsx)(h,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,U.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,U.jsx)(L,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),oe=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},K=(e,t)=>new oe(e,t),se=e=>e instanceof oe,ce=e=>e+1,q=(e,t)=>e===t,J=e=>{let t=e.indexOf(`,`);if(t<0)throw K(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},le=e=>Promise.resolve().then(()=>J(e)),Y=1,ue=56,X=(e,t,n)=>Math.min(n,Math.max(t,e)),de=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=ue&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},fe=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},pe=(e,t)=>{let n=t.minScale??Y,r=t.maxScale??5,i=X(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:X(e.x,-a,a),y:X(e.y,-o,o)}},me=(e,t,n,r,i)=>{let a=X(t,i.minScale??Y,i.maxScale??5),o=a/e.scale;return pe({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},he=(e,t,n)=>pe({...e,x:e.x+t.x,y:e.y+t.y},n),ge=(e,t,n,r,i,a)=>{let o=X(r,a.minScale??Y,a.maxScale??5),s=o/e.scale;return pe({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Z=500,_e=24,ve=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Z,i=t.maxDistance??_e,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},ye=(e,t,n={})=>{ve(e,n),t()},be=e(r(),1);function xe(e,t,n,r,i){let a=e instanceof HTMLImageElement?e:e.querySelector(`img`);if(!a||!t.complete||!t.naturalWidth||!t.animate)return;let o=t.getBoundingClientRect(),s=a.getBoundingClientRect();if(!o.width||!o.height||!s.width||!s.height)return;let c=getComputedStyle(a),l=t.naturalWidth/t.naturalHeight,u=c.objectFit===`cover`?Math.max(s.width,s.height*l):Math.min(s.width,s.height*l),d=u/l,f=c.objectPosition.split(` `);if(!f.every(e=>e.endsWith(`%`)))return;let p=(s.width-u)*parseFloat(f[0])/100,m=(s.height-d)*parseFloat(f[1]??f[0])/100,h=s.left,g=s.top,_=s.right,v=s.bottom,y=c.borderRadius;for(let e=a.parentElement;e;e=e.parentElement){let t=getComputedStyle(e),n=e.getBoundingClientRect();[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowX)&&(h=Math.max(h,n.left),_=Math.min(_,n.right)),[`hidden`,`clip`,`auto`,`scroll`].includes(t.overflowY)&&(g=Math.max(g,n.top),v=Math.min(v,n.bottom)),n.width===s.width&&n.height===s.height&&t.borderRadius!==`0px`&&(y=t.borderRadius)}if(_<=h||v<=g)return;let b=document.createElement(`div`);b.dataset.mediaCropAnimation=``,b.setAttribute(`aria-hidden`,`true`),Object.assign(b.style,{position:`fixed`,left:`0`,top:`0`,overflow:`hidden`,pointerEvents:`none`,zIndex:`51`,contain:`paint`});let x=document.createElement(`img`);x.src=t.currentSrc||t.src,x.alt=``,Object.assign(x.style,{display:`block`,width:`${o.width}px`,height:`${o.height}px`,maxWidth:`none`,transformOrigin:`0 0`}),b.append(x),document.body.append(b);let S={transform:`translate(${o.left}px, ${o.top}px)`,width:`${o.width}px`,height:`${o.height}px`,borderRadius:`0px`},C={transform:`translate(${h}px, ${g}px)`,width:`${_-h}px`,height:`${v-g}px`,borderRadius:y},w={transform:`translate(0px, 0px) scale(1)`},T={transform:`translate(${s.left+p-h}px, ${s.top+m-g}px) scale(${u/o.width})`},E={duration:280,easing:`cubic-bezier(0.2, 0, 0, 1)`,fill:`both`},D=t.style.visibility;t.style.visibility=`hidden`;let O=[b.animate(r?[S,C]:[C,S],E),x.animate(r?[w,T]:[T,w],E),n.animate({opacity:r?[1,0]:[0,1]},E)],k=!1,A=(e=!1)=>{b.remove(),t.style.visibility=D,O.forEach((t,n)=>{(!e||n!==2)&&t.cancel()})};return Promise.all(O.map(e=>e.finished)).then(()=>{k||(A(r),i())},()=>{k||(A(),i())}),()=>{k=!0,A()}}function Se(e,t,n,r,i=()=>{}){let a=e?.getBoundingClientRect(),o=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!o&&e?.isConnected&&t instanceof HTMLImageElement&&n&&a?.width&&a.height&&a.bottom>0&&a.top<window.innerHeight&&a.right>0&&a.left<window.innerWidth){let a=xe(e,t,n,r,i);if(a)return a}if(!document.startViewTransition||o||!e?.isConnected||!t||!n||!a?.width||!a.height||a.bottom<=0||a.top>=window.innerHeight||a.right<=0||a.left>=window.innerWidth){if(!n?.animate||o)return i(),()=>{};let e=n.animate({opacity:r?[1,0]:[0,1]},{duration:150,fill:`forwards`}),t=!1;return e.finished.then(()=>{t||i()},()=>{}),()=>{t=!0,e.cancel()}}let s=e.style.viewTransitionName,c=t.style.viewTransitionName,l=n.style.visibility,u=!1,d=`oc-media-preview`;e.style.viewTransitionName=r?`none`:d,t.style.viewTransitionName=r?d:`none`,r||(n.style.visibility=`hidden`);let f=document.startViewTransition(()=>{u||(e.style.viewTransitionName=r?d:`none`,t.style.viewTransitionName=r?`none`:d,n.style.visibility=r?`hidden`:l)}),p=()=>{e.style.viewTransitionName=s,t.style.viewTransitionName=c,n.style.visibility=l};f.ready.catch(()=>{});let m=()=>{u||(p(),i())};return f.finished.then(m,m),()=>{u=!0,f.skipTransition(),p()}}function Ce(e){let t=(0,V.c)(12),{onClose:n,isMobile:r,size:i}=e,{t:a}=u(),o;t[0]!==r||t[1]!==i?(o=r?{top:`calc(var(--oc-safe-area-top, 0px) + 0.5rem)`,right:`calc(var(--oc-safe-area-right, 0px) + 0.75rem)`}:{top:i?`calc(50% - ${i.height/2}px + 0.5rem)`:`0.5rem`,right:i?`calc(50% - ${i.width/2}px + 0.5rem)`:`0.5rem`},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a(`dialog.common.actions.close`),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,U.jsx)(h,{name:`close`,className:`size-5`}),t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==s?(l=(0,U.jsx)(f,{variant:`mobileGlass`,size:`mobileIcon`,"aria-label":s,onClick:n,children:c}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let d;return t[9]!==o||t[10]!==l?(d=(0,U.jsx)(`div`,{className:`absolute right-3 z-20`,style:o,children:l}),t[9]=o,t[10]=l,t[11]=d):d=t[11],d}function we(e){let t=(0,V.c)(25),{open:n,title:r,kind:i,source:a,isMobile:o,onOpenChange:s,children:c}=e,u=H.useRef(null),d=H.useRef(null),f=H.useRef(!1),[p,m]=H.useState(!1),h;t[0]!==s||t[1]!==a?(h=()=>{if(f.current)return;f.current=!0,d.current?.();let e=u.current?.querySelector(`[data-preview-transition-target]`)??null;d.current=Se(e?.dataset.previewReturn===`false`?void 0:a,e,u.current,!0,()=>{m(!0),s(!1)})},t[0]=s,t[1]=a,t[2]=h):h=t[2];let g=l(h),_=`${i}-preview`,v=n&&!p&&o,y;t[3]!==g||t[4]!==_||t[5]!==v?(y={id:_,active:v,layer:`overlay`,onBack:g,surfaceRef:u},t[3]=g,t[4]=_,t[5]=v,t[6]=y):y=t[6],b(y);let x,S;if(t[7]!==p||t[8]!==n||t[9]!==a?(x=()=>{if(!n){m(!1),f.current=!1;return}if(p)return;let e=u.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;return e?.querySelector(`button`)?.focus({preventScroll:!0}),d.current=Se(a,e?.querySelector(`[data-preview-transition-target]`)??null,e,!1),()=>{d.current?.(),d.current=null,f.current=!1,t?.isConnected&&t.focus({preventScroll:!0})}},S=[p,n,a],t[7]=p,t[8]=n,t[9]=a,t[10]=x,t[11]=S):(x=t[10],S=t[11]),H.useLayoutEffect(x,S),!n||p||typeof document>`u`)return null;let C=o?`var(--oc-media-preview-background)`:`color-mix(in srgb, var(--oc-media-preview-background) ${i===`mermaid`?90:70}%, transparent)`,w;t[12]===C?w=t[13]:(w={backgroundColor:C,color:`var(--oc-media-preview-foreground)`},t[12]=C,t[13]=w);let T;t[14]===g?T=t[15]:(T=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),g()),e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex="0"]`)),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},t[14]=g,t[15]=T);let E;t[16]!==c||t[17]!==g?(E=c(g),t[16]=c,t[17]=g,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==E||t[21]!==w||t[22]!==T||t[23]!==r?(D=(0,be.createPortal)((0,U.jsx)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,"data-media-preview":i,"data-page-scroll-lock":`true`,tabIndex:-1,className:`fixed inset-0 z-50 overflow-hidden select-none`,style:w,onClick:Te,onKeyDown:T,children:E}),document.body),t[19]=i,t[20]=E,t[21]=w,t[22]=T,t[23]=r,t[24]=D):D=t[24],D}function Te(e){e.preventDefault(),e.stopPropagation()}var Ee=500,De=400,Q=(e,t)=>new oe(e,t),Oe=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,U.jsx)(h,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,U.jsx)(h,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,U.jsx)(h,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,U.jsx)(h,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,U.jsx)(h,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,U.jsx)(h,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,U.jsx)(h,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,U.jsx)(h,{name:`search`,className:t}):n===`glob`?(0,U.jsx)(h,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,U.jsx)(h,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,U.jsx)(h,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,U.jsx)(h,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,U.jsx)(h,{name:`git-branch`,className:t}):(0,U.jsx)(h,{name:`tools`,className:t})},ke={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},Ae={download:!1,copy:!1,showPanZoomControls:!0},je=`
3
3
  [data-diff-header],
4
4
  [data-diff] {
5
5
  [data-separator] {
6
6
  height: 24px !important;
7
7
  }
8
8
  }
9
- `,$={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},Me=()=>{let e=(0,V.c)(22),t=g(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=y(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=y(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let m=p,h,_;e[12]!==m||e[13]!==f?(h=()=>{x(f),x(m)},_=[m,f],e[12]=m,e[13]=f,e[14]=h,e[15]=_):(h=e[14],_=e[15]),H.useEffect(h,_);let v=t?.currentTheme.metadata.variant??`light`,b;e[16]!==m.metadata.id||e[17]!==f.metadata.id?(b={light:f.metadata.id,dark:m.metadata.id},e[16]=m.metadata.id,e[17]=f.metadata.id,e[18]=b):b=e[18];let S=v===`dark`?`dark`:`light`,C;return e[19]!==b||e[20]!==S?(C={theme:b,themeType:S},e[19]=b,e[20]=S,e[21]=C):C=e[21],C},Ne=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Pe=e=>{let t=(0,V.c)(3),[n,r]=H.useState(Ne),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(Ne())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),H.useEffect(i,a),n},Fe=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=g(),a=w()??``,o=H.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=H.useState(()=>{let t=e.image?.index??o.findIndex(t=>t.url===e.image?.url);return t>=0&&t<o.length?t:0}),p=e.previewSource instanceof HTMLImageElement?e.previewSource:void 0,m=p?.naturalWidth&&p.naturalHeight?{width:p.naturalWidth,height:p.naturalHeight}:null,[h,y]=H.useState(m),[b,x]=H.useState(!!m),S=e.open,C=Pe(e.open),E=H.useRef(null),k=H.useRef(null),A=H.useRef(null),j=H.useRef(null),M=H.useRef({scale:1,x:0,y:0}),N=H.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),P=H.useRef(new Map),F=H.useRef(null),I=H.useRef(null),L=H.useRef(null),R=H.useRef(null),z=H.useRef(0);H.useEffect(()=>{e.open&&(z.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let ee=l(()=>(typeof performance<`u`?performance.now():Date.now())-z.current<De),B=l(()=>{let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});H.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let V=o[s]??o[0]??e.image,W=v(V?.url??``,a,`preview`),G=W.source||(V?.url===e.image?.url?p?.currentSrc:``)||``,te=`${W.key}\n${G}`,[ne,re]=H.useState(``),ie=!!(W.error||ne===te),ae=l(()=>re(te)),oe=V?.filename||e.title,K=o.length>1,se=l(()=>{let t=V?.url??e.image?.url??``;if(!t&&!G)return;let n=V?.mimeType||e.image?.mimeType,r=V?.filename||e.image?.filename||e.title,i=A.current;if(i&&i.naturalWidth>0){O(i,n||`image/png`).then(e=>{T({sourceUrl:t||G,displayUrl:G||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}T({sourceUrl:t||G,displayUrl:G||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),ce=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),q=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),J=H.useMemo(()=>{let e={width:Math.max(1,C.width*(n?1:.8)),height:Math.max(1,C.height*(n?1:.95))};return h?fe(h,e):e},[h,n,C.height,C.width]),le=H.useMemo(()=>({image:J,viewport:{width:Math.max(1,C.width),height:Math.max(1,C.height)},maxScale:5}),[J,C.height,C.width]),Y=l((e,t=!1)=>{let n=pe(e,N.current);M.current=n,R.current={transform:n,animate:t},!(L.current!==null||typeof window>`u`)&&(L.current=window.requestAnimationFrame(()=>{L.current=null;let e=R.current;R.current=null,e&&(A.current&&(A.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,A.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),j.current&&(j.current.textContent=`${Math.round(e.transform.scale*100)}%`),E.current&&(E.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),ue=l((e=!0)=>{Y({scale:1,x:0,y:0},e)}),X=l(()=>({x:N.current.viewport.width/2,y:N.current.viewport.height/2})),Z=l((e,t,n=!1)=>{Y(me(M.current,e,t,X(),N.current),n)}),_e=l(e=>{if(M.current.scale>1.01){ue(!0);return}Z(2,e,!0)}),ve=l(e=>{if(!(n||e.defaultPrevented)){if(e.key===`+`||e.key===`=`){e.preventDefault(),Z(M.current.scale*1.4,X(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),Z(M.current.scale/1.4,X(),!0);return}if(e.key===`0`){e.preventDefault(),ue(!0);return}if(e.key===`ArrowLeft`&&K){e.preventDefault(),ce();return}e.key===`ArrowRight`&&K&&(e.preventDefault(),q())}});H.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,ve),()=>{window.removeEventListener(`keydown`,ve)}},[e.open]),H.useEffect(()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let t=V?.url===e.image?.url?p:void 0;y(t?.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null),x(!!t?.naturalWidth),M.current={scale:1,x:0,y:0},P.current.clear(),F.current=null,I.current=null,A.current&&(A.current.style.transform=`translate3d(0, 0, 0) scale(1)`),j.current&&(j.current.textContent=`100%`)},[V?.url,G,e.image?.url,p]),H.useLayoutEffect(()=>{N.current=le;let e=pe(M.current,N.current);M.current=e,A.current&&(A.current.style.transition=`none`,A.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[le]),H.useEffect(()=>()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let be=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);Z(M.current.scale*r,t)});H.useEffect(()=>{let e=E.current;if(!(!S||n||!e))return e.addEventListener(`wheel`,be,{passive:!1}),()=>e.removeEventListener(`wheel`,be)},[n,S]);let xe=l(e=>{n||(e.preventDefault(),_e({x:e.clientX,y:e.clientY}))}),Se=l(e=>{e.preventDefault(),e.stopPropagation()}),we=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size===1){if(F.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:M.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||M.current.scale<=1.01){let t=F.current;t.longPressTimer=setTimeout(()=>{!F.current||F.current.pointerId!==e.pointerId||F.current.moved||(F.current.longPressTriggered=!0,F.current.suppressTap=!0,se())},Ee)}E.current&&M.current.scale>1&&(E.current.style.cursor=`grabbing`);return}B(),F.current&&(F.current.suppressTap=!0,F.current.longPressTriggered=!1);let n=Array.from(P.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;I.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:M.current},F.current&&(F.current.suppressTap=!0)}),Te=l(e=>{if(!P.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size>=2&&I.current){B();let e=Array.from(P.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=I.current.transform.scale*Math.hypot(t,n)/I.current.distance;Y(ge(I.current.transform,I.current.midpoint,r,i,X(),N.current));return}let n=F.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,B()),n.transform.scale>1.01&&Y(he(n.transform,r,N.current))}),Q=l((e,r)=>{let i=F.current,a=P.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(P.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(B(),a&&!i.longPressTriggered)){let e=de({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:K});if(e===`next`&&q(),e===`previous`&&ce(),e===`close`){if(ee())return;if(n&&i.pointerType!==`mouse`){ye(a,()=>t(!1));return}t(!1)}}if(P.current.size===1){let[e,t]=Array.from(P.current.entries())[0];F.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:M.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},I.current=null}else P.current.size===0&&(F.current=null,I.current=null,E.current&&(E.current.style.cursor=M.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),Oe=l(e=>{e.preventDefault(),e.stopPropagation(),se()}),ke=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&y(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),x(!0)});if(!S||!V||typeof document>`u`)return null;let Ae=i?.currentTheme.metadata.variant===`dark`,je=Ae?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,$=Ae?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`;return(0,U.jsxs)(`div`,{ref:k,className:`absolute inset-0 overflow-hidden select-none`,tabIndex:-1,onClick:Se,children:[(0,U.jsx)(Ce,{onClose:()=>t(!1),isMobile:n,size:J}),(0,U.jsxs)(`div`,{ref:E,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:xe,onContextMenu:Oe,onPointerDown:we,onPointerMove:Te,onPointerUp:e=>Q(e,!1),onPointerCancel:e=>Q(e,!0),onLostPointerCapture:e=>Q(e,!0),children:[!b&&!ie&&(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,U.jsx)(D,{className:`aspect-square w-64 max-w-[80vw] rounded-xl`})}),ie?(0,U.jsx)(`p`,{role:`status`,className:`px-6 text-center typography-ui-label`,children:r(`filesView.error.readFileFailed`)}):(0,U.jsx)(`img`,{ref:A,"data-preview-transition-target":``,"data-preview-return":V?.url===e.image?.url,src:G||void 0,alt:oe??``,className:d(`block max-w-none object-contain will-change-transform`,b?`opacity-100`:`opacity-0`),style:{width:`${J.width}px`,height:`${J.height}px`},loading:`lazy`,draggable:!1,onLoad:ke,onError:ae})]}),(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-2`,children:(0,U.jsxs)(`div`,{className:d(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,je),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[K&&(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:ce,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,U.jsx)(_,{name:`arrow-left-s`,className:`size-5`})}),K&&(0,U.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),K&&(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:q,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,U.jsx)(_,{name:`arrow-right-s`,className:`size-5`})}),K&&(0,U.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale/1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,U.jsx)(_,{name:`subtract`,className:`size-4`})}),(0,U.jsxs)(f,{variant:`ghost`,size:`sm`,className:d(`h-8 min-w-14 rounded-full px-2 tabular-nums`,$),onClick:()=>ue(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,U.jsx)(_,{name:`restart`,className:`size-3.5`}),(0,U.jsx)(`span`,{ref:j,children:`100%`})]}),(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale*1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,U.jsx)(_,{name:`add`,className:`size-4`})})]})})]})},Ie=H.memo(e=>{let t=(0,V.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:je},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,U.jsx)(`div`,{className:`typography-code`,children:(0,U.jsx)(c,{patch:a,metrics:$,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Ie.displayName=`DialogUnifiedDiff`;var Le=H.memo(e=>{let t=(0,V.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=N(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(Be).join(`
10
- `),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||C(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(Ve),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,U.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,U.jsx)(te,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});Le.displayName=`DialogReadContent`;var Re=({popup:e,onOpenChange:n,isMobile:r})=>{let{t:i}=u(),a=g(),o=H.useMemo(()=>a?.currentTheme.metadata.variant===`dark`?a.currentTheme:a?.availableThemes.find(e=>e.metadata.id===a.darkThemeId&&e.metadata.variant===`dark`)??y(!0),[a?.currentTheme,a?.availableThemes,a?.darkThemeId]),[s,c]=H.useState(e.mermaid?.source||``),[l,d]=H.useState(e.mermaid?.source?`ready`:`idle`),[f,p]=H.useState(``),m=H.useRef(0),h=H.useCallback(e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=e=>{if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)},r=e=>e.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>{let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`});if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null},[]),v=H.useCallback(async()=>{let n=e.mermaid,r=ce(m.current);if(m.current=r,!n?.url){d(`error`),p(i(`chat.toolOutputDialog.mermaid.missingSource`));return}if(n.source){c(n.source),d(`ready`),p(``);return}d(`loading`),p(``);let a;if(n.url.startsWith(`data:`))a=le(n.url);else if(n.url.toLowerCase().startsWith(`file://`)){let e=h(n.url);a=e?t(`/api/fs/raw`,{query:{path:e}}).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))):Promise.reject(Q(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let e=typeof URL.canParse==`function`&&URL.canParse(n.url,window.location.origin)?new URL(n.url,window.location.origin):null;a=!e||e.protocol!==`http:`&&e.protocol!==`https:`?Promise.reject(Q(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(e.toString()).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status})))}await a.then(e=>{q(m.current,r)&&(c(e),d(`ready`))}).catch(e=>{q(m.current,r)&&(d(`error`),p(se(e)?i(e.key,e.params):i(`chat.toolOutputDialog.mermaid.loadFailed`)))})},[h,e.mermaid,i]);H.useEffect(()=>{!e.open||!e.mermaid||v()},[v,e.mermaid,e.open]);let b=`\`\`\`mermaid\n${s}\n\`\`\``;return!e.open||typeof document>`u`?null:(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.target===e.currentTarget&&n(!1)},children:(0,U.jsxs)(`div`,{"data-mermaid-preview":`true`,"data-preview-transition-target":``,className:`relative flex min-h-0 flex-col overflow-hidden`,style:{width:r?`100%`:`80%`,height:r?`100%`:`95%`},onMouseDown:e=>e.stopPropagation(),children:[(0,U.jsx)(Ce,{onClose:()=>n(!1),isMobile:r}),(0,U.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[l===`loading`&&(0,U.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,U.jsx)(_,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,U.jsx)(`span`,{children:i(`chat.toolOutputDialog.mermaid.loading`)})]}),l===`error`&&(0,U.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,U.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||i(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{v()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:i(`chat.toolOutputDialog.mermaid.retry`)})]}),l===`ready`&&(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(S,{content:b,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:Ae,mermaidTheme:o,enableFileReferences:!1})})]})})]})})},ze=e=>{let t=(0,V.c)(51),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=H.useState(`unified`),f=Me(),h;t[0]===n.open?h=t[1]:(h=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=h);let g;if(t[2]!==n.open||t[3]!==n.title?(g=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=g):g=t[4],H.useEffect(h,g),n.image||n.mermaid){let e=n.image?`image`:`mermaid`,a;t[5]!==i||t[6]!==n?(a=e=>n.image?(0,U.jsx)(Fe,{popup:n,onOpenChange:e,isMobile:i}):(0,U.jsx)(Re,{popup:n,onOpenChange:e,isMobile:i}),t[5]=i,t[6]=n,t[7]=a):a=t[7];let o;return t[8]!==i||t[9]!==r||t[10]!==n.open||t[11]!==n.previewSource||t[12]!==n.title||t[13]!==e||t[14]!==a?(o=(0,U.jsx)(we,{open:n.open,title:n.title,kind:e,source:n.previewSource,isMobile:i,onOpenChange:r,children:a}),t[8]=i,t[9]=r,t[10]=n.open,t[11]=n.previewSource,t[12]=n.title,t[13]=e,t[14]=a,t[15]=o):o=t[15],o}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[16]!==y||t[17]!==b?(x=d(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[16]=y,t[17]=b,t[18]=x):x=t[18];let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`90vh`},t[19]=w):w=t[19];let T;t[20]===n.metadata?T=t[21]:(T=n.metadata?.tool?Oe(n.metadata.tool):(0,U.jsx)(_,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[20]=n.metadata,t[21]=T);let E;t[22]===n.title?E=t[23]:(E=(0,U.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[22]=n.title,t[23]=E);let D;t[24]!==c||t[25]!==n.isDiff?(D=n.isDiff&&(0,U.jsx)(F,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[24]=c,t[25]=n.isDiff,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==T||t[29]!==E?(O=(0,U.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[T,E,D]})}),t[27]=D,t[28]=T,t[29]=E,t[30]=O):O=t[30];let N;t[31]!==f||t[32]!==n.metadata?(N=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,U.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,U.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`||e.tool===`shell`?`Command:`:e.tool===`task`||e.tool===`subagent`?`Task Details:`:`Input:`}),(e.tool===`bash`||e.tool===`shell`)&&r(`command`)?(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,U.jsx)(j,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:ke.style,wrap:!0})}):(e.tool===`task`||e.tool===`subagent`)&&r(`prompt`)?(0,U.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)||r(`agent`)?`Agent Type: ${r(`subagent_type`)||r(`agent`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,U.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:C(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:f.theme,themeType:f.themeType},className:`block w-full`})}):(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:R(t,e.tool)})]})})():null,t[31]=f,t[32]=n.metadata,t[33]=N):N=t[33];let L;t[34]!==c||t[35]!==i||t[36]!==f||t[37]!==n||t[38]!==o?(L=n.isDiff?(0,U.jsx)(Ie,{popup:n,diffViewMode:c,pierreThemeConfig:f}):n.content?(0,U.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?I(n.content)||(0,U.jsx)(j,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0}):e===`list`?A(n.content)||(0,U.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?k(n.content,i)||(0,U.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?ee(n.content,i)||(0,U.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`subagent`||e===`reasoning`?(0,U.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,U.jsx)(S,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?P(n.content)||(0,U.jsx)(j,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0}):e===`read`?(0,U.jsx)(Le,{popup:n,pierreThemeConfig:f}):(n.content?M(n.content):{data:null,isJson:!1}).isJson?(0,U.jsx)(ae,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,U.jsx)(j,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0})})()}):(0,U.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,U.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,U.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[34]=c,t[35]=i,t[36]=f,t[37]=n,t[38]=o,t[39]=L):L=t[39];let z;t[40]!==N||t[41]!==L?(z=(0,U.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[N,L]})}),t[40]=N,t[41]=L,t[42]=z):z=t[42];let B;t[43]!==O||t[44]!==z||t[45]!==x?(B=(0,U.jsxs)(m,{className:x,style:w,children:[O,z]}),t[43]=O,t[44]=z,t[45]=x,t[46]=B):B=t[46];let W;return t[47]!==r||t[48]!==n.open||t[49]!==B?(W=(0,U.jsx)(p,{open:v,onOpenChange:r,children:B}),t[47]=r,t[48]=n.open,t[49]=B,t[50]=W):W=t[50],W};function Be(e){return e.text}function Ve(e){return e.lineNumber!==null}export{ze as default};
9
+ `,$={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},Me=()=>{let e=(0,V.c)(22),t=m(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=y(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=y(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let h=p,g,_;e[12]!==h||e[13]!==f?(g=()=>{x(f),x(h)},_=[h,f],e[12]=h,e[13]=f,e[14]=g,e[15]=_):(g=e[14],_=e[15]),H.useEffect(g,_);let v=t?.currentTheme.metadata.variant??`light`,b;e[16]!==h.metadata.id||e[17]!==f.metadata.id?(b={light:f.metadata.id,dark:h.metadata.id},e[16]=h.metadata.id,e[17]=f.metadata.id,e[18]=b):b=e[18];let S=v===`dark`?`dark`:`light`,C;return e[19]!==b||e[20]!==S?(C={theme:b,themeType:S},e[19]=b,e[20]=S,e[21]=C):C=e[21],C},Ne=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Pe=e=>{let t=(0,V.c)(3),[n,r]=H.useState(Ne),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(Ne())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),H.useEffect(i,a),n},Fe=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=m(),a=w()??``,o=H.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=H.useState(()=>{let t=e.image?.index??o.findIndex(t=>t.url===e.image?.url);return t>=0&&t<o.length?t:0}),p=e.previewSource instanceof HTMLImageElement?e.previewSource:void 0,g=p?.naturalWidth&&p.naturalHeight?{width:p.naturalWidth,height:p.naturalHeight}:null,[_,y]=H.useState(g),[b,x]=H.useState(!!g),S=e.open,C=Pe(e.open),E=H.useRef(null),k=H.useRef(null),A=H.useRef(null),j=H.useRef(null),M=H.useRef({scale:1,x:0,y:0}),N=H.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),P=H.useRef(new Map),F=H.useRef(null),I=H.useRef(null),L=H.useRef(null),R=H.useRef(null),z=H.useRef(0);H.useEffect(()=>{e.open&&(z.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let ee=l(()=>(typeof performance<`u`?performance.now():Date.now())-z.current<De),B=l(()=>{let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});H.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let V=o[s]??o[0]??e.image,W=v(V?.url??``,a,`preview`),G=W.source||(V?.url===e.image?.url?p?.currentSrc:``)||``,te=`${W.key}\n${G}`,[ne,re]=H.useState(``),ie=!!(W.error||ne===te),ae=l(()=>re(te)),oe=V?.filename||e.title,K=o.length>1,se=l(()=>{let t=V?.url??e.image?.url??``;if(!t&&!G)return;let n=V?.mimeType||e.image?.mimeType,r=V?.filename||e.image?.filename||e.title,i=A.current;if(i&&i.naturalWidth>0){O(i,n||`image/png`).then(e=>{T({sourceUrl:t||G,displayUrl:G||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}T({sourceUrl:t||G,displayUrl:G||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),ce=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),q=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),J=H.useMemo(()=>{let e={width:Math.max(1,C.width*(n?1:.8)),height:Math.max(1,C.height*(n?1:.95))};return _?fe(_,e):e},[_,n,C.height,C.width]),le=H.useMemo(()=>({image:J,viewport:{width:Math.max(1,C.width),height:Math.max(1,C.height)},maxScale:5}),[J,C.height,C.width]),Y=l((e,t=!1)=>{let n=pe(e,N.current);M.current=n,R.current={transform:n,animate:t},!(L.current!==null||typeof window>`u`)&&(L.current=window.requestAnimationFrame(()=>{L.current=null;let e=R.current;R.current=null,e&&(A.current&&(A.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,A.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),j.current&&(j.current.textContent=`${Math.round(e.transform.scale*100)}%`),E.current&&(E.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),ue=l((e=!0)=>{Y({scale:1,x:0,y:0},e)}),X=l(()=>({x:N.current.viewport.width/2,y:N.current.viewport.height/2})),Z=l((e,t,n=!1)=>{Y(me(M.current,e,t,X(),N.current),n)}),_e=l(e=>{if(M.current.scale>1.01){ue(!0);return}Z(2,e,!0)}),ve=l(e=>{if(!(n||e.defaultPrevented)){if(e.key===`+`||e.key===`=`){e.preventDefault(),Z(M.current.scale*1.4,X(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),Z(M.current.scale/1.4,X(),!0);return}if(e.key===`0`){e.preventDefault(),ue(!0);return}if(e.key===`ArrowLeft`&&K){e.preventDefault(),ce();return}e.key===`ArrowRight`&&K&&(e.preventDefault(),q())}});H.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,ve),()=>{window.removeEventListener(`keydown`,ve)}},[e.open]),H.useEffect(()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let t=V?.url===e.image?.url?p:void 0;y(t?.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null),x(!!t?.naturalWidth),M.current={scale:1,x:0,y:0},P.current.clear(),F.current=null,I.current=null,A.current&&(A.current.style.transform=`translate3d(0, 0, 0) scale(1)`),j.current&&(j.current.textContent=`100%`)},[V?.url,G,e.image?.url,p]),H.useLayoutEffect(()=>{N.current=le;let e=pe(M.current,N.current);M.current=e,A.current&&(A.current.style.transition=`none`,A.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[le]),H.useEffect(()=>()=>{L.current!==null&&window.cancelAnimationFrame(L.current),L.current=null,R.current=null;let e=F.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let be=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);Z(M.current.scale*r,t)});H.useEffect(()=>{let e=E.current;if(!(!S||n||!e))return e.addEventListener(`wheel`,be,{passive:!1}),()=>e.removeEventListener(`wheel`,be)},[n,S]);let xe=l(e=>{n||(e.preventDefault(),_e({x:e.clientX,y:e.clientY}))}),Se=l(e=>{e.preventDefault(),e.stopPropagation()}),we=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size===1){if(F.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:M.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||M.current.scale<=1.01){let t=F.current;t.longPressTimer=setTimeout(()=>{!F.current||F.current.pointerId!==e.pointerId||F.current.moved||(F.current.longPressTriggered=!0,F.current.suppressTap=!0,se())},Ee)}E.current&&M.current.scale>1&&(E.current.style.cursor=`grabbing`);return}B(),F.current&&(F.current.suppressTap=!0,F.current.longPressTriggered=!1);let n=Array.from(P.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;I.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:M.current},F.current&&(F.current.suppressTap=!0)}),Te=l(e=>{if(!P.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(P.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),P.current.size>=2&&I.current){B();let e=Array.from(P.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=I.current.transform.scale*Math.hypot(t,n)/I.current.distance;Y(ge(I.current.transform,I.current.midpoint,r,i,X(),N.current));return}let n=F.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,B()),n.transform.scale>1.01&&Y(he(n.transform,r,N.current))}),Q=l((e,r)=>{let i=F.current,a=P.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(P.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(B(),a&&!i.longPressTriggered)){let e=de({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:K});if(e===`next`&&q(),e===`previous`&&ce(),e===`close`){if(ee())return;if(n&&i.pointerType!==`mouse`){ye(a,()=>t(!1));return}t(!1)}}if(P.current.size===1){let[e,t]=Array.from(P.current.entries())[0];F.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:M.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},I.current=null}else P.current.size===0&&(F.current=null,I.current=null,E.current&&(E.current.style.cursor=M.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),Oe=l(e=>{e.preventDefault(),e.stopPropagation(),se()}),ke=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&y(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),x(!0)});if(!S||!V||typeof document>`u`)return null;let Ae=i?.currentTheme.metadata.variant===`dark`,je=Ae?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,$=Ae?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`;return(0,U.jsxs)(`div`,{ref:k,className:`absolute inset-0 overflow-hidden select-none`,tabIndex:-1,onClick:Se,children:[(0,U.jsx)(Ce,{onClose:()=>t(!1),isMobile:n,size:J}),(0,U.jsxs)(`div`,{ref:E,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:xe,onContextMenu:Oe,onPointerDown:we,onPointerMove:Te,onPointerUp:e=>Q(e,!1),onPointerCancel:e=>Q(e,!0),onLostPointerCapture:e=>Q(e,!0),children:[!b&&!ie&&(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,U.jsx)(D,{className:`aspect-square w-64 max-w-[80vw] rounded-xl`})}),ie?(0,U.jsx)(`p`,{role:`status`,className:`px-6 text-center typography-ui-label`,children:r(`filesView.error.readFileFailed`)}):(0,U.jsx)(`img`,{ref:A,"data-preview-transition-target":``,"data-preview-return":V?.url===e.image?.url,src:G||void 0,alt:oe??``,className:d(`block max-w-none object-contain will-change-transform`,b?`opacity-100`:`opacity-0`),style:{width:`${J.width}px`,height:`${J.height}px`},loading:`lazy`,draggable:!1,onLoad:ke,onError:ae})]}),(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-2`,children:(0,U.jsxs)(`div`,{className:d(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,je),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[K&&(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:ce,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,U.jsx)(h,{name:`arrow-left-s`,className:`size-5`})}),K&&(0,U.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),K&&(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:q,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,U.jsx)(h,{name:`arrow-right-s`,className:`size-5`})}),K&&(0,U.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale/1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,U.jsx)(h,{name:`subtract`,className:`size-4`})}),(0,U.jsxs)(f,{variant:`ghost`,size:`sm`,className:d(`h-8 min-w-14 rounded-full px-2 tabular-nums`,$),onClick:()=>ue(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,U.jsx)(h,{name:`restart`,className:`size-3.5`}),(0,U.jsx)(`span`,{ref:j,children:`100%`})]}),(0,U.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(M.current.scale*1.4,X(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,U.jsx)(h,{name:`add`,className:`size-4`})})]})})]})},Ie=H.memo(e=>{let t=(0,V.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:je},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,U.jsx)(`div`,{className:`typography-code`,children:(0,U.jsx)(c,{patch:a,metrics:$,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Ie.displayName=`DialogUnifiedDiff`;var Le=H.memo(e=>{let t=(0,V.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=N(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(Be).join(`
10
+ `),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||C(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(Ve),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,U.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,U.jsx)(te,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});Le.displayName=`DialogReadContent`;var Re=({popup:e,onOpenChange:n,isMobile:r})=>{let{t:i}=u(),a=m(),o=H.useMemo(()=>a?.currentTheme.metadata.variant===`dark`?a.currentTheme:a?.availableThemes.find(e=>e.metadata.id===a.darkThemeId&&e.metadata.variant===`dark`)??y(!0),[a?.currentTheme,a?.availableThemes,a?.darkThemeId]),[s,c]=H.useState(e.mermaid?.source||``),[l,d]=H.useState(e.mermaid?.source?`ready`:`idle`),[f,p]=H.useState(``),g=H.useRef(0),_=H.useCallback(e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=e=>{if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)},r=e=>e.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>{let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`});if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null},[]),v=H.useCallback(async()=>{let n=e.mermaid,r=ce(g.current);if(g.current=r,!n?.url){d(`error`),p(i(`chat.toolOutputDialog.mermaid.missingSource`));return}if(n.source){c(n.source),d(`ready`),p(``);return}d(`loading`),p(``);let a;if(n.url.startsWith(`data:`))a=le(n.url);else if(n.url.toLowerCase().startsWith(`file://`)){let e=_(n.url);a=e?t(`/api/fs/raw`,{query:{path:e}}).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))):Promise.reject(Q(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let e=typeof URL.canParse==`function`&&URL.canParse(n.url,window.location.origin)?new URL(n.url,window.location.origin):null;a=!e||e.protocol!==`http:`&&e.protocol!==`https:`?Promise.reject(Q(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(e.toString()).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status})))}await a.then(e=>{q(g.current,r)&&(c(e),d(`ready`))}).catch(e=>{q(g.current,r)&&(d(`error`),p(se(e)?i(e.key,e.params):i(`chat.toolOutputDialog.mermaid.loadFailed`)))})},[_,e.mermaid,i]);H.useEffect(()=>{!e.open||!e.mermaid||v()},[v,e.mermaid,e.open]);let b=`\`\`\`mermaid\n${s}\n\`\`\``;return!e.open||typeof document>`u`?null:(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.target===e.currentTarget&&n(!1)},children:(0,U.jsxs)(`div`,{"data-mermaid-preview":`true`,"data-preview-transition-target":``,className:`relative flex min-h-0 flex-col overflow-hidden`,style:{width:r?`100%`:`80%`,height:r?`100%`:`95%`},onMouseDown:e=>e.stopPropagation(),children:[(0,U.jsx)(Ce,{onClose:()=>n(!1),isMobile:r}),(0,U.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[l===`loading`&&(0,U.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,U.jsx)(h,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,U.jsx)(`span`,{children:i(`chat.toolOutputDialog.mermaid.loading`)})]}),l===`error`&&(0,U.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,U.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||i(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{v()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:i(`chat.toolOutputDialog.mermaid.retry`)})]}),l===`ready`&&(0,U.jsx)(`div`,{className:`h-full`,children:(0,U.jsx)(S,{content:b,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:Ae,mermaidTheme:o,enableFileReferences:!1})})]})})]})})},ze=e=>{let t=(0,V.c)(51),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=H.useState(`unified`),f=Me(),p;t[0]===n.open?p=t[1]:(p=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=p);let m;if(t[2]!==n.open||t[3]!==n.title?(m=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=m):m=t[4],H.useEffect(p,m),n.image||n.mermaid){let e=n.image?`image`:`mermaid`,a;t[5]!==i||t[6]!==n?(a=e=>n.image?(0,U.jsx)(Fe,{popup:n,onOpenChange:e,isMobile:i}):(0,U.jsx)(Re,{popup:n,onOpenChange:e,isMobile:i}),t[5]=i,t[6]=n,t[7]=a):a=t[7];let o;return t[8]!==i||t[9]!==r||t[10]!==n.open||t[11]!==n.previewSource||t[12]!==n.title||t[13]!==e||t[14]!==a?(o=(0,U.jsx)(we,{open:n.open,title:n.title,kind:e,source:n.previewSource,isMobile:i,onOpenChange:r,children:a}),t[8]=i,t[9]=r,t[10]=n.open,t[11]=n.previewSource,t[12]=n.title,t[13]=e,t[14]=a,t[15]=o):o=t[15],o}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[16]!==y||t[17]!==b?(x=d(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[16]=y,t[17]=b,t[18]=x):x=t[18];let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`90vh`},t[19]=w):w=t[19];let T;t[20]===n.metadata?T=t[21]:(T=n.metadata?.tool?Oe(n.metadata.tool):(0,U.jsx)(h,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[20]=n.metadata,t[21]=T);let E;t[22]===n.title?E=t[23]:(E=(0,U.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[22]=n.title,t[23]=E);let D;t[24]!==c||t[25]!==n.isDiff?(D=n.isDiff&&(0,U.jsx)(F,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[24]=c,t[25]=n.isDiff,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==T||t[29]!==E?(O=(0,U.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[T,E,D]})}),t[27]=D,t[28]=T,t[29]=E,t[30]=O):O=t[30];let N;t[31]!==f||t[32]!==n.metadata?(N=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,U.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,U.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`||e.tool===`shell`?`Command:`:e.tool===`task`||e.tool===`subagent`?`Task Details:`:`Input:`}),(e.tool===`bash`||e.tool===`shell`)&&r(`command`)?(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,U.jsx)(j,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:ke.style,wrap:!0})}):(e.tool===`task`||e.tool===`subagent`)&&r(`prompt`)?(0,U.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)||r(`agent`)?`Agent Type: ${r(`subagent_type`)||r(`agent`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,U.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:C(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:f.theme,themeType:f.themeType},className:`block w-full`})}):(0,U.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:R(t,e.tool)})]})})():null,t[31]=f,t[32]=n.metadata,t[33]=N):N=t[33];let L;t[34]!==c||t[35]!==i||t[36]!==f||t[37]!==n||t[38]!==o?(L=n.isDiff?(0,U.jsx)(Ie,{popup:n,diffViewMode:c,pierreThemeConfig:f}):n.content?(0,U.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?I(n.content)||(0,U.jsx)(j,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0}):e===`list`?A(n.content)||(0,U.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?k(n.content,i)||(0,U.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?ee(n.content,i)||(0,U.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`subagent`||e===`reasoning`?(0,U.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,U.jsx)(S,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?P(n.content)||(0,U.jsx)(j,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0}):e===`read`?(0,U.jsx)(Le,{popup:n,pierreThemeConfig:f}):(n.content?M(n.content):{data:null,isJson:!1}).isJson?(0,U.jsx)(ae,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,U.jsx)(j,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:ke.style,wrap:!0})})()}):(0,U.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,U.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,U.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[34]=c,t[35]=i,t[36]=f,t[37]=n,t[38]=o,t[39]=L):L=t[39];let z;t[40]!==N||t[41]!==L?(z=(0,U.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,U.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[N,L]})}),t[40]=N,t[41]=L,t[42]=z):z=t[42];let B;t[43]!==O||t[44]!==z||t[45]!==x?(B=(0,U.jsxs)(g,{className:x,style:w,children:[O,z]}),t[43]=O,t[44]=z,t[45]=x,t[46]=B):B=t[46];let W;return t[47]!==r||t[48]!==n.open||t[49]!==B?(W=(0,U.jsx)(_,{open:v,onOpenChange:r,children:B}),t[47]=r,t[48]=n.open,t[49]=B,t[50]=W):W=t[50],W};function Be(e){return e.text}function Ve(e){return e.lineNumber!==null}export{ze as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r,t as i}from"./platform-z2erC6Bs.js";import{n as a}from"./vendor-react-BP2cRVqX.js";import{a as o,n as s}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{o as u}from"./useMobileNavigationStore-BsQYzG-5.js";import{l as d,t as f}from"./rasterizePng-DCmIQQsI.js";var p=e(n(),1),m=a(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var b=5,re=Math.ceil(b/2);function ie(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function ae(e){let t=Array.from({length:b},()=>Array.from({length:b},()=>!1));if(!e)return t;let n=ie(e);for(let e=0;e<b;e++)for(let r=0;r<re;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var oe=`oc-native-ios-composer`,x=`--oc-native-composer-height`,S=`--oc-native-composer-accessory`,se=33554432,C=`OpenChamberComposer`,w=`#22c55e`,ce=32,T=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),le=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:w,agentIdenticon:Array.from({length:25},()=>0),agentIcon:``,suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),ue=o(C),de=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function fe(e){return typeof window>`u`?!1:de({isCapacitor:r(),platform:i(),pluginAvailable:s.isPluginAvailable(C),isMobile:e,nativeUiEnabled:y()})}var pe=e=>e.classList.contains(`dark`)?`dark`:`light`,me=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},he=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},ge=(e,t)=>{if(!(t>0)){e.style.removeProperty(S);return}e.style.setProperty(S,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(oe,t),t||(e.style.removeProperty(x),e.style.removeProperty(S))},_e=e=>ae(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return w;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,w),w;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},ve=e=>k(d(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.agentIcon===t.agentIcon&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),ye=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},be=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),xe=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),Se=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},Ce=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},we=e=>F(e?.index)??0,Te=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Ee=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},De=e=>e.replacedText!==null&&e.incoming===e.replacedText,Oe=e=>setTimeout(e,0),ke=e=>{e.applyDocument(e.text),Oe(e.submit)},I=(e,t)=>e===t,Ae=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`agentIcon`,I),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},je=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Me=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},Ne=(e,t=se)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Me(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Pe=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Fe=e=>f(e,ce),R=()=>ue,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,Ce(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,Ne(t),je(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=Se(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,me(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,we(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(le()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c();let r=s||t>0;t=0,s=!1,o=!1,i=null,E(n,!1),r&&e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Ie=()=>o(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Le=(e,t)=>B(e)&&!B(t),Re=(e=z)=>{V(u.getState().secondary)&&e.conceal()},ze=(e=z)=>{let t=u.subscribe((t,n)=>{Le(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return s.getPlatform()===`ios`&&(async()=>{let t=Ie(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Be=()=>typeof window>`u`||r()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Be()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&U(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[H]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&U(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||U(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&U(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Ve=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=o(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),He=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=e=>{let t=K(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},J=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},Ue=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,We=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},Ge=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>We(e,t?100:0,r,n),Ke=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},qe=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,o;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||s.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,c=0,l=0,u=new Ke,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(Je)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ye),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(Xe),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},Y(t,0)},h=e=>{c=K(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&Y(t,c)}))},g=Ze,_=(n,r,i)=>{if(n&&Re(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&Y(t,r);let s=t,d=l;if(t=null,!s){if(!n)return!1;let e=W.getTopRoute();return He(e,f(e))}a=s;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ge(s.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(s.route.onBack(),await g(s)),d===l&&(J(s),a===s&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(Qe),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&J(t),a&&(a.surface.getAnimations().forEach($e),a.underlay?.getAnimations().forEach(et),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(tt),d.forEach(nt)}},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),p.useEffect(a,o)};function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=W.getTopRoute();return Ue({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=W.subscribe(()=>{o()&&a()});s()})}function Qe(){}function $e(e){return e.cancel()}function et(e){return e.cancel()}function tt(){}function nt(e){e.remove()}var rt=e=>/^#[0-9a-fA-F]{6}$/.test(e),it=e=>/^#[0-9a-fA-F]{8}$/.test(e),at=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?rt(e)?`${e}${t}`:it(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,ot=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},st=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":at(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function ct(e){return{name:e.metadata.name,type:e.metadata.variant,colors:st(e),tokenColors:ot(e)}}var lt=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>lt(e)?e.slice(0,7):e;function ut(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Q=new Map,$=new Set,dt=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ut({...e,name:t,fg:a,bg:i,settings:o},t)},ft=e=>ct(e),pt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=dt(ft(e),e.metadata.id);return Q.set(e.metadata.id,n),n},mt=e=>{let t=e.metadata.id;if($.has(t))return;let n=pt(e);c(t,async()=>n),$.add(t)};export{De as A,_e as C,k as D,Te as E,y as M,ee as N,Ee as O,v as P,pe as S,Fe as T,ke as _,qe as a,A as b,x as c,xe as d,be as f,R as g,T as h,Ve as i,te as j,E as k,ge as l,fe as m,pt as n,ze as o,Ae as p,W as r,z as s,mt as t,he as u,j as v,Pe as w,ve as x,ye as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r,t as i}from"./platform-CiBU2bCp.js";import{n as a}from"./vendor-react-BP2cRVqX.js";import{a as o,n as s}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{o as u}from"./useMobileNavigationStore-BE_8Q8WJ.js";import{n as d,t as f}from"./rasterizePng-CpK-xCkB.js";var p=e(n(),1),m=a(),h=`openchamber.iosNativeUi`,g=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}},_=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(h,`1`):window.localStorage.removeItem(h)}catch{}},v=t(e=>({enabled:g(),setEnabled:t=>{_(t),e({enabled:t})}})),y=()=>v.getState().enabled,ee=()=>v(ne),te=()=>r()&&i()===`ios`;function ne(e){return e.enabled}var b=5,re=Math.ceil(b/2);function ie(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function ae(e){let t=Array.from({length:b},()=>Array.from({length:b},()=>!1));if(!e)return t;let n=ie(e);for(let e=0;e<b;e++)for(let r=0;r<re;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var oe=`oc-native-ios-composer`,x=`--oc-native-composer-height`,S=`--oc-native-composer-accessory`,se=33554432,C=`OpenChamberComposer`,w=`#22c55e`,ce=32,T=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),le=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:w,agentIdenticon:Array.from({length:25},()=>0),agentIcon:``,suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:T()}),ue=o(C),de=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function fe(e){return typeof window>`u`?!1:de({isCapacitor:r(),platform:i(),pluginAvailable:s.isPluginAvailable(C),isMobile:e,nativeUiEnabled:y()})}var pe=e=>e.classList.contains(`dark`)?`dark`:`light`,me=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},he=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},ge=(e,t)=>{if(!(t>0)){e.style.removeProperty(S);return}e.style.setProperty(S,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(oe,t),t||(e.style.removeProperty(x),e.style.removeProperty(S))},_e=e=>ae(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return w;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,w),w;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},ve=e=>k(d(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.agentIcon===t.agentIcon&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),ye=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},be=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),xe=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),Se=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},F=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},Ce=e=>{let t=F(e?.selectionStart);if(t===null)return null;let n=F(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},we=e=>F(e?.index)??0,Te=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},Ee=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},De=e=>e.replacedText!==null&&e.incoming===e.replacedText,Oe=e=>setTimeout(e,0),ke=e=>{e.applyDocument(e.text),Oe(e.submit)},I=(e,t)=>e===t,Ae=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,I),a(`modelLabel`,I),a(`modelVariantLabel`,I),a(`modelIcon`,I),a(`canSend`,I),a(`canAbort`,I),a(`attachmentCount`,I),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,I),a(`attachAria`,I),a(`attachTitle`,I),a(`attachPhotosLabel`,I),a(`attachFilesLabel`,I),a(`attachCancelLabel`,I),a(`sendAria`,I),a(`queueAria`,I),a(`stopAria`,I),a(`modelAria`,I),a(`agentAria`,I),a(`agentLabel`,I),a(`agentColor`,I),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`agentIcon`,I),a(`suppressed`,I),a(`showScrollToBottom`,I),a(`scrollAria`,I),a(`autocomplete`,j),Object.keys(i).length===0?null:i},je=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},Me=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},Ne=(e,t=se)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=Me(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},L=80,Pe=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=L,e.height=L;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,L,L),r.drawImage(n,0,0,L,L);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Fe=e=>f(e,ce),R=()=>ue,z=((e=R)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,Ce(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,Ne(t),je(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=Se(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,me(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,we(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(le()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c();let r=s||t>0;t=0,s=!1,o=!1,i=null,E(n,!1),r&&e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),Ie=()=>o(`OpenChamberNavigation`),B=e=>e?.kind===`chat`||e?.kind===`draft`,V=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Le=(e,t)=>B(e)&&!B(t),Re=(e=z)=>{V(u.getState().secondary)&&e.conceal()},ze=(e=z)=>{let t=u.subscribe((t,n)=>{Le(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return s.getPlatform()===`ios`&&(async()=>{let t=Ie(),i=await t.addListener(`backStarted`,()=>{V(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},H=`__openchamberMobileBackRoute`,Be=()=>typeof window>`u`||r()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},U=e=>{let t=e?.[H];return typeof t==`number`&&Number.isFinite(t)?t:null},W=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Be()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&U(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[H]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&U(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||U(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&U(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&U(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[H]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Ve=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return W.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),p.useEffect(d,f)},G=o(`OpenChamberNavigation`),K=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),He=(e,t)=>!e||!t?!1:e.onBack()!==!1,q=e=>{let t=K(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},J=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},Y=(e,t)=>{let n=K(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},Ue=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,We=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},Ge=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=q({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>We(e,t?100:0,r,n),Ke=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},qe=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,o;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||s.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,c=0,l=0,u=new Ke,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(W.getTopRoute());G.setEnabled({enabled:e}).catch(Je)},m=()=>{if(W.cancelPresentation(),a)return;let e=W.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(Ye),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(Xe),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},Y(t,0)},h=e=>{c=K(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&Y(t,c)}))},g=Ze,_=(n,r,i)=>{if(n&&Re(),a)return n&&f(W.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&Y(t,r);let s=t,d=l;if(t=null,!s){if(!n)return!1;let e=W.getTopRoute();return He(e,f(e))}a=s;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=q({progress:K(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Ge(s.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(s.route.onBack(),await g(s)),d===l&&(J(s),a===s&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=W.setAnimatedBackDriver(e=>e!==W.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=W.subscribe(p);return(async()=>{let t=await G.addListener(`backStarted`,m),n=await G.addListener(`backProgressed`,e=>h(e.progress??0)),r=await G.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await G.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(Qe),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&J(t),a&&(a.surface.getAnimations().forEach($e),a.underlay?.getAnimations().forEach(et),J(a)),t=null,a=null,G.setEnabled({enabled:!1}).catch(tt),d.forEach(nt)}},o=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=o):(a=t[2],o=t[3]),p.useEffect(a,o)};function Je(){}function Ye(e){return e.cancel()}function Xe(e){return e.cancel()}function Ze(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=W.getTopRoute();return Ue({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=W.subscribe(()=>{o()&&a()});s()})}function Qe(){}function $e(e){return e.cancel()}function et(e){return e.cancel()}function tt(){}function nt(e){e.remove()}var rt=e=>/^#[0-9a-fA-F]{6}$/.test(e),it=e=>/^#[0-9a-fA-F]{8}$/.test(e),at=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?rt(e)?`${e}${t}`:it(e)?`${e.slice(0,7)}${t}`:e:e,X=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,ot=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>X(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},st=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=X(a.diffAddedBackground,r.successBackground),s=X(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":X(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":at(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":X(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":X(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":X(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":X(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":X(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":X(a.diffRemoved,r.error),"terminal.ansiGreen":X(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":X(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":X(e.colors.primary.foreground,t.background),"badge.foreground":X(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":X(e.colors.primary.foreground,t.background)}};function ct(e){return{name:e.metadata.name,type:e.metadata.variant,colors:st(e),tokenColors:ot(e)}}var lt=e=>/^#[0-9a-fA-F]{8}$/.test(e),Z=e=>lt(e)?e.slice(0,7):e;function ut(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Q=new Map,$=new Set,dt=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?Z(n):void 0,a=r?Z(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return ut({...e,name:t,fg:a,bg:i,settings:o},t)},ft=e=>ct(e),pt=e=>{let t=Q.get(e.metadata.id);if(t)return t;let n=dt(ft(e),e.metadata.id);return Q.set(e.metadata.id,n),n},mt=e=>{let t=e.metadata.id;if($.has(t))return;let n=pt(e);c(t,async()=>n),$.add(t)};export{De as A,_e as C,k as D,Te as E,y as M,ee as N,Ee as O,v as P,pe as S,Fe as T,ke as _,qe as a,A as b,x as c,xe as d,be as f,R as g,T as h,Ve as i,te as j,E as k,ge as l,fe as m,pt as n,ze as o,Ae as p,W as r,z as s,mt as t,he as u,j as v,Pe as w,ve as x,ye as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{nn as t,on as n,rn as r}from"./persistence-DUPZl7Oy.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c,o as l,t as u}from"./store-D5OeM4wB.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(i(),1),h=o(),g=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},_=async()=>{if(n())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(n())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(n())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},b=async e=>{if(n())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},x=async()=>{if(!n())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},S=m.createContext(null),C=a(),w=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(T),i=c(E),a=c(D),o=c(O),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&b(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let x;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(x={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=x):x=t[15];let w=x,k;return t[16]!==n||t[17]!==w?(k=(0,C.jsx)(S.Provider,{value:w,children:n}),t[16]=n,t[17]=w,t[18]=k):k=t[18],k};function T(e){return e.locale}function E(e){return e.dictionary}function D(e){return e.loadingLocale}function O(e){return e.setLocale}var k={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},A=e=>k[e]??`en-US`,j=()=>A(c.getState().locale);function M(){let e=m.useContext(S);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function N(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function P(...e){return p(d(e))}var F=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),I=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),L=()=>F()?`common.revealPath.finder`:I()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,R=e=>F()&&n()?e.metaKey:e.ctrlKey,z=()=>F()&&n()?`⌘`:`Ctrl`,B=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},V=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function H(e,t){if(!e)return``;let n=V(e);if(n===`/`)return`/`;let r=t?V(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function U(e,t){if(!e)return`/`;let n=V(e);if(!n||n===`/`)return`/`;let r=t?V(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function W(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function G(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var K=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=W(t,a?a.ref:void 0);if(!a)return null;let s=G(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),q=[`bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`text-[var(--primary-base)]`,`border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]`].join(` `),J=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),Y=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out 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`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:q,destructive:P(J,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:`bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active`,outline:`bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground`,mobileGlass:`oc-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:P(`border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground`,`aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`aria-pressed:text-[var(--primary-base)]`,`aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`aria-pressed:hover:text-[var(--primary-base)]`,`dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),X=new Set([`icon`,`mobileIcon`,`xs`]);function Z(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?K:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&X.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=P(Y({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,C.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{y as _,H as a,R as c,N as d,M as f,g,x as h,U as i,F as l,w as m,K as n,z as o,j as p,P as r,L as s,Z as t,B as u,v,_ as y};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{nn as t,on as n,rn as r}from"./persistence-B7ORJ371.js";import{it as i,rt as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c,o as l,t as u}from"./store-n-H5RvRn.js";import{n as d,t as f}from"./vendor-class-variance-authority-BLUaYARZ.js";import{t as p}from"./vendor-tailwind-merge-BicNWLTg.js";var m=e(i(),1),h=o(),g=async(e,n)=>{if(!t())throw Error(`Desktop runtime is not available`);return r(e,n)},_=async()=>{if(n())try{await g(`desktop_start_window_drag`)}catch{}},v=async e=>{if(n())try{await g(`desktop_set_window_title`,{title:e})}catch{}},y=async(e,t)=>{if(n())try{await g(`desktop_set_window_theme`,{themeMode:e,themeVariant:t})}catch{}},b=async e=>{if(n())try{await g(`desktop_set_menu_locale`,{locale:e})}catch{}},x=async()=>{if(!n())return null;try{let e=await g(`desktop_get_app_version`);return typeof e==`string`&&e.trim().length>0?e:null}catch{return null}},S=m.createContext(null),C=a(),w=e=>{let t=(0,h.c)(19),{children:n}=e,r=c(T),i=c(E),a=c(D),o=c(O),d,f;t[0]===r?(d=t[1],f=t[2]):(d=()=>{typeof document>`u`||(document.documentElement.lang=r)},f=[r],t[0]=r,t[1]=d,t[2]=f),m.useEffect(d,f);let p,g;t[3]!==a||t[4]!==r?(p=()=>{a===null&&b(r)},g=[r,a],t[3]=a,t[4]=r,t[5]=p,t[6]=g):(p=t[5],g=t[6]),m.useEffect(p,g);let _;t[7]===i?_=t[8]:(_=(e,t)=>u(i,e,t),t[7]=i,t[8]=_);let v=_,y;t[9]===v?y=t[10]:(y=e=>v(l[e]),t[9]=v,t[10]=y);let x;t[11]!==r||t[12]!==o||t[13]!==v||t[14]!==y?(x={locale:r,locales:s,setLocale:o,label:y,t:v},t[11]=r,t[12]=o,t[13]=v,t[14]=y,t[15]=x):x=t[15];let w=x,k;return t[16]!==n||t[17]!==w?(k=(0,C.jsx)(S.Provider,{value:w,children:n}),t[16]=n,t[17]=w,t[18]=k):k=t[18],k};function T(e){return e.locale}function E(e){return e.dictionary}function D(e){return e.loadingLocale}function O(e){return e.setLocale}var k={en:`en-US`,fr:`fr-FR`,"zh-CN":`zh-CN`,"zh-TW":`zh-TW`,uk:`uk-UA`,es:`es-ES`,"pt-BR":`pt-BR`,ko:`ko-KR`,pl:`pl-PL`,ja:`ja-JP`},A=e=>k[e]??`en-US`,j=()=>A(c.getState().locale);function M(){let e=m.useContext(S);if(!e)throw Error(`useI18n must be used within I18nProvider`);return e}async function N(e){let t=null;if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),{ok:!0,method:`clipboard`}}catch(e){t=e instanceof Error?e.message:String(e)}if(typeof document<`u`&&document.body){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.left=`-1000px`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=document.execCommand(`copy`);if(document.body.removeChild(t),n)return{ok:!0,method:`execCommand`}}return{ok:!1,error:t??`Clipboard access denied in current context`}}function P(...e){return p(d(e))}var F=()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),I=()=>typeof navigator>`u`?!1:/Windows/.test(navigator.userAgent||``),L=()=>F()?`common.revealPath.finder`:I()?`common.revealPath.fileExplorer`:`common.revealPath.fileManager`,R=e=>F()&&n()?e.metaKey:e.ctrlKey,z=()=>F()&&n()?`⌘`:`Ctrl`,B=(e,t)=>{let n=e??``,r=Math.max(16,t?.maxLength??45);if(n.length<=r)return n;let i=n.split(`/`);if(i.length<=1)return n;let a=i.pop()??``;if(!a)return n;let o=Math.max(0,r-(a.length+2));if(o<=0)return`…/${a}`;let s=``;for(let e of i){if(!e)continue;let t=s?`${s}/${e}`:e;if(t.length>o)break;s=t}if(!s){let e=i[0]??``;s=e?e.slice(0,o):``}return s?`${s}…/${a}`:`…/${a}`},V=e=>e?e===`/`?`/`:e.replace(/\/+$/,``):``;function H(e,t){if(!e)return``;let n=V(e);if(n===`/`)return`/`;let r=t?V(t):void 0;if(r&&r!==`/`){if(n===r)return`~`;if(n.startsWith(`${r}/`)){let e=n.slice(r.length+1);return e?`~/${e}`:`~`}}return n}function U(e,t){if(!e)return`/`;let n=V(e);if(!n||n===`/`)return`/`;let r=t?V(t):void 0;return r&&r!==`/`&&n===r?`~`:n.split(`/`).pop()||n||`/`}function W(e,t){let n=(0,h.c)(3),r;return n[0]!==e||n[1]!==t?(r=n=>{for(let r of[e,t])r&&(typeof r==`function`?r(n):r.current=n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],r}function G(e,t){let n={...t};for(let r in e){let i=t[r],a=e[r];n[r]=/^on[A-Z]/.test(r)&&typeof i==`function`&&typeof a==`function`?(...e)=>{a(...e),i(...e)}:r===`className`&&typeof i==`string`&&typeof a==`string`?`${a} ${i}`:r===`style`&&typeof i==`object`&&typeof a==`object`?{...a,...i}:a}return n}var K=m.forwardRef(function(e,t){let n=(0,h.c)(3),{children:r,...i}=e,a=m.isValidElement(r)?r:null,o=W(t,a?a.ref:void 0);if(!a)return null;let s=G(a.props,i),c;return n[0]!==o||n[1]!==s?(c={...s,ref:o},n[0]=o,n[1]=s,n[2]=c):c=n[2],m.cloneElement(a,c)}),q=[`bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`text-[var(--primary-base)]`,`border border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--primary-base)_22%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--primary-base)_30%,transparent)]`].join(` `),J=[`bg-[color-mix(in_srgb,var(--status-error)_7%,var(--background))]`,`text-[var(--status-error)]`,`border border-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`hover:bg-[color-mix(in_srgb,var(--status-error)_11%,var(--background))]`,`active:bg-[color-mix(in_srgb,var(--status-error)_16%,var(--background))]`,`dark:bg-[color-mix(in_srgb,var(--status-error)_9%,transparent)]`,`dark:border-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:hover:bg-[color-mix(in_srgb,var(--status-error)_14%,transparent)]`,`dark:active:bg-[color-mix(in_srgb,var(--status-error)_20%,transparent)]`].join(` `),Y=f([`group relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] typography-ui-label font-medium tracking-[0.01em] shrink-0 select-none`,`transition-[background-color,border-color,color,opacity,filter,transform] duration-150 ease-out 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`,`disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`],{variants:{variant:{default:q,destructive:P(J,`focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40`),neutral:`bg-interactive-hover text-foreground border border-border/60 hover:bg-interactive-active`,outline:`bg-[var(--surface-elevated)] text-foreground border border-border/60 hover:bg-interactive-hover hover:text-foreground`,mobileGlass:`oc-mobile-floating-action text-foreground hover:brightness-105 active:bg-interactive-active focus-visible:border-transparent focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,chip:P(`border border-border/60 bg-transparent text-foreground hover:bg-interactive-hover hover:text-foreground`,`aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_10%,var(--background))]`,`aria-pressed:text-[var(--primary-base)]`,`aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_12%,transparent)]`,`aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_16%,var(--background))]`,`aria-pressed:hover:text-[var(--primary-base)]`,`dark:aria-pressed:bg-[color-mix(in_srgb,var(--primary-base)_16%,transparent)]`,`dark:aria-pressed:border-[color-mix(in_srgb,var(--primary-base)_20%,transparent)]`,`dark:aria-pressed:hover:bg-[color-mix(in_srgb,var(--primary-base)_22%,transparent)]`),secondary:`bg-interactive-hover text-foreground hover:bg-interactive-active`,ghost:`text-foreground hover:bg-interactive-hover hover:text-foreground active:bg-interactive-active`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-3.5 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-2.5 has-[>svg]:px-2 rounded-[9px] supports-[corner-shape:squircle]:rounded-[50px]`,xs:`h-6 gap-1 px-2 typography-micro has-[>svg]:px-1.5 rounded-[7px] supports-[corner-shape:squircle]:rounded-[50px]`,lg:`h-10 px-4 has-[>svg]:px-3.5 rounded-[12px] supports-[corner-shape:squircle]:rounded-[50px]`,icon:`size-9`,mobileIcon:`size-10 min-h-10 min-w-10 rounded-full`}},defaultVariants:{variant:`default`,size:`default`}}),X=new Set([`icon`,`mobileIcon`,`xs`]);function Z(e){let t=(0,h.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:n,variant:s,size:i,asChild:a,type:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a!==void 0&&a,l=c?K:`button`,u;t[7]!==c||t[8]!==o?(u=c?o===void 0?{}:{type:o}:{type:o??`button`},t[7]=c,t[8]=o,t[9]=u):u=t[9];let d=u,f=i!=null&&X.has(i)?`compact`:void 0,p;t[10]!==n||t[11]!==i||t[12]!==s?(p=P(Y({variant:s,size:i,className:n})),t[10]=n,t[11]=i,t[12]=s,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==f||t[16]!==r||t[17]!==p||t[18]!==d?(m=(0,C.jsx)(l,{"data-slot":`button`,"data-mobile-press-feedback":f,className:p,...d,...r}),t[14]=l,t[15]=f,t[16]=r,t[17]=p,t[18]=d,t[19]=m):m=t[19],m}export{y as _,H as a,R as c,N as d,M as f,g,x as h,U as i,F as l,w as m,K as n,z as o,j as p,P as r,L as s,Z as t,B as u,v,_ as y};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,n,r,rt as i,t as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{r as s}from"./button-kJNzMb1G.js";var c=o(),l=e(t(),1),u=i(),d=r,f=e=>{let t=(0,c.c)(14),r,i,a,o;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4]):({className:a,asChild:r,children:i,...o}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o);let d;t[5]!==r||t[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},t[5]=r,t[6]=i,t[7]=d):d=t[7];let f=d,p;t[8]===a?p=t[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),t[8]=a,t[9]=p);let m;return t[10]!==o||t[11]!==f||t[12]!==p?(m=(0,u.jsx)(n,{className:p,...o,...f}),t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,n,r,rt as i,t as a}from"./vendor-base-ui-CdzJ6My_.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{r as s}from"./button-DymteyMv.js";var c=o(),l=e(t(),1),u=i(),d=r,f=e=>{let t=(0,c.c)(14),r,i,a,o;t[0]===e?(r=t[1],i=t[2],a=t[3],o=t[4]):({className:a,asChild:r,children:i,...o}=e,t[0]=e,t[1]=r,t[2]=i,t[3]=a,t[4]=o);let d;t[5]!==r||t[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},t[5]=r,t[6]=i,t[7]=d):d=t[7];let f=d,p;t[8]===a?p=t[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),t[8]=a,t[9]=p);let m;return t[10]!==o||t[11]!==f||t[12]!==p?(m=(0,u.jsx)(n,{className:p,...o,...f}),t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};