termdock 1.4.116 → 1.4.117

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 (67) hide show
  1. package/dist/client/assets/{ModelPreview-D3WI8Egu.js → ModelPreview-W7h96fo0.js} +1 -1
  2. package/dist/client/assets/{abnfDiagram-VRR7QNED-B569LPGl.js → abnfDiagram-VRR7QNED-Cu52A1NO.js} +1 -1
  3. package/dist/client/assets/{arc-7MUc4XGn.js → arc-DhoedXrI.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-ZJ3FMSHR-Doz58q1g.js → architectureDiagram-ZJ3FMSHR-D1HNxzqT.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-677ZJIJ3-CkxjBXBO.js → blockDiagram-677ZJIJ3-K3SQqeJd.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-LMCZKHZV-DLJNQ9lI.js → c4Diagram-LMCZKHZV-MjfFtzxZ.js} +1 -1
  7. package/dist/client/assets/channel-Dh-rQuvK.js +1 -0
  8. package/dist/client/assets/{chunk-2Q5K7J3B-BDgPfOVV.js → chunk-2Q5K7J3B-Dw03ECAr.js} +1 -1
  9. package/dist/client/assets/{chunk-32BRIVSS-BBSn7ckl.js → chunk-32BRIVSS-BNUkaz_y.js} +1 -1
  10. package/dist/client/assets/{chunk-5VM5RSS4-pNZrrZ4N.js → chunk-5VM5RSS4-CqVqdapS.js} +1 -1
  11. package/dist/client/assets/{chunk-EX3LRPZG-CTatM-fO.js → chunk-EX3LRPZG-BdcsV65P.js} +1 -1
  12. package/dist/client/assets/{chunk-JWPE2WC7-B8XdEpzH.js → chunk-JWPE2WC7-eaQCNWA9.js} +1 -1
  13. package/dist/client/assets/{chunk-MOJQB5TN-C8kC8KwF.js → chunk-MOJQB5TN-DuuCWE4b.js} +1 -1
  14. package/dist/client/assets/{chunk-RYQCIY6F-dc9CJJ2J.js → chunk-RYQCIY6F-BV4zVsjA.js} +1 -1
  15. package/dist/client/assets/{chunk-V7JOEXUC-CxS2s9hI.js → chunk-V7JOEXUC-CgCvJDfW.js} +1 -1
  16. package/dist/client/assets/{chunk-VR4S4FIN-B4I8ngmJ.js → chunk-VR4S4FIN-BfPxfJ9d.js} +1 -1
  17. package/dist/client/assets/{chunk-XXDRQBXY-BJPmETsH.js → chunk-XXDRQBXY-C64rSk_7.js} +1 -1
  18. package/dist/client/assets/classDiagram-OUVF2IWQ-aSOSNXz9.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-EOCWNBFH-aSOSNXz9.js +1 -0
  20. package/dist/client/assets/{cose-bilkent-JH36ORCC-D9x7P4Eq.js → cose-bilkent-JH36ORCC-B5xp7AU3.js} +1 -1
  21. package/dist/client/assets/{cynefin-VYW2F7L2-DvWT8h0R.js → cynefin-VYW2F7L2-Dw5bR5WD.js} +1 -1
  22. package/dist/client/assets/{cynefinDiagram-TSTJHNR4-CUv59Bw3.js → cynefinDiagram-TSTJHNR4-CeFANBHD.js} +1 -1
  23. package/dist/client/assets/{dagre-VKFMJZFB-s5bEdt1w.js → dagre-VKFMJZFB-CmPKCEuD.js} +1 -1
  24. package/dist/client/assets/{diagram-FQU43EPY-CKa0G8xF.js → diagram-FQU43EPY-Cpjl_IB3.js} +1 -1
  25. package/dist/client/assets/{diagram-G47NLZAW-r5YSFYsR.js → diagram-G47NLZAW-DaX4bvHs.js} +1 -1
  26. package/dist/client/assets/{diagram-NH7WQ7WH-BveQN9DC.js → diagram-NH7WQ7WH-YRncSc2p.js} +1 -1
  27. package/dist/client/assets/{diagram-OA4YK3LP-C5Aro8ZK.js → diagram-OA4YK3LP-DRTRPkJu.js} +1 -1
  28. package/dist/client/assets/{diagram-WEI45ONY-BAWeZapE.js → diagram-WEI45ONY-bjvZGWud.js} +1 -1
  29. package/dist/client/assets/{ebnfDiagram-CCIWWBDH-CYE9Chvd.js → ebnfDiagram-CCIWWBDH-wqqFnfp_.js} +1 -1
  30. package/dist/client/assets/{erDiagram-Q63AITRT-DUZJtm4q.js → erDiagram-Q63AITRT-C2pUy9lp.js} +1 -1
  31. package/dist/client/assets/{flowDiagram-23GEKE2U-BQR9a6DK.js → flowDiagram-23GEKE2U-8d0Ji6fZ.js} +1 -1
  32. package/dist/client/assets/{ganttDiagram-NO4QXBWP-DuFzszpU.js → ganttDiagram-NO4QXBWP-CxJ8EsFf.js} +1 -1
  33. package/dist/client/assets/{gitGraphDiagram-IHSO6WYX-DABzuPXe.js → gitGraphDiagram-IHSO6WYX-DakFTpAa.js} +1 -1
  34. package/dist/client/assets/{index-8uMWsajx.js → index-CpRY32uJ.js} +5 -5
  35. package/dist/client/assets/{infoDiagram-FWYZ7A6U-DRva3Ien.js → infoDiagram-FWYZ7A6U-vb3vXhZo.js} +1 -1
  36. package/dist/client/assets/{ishikawaDiagram-FXEZZL3T-CNRXrrLI.js → ishikawaDiagram-FXEZZL3T-D0YW_NSE.js} +1 -1
  37. package/dist/client/assets/{journeyDiagram-5HDEW3XC-D3rI6RBT.js → journeyDiagram-5HDEW3XC-6Vq1kXPA.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-HUTT4EX6-BpRQtZjC.js → kanban-definition-HUTT4EX6-megxRFUG.js} +1 -1
  39. package/dist/client/assets/{linear-CnEUJ7dP.js → linear-c9CEw62L.js} +1 -1
  40. package/dist/client/assets/{mermaid.core-CbGyS7XX.js → mermaid.core-CA8slCHp.js} +4 -4
  41. package/dist/client/assets/{mindmap-definition-LN4V7U3C-DZU8JwLn.js → mindmap-definition-LN4V7U3C-Dt1TLZwX.js} +1 -1
  42. package/dist/client/assets/{pegDiagram-2B236MQR-CDy2GzZq.js → pegDiagram-2B236MQR-5ncHGh8h.js} +1 -1
  43. package/dist/client/assets/{pieDiagram-ENE6RG2P-ChvqKPQc.js → pieDiagram-ENE6RG2P-DyJnLtRW.js} +1 -1
  44. package/dist/client/assets/{quadrantDiagram-ABIIQ3AL-CEsXtFFO.js → quadrantDiagram-ABIIQ3AL-CSBSlSdx.js} +1 -1
  45. package/dist/client/assets/{railroadDiagram-RFXS5EU6-2lIhT345.js → railroadDiagram-RFXS5EU6-BPuFl7M7.js} +1 -1
  46. package/dist/client/assets/{requirementDiagram-TGXJPOKE-0k84frRM.js → requirementDiagram-TGXJPOKE-6B48kqoE.js} +1 -1
  47. package/dist/client/assets/{sankeyDiagram-HTMAVEWB-mfgLZaap.js → sankeyDiagram-HTMAVEWB-CItpWYSq.js} +1 -1
  48. package/dist/client/assets/{sequenceDiagram-DBY2YBRQ-C-KseWZC.js → sequenceDiagram-DBY2YBRQ-COTh45K2.js} +1 -1
  49. package/dist/client/assets/{sizeCapture-X5ZJPWSS-DpId_v-j.js → sizeCapture-X5ZJPWSS-DdJ_uDyl.js} +1 -1
  50. package/dist/client/assets/{stateDiagram-2N3HPSRC-D80yi9Jm.js → stateDiagram-2N3HPSRC-Cs_fzGQx.js} +1 -1
  51. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-rftSyqMa.js +1 -0
  52. package/dist/client/assets/{swimlanes-5IMT3BWC-CDAhI-vs.js → swimlanes-5IMT3BWC-ACA0ApQZ.js} +2 -2
  53. package/dist/client/assets/swimlanesDiagram-G3AALYLV-7TuR3Wm7.js +8 -0
  54. package/dist/client/assets/{timeline-definition-FHXFAJF6-Da0mJHAf.js → timeline-definition-FHXFAJF6-DV2RVj3K.js} +1 -1
  55. package/dist/client/assets/{vennDiagram-L72KCM5P-BoXSxedu.js → vennDiagram-L72KCM5P-CWby1zJt.js} +1 -1
  56. package/dist/client/assets/{wardleyDiagram-EHGQE667-wwp1hsPG.js → wardleyDiagram-EHGQE667-DfydZGpy.js} +1 -1
  57. package/dist/client/assets/{xychartDiagram-FW5EYKEG-BhQ4kWvA.js → xychartDiagram-FW5EYKEG-CYrgADfb.js} +1 -1
  58. package/dist/client/index.html +1 -1
  59. package/dist/client/sw.js +1 -1
  60. package/dist/server/routes/terminal.js +3 -5
  61. package/package.json +1 -1
  62. package/runtime-manifest.json +2 -2
  63. package/dist/client/assets/channel-CQup56Qu.js +0 -1
  64. package/dist/client/assets/classDiagram-OUVF2IWQ-BJ-FlsJL.js +0 -1
  65. package/dist/client/assets/classDiagram-v2-EOCWNBFH-BJ-FlsJL.js +0 -1
  66. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-rTC_aFkU.js +0 -1
  67. package/dist/client/assets/swimlanesDiagram-G3AALYLV-D_we2o4F.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ca-rq7yX.js","assets/react-XDCjal2T.js","assets/ModelPreview-D3WI8Egu.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-CbGyS7XX.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ca-rq7yX.js","assets/react-XDCjal2T.js","assets/ModelPreview-W7h96fo0.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-CA8slCHp.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
2
2
  import{r as cg,a as zk,g as m7}from"./react-XDCjal2T.js";import{b,R as D,r as ia,a as Gk}from"./dnd-BCFAPC0L.js";import{L as Wk,l as Vk}from"./terminal-C7X98Amf.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var g1={exports:{}},B0={};var Sv;function qk(){if(Sv)return B0;Sv=1;var e=cg(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,f){var p,g={},y=null,v=null;f!==void 0&&(y=""+f),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(v=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(g[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)g[p]===void 0&&(g[p]=u[p]);return{$$typeof:t,type:c,key:y,ref:v,props:g,_owner:s.current}}return B0.Fragment=n,B0.jsx=l,B0.jsxs=l,B0}var Av;function Yk(){return Av||(Av=1,g1.exports=qk()),g1.exports}var o=Yk(),rp={},Tv;function Kk(){if(Tv)return rp;Tv=1;var e=zk();return rp.createRoot=e.createRoot,rp.hydrateRoot=e.hydrateRoot,rp}var Xk=Kk();const Zk=m7(Xk);function Cv(e){return e!==null&&typeof e=="object"&&"constructor"in e&&e.constructor===Object}function $2(e={},t={}){const n=["__proto__","constructor","prototype"];Object.keys(t).filter(r=>n.indexOf(r)<0).forEach(r=>{typeof e[r]>"u"?e[r]=t[r]:Cv(t[r])&&Cv(e[r])&&Object.keys(t[r]).length>0&&$2(e[r],t[r])})}const g7={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector(){return null},querySelectorAll(){return[]},getElementById(){return null},createEvent(){return{initEvent(){}}},createElement(){return{children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName(){return[]}}},createElementNS(){return{}},importNode(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function zu(){const e=typeof document<"u"?document:{};return $2(e,g7),e}const Jk={document:g7,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle(){return{getPropertyValue(){return""}}},Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia(){return{}},requestAnimationFrame(e){return typeof setTimeout>"u"?(e(),null):setTimeout(e,0)},cancelAnimationFrame(e){typeof setTimeout>"u"||clearTimeout(e)}};function Qo(){const e=typeof window<"u"?window:{};return $2(e,Jk),e}function e_(e=""){return e.trim().split(" ").filter(t=>!!t.trim())}function t_(e){const t=e;Object.keys(t).forEach(n=>{try{t[n]=null}catch{}try{delete t[n]}catch{}})}function x7(e,t=0){return setTimeout(e,t)}function vm(){return Date.now()}function n_(e){const t=Qo();let n;return t.getComputedStyle&&(n=t.getComputedStyle(e,null)),!n&&e.currentStyle&&(n=e.currentStyle),n||(n=e.style),n}function r_(e,t="x"){const n=Qo();let r,s,i;const l=n_(e);return n.WebKitCSSMatrix?(s=l.transform||l.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(c=>c.replace(",",".")).join(", ")),i=new n.WebKitCSSMatrix(s==="none"?"":s)):(i=l.MozTransform||l.OTransform||l.MsTransform||l.msTransform||l.transform||l.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),r=i.toString().split(",")),t==="x"&&(n.WebKitCSSMatrix?s=i.m41:r.length===16?s=parseFloat(r[12]):s=parseFloat(r[4])),t==="y"&&(n.WebKitCSSMatrix?s=i.m42:r.length===16?s=parseFloat(r[13]):s=parseFloat(r[5])),s||0}function sp(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"}function s_(e){return typeof window<"u"&&typeof window.HTMLElement<"u"?e instanceof HTMLElement:e&&(e.nodeType===1||e.nodeType===11)}function va(...e){const t=Object(e[0]);for(let n=1;n<e.length;n+=1){const r=e[n];if(r!=null&&!s_(r)){const s=Object.keys(Object(r)).filter(i=>i!=="__proto__"&&i!=="constructor"&&i!=="prototype");for(let i=0,l=s.length;i<l;i+=1){const c=s[i],u=Object.getOwnPropertyDescriptor(r,c);u!==void 0&&u.enumerable&&(sp(t[c])&&sp(r[c])?r[c].__swiper__?t[c]=r[c]:va(t[c],r[c]):!sp(t[c])&&sp(r[c])?(t[c]={},r[c].__swiper__?t[c]=r[c]:va(t[c],r[c])):t[c]=r[c])}}}return t}function fd(e,t,n){e.style.setProperty(t,n)}function b7({swiper:e,targetPosition:t,side:n}){const r=Qo(),s=-e.translate;let i=null,l;const c=e.params.speed;e.wrapperEl.style.scrollSnapType="none",r.cancelAnimationFrame(e.cssModeFrameID);const u=t>s?"next":"prev",f=(g,y)=>u==="next"&&g>=y||u==="prev"&&g<=y,p=()=>{l=new Date().getTime(),i===null&&(i=l);const g=Math.max(Math.min((l-i)/c,1),0),y=.5-Math.cos(g*Math.PI)/2;let v=s+y*(t-s);if(f(v,t)&&(v=t),e.wrapperEl.scrollTo({[n]:v}),f(v,t)){e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[n]:v})}),r.cancelAnimationFrame(e.cssModeFrameID);return}e.cssModeFrameID=r.requestAnimationFrame(p)};p()}function mc(e,t=""){const n=Qo(),r=[...e.children];return n.HTMLSlotElement&&e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(s=>s.matches(t)):r}function i_(e,t){const n=[t];for(;n.length>0;){const r=n.shift();if(e===r)return!0;n.push(...r.children,...r.shadowRoot?r.shadowRoot.children:[],...r.assignedElements?r.assignedElements():[])}}function o_(e,t){const n=Qo();let r=t.contains(e);return!r&&n.HTMLSlotElement&&t instanceof HTMLSlotElement&&(r=[...t.assignedElements()].includes(e),r||(r=i_(e,t))),r}function wm(e){try{console.warn(e);return}catch{}}function lb(e,t=[]){const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:e_(t)),n}function a_(e,t){const n=[];for(;e.previousElementSibling;){const r=e.previousElementSibling;t?r.matches(t)&&n.push(r):n.push(r),e=r}return n}function l_(e,t){const n=[];for(;e.nextElementSibling;){const r=e.nextElementSibling;t?r.matches(t)&&n.push(r):n.push(r),e=r}return n}function Uc(e,t){return Qo().getComputedStyle(e,null).getPropertyValue(t)}function kv(e){let t=e,n;if(t){for(n=0;(t=t.previousSibling)!==null;)t.nodeType===1&&(n+=1);return n}}function c_(e,t){const n=[];let r=e.parentElement;for(;r;)n.push(r),r=r.parentElement;return n}function _v(e,t,n){const r=Qo();return e[t==="width"?"offsetWidth":"offsetHeight"]+parseFloat(r.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-right":"margin-top"))+parseFloat(r.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-left":"margin-bottom"))}function Lv(e,t=""){typeof trustedTypes<"u"?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:n=>n}).createHTML(t):e.innerHTML=t}let x1;function u_(){const e=Qo(),t=zu();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}function y7(){return x1||(x1=u_()),x1}let b1;function d_({userAgent:e}={}){const t=y7(),n=Qo(),r=n.navigator.platform,s=e||n.navigator.userAgent,i={ios:!1,android:!1},l=n.screen.width,c=n.screen.height,u=s.match(/(Android);?[\s\/]+([\d.]+)?/);let f=s.match(/(iPad)(?!\1).*OS\s([\d_]+)/);const p=s.match(/(iPod)(.*OS\s([\d_]+))?/),g=!f&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),y=r==="Win32";let v=r==="MacIntel";const S=["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"];return!f&&v&&t.touch&&S.indexOf(`${l}x${c}`)>=0&&(f=s.match(/(Version)\/([\d.]+)/),f||(f=[0,1,"13_0_0"]),v=!1),u&&!y&&(i.os="android",i.android=!0),(f||g||p)&&(i.os="ios",i.ios=!0),i}function v7(e={}){return b1||(b1=d_(e)),b1}let y1;function f_(){const e=Qo(),t=v7();let n=!1;function r(){const c=e.navigator.userAgent.toLowerCase();return c.indexOf("safari")>=0&&c.indexOf("chrome")<0&&c.indexOf("android")<0}if(r()){const c=String(e.navigator.userAgent);if(c.includes("Version/")){const[u,f]=c.split("Version/")[1].split(" ")[0].split(".").map(p=>Number(p));n=u<16||u===16&&f<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),i=r(),l=i||s&&t.ios;return{isSafari:n||i,needPerspectiveFix:n,need3dFix:l,isWebView:s}}function w7(){return y1||(y1=f_()),y1}function h_({swiper:e,on:t,emit:n}){const r=Qo();let s=null,i=null;const l=()=>{!e||e.destroyed||!e.initialized||(n("beforeResize"),n("resize"))},c=()=>{!e||e.destroyed||!e.initialized||(s=new ResizeObserver(p=>{i=r.requestAnimationFrame(()=>{const{width:g,height:y}=e;let v=g,S=y;p.forEach(({contentBoxSize:A,contentRect:T,target:L})=>{L&&L!==e.el||(v=T?T.width:(A[0]||A).inlineSize,S=T?T.height:(A[0]||A).blockSize)}),(v!==g||S!==y)&&l()})}),s.observe(e.el))},u=()=>{i&&r.cancelAnimationFrame(i),s&&s.unobserve&&e.el&&(s.unobserve(e.el),s=null)},f=()=>{!e||e.destroyed||!e.initialized||n("orientationchange")};t("init",()=>{if(e.params.resizeObserver&&typeof r.ResizeObserver<"u"){c();return}r.addEventListener("resize",l),r.addEventListener("orientationchange",f)}),t("destroy",()=>{u(),r.removeEventListener("resize",l),r.removeEventListener("orientationchange",f)})}function p_({swiper:e,extendParams:t,on:n,emit:r}){const s=[],i=Qo(),l=(f,p={})=>{const g=i.MutationObserver||i.WebkitMutationObserver,y=new g(v=>{if(e.__preventObserver__)return;if(v.length===1){r("observerUpdate",v[0]);return}const S=function(){r("observerUpdate",v[0])};i.requestAnimationFrame?i.requestAnimationFrame(S):i.setTimeout(S,0)});y.observe(f,{attributes:typeof p.attributes>"u"?!0:p.attributes,childList:e.isElement||(typeof p.childList>"u"?!0:p).childList,characterData:typeof p.characterData>"u"?!0:p.characterData}),s.push(y)},c=()=>{if(e.params.observer){if(e.params.observeParents){const f=c_(e.hostEl);for(let p=0;p<f.length;p+=1)l(f[p])}l(e.hostEl,{childList:e.params.observeSlideChildren}),l(e.wrapperEl,{attributes:!1})}},u=()=>{s.forEach(f=>{f.disconnect()}),s.splice(0,s.length)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),n("init",c),n("destroy",u)}var m_={on(e,t,n){const r=this;if(!r.eventsListeners||r.destroyed||typeof t!="function")return r;const s=n?"unshift":"push";return e.split(" ").forEach(i=>{r.eventsListeners[i]||(r.eventsListeners[i]=[]),r.eventsListeners[i][s](t)}),r},once(e,t,n){const r=this;if(!r.eventsListeners||r.destroyed||typeof t!="function")return r;function s(...i){r.off(e,s),s.__emitterProxy&&delete s.__emitterProxy,t.apply(r,i)}return s.__emitterProxy=t,r.on(e,s,n)},onAny(e,t){const n=this;if(!n.eventsListeners||n.destroyed||typeof e!="function")return n;const r=t?"unshift":"push";return n.eventsAnyListeners.indexOf(e)<0&&n.eventsAnyListeners[r](e),n},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsAnyListeners)return t;const n=t.eventsAnyListeners.indexOf(e);return n>=0&&t.eventsAnyListeners.splice(n,1),t},off(e,t){const n=this;return!n.eventsListeners||n.destroyed||!n.eventsListeners||e.split(" ").forEach(r=>{typeof t>"u"?n.eventsListeners[r]=[]:n.eventsListeners[r]&&n.eventsListeners[r].forEach((s,i)=>{(s===t||s.__emitterProxy&&s.__emitterProxy===t)&&n.eventsListeners[r].splice(i,1)})}),n},emit(...e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsListeners)return t;let n,r,s;return typeof e[0]=="string"||Array.isArray(e[0])?(n=e[0],r=e.slice(1,e.length),s=t):(n=e[0].events,r=e[0].data,s=e[0].context||t),r.unshift(s),(Array.isArray(n)?n:n.split(" ")).forEach(l=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach(c=>{c.apply(s,[l,...r])}),t.eventsListeners&&t.eventsListeners[l]&&t.eventsListeners[l].forEach(c=>{c.apply(s,r)})}),t}};function g_(){const e=this;let t,n;const r=e.el;typeof e.params.width<"u"&&e.params.width!==null?t=e.params.width:t=r.clientWidth,typeof e.params.height<"u"&&e.params.height!==null?n=e.params.height:n=r.clientHeight,!(t===0&&e.isHorizontal()||n===0&&e.isVertical())&&(t=t-parseInt(Uc(r,"padding-left")||0,10)-parseInt(Uc(r,"padding-right")||0,10),n=n-parseInt(Uc(r,"padding-top")||0,10)-parseInt(Uc(r,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(n)&&(n=0),Object.assign(e,{width:t,height:n,size:e.isHorizontal()?t:n}))}function x_(){const e=this;function t(q,V){return parseFloat(q.getPropertyValue(e.getDirectionLabel(V))||0)}const n=e.params,{wrapperEl:r,slidesEl:s,rtlTranslate:i,wrongRTL:l}=e,c=e.virtual&&n.virtual.enabled,u=c?e.virtual.slides.length:e.slides.length,f=mc(s,`.${e.params.slideClass}, swiper-slide`),p=c?e.virtual.slides.length:f.length;let g=[];const y=[],v=[];let S=n.slidesOffsetBefore;typeof S=="function"&&(S=n.slidesOffsetBefore.call(e));let A=n.slidesOffsetAfter;typeof A=="function"&&(A=n.slidesOffsetAfter.call(e));const T=e.snapGrid.length,L=e.slidesGrid.length,I=e.size-S-A;let j=n.spaceBetween,P=-S,F=0,R=0;if(typeof I>"u")return;typeof j=="string"&&j.indexOf("%")>=0?j=parseFloat(j.replace("%",""))/100*I:typeof j=="string"&&(j=parseFloat(j)),e.virtualSize=-j-S-A,f.forEach(q=>{i?q.style.marginLeft="":q.style.marginRight="",q.style.marginBottom="",q.style.marginTop=""}),n.centeredSlides&&n.cssMode&&(fd(r,"--swiper-centered-offset-before",""),fd(r,"--swiper-centered-offset-after","")),n.cssMode&&(fd(r,"--swiper-slides-offset-before",`${S}px`),fd(r,"--swiper-slides-offset-after",`${A}px`));const C=n.grid&&n.grid.rows>1&&e.grid;C?e.grid.initSlides(f):e.grid&&e.grid.unsetSlides();let $;const Q=n.slidesPerView==="auto"&&n.breakpoints&&Object.keys(n.breakpoints).filter(q=>typeof n.breakpoints[q].slidesPerView<"u").length>0;for(let q=0;q<p;q+=1){$=0;const V=f[q];if(!(V&&(C&&e.grid.updateSlide(q,V,f),Uc(V,"display")==="none"))){if(c&&n.slidesPerView==="auto")n.virtual.slidesPerViewAutoSlideSize&&($=n.virtual.slidesPerViewAutoSlideSize),$&&V&&(n.roundLengths&&($=Math.floor($)),V.style[e.getDirectionLabel("width")]=`${$}px`);else if(n.slidesPerView==="auto"){Q&&(V.style[e.getDirectionLabel("width")]="");const fe=getComputedStyle(V),X=V.style.transform,he=V.style.webkitTransform;if(X&&(V.style.transform="none"),he&&(V.style.webkitTransform="none"),n.roundLengths)$=e.isHorizontal()?_v(V,"width"):_v(V,"height");else{const me=t(fe,"width"),de=t(fe,"padding-left"),le=t(fe,"padding-right"),W=t(fe,"margin-left"),z=t(fe,"margin-right"),K=fe.getPropertyValue("box-sizing");if(K&&K==="border-box")$=me+W+z;else{const{clientWidth:se,offsetWidth:ge}=V;$=me+de+le+W+z+(ge-se)}}X&&(V.style.transform=X),he&&(V.style.webkitTransform=he),n.roundLengths&&($=Math.floor($))}else $=(I-(n.slidesPerView-1)*j)/n.slidesPerView,n.roundLengths&&($=Math.floor($)),V&&(V.style[e.getDirectionLabel("width")]=`${$}px`);V&&(V.swiperSlideSize=$),v.push($),n.centeredSlides?(P=P+$/2+F/2+j,F===0&&q!==0&&(P=P-I/2-j),q===0&&(P=P-I/2-j),Math.abs(P)<1/1e3&&(P=0),n.roundLengths&&(P=Math.floor(P)),R%n.slidesPerGroup===0&&g.push(P),y.push(P)):(n.roundLengths&&(P=Math.floor(P)),(R-Math.min(e.params.slidesPerGroupSkip,R))%e.params.slidesPerGroup===0&&g.push(P),y.push(P),P=P+$+j),e.virtualSize+=$+j,F=$,R+=1}}if(e.virtualSize=Math.max(e.virtualSize,I)+A,i&&l&&(n.effect==="slide"||n.effect==="coverflow")&&(r.style.width=`${e.virtualSize+j}px`),n.setWrapperSize&&(r.style[e.getDirectionLabel("width")]=`${e.virtualSize+j}px`),C&&e.grid.updateWrapperSize($,g),!n.centeredSlides){const q=n.slidesPerView!=="auto"&&n.slidesPerView%1!==0,V=n.snapToSlideEdge&&!n.loop&&(n.slidesPerView==="auto"||q);let fe=g.length;if(V){let he;if(n.slidesPerView==="auto"){he=1;let me=0;for(let de=v.length-1;de>=0&&(me+=v[de]+(de<v.length-1?j:0),me<=I);de-=1)he=v.length-de}else he=Math.floor(n.slidesPerView);fe=Math.max(p-he,0)}const X=[];for(let he=0;he<g.length;he+=1){let me=g[he];n.roundLengths&&(me=Math.floor(me)),V?he<=fe&&X.push(me):g[he]<=e.virtualSize-I&&X.push(me)}g=X,Math.floor(e.virtualSize-I)-Math.floor(g[g.length-1])>1&&(V||g.push(e.virtualSize-I))}if(c&&n.loop){const q=v[0]+j;if(n.slidesPerGroup>1){const V=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/n.slidesPerGroup),fe=q*n.slidesPerGroup;for(let X=0;X<V;X+=1)g.push(g[g.length-1]+fe)}for(let V=0;V<e.virtual.slidesBefore+e.virtual.slidesAfter;V+=1)n.slidesPerGroup===1&&g.push(g[g.length-1]+q),y.push(y[y.length-1]+q),e.virtualSize+=q}if(g.length===0&&(g=[0]),j!==0){const q=e.isHorizontal()&&i?"marginLeft":e.getDirectionLabel("marginRight");f.filter((V,fe)=>!n.cssMode||n.loop?!0:fe!==f.length-1).forEach(V=>{V.style[q]=`${j}px`})}if(n.centeredSlides&&n.centeredSlidesBounds){let q=0;v.forEach(fe=>{q+=fe+(j||0)}),q-=j;const V=q>I?q-I:0;g=g.map(fe=>fe<=0?-S:fe>V?V+A:fe)}if(n.centerInsufficientSlides){let q=0;if(v.forEach(V=>{q+=V+(j||0)}),q-=j,q<I){const V=(I-q)/2;g.forEach((fe,X)=>{g[X]=fe-V}),y.forEach((fe,X)=>{y[X]=fe+V})}}if(Object.assign(e,{slides:f,snapGrid:g,slidesGrid:y,slidesSizesGrid:v}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){fd(r,"--swiper-centered-offset-before",`${-g[0]}px`),fd(r,"--swiper-centered-offset-after",`${e.size/2-v[v.length-1]/2}px`);const q=-e.snapGrid[0],V=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(fe=>fe+q),e.slidesGrid=e.slidesGrid.map(fe=>fe+V)}if(p!==u&&e.emit("slidesLengthChange"),g.length!==T&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),y.length!==L&&e.emit("slidesGridLengthChange"),n.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!c&&!n.cssMode&&(n.effect==="slide"||n.effect==="fade")){const q=`${n.containerModifierClass}backface-hidden`,V=e.el.classList.contains(q);p<=n.maxBackfaceHiddenSlides?V||e.el.classList.add(q):V&&e.el.classList.remove(q)}}function b_(e){const t=this,n=[],r=t.virtual&&t.params.virtual.enabled;let s=0,i;typeof e=="number"?t.setTransition(e):e===!0&&t.setTransition(t.params.speed);const l=c=>r?t.slides[t.getSlideIndexByData(c)]:t.slides[c];if(t.params.slidesPerView!=="auto"&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(c=>{n.push(c)});else for(i=0;i<Math.ceil(t.params.slidesPerView);i+=1){const c=t.activeIndex+i;if(c>t.slides.length&&!r)break;n.push(l(c))}else n.push(l(t.activeIndex));for(i=0;i<n.length;i+=1)if(typeof n[i]<"u"){const c=n[i].offsetHeight;s=c>s?c:s}(s||s===0)&&(t.wrapperEl.style.height=`${s}px`)}function y_(){const e=this,t=e.slides,n=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let r=0;r<t.length;r+=1)t[r].swiperSlideOffset=(e.isHorizontal()?t[r].offsetLeft:t[r].offsetTop)-n-e.cssOverflowAdjustment()}const Ev=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function v_(e=this&&this.translate||0){const t=this,n=t.params,{slides:r,rtlTranslate:s,snapGrid:i}=t;if(r.length===0)return;typeof r[0].swiperSlideOffset>"u"&&t.updateSlidesOffset();let l=-e;s&&(l=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let c=n.spaceBetween;typeof c=="string"&&c.indexOf("%")>=0?c=parseFloat(c.replace("%",""))/100*t.size:typeof c=="string"&&(c=parseFloat(c));for(let u=0;u<r.length;u+=1){const f=r[u];let p=f.swiperSlideOffset;n.cssMode&&n.centeredSlides&&(p-=r[0].swiperSlideOffset);const g=(l+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),y=(l-i[0]+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),v=-(l-p),S=v+t.slidesSizesGrid[u],A=v>=0&&v<=t.size-t.slidesSizesGrid[u],T=v>=0&&v<t.size-1||S>1&&S<=t.size||v<=0&&S>=t.size;T&&(t.visibleSlides.push(f),t.visibleSlidesIndexes.push(u)),Ev(f,T,n.slideVisibleClass),Ev(f,A,n.slideFullyVisibleClass),f.progress=s?-g:g,f.originalProgress=s?-y:y}}function w_(e){const t=this;if(typeof e>"u"){const p=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*p||0}const n=t.params,r=t.maxTranslate()-t.minTranslate();let{progress:s,isBeginning:i,isEnd:l,progressLoop:c}=t;const u=i,f=l;if(r===0)s=0,i=!0,l=!0;else{s=(e-t.minTranslate())/r;const p=Math.abs(e-t.minTranslate())<1,g=Math.abs(e-t.maxTranslate())<1;i=p||s<=0,l=g||s>=1,p&&(s=0),g&&(s=1)}if(n.loop){const p=t.getSlideIndexByData(0),g=t.getSlideIndexByData(t.slides.length-1),y=t.slidesGrid[p],v=t.slidesGrid[g],S=t.slidesGrid[t.slidesGrid.length-1],A=Math.abs(e);A>=y?c=(A-y)/S:c=(A+S-v)/S,c>1&&(c-=1)}Object.assign(t,{progress:s,progressLoop:c,isBeginning:i,isEnd:l}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),i&&!u&&t.emit("reachBeginning toEdge"),l&&!f&&t.emit("reachEnd toEdge"),(u&&!i||f&&!l)&&t.emit("fromEdge"),t.emit("progress",s)}const v1=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function S_(){const e=this,{slides:t,params:n,slidesEl:r,activeIndex:s}=e,i=e.virtual&&n.virtual.enabled,l=e.grid&&n.grid&&n.grid.rows>1,c=g=>mc(r,`.${n.slideClass}${g}, swiper-slide${g}`)[0];let u,f,p;if(i)if(n.loop){let g=s-e.virtual.slidesBefore;g<0&&(g=e.virtual.slides.length+g),g>=e.virtual.slides.length&&(g-=e.virtual.slides.length),u=c(`[data-swiper-slide-index="${g}"]`)}else u=c(`[data-swiper-slide-index="${s}"]`);else l?(u=t.find(g=>g.column===s),p=t.find(g=>g.column===s+1),f=t.find(g=>g.column===s-1)):u=t[s];u&&(l||(p=l_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!p&&(p=t[0]),f=a_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!f===0&&(f=t[t.length-1]))),t.forEach(g=>{v1(g,g===u,n.slideActiveClass),v1(g,g===p,n.slideNextClass),v1(g,g===f,n.slidePrevClass)}),e.emitSlidesClasses()}const Yp=(e,t)=>{if(!e||e.destroyed||!e.params)return;const n=()=>e.isElement?"swiper-slide":`.${e.params.slideClass}`,r=t.closest(n());if(r){let s=r.querySelector(`.${e.params.lazyPreloaderClass}`);!s&&e.isElement&&(r.shadowRoot?s=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(s=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),s&&!s.lazyPreloaderManaged&&s.remove())})),s&&!s.lazyPreloaderManaged&&s.remove()}},w1=(e,t)=>{if(!e.slides[t])return;const n=e.slides[t].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},cb=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const n=e.slides.length;if(!n||!t||t<0)return;t=Math.min(t,n);const r=e.params.slidesPerView==="auto"?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),s=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const l=s,c=[l-t];c.push(...Array.from({length:t}).map((u,f)=>l+r+f)),e.slides.forEach((u,f)=>{c.includes(u.column)&&w1(e,f)});return}const i=s+r-1;if(e.params.rewind||e.params.loop)for(let l=s-t;l<=i+t;l+=1){const c=(l%n+n)%n;(c<s||c>i)&&w1(e,c)}else for(let l=Math.max(s-t,0);l<=Math.min(i+t,n-1);l+=1)l!==s&&(l>i||l<s)&&w1(e,l)};function A_(e){const{slidesGrid:t,params:n}=e,r=e.rtlTranslate?e.translate:-e.translate;let s;for(let i=0;i<t.length;i+=1)typeof t[i+1]<"u"?r>=t[i]&&r<t[i+1]-(t[i+1]-t[i])/2?s=i:r>=t[i]&&r<t[i+1]&&(s=i+1):r>=t[i]&&(s=i);return n.normalizeSlideIndex&&(s<0||typeof s>"u")&&(s=0),s}function T_(e){const t=this,n=t.rtlTranslate?t.translate:-t.translate,{snapGrid:r,params:s,activeIndex:i,realIndex:l,snapIndex:c}=t;let u=e,f;const p=v=>{let S=v-t.virtual.slidesBefore;return S<0&&(S=t.virtual.slides.length+S),S>=t.virtual.slides.length&&(S-=t.virtual.slides.length),S};if(typeof u>"u"&&(u=A_(t)),r.indexOf(n)>=0)f=r.indexOf(n);else{const v=Math.min(s.slidesPerGroupSkip,u);f=v+Math.floor((u-v)/s.slidesPerGroup)}if(f>=r.length&&(f=r.length-1),u===i&&!t.params.loop){f!==c&&(t.snapIndex=f,t.emit("snapIndexChange"));return}if(u===i&&t.params.loop&&t.virtual&&t.params.virtual.enabled){t.realIndex=p(u);return}const g=t.grid&&s.grid&&s.grid.rows>1;let y;if(t.virtual&&s.virtual.enabled)s.loop?y=p(u):y=u;else if(g){const v=t.slides.find(A=>A.column===u);let S=parseInt(v.getAttribute("data-swiper-slide-index"),10);Number.isNaN(S)&&(S=Math.max(t.slides.indexOf(v),0)),y=Math.floor(S/s.grid.rows)}else if(t.slides[u]){const v=t.slides[u].getAttribute("data-swiper-slide-index");v?y=parseInt(v,10):y=u}else y=u;Object.assign(t,{previousSnapIndex:c,snapIndex:f,previousRealIndex:l,realIndex:y,previousIndex:i,activeIndex:u}),t.initialized&&cb(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(l!==y&&t.emit("realIndexChange"),t.emit("slideChange"))}function C_(e,t){const n=this,r=n.params;let s=e.closest(`.${r.slideClass}, swiper-slide`);!s&&n.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(c=>{!s&&c.matches&&c.matches(`.${r.slideClass}, swiper-slide`)&&(s=c)});let i=!1,l;if(s){for(let c=0;c<n.slides.length;c+=1)if(n.slides[c]===s){i=!0,l=c;break}}if(s&&i)n.clickedSlide=s,n.virtual&&n.params.virtual.enabled?n.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):n.clickedIndex=l;else{n.clickedSlide=void 0,n.clickedIndex=void 0;return}r.slideToClickedSlide&&n.clickedIndex!==void 0&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}var k_={updateSize:g_,updateSlides:x_,updateAutoHeight:b_,updateSlidesOffset:y_,updateSlidesProgress:v_,updateProgress:w_,updateSlidesClasses:S_,updateActiveIndex:T_,updateClickedSlide:C_};function __(e=this.isHorizontal()?"x":"y"){const t=this,{params:n,rtlTranslate:r,translate:s,wrapperEl:i}=t;if(n.virtualTranslate)return r?-s:s;if(n.cssMode)return s;let l=r_(i,e);return l+=t.cssOverflowAdjustment(),r&&(l=-l),l||0}function L_(e,t){const n=this,{rtlTranslate:r,params:s,wrapperEl:i,progress:l}=n;let c=0,u=0;const f=0;n.isHorizontal()?c=r?-e:e:u=e,s.roundLengths&&(c=Math.floor(c),u=Math.floor(u)),n.previousTranslate=n.translate,n.translate=n.isHorizontal()?c:u,s.cssMode?i[n.isHorizontal()?"scrollLeft":"scrollTop"]=n.isHorizontal()?-c:-u:s.virtualTranslate||(n.isHorizontal()?c-=n.cssOverflowAdjustment():u-=n.cssOverflowAdjustment(),i.style.transform=`translate3d(${c}px, ${u}px, ${f}px)`);let p;const g=n.maxTranslate()-n.minTranslate();g===0?p=0:p=(e-n.minTranslate())/g,p!==l&&n.updateProgress(e),n.emit("setTranslate",n.translate,t)}function E_(){return-this.snapGrid[0]}function I_(){return-this.snapGrid[this.snapGrid.length-1]}function R_(e=0,t=this.params.speed,n=!0,r=!0,s){const i=this,{params:l,wrapperEl:c}=i;if(i.animating&&l.preventInteractionOnTransition)return!1;const u=i.minTranslate(),f=i.maxTranslate();let p;if(r&&e>u?p=u:r&&e<f?p=f:p=e,i.updateProgress(p),l.cssMode){const g=i.isHorizontal();if(t===0)c[g?"scrollLeft":"scrollTop"]=-p;else{if(!i.support.smoothScroll)return b7({swiper:i,targetPosition:-p,side:g?"left":"top"}),!0;c.scrollTo({[g?"left":"top"]:-p,behavior:"smooth"})}return!0}return t===0?(i.setTransition(0),i.setTranslate(p),n&&(i.emit("beforeTransitionStart",t,s),i.emit("transitionEnd"))):(i.setTransition(t),i.setTranslate(p),n&&(i.emit("beforeTransitionStart",t,s),i.emit("transitionStart")),i.animating||(i.animating=!0,i.onTranslateToWrapperTransitionEnd||(i.onTranslateToWrapperTransitionEnd=function(y){!i||i.destroyed||y.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onTranslateToWrapperTransitionEnd),i.onTranslateToWrapperTransitionEnd=null,delete i.onTranslateToWrapperTransitionEnd,i.animating=!1,n&&i.emit("transitionEnd"))}),i.wrapperEl.addEventListener("transitionend",i.onTranslateToWrapperTransitionEnd))),!0}var N_={getTranslate:__,setTranslate:L_,minTranslate:E_,maxTranslate:I_,translateTo:R_};function M_(e,t){const n=this;n.params.cssMode||(n.wrapperEl.style.transitionDuration=`${e}ms`,n.wrapperEl.style.transitionDelay=e===0?"0ms":""),n.emit("setTransition",e,t)}function S7({swiper:e,runCallbacks:t,direction:n,step:r}){const{activeIndex:s,previousIndex:i}=e;let l=n;l||(s>i?l="next":s<i?l="prev":l="reset"),e.emit(`transition${r}`),t&&l==="reset"?e.emit(`slideResetTransition${r}`):t&&s!==i&&(e.emit(`slideChangeTransition${r}`),l==="next"?e.emit(`slideNextTransition${r}`):e.emit(`slidePrevTransition${r}`))}function D_(e=!0,t){const n=this,{params:r}=n;r.cssMode||(r.autoHeight&&n.updateAutoHeight(),S7({swiper:n,runCallbacks:e,direction:t,step:"Start"}))}function j_(e=!0,t){const n=this,{params:r}=n;n.animating=!1,!r.cssMode&&(n.setTransition(0),S7({swiper:n,runCallbacks:e,direction:t,step:"End"}))}var P_={setTransition:M_,transitionStart:D_,transitionEnd:j_};function B_(e=0,t,n=!0,r,s){typeof e=="string"&&(e=parseInt(e,10));const i=this;let l=e;l<0&&(l=0);const{params:c,snapGrid:u,slidesGrid:f,previousIndex:p,activeIndex:g,rtlTranslate:y,wrapperEl:v,enabled:S}=i;if(!S&&!r&&!s||i.destroyed||i.animating&&c.preventInteractionOnTransition)return!1;typeof t>"u"&&(t=i.params.speed);const A=Math.min(i.params.slidesPerGroupSkip,l);let T=A+Math.floor((l-A)/i.params.slidesPerGroup);T>=u.length&&(T=u.length-1);const L=-u[T];if(c.normalizeSlideIndex)for(let C=0;C<f.length;C+=1){const $=-Math.floor(L*100),Q=Math.floor(f[C]*100),q=Math.floor(f[C+1]*100);typeof f[C+1]<"u"?$>=Q&&$<q-(q-Q)/2?l=C:$>=Q&&$<q&&(l=C+1):$>=Q&&(l=C)}if(i.initialized&&l!==g&&(!i.allowSlideNext&&(y?L>i.translate&&L>i.minTranslate():L<i.translate&&L<i.minTranslate())||!i.allowSlidePrev&&L>i.translate&&L>i.maxTranslate()&&(g||0)!==l))return!1;l!==(p||0)&&n&&i.emit("beforeSlideChangeStart"),i.updateProgress(L);let I;l>g?I="next":l<g?I="prev":I="reset";const j=i.virtual&&i.params.virtual.enabled;if(!(j&&s)&&(y&&-L===i.translate||!y&&L===i.translate))return i.updateActiveIndex(l),c.autoHeight&&i.updateAutoHeight(),i.updateSlidesClasses(),c.effect!=="slide"&&i.setTranslate(L),I!=="reset"&&(i.transitionStart(n,I),i.transitionEnd(n,I)),!1;if(c.cssMode){const C=i.isHorizontal(),$=y?L:-L;if(t===0)j&&(i.wrapperEl.style.scrollSnapType="none",i._immediateVirtual=!0),j&&!i._cssModeVirtualInitialSet&&i.params.initialSlide>0?(i._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{v[C?"scrollLeft":"scrollTop"]=$})):v[C?"scrollLeft":"scrollTop"]=$,j&&requestAnimationFrame(()=>{i.wrapperEl.style.scrollSnapType="",i._immediateVirtual=!1});else{if(!i.support.smoothScroll)return b7({swiper:i,targetPosition:$,side:C?"left":"top"}),!0;v.scrollTo({[C?"left":"top"]:$,behavior:"smooth"})}return!0}const R=w7().isSafari;return j&&!s&&R&&i.isElement&&i.virtual.update(!1,!1,l),i.setTransition(t),i.setTranslate(L),i.updateActiveIndex(l),i.updateSlidesClasses(),i.emit("beforeTransitionStart",t,r),i.transitionStart(n,I),t===0?i.transitionEnd(n,I):i.animating||(i.animating=!0,i.onSlideToWrapperTransitionEnd||(i.onSlideToWrapperTransitionEnd=function($){!i||i.destroyed||$.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onSlideToWrapperTransitionEnd),i.onSlideToWrapperTransitionEnd=null,delete i.onSlideToWrapperTransitionEnd,i.transitionEnd(n,I))}),i.wrapperEl.addEventListener("transitionend",i.onSlideToWrapperTransitionEnd)),!0}function F_(e=0,t,n=!0,r){typeof e=="string"&&(e=parseInt(e,10));const s=this;if(s.destroyed)return;typeof t>"u"&&(t=s.params.speed);const i=s.grid&&s.params.grid&&s.params.grid.rows>1;let l=e;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)l=l+s.virtual.slidesBefore;else{let c;if(i){const A=l*s.params.grid.rows;c=s.slides.find(T=>T.getAttribute("data-swiper-slide-index")*1===A).column}else c=s.getSlideIndexByData(l);const u=i?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:f,slidesOffsetBefore:p,slidesOffsetAfter:g}=s.params,y=f||!!p||!!g;let v=s.params.slidesPerView;v==="auto"?v=s.slidesPerViewDynamic():(v=Math.ceil(parseFloat(s.params.slidesPerView,10)),y&&v%2===0&&(v=v+1));let S=u-c<v;if(y&&(S=S||c<Math.ceil(v/2)),r&&y&&s.params.slidesPerView!=="auto"&&!i&&(S=!1),S){const A=y?c<s.activeIndex?"prev":"next":c-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:A,slideTo:!0,activeSlideIndex:A==="next"?c+1:c-u+1,slideRealIndex:A==="next"?s.realIndex:void 0})}if(i){const A=l*s.params.grid.rows;l=s.slides.find(T=>T.getAttribute("data-swiper-slide-index")*1===A).column}else l=s.getSlideIndexByData(l)}return requestAnimationFrame(()=>{s.slideTo(l,t,n,r)}),s}function O_(e,t=!0,n){const r=this,{enabled:s,params:i,animating:l}=r;if(!s||r.destroyed)return r;typeof e>"u"&&(e=r.params.speed);let c=i.slidesPerGroup;i.slidesPerView==="auto"&&i.slidesPerGroup===1&&i.slidesPerGroupAuto&&(c=Math.max(r.slidesPerViewDynamic("current",!0),1));const u=r.activeIndex<i.slidesPerGroupSkip?1:c,f=r.virtual&&i.virtual.enabled;if(i.loop){if(l&&!f&&i.loopPreventsSliding)return!1;if(r.loopFix({direction:"next"}),r._clientLeft=r.wrapperEl.clientLeft,r.activeIndex===r.slides.length-1&&i.cssMode)return requestAnimationFrame(()=>{r.slideTo(r.activeIndex+u,e,t,n)}),!0}return i.rewind&&r.isEnd?r.slideTo(0,e,t,n):r.slideTo(r.activeIndex+u,e,t,n)}function Q_(e,t=!0,n){const r=this,{params:s,snapGrid:i,slidesGrid:l,rtlTranslate:c,enabled:u,animating:f}=r;if(!u||r.destroyed)return r;typeof e>"u"&&(e=r.params.speed);const p=r.virtual&&s.virtual.enabled;if(s.loop){if(f&&!p&&s.loopPreventsSliding)return!1;r.loopFix({direction:"prev"}),r._clientLeft=r.wrapperEl.clientLeft}const g=c?r.translate:-r.translate;function y(I){return I<0?-Math.floor(Math.abs(I)):Math.floor(I)}const v=y(g),S=i.map(I=>y(I)),A=s.freeMode&&s.freeMode.enabled;let T=i[S.indexOf(v)-1];if(typeof T>"u"&&(s.cssMode||A)){let I;i.forEach((j,P)=>{v>=j&&(I=P)}),typeof I<"u"&&(T=A?i[I]:i[I>0?I-1:I])}let L=0;if(typeof T<"u"&&(L=l.indexOf(T),L<0&&(L=r.activeIndex-1),s.slidesPerView==="auto"&&s.slidesPerGroup===1&&s.slidesPerGroupAuto&&(L=L-r.slidesPerViewDynamic("previous",!0)+1,L=Math.max(L,0))),s.rewind&&r.isBeginning){const I=r.params.virtual&&r.params.virtual.enabled&&r.virtual?r.virtual.slides.length-1:r.slides.length-1;return r.slideTo(I,e,t,n)}else if(s.loop&&r.activeIndex===0&&s.cssMode)return requestAnimationFrame(()=>{r.slideTo(L,e,t,n)}),!0;return r.slideTo(L,e,t,n)}function $_(e,t=!0,n){const r=this;if(!r.destroyed)return typeof e>"u"&&(e=r.params.speed),r.slideTo(r.activeIndex,e,t,n)}function H_(e,t=!0,n,r=.5){const s=this;if(s.destroyed)return;typeof e>"u"&&(e=s.params.speed);let i=s.activeIndex;const l=Math.min(s.params.slidesPerGroupSkip,i),c=l+Math.floor((i-l)/s.params.slidesPerGroup),u=s.rtlTranslate?s.translate:-s.translate;if(u>=s.snapGrid[c]){const f=s.snapGrid[c],p=s.snapGrid[c+1];u-f>(p-f)*r&&(i+=s.params.slidesPerGroup)}else{const f=s.snapGrid[c-1],p=s.snapGrid[c];u-f<=(p-f)*r&&(i-=s.params.slidesPerGroup)}return i=Math.max(i,0),i=Math.min(i,s.slidesGrid.length-1),s.slideTo(i,e,t,n)}function U_(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:n}=e,r=t.slidesPerView==="auto"?e.slidesPerViewDynamic():t.slidesPerView;let s=e.getSlideIndexWhenGrid(e.clickedIndex),i;const l=e.isElement?"swiper-slide":`.${t.slideClass}`,c=e.grid&&e.params.grid&&e.params.grid.rows>1;if(t.loop){if(e.animating)return;i=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?e.slideToLoop(i):s>(c?(e.slides.length-r)/2-(e.params.grid.rows-1):e.slides.length-r)?(e.loopFix(),s=e.getSlideIndex(mc(n,`${l}[data-swiper-slide-index="${i}"]`)[0]),x7(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}var z_={slideTo:B_,slideToLoop:F_,slideNext:O_,slidePrev:Q_,slideReset:$_,slideToClosest:H_,slideToClickedSlide:U_};function G_(e,t){const n=this,{params:r,slidesEl:s}=n;if(!r.loop||n.virtual&&n.params.virtual.enabled)return;const i=()=>{mc(s,`.${r.slideClass}, swiper-slide`).forEach((S,A)=>{S.setAttribute("data-swiper-slide-index",A)})},l=()=>{const v=mc(s,`.${r.slideBlankClass}`);v.forEach(S=>{S.remove()}),v.length>0&&(n.recalcSlides(),n.updateSlides())},c=n.grid&&r.grid&&r.grid.rows>1;r.loopAddBlankSlides&&(r.slidesPerGroup>1||c)&&l();const u=r.slidesPerGroup*(c?r.grid.rows:1),f=n.slides.length%u!==0,p=c&&n.slides.length%r.grid.rows!==0,g=v=>{for(let S=0;S<v;S+=1){const A=n.isElement?lb("swiper-slide",[r.slideBlankClass]):lb("div",[r.slideClass,r.slideBlankClass]);n.slidesEl.append(A)}};if(f){if(r.loopAddBlankSlides){const v=u-n.slides.length%u;g(v),n.recalcSlides(),n.updateSlides()}else wm("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");i()}else if(p){if(r.loopAddBlankSlides){const v=r.grid.rows-n.slides.length%r.grid.rows;g(v),n.recalcSlides(),n.updateSlides()}else wm("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");i()}else i();const y=r.centeredSlides||!!r.slidesOffsetBefore||!!r.slidesOffsetAfter;n.loopFix({slideRealIndex:e,direction:y?void 0:"next",initial:t})}function W_({slideRealIndex:e,slideTo:t=!0,direction:n,setTranslate:r,activeSlideIndex:s,initial:i,byController:l,byMousewheel:c}={}){const u=this;if(!u.params.loop)return;u.emit("beforeLoopFix");const{slides:f,allowSlidePrev:p,allowSlideNext:g,slidesEl:y,params:v}=u,{centeredSlides:S,slidesOffsetBefore:A,slidesOffsetAfter:T,initialSlide:L}=v,I=S||!!A||!!T;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&v.virtual.enabled){t&&(!I&&u.snapIndex===0?u.slideTo(u.virtual.slides.length,0,!1,!0):I&&u.snapIndex<v.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0)),u.allowSlidePrev=p,u.allowSlideNext=g,u.emit("loopFix");return}let j=v.slidesPerView;j==="auto"?j=u.slidesPerViewDynamic():(j=Math.ceil(parseFloat(v.slidesPerView,10)),I&&j%2===0&&(j=j+1));const P=v.slidesPerGroupAuto?j:v.slidesPerGroup;let F=I?Math.max(P,Math.ceil(j/2)):P;F%P!==0&&(F+=P-F%P),F+=v.loopAdditionalSlides,u.loopedSlides=F;const R=u.grid&&v.grid&&v.grid.rows>1;f.length<j+F||u.params.effect==="cards"&&f.length<j+F*2?wm("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):R&&v.grid.fill==="row"&&wm("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const C=[],$=[],Q=R?Math.ceil(f.length/v.grid.rows):f.length,q=i&&Q-L<j&&!I;let V=q?L:u.activeIndex;typeof s>"u"?s=u.getSlideIndex(f.find(W=>W.classList.contains(v.slideActiveClass))):V=s;const fe=n==="next"||!n,X=n==="prev"||!n;let he=0,me=0;const le=(R?f[s].column:s)+(I&&typeof r>"u"?-j/2+.5:0);if(le<F){he=Math.max(F-le,P);for(let W=0;W<F-le;W+=1){const z=W-Math.floor(W/Q)*Q;if(R){const K=Q-z-1;for(let se=f.length-1;se>=0;se-=1)f[se].column===K&&C.push(se)}else C.push(Q-z-1)}}else if(le+j>Q-F){me=Math.max(le-(Q-F*2),P),q&&(me=Math.max(me,j-Q+L+1));for(let W=0;W<me;W+=1){const z=W-Math.floor(W/Q)*Q;R?f.forEach((K,se)=>{K.column===z&&$.push(se)}):$.push(z)}}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),u.params.effect==="cards"&&f.length<j+F*2&&($.includes(s)&&$.splice($.indexOf(s),1),C.includes(s)&&C.splice(C.indexOf(s),1)),X&&C.forEach(W=>{f[W].swiperLoopMoveDOM=!0,y.prepend(f[W]),f[W].swiperLoopMoveDOM=!1}),fe&&$.forEach(W=>{f[W].swiperLoopMoveDOM=!0,y.append(f[W]),f[W].swiperLoopMoveDOM=!1}),u.recalcSlides(),v.slidesPerView==="auto"?u.updateSlides():R&&(C.length>0&&X||$.length>0&&fe)&&u.slides.forEach((W,z)=>{u.grid.updateSlide(z,W,u.slides)}),v.watchSlidesProgress&&u.updateSlidesOffset(),t){if(C.length>0&&X){if(typeof e>"u"){const W=u.slidesGrid[V],K=u.slidesGrid[V+he]-W;c?u.setTranslate(u.translate-K):(u.slideTo(V+Math.ceil(he),0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-K,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-K))}else if(r){const W=R?C.length/v.grid.rows:C.length;u.slideTo(u.activeIndex+W,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if($.length>0&&fe)if(typeof e>"u"){const W=u.slidesGrid[V],K=u.slidesGrid[V-me]-W;c?u.setTranslate(u.translate-K):(u.slideTo(V-me,0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-K,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-K))}else{const W=R?$.length/v.grid.rows:$.length;u.slideTo(u.activeIndex-W,0,!1,!0)}}if(u.allowSlidePrev=p,u.allowSlideNext=g,u.controller&&u.controller.control&&!l){const W={slideRealIndex:e,direction:n,setTranslate:r,activeSlideIndex:s,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(z=>{!z.destroyed&&z.params.loop&&z.loopFix({...W,slideTo:z.params.slidesPerView===v.slidesPerView?t:!1})}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix({...W,slideTo:u.controller.control.params.slidesPerView===v.slidesPerView?t:!1})}u.emit("loopFix")}function V_(){const e=this,{params:t,slidesEl:n}=e;if(!t.loop||!n||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const r=[];e.slides.forEach(s=>{const i=typeof s.swiperSlideIndex>"u"?s.getAttribute("data-swiper-slide-index")*1:s.swiperSlideIndex;r[i]=s}),e.slides.forEach(s=>{s.removeAttribute("data-swiper-slide-index")}),r.forEach(s=>{n.append(s)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}var q_={loopCreate:G_,loopFix:W_,loopDestroy:V_};function Y_(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const n=t.params.touchEventsTarget==="container"?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),n.style.cursor="move",n.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}function K_(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e[e.params.touchEventsTarget==="container"?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}var X_={setGrabCursor:Y_,unsetGrabCursor:K_};function Z_(e,t=this){function n(r){if(!r||r===zu()||r===Qo())return null;r.assignedSlot&&(r=r.assignedSlot);const s=r.closest(e);return!s&&!r.getRootNode?null:s||n(r.getRootNode().host)}return n(t)}function Iv(e,t,n){const r=Qo(),{params:s}=e,i=s.edgeSwipeDetection,l=s.edgeSwipeThreshold;return i&&(n<=l||n>=r.innerWidth-l)?i==="prevent"?(t.preventDefault(),!0):!1:!0}function J_(e){const t=this;if(t.destroyed)return;const n=zu();let r=e;r.originalEvent&&(r=r.originalEvent);const s=t.touchEventsData;if(r.type==="pointerdown"){if(s.pointerId!==null&&s.pointerId!==r.pointerId)return;s.pointerId=r.pointerId}else r.type==="touchstart"&&r.targetTouches.length===1&&(s.touchId=r.targetTouches[0].identifier);if(r.type==="touchstart"){Iv(t,r,r.targetTouches[0].pageX);return}const{params:i,touches:l,enabled:c}=t;if(!c||!i.simulateTouch&&r.pointerType==="mouse"||t.animating&&i.preventInteractionOnTransition)return;!t.animating&&i.cssMode&&i.loop&&t.loopFix();let u=r.target;if(i.touchEventsTarget==="wrapper"&&!o_(u,t.wrapperEl)||"which"in r&&r.which===3||"button"in r&&r.button>0||s.isTouched&&s.isMoved)return;const f=!!i.noSwipingClass&&i.noSwipingClass!=="",p=r.composedPath?r.composedPath():r.path;f&&r.target&&r.target.shadowRoot&&p&&(u=p[0]);const g=i.noSwipingSelector?i.noSwipingSelector:`.${i.noSwipingClass}`,y=!!(r.target&&r.target.shadowRoot);if(i.noSwiping&&(y?Z_(g,u):u.closest(g))){t.allowClick=!0;return}if(i.swipeHandler&&!u.closest(i.swipeHandler))return;l.currentX=r.pageX,l.currentY=r.pageY;const v=l.currentX,S=l.currentY;if(!Iv(t,r,v))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),l.startX=v,l.startY=S,s.touchStartTime=vm(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,i.threshold>0&&(s.allowThresholdMove=!1);let A=!0;u.matches(s.focusableElements)&&(A=!1,u.nodeName==="SELECT"&&(s.isTouched=!1)),n.activeElement&&n.activeElement.matches(s.focusableElements)&&n.activeElement!==u&&(r.pointerType==="mouse"||r.pointerType!=="mouse"&&!u.matches(s.focusableElements))&&n.activeElement.blur();const T=A&&t.allowTouchMove&&i.touchStartPreventDefault;(i.touchStartForcePreventDefault||T)&&!u.isContentEditable&&r.preventDefault(),i.freeMode&&i.freeMode.enabled&&t.freeMode&&t.animating&&!i.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",r)}function eL(e){const t=zu(),n=this;if(n.destroyed)return;const r=n.touchEventsData,{params:s,touches:i,rtlTranslate:l,enabled:c}=n;if(!c||!s.simulateTouch&&e.pointerType==="mouse")return;let u=e;if(u.originalEvent&&(u=u.originalEvent),u.type==="pointermove"&&(r.touchId!==null||u.pointerId!==r.pointerId))return;let f;if(u.type==="touchmove"){if(f=[...u.changedTouches].find(F=>F.identifier===r.touchId),!f||f.identifier!==r.touchId)return}else f=u;if(!r.isTouched){r.startMoving&&r.isScrolling&&n.emit("touchMoveOpposite",u);return}const p=f.pageX,g=f.pageY;if(u.preventedByNestedSwiper){i.startX=p,i.startY=g;return}if(!n.allowTouchMove){u.target.matches(r.focusableElements)||(n.allowClick=!1),r.isTouched&&(Object.assign(i,{startX:p,startY:g,currentX:p,currentY:g}),r.touchStartTime=vm());return}if(s.touchReleaseOnEdges&&!s.loop)if(n.isVertical()){if(g<i.startY&&n.translate<=n.maxTranslate()||g>i.startY&&n.translate>=n.minTranslate()){r.isTouched=!1,r.isMoved=!1;return}}else{if(l&&(p>i.startX&&-n.translate<=n.maxTranslate()||p<i.startX&&-n.translate>=n.minTranslate()))return;if(!l&&(p<i.startX&&n.translate<=n.maxTranslate()||p>i.startX&&n.translate>=n.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(r.focusableElements)&&t.activeElement!==u.target&&u.pointerType!=="mouse"&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(r.focusableElements)){r.isMoved=!0,n.allowClick=!1;return}r.allowTouchCallbacks&&n.emit("touchMove",u),i.previousX=i.currentX,i.previousY=i.currentY,i.currentX=p,i.currentY=g;const y=i.currentX-i.startX,v=i.currentY-i.startY;if(n.params.threshold&&Math.sqrt(y**2+v**2)<n.params.threshold)return;if(typeof r.isScrolling>"u"){let F;n.isHorizontal()&&i.currentY===i.startY||n.isVertical()&&i.currentX===i.startX?r.isScrolling=!1:y*y+v*v>=25&&(F=Math.atan2(Math.abs(v),Math.abs(y))*180/Math.PI,r.isScrolling=n.isHorizontal()?F>s.touchAngle:90-F>s.touchAngle)}if(r.isScrolling&&n.emit("touchMoveOpposite",u),typeof r.startMoving>"u"&&(i.currentX!==i.startX||i.currentY!==i.startY)&&(r.startMoving=!0),r.isScrolling||u.type==="touchmove"&&r.preventTouchMoveFromPointerMove){r.isTouched=!1;return}if(!r.startMoving)return;n.allowClick=!1,!s.cssMode&&u.cancelable&&u.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&u.stopPropagation();let S=n.isHorizontal()?y:v,A=n.isHorizontal()?i.currentX-i.previousX:i.currentY-i.previousY;s.oneWayMovement&&(S=Math.abs(S)*(l?1:-1),A=Math.abs(A)*(l?1:-1)),i.diff=S,S*=s.touchRatio,l&&(S=-S,A=-A);const T=n.touchesDirection;n.swipeDirection=S>0?"prev":"next",n.touchesDirection=A>0?"prev":"next";const L=n.params.loop&&!s.cssMode,I=n.touchesDirection==="next"&&n.allowSlideNext||n.touchesDirection==="prev"&&n.allowSlidePrev;if(!r.isMoved){if(L&&I&&n.loopFix({direction:n.swipeDirection}),r.startTranslate=n.getTranslate(),n.setTransition(0),n.animating){const F=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});n.wrapperEl.dispatchEvent(F)}r.allowMomentumBounce=!1,s.grabCursor&&(n.allowSlideNext===!0||n.allowSlidePrev===!0)&&n.setGrabCursor(!0),n.emit("sliderFirstMove",u)}if(new Date().getTime(),s._loopSwapReset!==!1&&r.isMoved&&r.allowThresholdMove&&T!==n.touchesDirection&&L&&I&&Math.abs(S)>=1){Object.assign(i,{startX:p,startY:g,currentX:p,currentY:g,startTranslate:r.currentTranslate}),r.loopSwapReset=!0,r.startTranslate=r.currentTranslate;return}n.emit("sliderMove",u),r.isMoved=!0,r.currentTranslate=S+r.startTranslate;let j=!0,P=s.resistanceRatio;if(s.touchReleaseOnEdges&&(P=0),S>0?(L&&I&&r.allowThresholdMove&&r.currentTranslate>(s.centeredSlides?n.minTranslate()-n.slidesSizesGrid[n.activeIndex+1]-(s.slidesPerView!=="auto"&&n.slides.length-s.slidesPerView>=2?n.slidesSizesGrid[n.activeIndex+1]+n.params.spaceBetween:0)-n.params.spaceBetween:n.minTranslate())&&n.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),r.currentTranslate>n.minTranslate()&&(j=!1,s.resistance&&(r.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+r.startTranslate+S)**P))):S<0&&(L&&I&&r.allowThresholdMove&&r.currentTranslate<(s.centeredSlides?n.maxTranslate()+n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween+(s.slidesPerView!=="auto"&&n.slides.length-s.slidesPerView>=2?n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween:0):n.maxTranslate())&&n.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:n.slides.length-(s.slidesPerView==="auto"?n.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),r.currentTranslate<n.maxTranslate()&&(j=!1,s.resistance&&(r.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-r.startTranslate-S)**P))),j&&(u.preventedByNestedSwiper=!0),!n.allowSlideNext&&n.swipeDirection==="next"&&r.currentTranslate<r.startTranslate&&(r.currentTranslate=r.startTranslate),!n.allowSlidePrev&&n.swipeDirection==="prev"&&r.currentTranslate>r.startTranslate&&(r.currentTranslate=r.startTranslate),!n.allowSlidePrev&&!n.allowSlideNext&&(r.currentTranslate=r.startTranslate),s.threshold>0)if(Math.abs(S)>s.threshold||r.allowThresholdMove){if(!r.allowThresholdMove){r.allowThresholdMove=!0,i.startX=i.currentX,i.startY=i.currentY,r.currentTranslate=r.startTranslate,i.diff=n.isHorizontal()?i.currentX-i.startX:i.currentY-i.startY;return}}else{r.currentTranslate=r.startTranslate;return}!s.followFinger||s.cssMode||((s.freeMode&&s.freeMode.enabled&&n.freeMode||s.watchSlidesProgress)&&(n.updateActiveIndex(),n.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&n.freeMode&&n.freeMode.onTouchMove(),n.updateProgress(r.currentTranslate),n.setTranslate(r.currentTranslate))}function tL(e){const t=this;if(t.destroyed)return;const n=t.touchEventsData;let r=e;r.originalEvent&&(r=r.originalEvent);let s;if(r.type==="touchend"||r.type==="touchcancel"){if(s=[...r.changedTouches].find(F=>F.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else{if(n.touchId!==null||r.pointerId!==n.pointerId)return;s=r}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(r.type)&&!(["pointercancel","contextmenu"].includes(r.type)&&(t.browser.isSafari||t.browser.isWebView)))return;n.pointerId=null,n.touchId=null;const{params:l,touches:c,rtlTranslate:u,slidesGrid:f,enabled:p}=t;if(!p||!l.simulateTouch&&r.pointerType==="mouse")return;if(n.allowTouchCallbacks&&t.emit("touchEnd",r),n.allowTouchCallbacks=!1,!n.isTouched){n.isMoved&&l.grabCursor&&t.setGrabCursor(!1),n.isMoved=!1,n.startMoving=!1;return}l.grabCursor&&n.isMoved&&n.isTouched&&(t.allowSlideNext===!0||t.allowSlidePrev===!0)&&t.setGrabCursor(!1);const g=vm(),y=g-n.touchStartTime;if(t.allowClick){const F=r.path||r.composedPath&&r.composedPath();t.updateClickedSlide(F&&F[0]||r.target,F),t.emit("tap click",r),y<300&&g-n.lastClickTime<300&&t.emit("doubleTap doubleClick",r)}if(n.lastClickTime=vm(),x7(()=>{t.destroyed||(t.allowClick=!0)}),!n.isTouched||!n.isMoved||!t.swipeDirection||c.diff===0&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset){n.isTouched=!1,n.isMoved=!1,n.startMoving=!1;return}n.isTouched=!1,n.isMoved=!1,n.startMoving=!1;let v;if(l.followFinger?v=u?t.translate:-t.translate:v=-n.currentTranslate,l.cssMode)return;if(l.freeMode&&l.freeMode.enabled){t.freeMode.onTouchEnd({currentPos:v});return}const S=v>=-t.maxTranslate()&&!t.params.loop;let A=0,T=t.slidesSizesGrid[0];for(let F=0;F<f.length;F+=F<l.slidesPerGroupSkip?1:l.slidesPerGroup){const R=F<l.slidesPerGroupSkip-1?1:l.slidesPerGroup;typeof f[F+R]<"u"?(S||v>=f[F]&&v<f[F+R])&&(A=F,T=f[F+R]-f[F]):(S||v>=f[F])&&(A=F,T=f[f.length-1]-f[f.length-2])}let L=null,I=null;l.rewind&&(t.isBeginning?I=l.virtual&&l.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(L=0));const j=(v-f[A])/T,P=A<l.slidesPerGroupSkip-1?1:l.slidesPerGroup;if(y>l.longSwipesMs){if(!l.longSwipes){t.slideTo(t.activeIndex);return}t.swipeDirection==="next"&&(j>=l.longSwipesRatio?t.slideTo(l.rewind&&t.isEnd?L:A+P):t.slideTo(A)),t.swipeDirection==="prev"&&(j>1-l.longSwipesRatio?t.slideTo(A+P):I!==null&&j<0&&Math.abs(j)>l.longSwipesRatio?t.slideTo(I):t.slideTo(A))}else{if(!l.shortSwipes){t.slideTo(t.activeIndex);return}t.navigation&&(r.target===t.navigation.nextEl||r.target===t.navigation.prevEl)?r.target===t.navigation.nextEl?t.slideTo(A+P):t.slideTo(A):(t.swipeDirection==="next"&&t.slideTo(L!==null?L:A+P),t.swipeDirection==="prev"&&t.slideTo(I!==null?I:A))}}function Rv(){const e=this,{params:t,el:n}=e;if(n&&n.offsetWidth===0)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:r,allowSlidePrev:s,snapGrid:i}=e,l=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const c=l&&t.loop;if((t.slidesPerView==="auto"||t.slidesPerView>1)&&e.isEnd&&!e.isBeginning&&!e.params.centeredSlides&&!c){const u=l?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}else e.params.loop&&!l?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=s,e.allowSlideNext=r,e.params.watchOverflow&&i!==e.snapGrid&&e.checkOverflow()}function nL(e){const t=this;t.destroyed||t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function rL(){const e=this;if(e.destroyed)return;const{wrapperEl:t,rtlTranslate:n,enabled:r}=e;if(!r)return;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,e.translate===0&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();let s;const i=e.maxTranslate()-e.minTranslate();i===0?s=0:s=(e.translate-e.minTranslate())/i,s!==e.progress&&e.updateProgress(n?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function sL(e){const t=this;t.destroyed||(Yp(t,e.target),!(t.params.cssMode||t.params.slidesPerView!=="auto"&&!t.params.autoHeight)&&t.update())}function iL(){const e=this;e.destroyed||e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const A7=(e,t)=>{const n=zu(),{params:r,el:s,wrapperEl:i,device:l}=e,c=!!r.nested,u=t==="on"?"addEventListener":"removeEventListener",f=t;!s||typeof s=="string"||(n[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:c}),s[u]("touchstart",e.onTouchStart,{passive:!1}),s[u]("pointerdown",e.onTouchStart,{passive:!1}),n[u]("touchmove",e.onTouchMove,{passive:!1,capture:c}),n[u]("pointermove",e.onTouchMove,{passive:!1,capture:c}),n[u]("touchend",e.onTouchEnd,{passive:!0}),n[u]("pointerup",e.onTouchEnd,{passive:!0}),n[u]("pointercancel",e.onTouchEnd,{passive:!0}),n[u]("touchcancel",e.onTouchEnd,{passive:!0}),n[u]("pointerout",e.onTouchEnd,{passive:!0}),n[u]("pointerleave",e.onTouchEnd,{passive:!0}),n[u]("contextmenu",e.onTouchEnd,{passive:!0}),(r.preventClicks||r.preventClicksPropagation)&&s[u]("click",e.onClick,!0),r.cssMode&&i[u]("scroll",e.onScroll),r.updateOnWindowResize?e[f](l.ios||l.android?"resize orientationchange observerUpdate":"resize observerUpdate",Rv,!0):e[f]("observerUpdate",Rv,!0),s[u]("load",e.onLoad,{capture:!0}))};function oL(){const e=this,{params:t}=e;e.onTouchStart=J_.bind(e),e.onTouchMove=eL.bind(e),e.onTouchEnd=tL.bind(e),e.onDocumentTouchStart=iL.bind(e),t.cssMode&&(e.onScroll=rL.bind(e)),e.onClick=nL.bind(e),e.onLoad=sL.bind(e),A7(e,"on")}function aL(){A7(this,"off")}var lL={attachEvents:oL,detachEvents:aL};const Nv=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;function cL(){const e=this,{realIndex:t,initialized:n,params:r,el:s}=e,i=r.breakpoints;if(!i||i&&Object.keys(i).length===0)return;const l=zu(),c=r.breakpointsBase==="window"||!r.breakpointsBase?r.breakpointsBase:"container",u=["window","container"].includes(r.breakpointsBase)||!r.breakpointsBase?e.el:l.querySelector(r.breakpointsBase),f=e.getBreakpoint(i,c,u);if(!f||e.currentBreakpoint===f)return;const g=(f in i?i[f]:void 0)||e.originalParams,y=Nv(e,r),v=Nv(e,g),S=e.params.grabCursor,A=g.grabCursor,T=r.enabled;y&&!v?(s.classList.remove(`${r.containerModifierClass}grid`,`${r.containerModifierClass}grid-column`),e.emitContainerClasses()):!y&&v&&(s.classList.add(`${r.containerModifierClass}grid`),(g.grid.fill&&g.grid.fill==="column"||!g.grid.fill&&r.grid.fill==="column")&&s.classList.add(`${r.containerModifierClass}grid-column`),e.emitContainerClasses()),S&&!A?e.unsetGrabCursor():!S&&A&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(R=>{if(typeof g[R]>"u")return;const C=r[R]&&r[R].enabled,$=g[R]&&g[R].enabled;C&&!$&&e[R].disable(),!C&&$&&e[R].enable()});const L=g.direction&&g.direction!==r.direction,I=r.loop&&(g.slidesPerView!==r.slidesPerView||L),j=r.loop;L&&n&&e.changeDirection(),va(e.params,g);const P=e.params.enabled,F=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),T&&!P?e.disable():!T&&P&&e.enable(),e.currentBreakpoint=f,e.emit("_beforeBreakpoint",g),n&&(I?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!j&&F?(e.loopCreate(t),e.updateSlides()):j&&!F&&e.loopDestroy()),e.emit("breakpoint",g)}function uL(e,t="window",n){if(!e||t==="container"&&!n)return;let r=!1;const s=Qo(),i=t==="window"?s.innerHeight:n.clientHeight,l=Object.keys(e).map(c=>{if(typeof c=="string"&&c.indexOf("@")===0){const u=parseFloat(c.substr(1));return{value:i*u,point:c}}return{value:c,point:c}});l.sort((c,u)=>parseInt(c.value,10)-parseInt(u.value,10));for(let c=0;c<l.length;c+=1){const{point:u,value:f}=l[c];t==="window"?s.matchMedia(`(min-width: ${f}px)`).matches&&(r=u):f<=n.clientWidth&&(r=u)}return r||"max"}var dL={setBreakpoint:cL,getBreakpoint:uL};function fL(e,t){const n=[];return e.forEach(r=>{typeof r=="object"?Object.keys(r).forEach(s=>{r[s]&&n.push(t+s)}):typeof r=="string"&&n.push(t+r)}),n}function hL(){const e=this,{classNames:t,params:n,rtl:r,el:s,device:i}=e,l=fL(["initialized",n.direction,{"free-mode":e.params.freeMode&&n.freeMode.enabled},{autoheight:n.autoHeight},{rtl:r},{grid:n.grid&&n.grid.rows>1},{"grid-column":n.grid&&n.grid.rows>1&&n.grid.fill==="column"},{android:i.android},{ios:i.ios},{"css-mode":n.cssMode},{centered:n.cssMode&&n.centeredSlides},{"watch-progress":n.watchSlidesProgress}],n.containerModifierClass);t.push(...l),s.classList.add(...t),e.emitContainerClasses()}function pL(){const e=this,{el:t,classNames:n}=e;!t||typeof t=="string"||(t.classList.remove(...n),e.emitContainerClasses())}var mL={addClasses:hL,removeClasses:pL};function gL(){const e=this,{isLocked:t,params:n}=e,{slidesOffsetBefore:r}=n;if(r){const s=e.slides.length-1,i=e.slidesGrid[s]+e.slidesSizesGrid[s]+r*2;e.isLocked=e.size>i}else e.isLocked=e.snapGrid.length===1;n.allowSlideNext===!0&&(e.allowSlideNext=!e.isLocked),n.allowSlidePrev===!0&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}var xL={checkOverflow:gL},ub={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function bL(e,t){return function(r={}){const s=Object.keys(r)[0],i=r[s];if(typeof i!="object"||i===null){va(t,r);return}if(e[s]===!0&&(e[s]={enabled:!0}),s==="navigation"&&e[s]&&e[s].enabled&&!e[s].prevEl&&!e[s].nextEl&&(e[s].auto=!0),["pagination","scrollbar"].indexOf(s)>=0&&e[s]&&e[s].enabled&&!e[s].el&&(e[s].auto=!0),!(s in e&&"enabled"in i)){va(t,r);return}typeof e[s]=="object"&&!("enabled"in e[s])&&(e[s].enabled=!0),e[s]||(e[s]={enabled:!1}),va(t,r)}}const S1={eventsEmitter:m_,update:k_,translate:N_,transition:P_,slide:z_,loop:q_,grabCursor:X_,events:lL,breakpoints:dL,checkOverflow:xL,classes:mL},A1={};let H2=class fc{constructor(...t){let n,r;t.length===1&&t[0].constructor&&Object.prototype.toString.call(t[0]).slice(8,-1)==="Object"?r=t[0]:[n,r]=t,r||(r={}),r=va({},r),n&&!r.el&&(r.el=n);const s=zu();if(r.el&&typeof r.el=="string"&&s.querySelectorAll(r.el).length>1){const u=[];return s.querySelectorAll(r.el).forEach(f=>{const p=va({},r,{el:f});u.push(new fc(p))}),u}const i=this;i.__swiper__=!0,i.support=y7(),i.device=v7({userAgent:r.userAgent}),i.browser=w7(),i.eventsListeners={},i.eventsAnyListeners=[],i.modules=[...i.__modules__],r.modules&&Array.isArray(r.modules)&&r.modules.forEach(u=>{typeof u=="function"&&i.modules.indexOf(u)<0&&i.modules.push(u)});const l={};i.modules.forEach(u=>{u({params:r,swiper:i,extendParams:bL(r,l),on:i.on.bind(i),once:i.once.bind(i),off:i.off.bind(i),emit:i.emit.bind(i)})});const c=va({},ub,l);return i.params=va({},c,A1,r),i.originalParams=va({},i.params),i.passedParams=va({},r),i.params&&i.params.on&&Object.keys(i.params.on).forEach(u=>{i.on(u,i.params.on[u])}),i.params&&i.params.onAny&&i.onAny(i.params.onAny),Object.assign(i,{enabled:i.params.enabled,el:n,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal(){return i.params.direction==="horizontal"},isVertical(){return i.params.direction==="vertical"},activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:i.params.allowSlideNext,allowSlidePrev:i.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:i.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:i.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),i.emit("_swiper"),i.params.init&&i.init(),i}getDirectionLabel(t){return this.isHorizontal()?t:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[t]}getSlideIndex(t){const{slidesEl:n,params:r}=this,s=mc(n,`.${r.slideClass}, swiper-slide`),i=kv(s[0]);return kv(t)-i}getSlideIndexByData(t){return this.getSlideIndex(this.slides.find(n=>n.getAttribute("data-swiper-slide-index")*1===t))}getSlideIndexWhenGrid(t){return this.grid&&this.params.grid&&this.params.grid.rows>1&&(this.params.grid.fill==="column"?t=Math.floor(t/this.params.grid.rows):this.params.grid.fill==="row"&&(t=t%Math.ceil(this.slides.length/this.params.grid.rows))),t}recalcSlides(){const t=this,{slidesEl:n,params:r}=t;t.slides=mc(n,`.${r.slideClass}, swiper-slide`)}enable(){const t=this;t.enabled||(t.enabled=!0,t.params.grabCursor&&t.setGrabCursor(),t.emit("enable"))}disable(){const t=this;t.enabled&&(t.enabled=!1,t.params.grabCursor&&t.unsetGrabCursor(),t.emit("disable"))}setProgress(t,n){const r=this;t=Math.min(Math.max(t,0),1);const s=r.minTranslate(),l=(r.maxTranslate()-s)*t+s;r.translateTo(l,typeof n>"u"?0:n),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const n=t.el.className.split(" ").filter(r=>r.indexOf("swiper")===0||r.indexOf(t.params.containerModifierClass)===0);t.emit("_containerClasses",n.join(" "))}getSlideClasses(t){const n=this;return n.destroyed?"":t.className.split(" ").filter(r=>r.indexOf("swiper-slide")===0||r.indexOf(n.params.slideClass)===0).join(" ")}emitSlidesClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const n=[];t.slides.forEach(r=>{const s=t.getSlideClasses(r);n.push({slideEl:r,classNames:s}),t.emit("_slideClass",r,s)}),t.emit("_slideClasses",n)}slidesPerViewDynamic(t="current",n=!1){const r=this,{params:s,slides:i,slidesGrid:l,slidesSizesGrid:c,size:u,activeIndex:f}=r;let p=1;if(typeof s.slidesPerView=="number")return s.slidesPerView;if(s.centeredSlides){let g=i[f]?Math.ceil(i[f].swiperSlideSize):0,y;for(let v=f+1;v<i.length;v+=1)i[v]&&!y&&(g+=Math.ceil(i[v].swiperSlideSize),p+=1,g>u&&(y=!0));for(let v=f-1;v>=0;v-=1)i[v]&&!y&&(g+=i[v].swiperSlideSize,p+=1,g>u&&(y=!0))}else if(t==="current")for(let g=f+1;g<i.length;g+=1)(n?l[g]+c[g]-l[f]<u:l[g]-l[f]<u)&&(p+=1);else for(let g=f-1;g>=0;g-=1)l[f]-l[g]<u&&(p+=1);return p}update(){const t=this;if(!t||t.destroyed)return;const{snapGrid:n,params:r}=t;r.breakpoints&&t.setBreakpoint(),[...t.el.querySelectorAll('[loading="lazy"]')].forEach(l=>{l.complete&&Yp(t,l)}),t.updateSize(),t.updateSlides(),t.updateProgress(),t.updateSlidesClasses();function s(){const l=t.rtlTranslate?t.translate*-1:t.translate,c=Math.min(Math.max(l,t.maxTranslate()),t.minTranslate());t.setTranslate(c),t.updateActiveIndex(),t.updateSlidesClasses()}let i;if(r.freeMode&&r.freeMode.enabled&&!r.cssMode)s(),r.autoHeight&&t.updateAutoHeight();else{if((r.slidesPerView==="auto"||r.slidesPerView>1)&&t.isEnd&&!r.centeredSlides){const l=t.virtual&&r.virtual.enabled?t.virtual.slides:t.slides;i=t.slideTo(l.length-1,0,!1,!0)}else i=t.slideTo(t.activeIndex,0,!1,!0);i||s()}r.watchOverflow&&n!==t.snapGrid&&t.checkOverflow(),t.emit("update")}changeDirection(t,n=!0){const r=this,s=r.params.direction;return t||(t=s==="horizontal"?"vertical":"horizontal"),t===s||t!=="horizontal"&&t!=="vertical"||(r.el.classList.remove(`${r.params.containerModifierClass}${s}`),r.el.classList.add(`${r.params.containerModifierClass}${t}`),r.emitContainerClasses(),r.params.direction=t,r.slides.forEach(i=>{t==="vertical"?i.style.width="":i.style.height=""}),r.emit("changeDirection"),n&&r.update()),r}changeLanguageDirection(t){const n=this;n.rtl&&t==="rtl"||!n.rtl&&t==="ltr"||(n.rtl=t==="rtl",n.rtlTranslate=n.params.direction==="horizontal"&&n.rtl,n.rtl?(n.el.classList.add(`${n.params.containerModifierClass}rtl`),n.el.dir="rtl"):(n.el.classList.remove(`${n.params.containerModifierClass}rtl`),n.el.dir="ltr"),n.update())}mount(t){const n=this;if(n.mounted)return!0;let r=t||n.params.el;if(typeof r=="string"&&(r=document.querySelector(r)),!r)return!1;r.swiper=n,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===n.params.swiperElementNodeName.toUpperCase()&&(n.isElement=!0);const s=()=>`.${(n.params.wrapperClass||"").trim().split(" ").join(".")}`;let l=r&&r.shadowRoot&&r.shadowRoot.querySelector?r.shadowRoot.querySelector(s()):mc(r,s())[0];return!l&&n.params.createElements&&(l=lb("div",n.params.wrapperClass),r.append(l),mc(r,`.${n.params.slideClass}`).forEach(c=>{l.append(c)})),Object.assign(n,{el:r,wrapperEl:l,slidesEl:n.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:l,hostEl:n.isElement?r.parentNode.host:r,mounted:!0,rtl:r.dir.toLowerCase()==="rtl"||Uc(r,"direction")==="rtl",rtlTranslate:n.params.direction==="horizontal"&&(r.dir.toLowerCase()==="rtl"||Uc(r,"direction")==="rtl"),wrongRTL:Uc(l,"display")==="-webkit-box"}),!0}init(t){const n=this;if(n.initialized||n.mount(t)===!1)return n;n.emit("beforeInit"),n.params.breakpoints&&n.setBreakpoint(),n.addClasses(),n.updateSize(),n.updateSlides(),n.params.watchOverflow&&n.checkOverflow(),n.params.grabCursor&&n.enabled&&n.setGrabCursor(),n.params.loop&&n.virtual&&n.params.virtual.enabled?n.slideTo(n.params.initialSlide+n.virtual.slidesBefore,0,n.params.runCallbacksOnInit,!1,!0):n.slideTo(n.params.initialSlide,0,n.params.runCallbacksOnInit,!1,!0),n.params.loop&&n.loopCreate(void 0,!0),n.attachEvents();const s=[...n.el.querySelectorAll('[loading="lazy"]')];return n.isElement&&s.push(...n.hostEl.querySelectorAll('[loading="lazy"]')),s.forEach(i=>{i.complete?Yp(n,i):i.addEventListener("load",l=>{Yp(n,l.target)})}),cb(n),n.initialized=!0,cb(n),n.emit("init"),n.emit("afterInit"),n}destroy(t=!0,n=!0){const r=this,{params:s,el:i,wrapperEl:l,slides:c}=r;return typeof r.params>"u"||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),s.loop&&r.loopDestroy(),n&&(r.removeClasses(),i&&typeof i!="string"&&i.removeAttribute("style"),l&&l.removeAttribute("style"),c&&c.length&&c.forEach(u=>{u.classList.remove(s.slideVisibleClass,s.slideFullyVisibleClass,s.slideActiveClass,s.slideNextClass,s.slidePrevClass),u.removeAttribute("style"),u.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(u=>{r.off(u)}),t!==!1&&(r.el&&typeof r.el!="string"&&(r.el.swiper=null),t_(r)),r.destroyed=!0),null}static extendDefaults(t){va(A1,t)}static get extendedDefaults(){return A1}static get defaults(){return ub}static installModule(t){fc.prototype.__modules__||(fc.prototype.__modules__=[]);const n=fc.prototype.__modules__;typeof t=="function"&&n.indexOf(t)<0&&n.push(t)}static use(t){return Array.isArray(t)?(t.forEach(n=>fc.installModule(n)),fc):(fc.installModule(t),fc)}};Object.keys(S1).forEach(e=>{Object.keys(S1[e]).forEach(t=>{H2.prototype[t]=S1[e][t]})});H2.use([h_,p_]);const T7=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_snapToSlideEdge","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function Ou(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"&&!e.__swiper__}function Hd(e,t){const n=["__proto__","constructor","prototype"];Object.keys(t).filter(r=>n.indexOf(r)<0).forEach(r=>{typeof e[r]>"u"?e[r]=t[r]:Ou(t[r])&&Ou(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Hd(e[r],t[r]):e[r]=t[r]})}function C7(e={}){return e.navigation&&typeof e.navigation.nextEl>"u"&&typeof e.navigation.prevEl>"u"}function k7(e={}){return e.pagination&&typeof e.pagination.el>"u"}function _7(e={}){return e.scrollbar&&typeof e.scrollbar.el>"u"}function L7(e=""){const t=e.split(" ").map(r=>r.trim()).filter(r=>!!r),n=[];return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n.join(" ")}function yL(e=""){return e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function vL({swiper:e,slides:t,passedParams:n,changedParams:r,nextEl:s,prevEl:i,scrollbarEl:l,paginationEl:c}){const u=r.filter($=>$!=="children"&&$!=="direction"&&$!=="wrapperClass"),{params:f,pagination:p,navigation:g,scrollbar:y,virtual:v,thumbs:S}=e;let A,T,L,I,j,P,F,R;r.includes("thumbs")&&n.thumbs&&n.thumbs.swiper&&!n.thumbs.swiper.destroyed&&f.thumbs&&(!f.thumbs.swiper||f.thumbs.swiper.destroyed)&&(A=!0),r.includes("controller")&&n.controller&&n.controller.control&&f.controller&&!f.controller.control&&(T=!0),r.includes("pagination")&&n.pagination&&(n.pagination.el||c)&&(f.pagination||f.pagination===!1)&&p&&!p.el&&(L=!0),r.includes("scrollbar")&&n.scrollbar&&(n.scrollbar.el||l)&&(f.scrollbar||f.scrollbar===!1)&&y&&!y.el&&(I=!0),r.includes("navigation")&&n.navigation&&(n.navigation.prevEl||i)&&(n.navigation.nextEl||s)&&(f.navigation||f.navigation===!1)&&g&&!g.prevEl&&!g.nextEl&&(j=!0);const C=$=>{e[$]&&(e[$].destroy(),$==="navigation"?(e.isElement&&(e[$].prevEl.remove(),e[$].nextEl.remove()),f[$].prevEl=void 0,f[$].nextEl=void 0,e[$].prevEl=void 0,e[$].nextEl=void 0):(e.isElement&&e[$].el.remove(),f[$].el=void 0,e[$].el=void 0))};r.includes("loop")&&e.isElement&&(f.loop&&!n.loop?P=!0:!f.loop&&n.loop?F=!0:R=!0),u.forEach($=>{if(Ou(f[$])&&Ou(n[$]))Object.assign(f[$],n[$]),($==="navigation"||$==="pagination"||$==="scrollbar")&&"enabled"in n[$]&&!n[$].enabled&&C($);else{const Q=n[$];(Q===!0||Q===!1)&&($==="navigation"||$==="pagination"||$==="scrollbar")?Q===!1&&C($):f[$]=n[$]}}),u.includes("controller")&&!T&&e.controller&&e.controller.control&&f.controller&&f.controller.control&&(e.controller.control=f.controller.control),r.includes("children")&&t&&v&&f.virtual.enabled?(v.slides=t,v.update(!0)):r.includes("virtual")&&v&&f.virtual.enabled&&(t&&(v.slides=t),v.update(!0)),r.includes("children")&&t&&f.loop&&(R=!0),A&&S.init()&&S.update(!0),T&&(e.controller.control=f.controller.control),L&&(e.isElement&&(!c||typeof c=="string")&&(c=document.createElement("div"),c.classList.add("swiper-pagination"),c.part.add("pagination"),e.el.appendChild(c)),c&&(f.pagination.el=c),p.init(),p.render(),p.update()),I&&(e.isElement&&(!l||typeof l=="string")&&(l=document.createElement("div"),l.classList.add("swiper-scrollbar"),l.part.add("scrollbar"),e.el.appendChild(l)),l&&(f.scrollbar.el=l),y.init(),y.updateSize(),y.setTranslate()),j&&(e.isElement&&((!s||typeof s=="string")&&(s=document.createElement("div"),s.classList.add("swiper-button-next"),Lv(s,e.navigation.arrowSvg),s.part.add("button-next"),e.el.appendChild(s)),(!i||typeof i=="string")&&(i=document.createElement("div"),i.classList.add("swiper-button-prev"),Lv(i,e.navigation.arrowSvg),i.part.add("button-prev"),e.el.appendChild(i))),s&&(f.navigation.nextEl=s),i&&(f.navigation.prevEl=i),g.init(),g.update()),r.includes("allowSlideNext")&&(e.allowSlideNext=n.allowSlideNext),r.includes("allowSlidePrev")&&(e.allowSlidePrev=n.allowSlidePrev),r.includes("direction")&&e.changeDirection(n.direction,!1),(P||R)&&e.loopDestroy(),(F||R)&&e.loopCreate(),e.update()}function wL(e={},t=!0){const n={on:{}},r={},s={};Hd(n,ub),n._emitClasses=!0,n.init=!1;const i={},l=T7.map(u=>u.replace(/_/,"")),c=Object.assign({},e);return Object.keys(c).forEach(u=>{typeof e[u]>"u"||(l.indexOf(u)>=0?Ou(e[u])?(n[u]={},s[u]={},Hd(n[u],e[u]),Hd(s[u],e[u])):(n[u]=e[u],s[u]=e[u]):u.search(/on[A-Z]/)===0&&typeof e[u]=="function"?t?r[`${u[2].toLowerCase()}${u.substr(3)}`]=e[u]:n.on[`${u[2].toLowerCase()}${u.substr(3)}`]=e[u]:i[u]=e[u])}),["navigation","pagination","scrollbar"].forEach(u=>{n[u]===!0&&(n[u]={}),n[u]===!1&&delete n[u]}),{params:n,passedParams:s,rest:i,events:r}}function SL({el:e,nextEl:t,prevEl:n,paginationEl:r,scrollbarEl:s,swiper:i},l){C7(l)&&t&&n&&(i.params.navigation.nextEl=t,i.originalParams.navigation.nextEl=t,i.params.navigation.prevEl=n,i.originalParams.navigation.prevEl=n),k7(l)&&r&&(i.params.pagination.el=r,i.originalParams.pagination.el=r),_7(l)&&s&&(i.params.scrollbar.el=s,i.originalParams.scrollbar.el=s),i.init(e)}function AL(e,t,n,r,s){const i=[];if(!t)return i;const l=u=>{i.indexOf(u)<0&&i.push(u)};if(n&&r){const u=r.map(s),f=n.map(s);u.join("")!==f.join("")&&l("children"),r.length!==n.length&&l("children")}return T7.filter(u=>u[0]==="_").map(u=>u.replace(/_/,"")).forEach(u=>{if(u in e&&u in t)if(Ou(e[u])&&Ou(t[u])){const f=Object.keys(e[u]),p=Object.keys(t[u]);f.length!==p.length?l(u):(f.forEach(g=>{e[u][g]!==t[u][g]&&l(u)}),p.forEach(g=>{e[u][g]!==t[u][g]&&l(u)}))}else e[u]!==t[u]&&l(u)}),i}const TL=e=>{!e||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.emit("_virtualUpdated"),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())};function Sm(){return Sm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Sm.apply(this,arguments)}function E7(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function I7(e){const t=[];return D.Children.toArray(e).forEach(n=>{E7(n)?t.push(n):n.props&&n.props.children&&I7(n.props.children).forEach(r=>t.push(r))}),t}function CL(e){const t=[],n={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return D.Children.toArray(e).forEach(r=>{if(E7(r))t.push(r);else if(r.props&&r.props.slot&&n[r.props.slot])n[r.props.slot].push(r);else if(r.props&&r.props.children){const s=I7(r.props.children);s.length>0?s.forEach(i=>t.push(i)):n["container-end"].push(r)}else n["container-end"].push(r)}),{slides:t,slots:n}}function kL(e,t,n){if(!n)return null;const r=p=>{let g=p;return p<0?g=t.length+p:g>=t.length&&(g=g-t.length),g},s=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${n.offset}px`}:{top:`${n.offset}px`},{from:i,to:l}=n,c=e.params.loop?-t.length:0,u=e.params.loop?t.length*2:t.length,f=[];for(let p=c;p<u;p+=1)p>=i&&p<=l&&f.push(t[r(p)]);return f.map((p,g)=>D.cloneElement(p,{swiper:e,style:s,key:p.props.virtualIndex||p.key||`slide-${g}`}))}function kf(e,t){return typeof window>"u"?b.useEffect(e,t):b.useLayoutEffect(e,t)}const Mv=b.createContext(null),_L=b.createContext(null),sh=b.forwardRef(({className:e,tag:t="div",wrapperTag:n="div",children:r,onSwiper:s,...i}={},l)=>{let c=!1;const[u,f]=b.useState("swiper"),[p,g]=b.useState(null),[y,v]=b.useState(!1),S=b.useRef(!1),A=b.useRef(null),T=b.useRef(null),L=b.useRef(null),I=b.useRef(null),j=b.useRef(null),P=b.useRef(null),F=b.useRef(null),R=b.useRef(null),{params:C,passedParams:$,rest:Q,events:q}=wL(i),{slides:V,slots:fe}=CL(r),X=()=>{v(!y)};Object.assign(C.on,{_containerClasses(W,z){f(z)}});const he=()=>{Object.assign(C.on,q),c=!0;const W={...C};if(delete W.wrapperClass,T.current=new H2(W),T.current.virtual&&T.current.params.virtual.enabled){T.current.virtual.slides=V;const z={cache:!1,slides:V,renderExternal:g,renderExternalUpdate:!1};Hd(T.current.params.virtual,z),Hd(T.current.originalParams.virtual,z)}};A.current||he(),T.current&&T.current.on("_beforeBreakpoint",X);const me=()=>{c||!q||!T.current||Object.keys(q).forEach(W=>{T.current.on(W,q[W])})},de=()=>{!q||!T.current||Object.keys(q).forEach(W=>{T.current.off(W,q[W])})};b.useEffect(()=>()=>{T.current&&T.current.off("_beforeBreakpoint",X)}),b.useEffect(()=>{!S.current&&T.current&&(T.current.emitSlidesClasses(),S.current=!0)}),kf(()=>{if(l&&(l.current=A.current),!!A.current)return T.current.destroyed&&he(),SL({el:A.current,nextEl:j.current,prevEl:P.current,paginationEl:F.current,scrollbarEl:R.current,swiper:T.current},C),s&&!T.current.destroyed&&s(T.current),()=>{T.current&&!T.current.destroyed&&T.current.destroy(!0,!1)}},[]),kf(()=>{me();const W=AL($,L.current,V,I.current,z=>z.key);return L.current=$,I.current=V,W.length&&T.current&&!T.current.destroyed&&vL({swiper:T.current,slides:V,passedParams:$,changedParams:W,nextEl:j.current,prevEl:P.current,scrollbarEl:R.current,paginationEl:F.current}),()=>{de()}}),kf(()=>{TL(T.current)},[p]);function le(){return C.virtual?kL(T.current,V,p):V.map((W,z)=>D.cloneElement(W,{swiper:T.current,swiperSlideIndex:z}))}return D.createElement(t,Sm({ref:A,className:L7(`${u}${e?` ${e}`:""}`)},Q),D.createElement(_L.Provider,{value:T.current},fe["container-start"],D.createElement(n,{className:yL(C.wrapperClass)},fe["wrapper-start"],le(),fe["wrapper-end"]),C7(C)&&D.createElement(D.Fragment,null,D.createElement("div",{ref:P,className:"swiper-button-prev"}),D.createElement("div",{ref:j,className:"swiper-button-next"})),_7(C)&&D.createElement("div",{ref:R,className:"swiper-scrollbar"}),k7(C)&&D.createElement("div",{ref:F,className:"swiper-pagination"}),fe["container-end"]))});sh.displayName="Swiper";const Qu=b.forwardRef(({tag:e="div",children:t,className:n="",swiper:r,zoom:s,lazy:i,virtualIndex:l,swiperSlideIndex:c,...u}={},f)=>{const p=b.useRef(null),[g,y]=b.useState("swiper-slide"),[v,S]=b.useState(!1);function A(j,P,F){P===p.current&&y(F)}kf(()=>{if(typeof c<"u"&&(p.current.swiperSlideIndex=c),f&&(f.current=p.current),!(!p.current||!r)){if(r.destroyed){g!=="swiper-slide"&&y("swiper-slide");return}return r.on("_slideClass",A),()=>{r&&r.off("_slideClass",A)}}}),kf(()=>{r&&p.current&&!r.destroyed&&y(r.getSlideClasses(p.current))},[r]);const T={isActive:g.indexOf("swiper-slide-active")>=0,isVisible:g.indexOf("swiper-slide-visible")>=0,isFullyVisible:g.indexOf("swiper-slide-fully-visible")>=0,isPrev:g.indexOf("swiper-slide-prev")>=0,isNext:g.indexOf("swiper-slide-next")>=0},L=()=>typeof t=="function"?t(T):t,I=()=>{S(!0)};return D.createElement(e,Sm({ref:p,className:L7(`${g}${n?` ${n}`:""}`),"data-swiper-slide-index":l,onLoad:I},u),s&&D.createElement(Mv.Provider,{value:T},D.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":typeof s=="number"?s:void 0},L(),i&&!v&&D.createElement("div",{className:"swiper-lazy-preloader",ref:j=>{j&&(j.lazyPreloaderManaged=!0)}}))),!s&&D.createElement(Mv.Provider,{value:T},L(),i&&!v&&D.createElement("div",{className:"swiper-lazy-preloader",ref:j=>{j&&(j.lazyPreloaderManaged=!0)}})))});Qu.displayName="SwiperSlide";const Ki=[];for(let e=0;e<256;++e)Ki.push((e+256).toString(16).slice(1));function LL(e,t=0){return(Ki[e[t+0]]+Ki[e[t+1]]+Ki[e[t+2]]+Ki[e[t+3]]+"-"+Ki[e[t+4]]+Ki[e[t+5]]+"-"+Ki[e[t+6]]+Ki[e[t+7]]+"-"+Ki[e[t+8]]+Ki[e[t+9]]+"-"+Ki[e[t+10]]+Ki[e[t+11]]+Ki[e[t+12]]+Ki[e[t+13]]+Ki[e[t+14]]+Ki[e[t+15]]).toLowerCase()}let T1;const EL=new Uint8Array(16);function IL(){if(!T1){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");T1=crypto.getRandomValues.bind(crypto)}return T1(EL)}const RL=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Dv={randomUUID:RL};function NL(e,t,n){e=e||{};const r=e.random??e.rng?.()??IL();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,LL(r)}function ML(e,t,n){return Dv.randomUUID&&!e?Dv.randomUUID():NL(e)}const DL={},jv=e=>{let t;const n=new Set,r=(p,g)=>{const y=typeof p=="function"?p(t):p;if(!Object.is(y,t)){const v=t;t=g??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(S=>S(t,v))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(DL?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(r,s,u);return u},jL=e=>e?jv(e):jv;var C1={exports:{}},k1={},_1={exports:{}},L1={};var Pv;function PL(){if(Pv)return L1;Pv=1;var e=cg();function t(g,y){return g===y&&(g!==0||1/g===1/y)||g!==g&&y!==y}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,i=e.useLayoutEffect,l=e.useDebugValue;function c(g,y){var v=y(),S=r({inst:{value:v,getSnapshot:y}}),A=S[0].inst,T=S[1];return i(function(){A.value=v,A.getSnapshot=y,u(A)&&T({inst:A})},[g,v,y]),s(function(){return u(A)&&T({inst:A}),g(function(){u(A)&&T({inst:A})})},[g]),l(v),v}function u(g){var y=g.getSnapshot;g=g.value;try{var v=y();return!n(g,v)}catch{return!0}}function f(g,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return L1.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,L1}var Bv;function BL(){return Bv||(Bv=1,_1.exports=PL()),_1.exports}var Fv;function FL(){if(Fv)return k1;Fv=1;var e=cg(),t=BL();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,i=e.useRef,l=e.useEffect,c=e.useMemo,u=e.useDebugValue;return k1.useSyncExternalStoreWithSelector=function(f,p,g,y,v){var S=i(null);if(S.current===null){var A={hasValue:!1,value:null};S.current=A}else A=S.current;S=c(function(){function L(R){if(!I){if(I=!0,j=R,R=y(R),v!==void 0&&A.hasValue){var C=A.value;if(v(C,R))return P=C}return P=R}if(C=P,r(j,R))return C;var $=y(R);return v!==void 0&&v(C,$)?(j=R,C):(j=R,P=$)}var I=!1,j,P,F=g===void 0?null:g;return[function(){return L(p())},F===null?void 0:function(){return L(F())}]},[p,g,y,v]);var T=s(f,S[0],S[1]);return l(function(){A.hasValue=!0,A.value=T},[T]),u(T),T},k1}var Ov;function OL(){return Ov||(Ov=1,C1.exports=FL()),C1.exports}var QL=OL();const $L=m7(QL),R7={},{useDebugValue:HL}=D,{useSyncExternalStoreWithSelector:UL}=$L;let Qv=!1;const zL=e=>e;function GL(e,t=zL,n){(R7?"production":void 0)!=="production"&&n&&!Qv&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Qv=!0);const r=UL(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return HL(r),r}const $v=e=>{(R7?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?jL(e):e,n=(r,s)=>GL(t,r,s);return Object.assign(n,t),n},N7=e=>e?$v(e):$v,Am="auth:unauthorized";let Fd=null;class La extends Error{constructor(t,n,r){super(t),this.status=n,this.code=r,this.name="TerminalApiError"}status;code}async function WL(){const e=await fetch("/api/terminal/update");if(!e.ok)throw new La("Failed to load update state",e.status);return e.json()}async function VL(){const e=await hr(),t=await fetch("/api/terminal/update/check",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new La("Failed to check for updates",t.status);return t.json()}async function qL(){const e=await hr(),t=await fetch("/api/terminal/update/restart",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to restart Termdock"}));throw new La(n.error||"Failed to restart Termdock",t.status)}return t.json()}async function YL(){const e=await fetch("/api/terminal/quota");if(!e.ok)throw new La("Failed to fetch quota",e.status);return e.json()}async function KL(){const e=await hr(),t=await fetch("/api/terminal/quota/refresh",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new La("Failed to refresh quota",t.status);return t.json()}const eu=8e3,XL=32e3,Vl=1e4,Ud=45e3,ZL=8e3,JL=8e3,eE=15e3,tE=1e4,Xd=5e3;let nE=0;const Kp=[];let E1=!1;function Dc(e,t={}){if(typeof window>"u")return;const n=JSON.stringify({level:e==="error"||e==="timeout_or_abort"||e==="response_body_timeout"||e==="response_body_parse_error"?"warn":"info",message:`DIFF_API ${e}`,data:{seq:++nE,ts:Date.now(),...t}});Kp.push(n),rE()}async function rE(){if(!E1){E1=!0;try{for(;Kp.length>0;){const e=Kp[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),Kp.shift()}catch{break}}}finally{E1=!1}}}function sE(e,t,n){const r=new AbortController;let s=setTimeout(()=>{r.abort(new DOMException(n,"TimeoutError"))},t);const i=()=>r.abort(e?.reason);return e&&(e.aborted?i():e.addEventListener("abort",i,{once:!0})),{signal:r.signal,cleanup:()=>{s&&(clearTimeout(s),s=null),e?.removeEventListener("abort",i)}}}async function Rs(e,t,n,r){const{signal:s,cleanup:i}=sE(t?.signal??void 0,n,r);try{return await fetch(e,{...t,signal:s})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(r):l}finally{i()}}async function M7(e,t,n){let r=null;const s=new Promise((i,l)=>{r=setTimeout(()=>l(new Error(n)),t)});try{return await Promise.race([e.text(),s])}finally{r&&clearTimeout(r)}}async function Zd(e,t,n){const r=await M7(e,t,n);return JSON.parse(r)}if(typeof window<"u"&&!window.__termdockFetchPatched){window.__termdockFetchPatched=!0;const e=window.fetch.bind(window);window.fetch=async(...t)=>{const n=await e(...t);if(n.status===401){Fd=null;try{window.dispatchEvent(new CustomEvent(Am))}catch{}}return n}}async function hr(){if(Fd)return Fd;const e=await Rs("/api/csrf-token",void 0,ZL,"CSRF token request timed out");if(!e.ok)throw new Error("Failed to get CSRF token");const t=await Zd(e,Xd,"CSRF token response timed out");if(!t.csrfToken)throw new Error("Invalid CSRF token response");return Fd=t.csrfToken,Fd}function D7(){Fd=null}const iE=2e4,Hv=8e3,oE=1500,so=new Map,aE=24,lE=40,cE=40;function uE(e){return e.retryState.retryCount>=2||e.pendingInputs.length>=cE?"congested":e.retryState.retryCount>=1||e.pendingInputs.length>=8?"degraded":"good"}function Uv(e){if(e.pendingInputs.length===0||e.ws.readyState!==WebSocket.OPEN)return;const t=e.pendingInputs.splice(0);for(const n of t)try{e.ws.send(JSON.stringify({type:"input",data:n}))}catch{}}function j7(e){if(e.ws.readyState!==WebSocket.OPEN)return;const t=uE(e);if(t==="good"){Uv(e);return}if(e.inputFlushTimer)return;const n=t==="congested"?lE:aE;e.inputFlushTimer=setTimeout(()=>{e.inputFlushTimer=null,Uv(e)},n)}const _f=new Map;function dE(e,t,n,r){const s=_f.get(e);s&&(_f.delete(e),t?s.resolve({success:!0,layout:n}):s.reject(new Error(r||"Tmux action failed")))}function fE(e,t){const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/terminal/${e}/ws`;return t>0?`${r}?since=${t}`:r}const zv=new Map;async function hE(e){const t=await hr(),n=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({cols:e.cols||80,rows:e.rows||24,mode:e.mode||"shell",tmuxSessionName:e.tmuxSessionName,cwd:e.cwd,termType:e.termType})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(r.error||"Failed to create terminal session")}return n.json()}function pE(e,t,n,r={}){const{maxRetries:s=10,initialRetryDelay:i=1e3,maxRetryDelay:l=2e4,connectionTimeout:c=15e3}=r,u={maxRetries:s,initialDelayMs:i,maxDelayMs:l,connectionTimeoutMs:c,retryCount:0,retryTimeout:null,connectionTimeoutId:null,isClosed:!1,isSuspended:!1};let f=null,p=zv.get(e)??0;zv.delete(e);const g=[];let y=!1,v=null;const S=new WeakSet,A=()=>{u.retryTimeout&&(clearTimeout(u.retryTimeout),u.retryTimeout=null),u.connectionTimeoutId&&(clearTimeout(u.connectionTimeoutId),u.connectionTimeoutId=null),v&&(clearTimeout(v),v=null)},T=F=>{F.heartbeatTimer&&(clearInterval(F.heartbeatTimer),F.heartbeatTimer=null),F.pongTimer&&(clearTimeout(F.pongTimer),F.pongTimer=null),F.inputFlushTimer&&(clearTimeout(F.inputFlushTimer),F.inputFlushTimer=null)},L=F=>{T(F),F.heartbeatTimer=setInterval(()=>{if(F.ws.readyState===WebSocket.OPEN){try{F.ws.send(JSON.stringify({type:"ping"}))}catch{}F.pongTimer&&clearTimeout(F.pongTimer),F.pongTimer=setTimeout(()=>{if(Date.now()-F.lastInboundAt>=Hv)try{F.ws.close()}catch{}},Hv)}},iE)},I=()=>{if(u.isClosed=!0,A(),f){T(f),so.delete(e);try{f.ws.close()}catch{}f=null}},j=()=>{if(u.isClosed)return;if(f){S.add(f.ws),T(f);try{f.ws.close()}catch{}}const F=fE(e,p),R=new WebSocket(F);y=!1,u.connectionTimeoutId=setTimeout(()=>{R.readyState!==WebSocket.OPEN&&(y=!0,R.close(),P(new Error("WebSocket connection timeout"),!1))},c);const C={ws:R,onEvent:t,onError:n,reconnectNow:()=>{if(!u.isClosed&&(u.isSuspended=!1,!v)){if(A(),f){S.add(f.ws),T(f);try{f.ws.close()}catch{}}t({type:"reconnecting",attempt:Math.min(u.retryCount+1,s),maxAttempts:s}),u.retryCount=Math.min(u.retryCount+1,s),y=!0,v=setTimeout(()=>{v=null,y=!1,j()},0)}},suspendReconnect:()=>{u.isClosed||(u.isSuspended=!0,u.retryTimeout&&(clearTimeout(u.retryTimeout),u.retryTimeout=null))},retryState:u,lastSeq:p,pendingInputs:g,inputFlushTimer:null,heartbeatTimer:null,pongTimer:null,lastInboundAt:Date.now(),inboundSequence:0};R.onopen=()=>{A(),u.retryCount=0,C.lastInboundAt=Date.now(),C.inboundSequence+=1,L(C),j7(C)},R.onmessage=$=>{C.lastInboundAt=Date.now(),C.inboundSequence+=1;try{const Q=JSON.parse($.data);if(Q.type==="pong"){C.pongTimer&&(clearTimeout(C.pongTimer),C.pongTimer=null);return}if(Q.type==="tmux-result"&&Q.reqId){dE(Q.reqId,Q.success!==!1,Q.layout,Q.error);return}if(Q.type==="tmux-layout"&&Q.layout){t({type:"tmux-layout",layout:Q.layout});return}if(Q.type==="tmux-screen-sync"&&Array.isArray(Q.chunks)){t({type:"tmux-screen-sync",chunks:Q.chunks.filter(V=>typeof V=="string"),cols:typeof Q.cols=="number"?Q.cols:void 0,rows:typeof Q.rows=="number"?Q.rows:void 0,generation:typeof Q.generation=="number"?Q.generation:void 0});return}if(Q.type==="active-program"){t({type:"active-program",activeProgram:Q.activeProgram,activeProgramRaw:Q.activeProgramRaw,activeProgramSource:Q.activeProgramSource});return}if(Q.type==="cwd"){t({type:"cwd",cwd:Q.cwd});return}if(Q.type==="agent-status"){t({type:"agent-status",agentStatus:Q.agentStatus??null,agentIndicator:Q.agentIndicator??null,agentStatusDetail:Q.agentStatusDetail??null,agent:Q.agent??null,agentMessage:Q.agentMessage??null,agentNativeSessionId:Q.agentNativeSessionId??null,agentResumeRecovered:Q.agentResumeRecovered===!0,agentRich:Q.agentRich===!0,agentActivity:typeof Q.agentActivity=="number"?Q.agentActivity:0,agentCwd:Q.agentCwd??null,reviewed:typeof Q.reviewed=="boolean"?Q.reviewed:null});return}if(Q.type==="git-status"){t({type:"git-status",gitStatus:Q.gitStatus??null});return}if(Q.type==="quota-status"&&Array.isArray(Q.providers)){window.dispatchEvent(new CustomEvent("termdock:quota-update",{detail:Q.providers}));return}if(Q.type==="focus-mode"){t({type:"focus-mode",focusTrackingRequested:Q.focusTrackingRequested===!0});return}if(Q.type==="resize-ack"){t({type:"resize-ack",seq:typeof Q.seq=="number"?Q.seq:void 0,cols:typeof Q.cols=="number"?Q.cols:void 0,rows:typeof Q.rows=="number"?Q.rows:void 0,ok:Q.ok!==!1,error:typeof Q.error=="string"?Q.error:void 0});return}if(Q.type==="pty-size"){t({type:"pty-size",cols:typeof Q.cols=="number"?Q.cols:void 0,rows:typeof Q.rows=="number"?Q.rows:void 0,source:typeof Q.source=="string"?Q.source:void 0});return}if(Q.type==="shell-title"){t({type:"shell-title",title:typeof Q.title=="string"?Q.title:""});return}if(Q.type==="prompt-state"){t({type:"prompt-state",state:Q.state==="running"?"running":"idle",exitCode:typeof Q.exitCode=="number"?Q.exitCode:void 0});return}const q=Q;if(q.type==="connected"){typeof q.replayLastSeq=="number"&&q.replayLastSeq>0&&(p=q.replayLastSeq,C.lastSeq=p),t(q);return}if(q.type==="exit"){I(),t(q);return}t(q),q.type==="data"&&typeof q.seq=="number"&&Number.isFinite(q.seq)&&q.seq>p&&(p=q.seq,C.lastSeq=p)}catch(Q){n?.(Q,!1)}},R.onerror=()=>{S.has(R)||(A(),T(C),y||(y=!0,P(new Error("WebSocket connection error"),!1)))},R.onclose=$=>{if(!S.has(R)&&(A(),T(C),!u.isClosed&&!y)){if(y=!0,$.code===4001){console.warn("[Terminal] WS 4001: Session not found on server",{code:$.code,reason:$.reason,stack:new Error().stack}),P(new Error("Session not found on server"),!0);return}if($.code===4003||$.code===4401){try{window.dispatchEvent(new CustomEvent(Am))}catch{}P(new Error("Authentication required"),!0);return}P(new Error("WebSocket connection closed"),!1)}},f=C,so.set(e,f)},P=(F,R)=>{if(!u.isClosed)if(R)n?.(F,!0),I();else{u.retryCount=Math.min(u.retryCount+1,Math.max(1,s));const C=Math.min(i*Math.pow(2,u.retryCount-1),l);if(t({type:"reconnecting",attempt:u.retryCount,maxAttempts:s}),u.isSuspended)return;u.retryTimeout=setTimeout(()=>{u.isClosed||j()},C)}};return j(),I}async function P7(e,t){const n=so.get(e);if(n){if(n.ws.readyState===WebSocket.OPEN){n.pendingInputs.push(t),j7(n);return}if(n.ws.readyState===WebSocket.CONNECTING){n.pendingInputs.push(t);return}}const r=await hr(),s=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain","X-XSRF-TOKEN":r},body:t});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to send input"}));throw new Error(i.error||"Failed to send terminal input")}}function mE(e,t){const n=so.get(e);if(!n)return!1;if(n.retryState.isSuspended=!1,n.ws.readyState!==WebSocket.OPEN)return n.reconnectNow(),!0;const r=n.inboundSequence;try{n.ws.send(JSON.stringify({type:"ping"}))}catch{}return setTimeout(()=>{so.get(e)!==n||n.retryState.isClosed||(n.inboundSequence<=r?n.reconnectNow():t?.())},oE),!0}function gE(e){const t=so.get(e);return t?(t.reconnectNow(),!0):!1}function Gv(){for(const e of so.values())e.suspendReconnect()}function Wv(e,t,n){const r=so.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"focus",focused:t,reason:n}))}catch{}}function Vv(e,t,n){const r=so.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"viewing",viewing:t,reason:n}))}catch{}}function qv(e){const t=so.get(e);if(!(!t||t.ws.readyState!==WebSocket.OPEN))try{t.ws.send(JSON.stringify({type:"agent-review-ack"}))}catch{}}function Yv(e,t,n){const r=so.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"flow-control",paused:t,reason:n}))}catch{}}async function xE(e,t,n,r){const s=so.get(e);if(s&&s.ws.readyState===WebSocket.OPEN)try{s.ws.send(JSON.stringify({type:"resize",cols:t,rows:n,seq:r}));return}catch{}const i=await hr(),l=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":i},body:JSON.stringify({cols:t,rows:n,seq:r})});if(!l.ok){const u=await l.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(u.error||"Failed to resize terminal")}const c=await l.json().catch(()=>({success:!0}));if(c?.success===!1||c?.ok===!1)throw new Error(c?.error||"Failed to resize terminal")}async function bE(e,t){const n=so.get(e);if(n&&n.ws.readyState===WebSocket.OPEN)return t.action==="scroll"?(n.ws.send(JSON.stringify({type:"tmux",...t})),{success:!0}):new Promise((i,l)=>{const c=Math.random().toString(36).substring(7);_f.set(c,{resolve:i,reject:l}),n.ws.send(JSON.stringify({type:"tmux",reqId:c,...t})),setTimeout(()=>{_f.has(c)&&(_f.delete(c),l(new Error("Tmux action timed out")))},3e4)});const r=await hr(),s=await fetch(`/api/terminal/${e}/tmux`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(t)});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to execute tmux action"}));throw new Error(i.error||"Failed to execute tmux action")}return s.json()}async function B7(e){const t=so.get(e);if(t){t.retryState.isClosed=!0;try{t.ws.close()}catch{}so.delete(e)}const n=await hr(),r=await fetch(`/api/terminal/${e}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":n}});if(r.status!==404&&!r.ok){const s=await r.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(s.error||"Failed to close terminal")}}async function yE(e,t){const n=so.get(e);if(n){n.retryState.isClosed=!0;try{n.ws.close()}catch{}so.delete(e)}const r=await hr(),s=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify({...t.cwd?{cwd:t.cwd}:{},cols:t.cols??80,rows:t.rows??24,mode:t.mode,tmuxSessionName:t.tmuxSessionName})});if(!s.ok){const i=await s.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(i.error||"Failed to restart terminal session")}return s.json()}async function vE(e){const t=await Rs(`/api/terminal/${e}/health`,{method:"GET"},JL,"Terminal health check timed out");if(!t.ok){if(t.status===404)return{healthy:!1,sessionId:e};const n=await Zd(t,Xd,"Terminal health error response timed out").catch(()=>({error:"Failed to check terminal health"}));throw new Error(n.error||"Failed to check terminal health")}return Zd(t,Xd,"Terminal health response timed out")}async function wE(e){const t=await hr(),n=await Rs("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)},tE,"Terminal force-kill request timed out");if(!n.ok){const r=await Zd(n,Xd,"Terminal force-kill error response timed out").catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}}async function db(){const e=await fetch("/api/terminal/tmux/sessions",{method:"GET"});if(!e.ok){const n=await e.json().catch(()=>({error:"Failed to list tmux sessions"}));throw new Error(n.error||"Failed to list tmux sessions")}const t=await e.json();return Array.isArray(t.sessions)?t.sessions:[]}async function fb(){const e=await fetch("/api/terminal/tmux/status",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to get tmux status"}));throw new Error(t.error||"Failed to get tmux status")}return e.json()}async function F7(e){const t=e.trim();if(!t)throw new Error("tmux session name is required");const n=await hr(),r=await fetch(`/api/terminal/tmux/sessions/${encodeURIComponent(t)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":n}});if(!r.ok){const i=await r.json().catch(()=>({error:"Failed to kill tmux session"}));throw new Error(i.error||"Failed to kill tmux session")}const s=await r.json();return{cleanedSessions:Array.isArray(s.cleanedSessions)?s.cleanedSessions:[],alreadyGone:!!s.alreadyGone}}async function SE(){const e=await hr(),t=await fetch("/api/terminal/tmux/recovery/restore-all",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),n=await t.json().catch(()=>({}));if(!t.ok)throw new La(n.error||"Failed to restore tmux Agent sessions",t.status);return n}async function AE(){const e=await hr(),t=await fetch("/api/terminal/tmux/recovery",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new La("Failed to dismiss tmux recovery",t.status)}const ip=new Map;function TE(e){return JSON.stringify({preferredFrontendSessionId:e.preferredFrontendSessionId??null,mode:e.mode??null,tmuxSessionName:e.tmuxSessionName??null,cwd:e.cwd??null,termType:e.termType??null,createIfEmpty:e.createIfEmpty===!0,requireExisting:e.requireExisting===!0})}async function CE(){const e=await fetch("/api/terminal/session-inventory",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load session inventory"}));throw new Error(t.error||"Failed to load session inventory")}return e.json()}async function O7(e){const t=TE(e),n=ip.get(t);if(n)return n;const r=await hr(),s=Rs("/api/terminal/session-inventory/open",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(e)},eE,"Terminal session open request timed out").then(async i=>{if(!i.ok){const l=await Zd(i,Xd,"Terminal session open error response timed out").catch(()=>({error:"Failed to open session"}));throw new La(l.error||"Failed to open session",i.status,typeof l.code=="string"?l.code:void 0)}return Zd(i,Xd,"Terminal session open response timed out")}).finally(()=>{ip.get(t)===s&&ip.delete(t)});return ip.set(t,s),s}async function Xp(e,t){const n=await hr(),r=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to update session"}));throw new Error(s.error||"Failed to update session")}return r.json()}async function kE(e){const t=await hr(),n=await fetch("/api/terminal/session-inventory/reorder",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({sessionIds:e})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to reorder sessions"}));throw new Error(r.error||"Failed to reorder sessions")}return n.json()}async function _E(e){const t=await hr(),n=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to remove session"}));throw new Error(r.error||"Failed to remove session")}}async function LE(){const e=await hr(),t=await fetch("/api/terminal/session-inventory/sessions",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok){const n=await t.json().catch(()=>({error:"Failed to clear sessions"}));throw new Error(n.error||"Failed to clear sessions")}}async function Kv(){const e=await fetch("/api/terminal/toolbar-presets",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load toolbar presets"}));throw new Error(t.error||"Failed to load toolbar presets")}return e.json()}async function EE(e){const t=await hr(),n=await fetch("/api/terminal/toolbar-presets",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save toolbar presets"})),s=new Error(r.error||"Failed to save toolbar presets");throw s.current=r.current,s.code=r.code,s}return n.json()}async function ug(){const e=await fetch("/api/terminal/settings",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load settings"}));throw new Error(t.error||"Failed to load settings")}return e.json()}async function Va(e){const t=await hr(),n=await fetch("/api/terminal/settings",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to update settings"}));throw new Error(r.error||"Failed to update settings")}return n.json()}async function F0(e=!1){const t=await fetch(`/api/terminal/auto-title/catalog${e?"?refresh=1":""}`);if(!t.ok)throw new Error("Failed to discover title models");const n=await t.json();return Array.isArray(n?.namers)?n.namers:[]}async function IE(){const e=await fetch("/api/terminal/context-draft",{method:"GET"});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to load context draft"}));throw new Error(t.error||"Failed to load context draft")}return e.json()}async function RE(e,t){const n=await hr(),r=await fetch("/api/terminal/context-draft",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},body:JSON.stringify({text:e,origin:t})});if(!r.ok){const s=await r.json().catch(()=>({error:"Failed to update context draft"}));throw new Error(s.error||"Failed to update context draft")}return r.json()}async function NE(){const e=await fetch("/api/auth/status");if(!e.ok)throw new Error("Failed to query auth status");return e.json()}async function ME(e){const t=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok)return D7(),{ok:!0};const n=await t.json().catch(()=>null);return t.status===429?{ok:!1,rateLimited:!0,retryAfterMs:typeof n?.retryAfterMs=="number"?n.retryAfterMs:void 0,error:n?.error||"Too many failed attempts. Please wait and try again."}:{ok:!1,error:n?.error||"Login failed"}}async function DE(){const e=await hr();await fetch("/api/auth/logout",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),D7()}async function Q7(){const e=await fetch("/api/terminal/agent-launchers");if(!e.ok)throw new Error("Failed to detect agent launchers");const t=await e.json();return Array.isArray(t?.agents)?t.agents:[]}async function jE(){const e=await fetch("/api/terminal/agent-hooks");if(!e.ok)throw new Error("Failed to get agent hooks");const t=await e.json();return Array.isArray(t?.agents)?t.agents:[]}async function PE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/install`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to install agent hooks");return{summary:r.summary??"Installed",devMode:r.devMode===!0}}async function BE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/uninstall`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to uninstall agent hooks");return r.summary??"Removed"}class U2 extends Error{constructor(t,n,r){super(t),this.code=n,this.migration=r,this.name="AgentPluginManifestError"}code;migration}async function FE(){const e=await fetch("/api/terminal/agent-plugins");if(!e.ok)throw new Error("Failed to get agent plugins");return await e.json()}async function OE(e){const t=await hr(),n=await fetch("/api/terminal/agent-plugins",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(!n.ok)throw new U2(r.error||"Failed to create agent plugin",r.code,r.migration);return r}async function QE(e){const t=await hr(),n=await fetch("/api/terminal/agent-plugins/install",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({source:e})}),r=await n.json().catch(()=>({}));if(!n.ok)throw new U2(r.error||"Failed to install agent plugin",r.code,r.migration);return r}async function $E(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/check-update`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to check plugin updates");return r}async function HE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/update`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to update plugin");return r}async function UE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}/doctor`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new Error(r.error||"Failed to diagnose plugin");return r}async function zE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete agent plugin")}}async function GE(e){const t=await hr(),n=await fetch(`/api/terminal/${encodeURIComponent(e)}/agent-resume`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new La(r.error||"Failed to resume agent session",n.status,typeof r.code=="string"?r.code:void 0);return{command:r.command??""}}async function Xv(){const e=await fetch("/api/terminal/agent-resume-history",{method:"GET"});if(!e.ok)throw new Error("Failed to load Agent resume history");const t=await e.json().catch(()=>({entries:[]}));return Array.isArray(t.entries)?t.entries:[]}async function $7(e){const t=await hr(),n=await fetch(`/api/terminal/agent-resume-history/${encodeURIComponent(e)}/prepare`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new La(r.error||"Failed to prepare Agent session resume",n.status,typeof r.code=="string"?r.code:void 0);return r}async function WE(e){const t=await hr(),n=await fetch(`/api/terminal/agent-resume-history/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!n.ok&&n.status!==404)throw new Error("Failed to remove Agent resume history")}async function hd(e){const t=await hr(),n=await fetch("/api/terminal/program-rules",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to update program rules"}));throw new Error(r.error||"Failed to update program rules")}return n.json()}async function VE(){const e=await hr(),t=await fetch("/api/terminal/program-rules",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Error("Failed to reset program rules");return t.json()}async function qE(){const e=await fetch("/api/terminal/program-detection");if(!e.ok)throw new Error("Failed to get program detection config");return e.json()}async function Zv(e){const t=await hr(),n=await fetch("/api/terminal/program-detection",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!n.ok)throw new Error("Failed to save program detection config");return n.json()}async function YE(){const e=await hr(),t=await fetch("/api/terminal/program-detection",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new Error("Failed to reset program detection config");return t.json()}const KE={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".bmp":"image/bmp",".ico":"image/x-icon",".svg":"image/svg+xml",".heic":"image/heic",".heif":"image/heif"};function z2(e){const t=e.lastIndexOf(".");return t<0?null:KE[e.slice(t).toLowerCase()]??null}function G2(e){return z2(e)!==null}function H7(e){const t=z2(e);return t==="image/heic"||t==="image/heif"}const XE={".mp4":"video/mp4",".m4v":"video/x-m4v",".webm":"video/webm",".mov":"video/quicktime",".ogv":"video/ogg",".mpeg":"video/mpeg",".mpg":"video/mpeg"};function U7(e){const t=e.lastIndexOf(".");return t<0?null:XE[e.slice(t).toLowerCase()]??null}function z7(e){return U7(e)!==null}function ZE(e){return`/api/terminal/fs/video?path=${encodeURIComponent(e)}&action=view_file`}const JE=[".stl",".glb",".gltf"];function G7(e){const t=e.lastIndexOf(".");if(t<0)return null;const n=e.slice(t).toLowerCase();return JE.includes(n)?n:null}function W7(e){return G7(e)!==null}function V7(e){const t=e.toLowerCase();return t.endsWith(".kicad_sch")?".kicad_sch":t.endsWith(".kicad_pcb")?".kicad_pcb":null}function eI(e){return V7(e)!==null}function tI(e){return V7(e)===".kicad_pcb"?"pcb-front":"schematic"}const nI=[".html",".htm"];function O0(e){const t=e.lastIndexOf(".");if(t<0)return!1;const n=e.slice(t).toLowerCase();return nI.includes(n)}function rI(e){return`/api/terminal/fs/preview/${e.split(/[\\/]+/).filter(Boolean).map(n=>encodeURIComponent(n)).join("/")}`}const sI={".stl":"model/stl",".glb":"model/gltf-binary",".gltf":"model/gltf+json"};async function q7(e,t,n,r="list_directory",s){const i=new URLSearchParams({path:e});n&&i.set("showHidden","true"),i.set("action",r),s&&i.set("requestSlotId",s);const l=await Rs(`/api/terminal/fs/list?${i}`,{signal:t},eu,"Directory listing took too long. The folder may be on slow storage or blocked by another process.");if(!l.ok){const c=await l.json().catch(()=>({error:"Failed to list directory"}));throw new Error(c.error||"Failed to list directory")}return l.json()}async function iI(e,t,n,r,s,i="name",l){const c=new URLSearchParams({path:e,query:t,stream:"true"});s&&c.set("showHidden","true"),i==="content"&&c.set("mode","content"),l&&c.set("requestSlotId",l);const u=await fetch(`/api/terminal/fs/search?${c}`,{signal:r});if(!u.ok||!u.body){const v=await u.json().catch(()=>({error:"Failed to search files"}));throw new Error(v.error||"Failed to search files")}const f=u.body.getReader(),p=new TextDecoder;let g="";const y=v=>{if(!v.trim())return;const S=JSON.parse(v);if(S.type==="meta")n({path:S.path,query:S.query,engine:S.engine,mode:S.mode,limited:S.limited});else if(S.type==="batch")n({entries:S.entries??[]});else if(S.type==="content-batch")n({contentEntries:S.contentEntries??[]});else{if(S.type==="error")throw new Error(S.message||"Search failed");S.type==="done"&&n({total:S.total,truncated:S.truncated,limited:S.limited,engine:S.engine,mode:S.mode,done:!0})}};for(;;){const{value:v,done:S}=await f.read();if(S)break;g+=p.decode(v,{stream:!0});let A=g.indexOf(`
3
3
  `);for(;A>=0;)y(g.slice(0,A)),g=g.slice(A+1),A=g.indexOf(`
4
4
  `)}g+=p.decode(),y(g)}async function oI(e,t,n){const r=new URLSearchParams;r.set("roots",e.join("|"));const s=await fetch(`/api/terminal/fs/watch?${r}`,{signal:n});if(!s.ok||!s.body){const f=await s.json().catch(()=>({error:"Failed to watch files"}));throw new Error(f.error||"Failed to watch files")}const i=s.body.getReader(),l=new TextDecoder;let c="";const u=f=>{if(!f.trim())return;const p=JSON.parse(f);p.type==="events"&&p.events?.length&&t(p.events)};for(;;){const{value:f,done:p}=await i.read();if(p)break;c+=l.decode(f,{stream:!0});let g=c.indexOf(`
@@ -132,7 +132,7 @@ ${be.current.stack}
132
132
  -moz-user-select: none;
133
133
  -ms-user-select: none;
134
134
  overflow-anchor: none;
135
- `}}];return{always:sf(l,"always"),resting:sf(l,"resting"),dragging:sf(l,"dragging"),dropAnimating:sf(l,"dropAnimating"),userCancel:sf(l,"userCancel")}};const _a=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,yx=()=>{const e=document.querySelector("head");return e||$t(),e},I3=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function az(e,t){const n=Qr(()=>oz(e),[e]),r=b.useRef(null),s=b.useRef(null),i=Dn(Bi(g=>{const y=s.current;y||$t(),y.textContent=g}),[]),l=Dn(g=>{const y=r.current;y||$t(),y.textContent=g},[]);_a(()=>{!r.current&&!s.current||$t();const g=I3(t),y=I3(t);return r.current=g,s.current=y,g.setAttribute(`${s0}-always`,e),y.setAttribute(`${s0}-dynamic`,e),yx().appendChild(g),yx().appendChild(y),l(n.always),i(n.resting),()=>{const v=S=>{const A=S.current;A||$t(),yx().removeChild(A),S.current=null};v(r),v(s)}},[t,l,i,n.always,n.resting,e]);const c=Dn(()=>i(n.dragging),[i,n.dragging]),u=Dn(g=>{if(g==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),f=Dn(()=>{s.current&&i(n.resting)},[i,n.resting]);return Qr(()=>({dragging:c,dropping:u,resting:f}),[c,u,f])}function MA(e,t){return Array.from(e.querySelectorAll(t))}var DA=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function _g(e){return e instanceof DA(e).HTMLElement}function lz(e,t){const n=`[${i0.contextId}="${e}"]`,r=MA(document,n);if(!r.length)return null;const s=r.find(i=>i.getAttribute(i0.draggableId)===t);return!s||!_g(s)?null:s}function cz(e){const t=b.useRef({}),n=b.useRef(null),r=b.useRef(null),s=b.useRef(!1),i=Dn(function(y,v){const S={id:y,focus:v};return t.current[y]=S,function(){const T=t.current;T[y]!==S&&delete T[y]}},[]),l=Dn(function(y){const v=lz(e,y);v&&v!==document.activeElement&&v.focus()},[e]),c=Dn(function(y,v){n.current===y&&(n.current=v)},[]),u=Dn(function(){r.current||s.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const y=n.current;y&&l(y)}))},[l]),f=Dn(function(y){n.current=null;const v=document.activeElement;v&&v.getAttribute(i0.draggableId)===y&&(n.current=y)},[]);return _a(()=>(s.current=!0,function(){s.current=!1;const y=r.current;y&&cancelAnimationFrame(y)}),[]),Qr(()=>({register:i,tryRecordFocus:f,tryRestoreFocusRecorded:u,tryShiftRecord:c}),[i,f,u,c])}function uz(){const e={draggables:{},droppables:{}},t=[];function n(g){return t.push(g),function(){const v=t.indexOf(g);v!==-1&&t.splice(v,1)}}function r(g){t.length&&t.forEach(y=>y(g))}function s(g){return e.draggables[g]||null}function i(g){const y=s(g);return y||$t(),y}const l={register:g=>{e.draggables[g.descriptor.id]=g,r({type:"ADDITION",value:g})},update:(g,y)=>{const v=e.draggables[y.descriptor.id];v&&v.uniqueId===g.uniqueId&&(delete e.draggables[y.descriptor.id],e.draggables[g.descriptor.id]=g)},unregister:g=>{const y=g.descriptor.id,v=s(y);v&&g.uniqueId===v.uniqueId&&(delete e.draggables[y],e.droppables[g.descriptor.droppableId]&&r({type:"REMOVAL",value:g}))},getById:i,findById:s,exists:g=>!!s(g),getAllByType:g=>Object.values(e.draggables).filter(y=>y.descriptor.type===g)};function c(g){return e.droppables[g]||null}function u(g){const y=c(g);return y||$t(),y}const f={register:g=>{e.droppables[g.descriptor.id]=g},unregister:g=>{const y=c(g.descriptor.id);y&&g.uniqueId===y.uniqueId&&delete e.droppables[g.descriptor.id]},getById:u,findById:c,exists:g=>!!c(g),getAllByType:g=>Object.values(e.droppables).filter(y=>y.descriptor.type===g)};function p(){e.draggables={},e.droppables={},t.length=0}return{draggable:l,droppable:f,subscribe:n,clean:p}}function dz(){const e=Qr(uz,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var Ny=D.createContext(null),Hm=()=>{const e=document.body;return e||$t(),e};const fz={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},hz=e=>`rfd-announcement-${e}`;function pz(e){const t=Qr(()=>hz(e),[e]),n=b.useRef(null);return b.useEffect(function(){const i=document.createElement("div");return n.current=i,i.id=t,i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),Fm(i.style,fz),Hm().appendChild(i),function(){setTimeout(function(){const u=Hm();u.contains(i)&&u.removeChild(i),i===n.current&&(n.current=null)})}},[t]),Dn(s=>{const i=n.current;if(i){i.textContent=s;return}},[])}const mz={separator:"::"};function My(e,t=mz){const n=D.useId();return Qr(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function gz({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function xz({contextId:e,text:t}){const n=My("hidden-text",{separator:"-"}),r=Qr(()=>gz({contextId:e,uniqueId:n}),[n,e]);return b.useEffect(function(){const i=document.createElement("div");return i.id=r,i.textContent=t,i.style.display="none",Hm().appendChild(i),function(){const c=Hm();c.contains(i)&&c.removeChild(i)}},[r,t]),r}var Lg=D.createContext(null);function jA(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function bz(){let e=null;function t(){return!!e}function n(l){return l===e}function r(l){e&&$t();const c={abandon:l};return e=c,c}function s(){e||$t(),e=null}function i(){e&&(e.abandon(),s())}return{isClaimed:t,isActive:n,claim:r,release:s,tryAbandon:i}}function Yf(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const yz=9,vz=13,Dy=27,PA=32,wz=33,Sz=34,Az=35,Tz=36,Cz=37,kz=38,_z=39,Lz=40,Ez={[vz]:!0,[yz]:!0};var BA=e=>{Ez[e.keyCode]&&e.preventDefault()};const Eg=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(r=>`on${r}`in document)||e})(),FA=0,R3=5;function Iz(e,t){return Math.abs(t.x-e.x)>=R3||Math.abs(t.y-e.y)>=R3}const N3={type:"IDLE"};function Rz({cancel:e,completed:t,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:s=>{const{button:i,clientX:l,clientY:c}=s;if(i!==FA)return;const u={x:l,y:c},f=n();if(f.type==="DRAGGING"){s.preventDefault(),f.actions.move(u);return}f.type!=="PENDING"&&$t();const p=f.point;if(!Iz(p,u))return;s.preventDefault();const g=f.actions.fluidLift(u);r({type:"DRAGGING",actions:g})}},{eventName:"mouseup",fn:s=>{const i=n();if(i.type!=="DRAGGING"){e();return}s.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:s=>{n().type==="DRAGGING"&&s.preventDefault(),e()}},{eventName:"keydown",fn:s=>{if(n().type==="PENDING"){e();return}if(s.keyCode===Dy){s.preventDefault(),e();return}BA(s)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:s=>{const i=n();if(i.type==="IDLE"&&$t(),i.actions.shouldRespectForcePress()){e();return}s.preventDefault()}},{eventName:Eg,fn:e}]}function Nz(e){const t=b.useRef(N3),n=b.useRef(Vc),r=Qr(()=>({eventName:"mousedown",fn:function(g){if(g.defaultPrevented||g.button!==FA||g.ctrlKey||g.metaKey||g.shiftKey||g.altKey)return;const y=e.findClosestDraggableId(g);if(!y)return;const v=e.tryGetLock(y,l,{sourceEvent:g});if(!v)return;g.preventDefault();const S={x:g.clientX,y:g.clientY};n.current(),f(v,S)}}),[e]),s=Qr(()=>({eventName:"webkitmouseforcewillbegin",fn:p=>{if(p.defaultPrevented)return;const g=e.findClosestDraggableId(p);if(!g)return;const y=e.findOptionsForDraggable(g);y&&(y.shouldRespectForcePress||e.canGetLock(g)&&p.preventDefault())}}),[e]),i=Dn(function(){const g={passive:!1,capture:!0};n.current=Xa(window,[s,r],g)},[s,r]),l=Dn(()=>{t.current.type!=="IDLE"&&(t.current=N3,n.current(),i())},[i]),c=Dn(()=>{const p=t.current;l(),p.type==="DRAGGING"&&p.actions.cancel({shouldBlockNextClick:!0}),p.type==="PENDING"&&p.actions.abort()},[l]),u=Dn(function(){const g={capture:!0,passive:!1},y=Rz({cancel:c,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});n.current=Xa(window,y,g)},[c,l]),f=Dn(function(g,y){t.current.type!=="IDLE"&&$t(),t.current={type:"PENDING",point:y,actions:g},u()},[u]);_a(function(){return i(),function(){n.current()}},[i])}function Mz(){}const Dz={[Sz]:!0,[wz]:!0,[Tz]:!0,[Az]:!0};function jz(e,t){function n(){t(),e.cancel()}function r(){t(),e.drop()}return[{eventName:"keydown",fn:s=>{if(s.keyCode===Dy){s.preventDefault(),n();return}if(s.keyCode===PA){s.preventDefault(),r();return}if(s.keyCode===Lz){s.preventDefault(),e.moveDown();return}if(s.keyCode===kz){s.preventDefault(),e.moveUp();return}if(s.keyCode===_z){s.preventDefault(),e.moveRight();return}if(s.keyCode===Cz){s.preventDefault(),e.moveLeft();return}if(Dz[s.keyCode]){s.preventDefault();return}BA(s)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:Eg,fn:n}]}function Pz(e){const t=b.useRef(Mz),n=Qr(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==PA)return;const l=e.findClosestDraggableId(i);if(!l)return;const c=e.tryGetLock(l,p,{sourceEvent:i});if(!c)return;i.preventDefault();let u=!0;const f=c.snapLift();t.current();function p(){u||$t(),u=!1,t.current(),r()}t.current=Xa(window,jz(f,p),{capture:!0,passive:!1})}}),[e]),r=Dn(function(){const i={passive:!1,capture:!0};t.current=Xa(window,[n],i)},[n]);_a(function(){return r(),function(){t.current()}},[r])}const vx={type:"IDLE"},Bz=120,Fz=.15;function Oz({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(t().type!=="DRAGGING"){e();return}n.keyCode===Dy&&n.preventDefault(),e()}},{eventName:Eg,fn:e}]}function Qz({cancel:e,completed:t,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:r=>{const s=n();if(s.type!=="DRAGGING"){e();return}s.hasMoved=!0;const{clientX:i,clientY:l}=r.touches[0],c={x:i,y:l};r.preventDefault(),s.actions.move(c)}},{eventName:"touchend",fn:r=>{const s=n();if(s.type!=="DRAGGING"){e();return}r.preventDefault(),s.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:r=>{if(n().type!=="DRAGGING"){e();return}r.preventDefault(),e()}},{eventName:"touchforcechange",fn:r=>{const s=n();s.type==="IDLE"&&$t();const i=r.touches[0];if(!i||!(i.force>=Fz))return;const c=s.actions.shouldRespectForcePress();if(s.type==="PENDING"){c&&e();return}if(c){if(s.hasMoved){r.preventDefault();return}e();return}r.preventDefault()}},{eventName:Eg,fn:e}]}function $z(e){const t=b.useRef(vx),n=b.useRef(Vc),r=Dn(function(){return t.current},[]),s=Dn(function(v){t.current=v},[]),i=Qr(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const S=e.findClosestDraggableId(v);if(!S)return;const A=e.tryGetLock(S,c,{sourceEvent:v});if(!A)return;const T=v.touches[0],{clientX:L,clientY:I}=T,j={x:L,y:I};n.current(),g(A,j)}}),[e]),l=Dn(function(){const v={capture:!0,passive:!1};n.current=Xa(window,[i],v)},[i]),c=Dn(()=>{const y=t.current;y.type!=="IDLE"&&(y.type==="PENDING"&&clearTimeout(y.longPressTimerId),s(vx),n.current(),l())},[l,s]),u=Dn(()=>{const y=t.current;c(),y.type==="DRAGGING"&&y.actions.cancel({shouldBlockNextClick:!0}),y.type==="PENDING"&&y.actions.abort()},[c]),f=Dn(function(){const v={capture:!0,passive:!1},S={cancel:u,completed:c,getPhase:r},A=Xa(window,Qz(S),v),T=Xa(window,Oz(S),v);n.current=function(){A(),T()}},[u,r,c]),p=Dn(function(){const v=r();v.type!=="PENDING"&&$t();const S=v.actions.fluidLift(v.point);s({type:"DRAGGING",actions:S,hasMoved:!1})},[r,s]),g=Dn(function(v,S){r().type!=="IDLE"&&$t();const A=setTimeout(p,Bz);s({type:"PENDING",point:S,actions:v,longPressTimerId:A}),f()},[f,r,s,p]);_a(function(){return l(),function(){n.current();const S=r();S.type==="PENDING"&&(clearTimeout(S.longPressTimerId),s(vx))}},[r,l,s]),_a(function(){return Xa(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const Hz=["input","button","textarea","select","option","optgroup","video","audio"];function OA(e,t){if(t==null)return!1;if(Hz.includes(t.tagName.toLowerCase()))return!0;const r=t.getAttribute("contenteditable");return r==="true"||r===""?!0:t===e?!1:OA(e,t.parentElement)}function Uz(e,t){const n=t.target;return _g(n)?OA(e,n):!1}var zz=e=>Sl(e.getBoundingClientRect()).center;function Gz(e){return e instanceof DA(e).Element}const Wz=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||e})();function QA(e,t){return e==null?null:e[Wz](t)?e:QA(e.parentElement,t)}function Vz(e,t){return e.closest?e.closest(t):QA(e,t)}function qz(e){return`[${i0.contextId}="${e}"]`}function Yz(e,t){const n=t.target;if(!Gz(n))return null;const r=qz(e),s=Vz(n,r);return!s||!_g(s)?null:s}function Kz(e,t){const n=Yz(e,t);return n?n.getAttribute(i0.draggableId):null}function Xz(e,t){const n=`[${e2.contextId}="${e}"]`,s=MA(document,n).find(i=>i.getAttribute(e2.id)===t);return!s||!_g(s)?null:s}function Zz(e){e.preventDefault()}function _p({expected:e,phase:t,isLockActive:n,shouldWarn:r}){return!(!n()||e!==t)}function $A({lockAPI:e,store:t,registry:n,draggableId:r}){if(e.isClaimed())return!1;const s=n.draggable.findById(r);return!(!s||!s.options.isEnabled||!EA(t.getState(),r))}function Jz({lockAPI:e,contextId:t,store:n,registry:r,draggableId:s,forceSensorStop:i,sourceEvent:l}){if(!$A({lockAPI:e,store:n,registry:r,draggableId:s}))return null;const u=r.draggable.getById(s),f=Xz(t,u.descriptor.id);if(!f||l&&!u.options.canDragInteractiveElements&&Uz(f,l))return null;const p=e.claim(i||Vc);let g="PRE_DRAG";function y(){return u.options.shouldRespectForcePress}function v(){return e.isActive(p)}function S(F,R){_p({expected:F,phase:g,isLockActive:v,shouldWarn:!0})&&n.dispatch(R())}const A=S.bind(null,"DRAGGING");function T(F){function R(){e.release(),g="COMPLETED"}g!=="PRE_DRAG"&&(R(),$t()),n.dispatch(VH(F.liftActionArgs)),g="DRAGGING";function C($,Q={shouldBlockNextClick:!1}){if(F.cleanup(),Q.shouldBlockNextClick){const q=Xa(window,[{eventName:"click",fn:Zz,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(q)}R(),n.dispatch(wA({reason:$}))}return{isActive:()=>_p({expected:"DRAGGING",phase:g,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:y,drop:$=>C("DROP",$),cancel:$=>C("CANCEL",$),...F.actions}}function L(F){const R=Uf($=>{A(()=>vA({client:$}))});return{...T({liftActionArgs:{id:s,clientSelection:F,movementMode:"FLUID"},cleanup:()=>R.cancel(),actions:{move:R}}),move:R}}function I(){const F={moveUp:()=>A(nU),moveRight:()=>A(sU),moveDown:()=>A(rU),moveLeft:()=>A(iU)};return T({liftActionArgs:{id:s,clientSelection:zz(f),movementMode:"SNAP"},cleanup:Vc,actions:F})}function j(){_p({expected:"PRE_DRAG",phase:g,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>_p({expected:"PRE_DRAG",phase:g,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:y,fluidLift:L,snapLift:I,abort:j}}const eG=[Nz,Pz,$z];function tG({contextId:e,store:t,registry:n,customSensors:r,enableDefaultSensors:s}){const i=[...s?eG:[],...r||[]],l=b.useState(()=>bz())[0],c=Dn(function(T,L){Yf(T)&&!Yf(L)&&l.tryAbandon()},[l]);_a(function(){let T=t.getState();return t.subscribe(()=>{const I=t.getState();c(T,I),T=I})},[l,t,c]),_a(()=>l.tryAbandon,[l.tryAbandon]);const u=Dn(A=>$A({lockAPI:l,registry:n,store:t,draggableId:A}),[l,n,t]),f=Dn((A,T,L)=>Jz({lockAPI:l,registry:n,contextId:e,store:t,draggableId:A,forceSensorStop:T||null,sourceEvent:L&&L.sourceEvent?L.sourceEvent:null}),[e,l,n,t]),p=Dn(A=>Kz(e,A),[e]),g=Dn(A=>{const T=n.draggable.findById(A);return T?T.options:null},[n.draggable]),y=Dn(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(Cy()))},[l,t]),v=Dn(()=>l.isClaimed(),[l]),S=Qr(()=>({canGetLock:u,tryGetLock:f,findClosestDraggableId:p,findOptionsForDraggable:g,tryReleaseLock:y,isLockClaimed:v}),[u,f,p,g,y,v]);for(let A=0;A<i.length;A++)i[A](S)}const nG=e=>({onBeforeCapture:t=>{const n=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};ia.flushSync(n)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),rG=e=>({...qf,...e.autoScrollerOptions,durationDampening:{...qf.durationDampening,...e.autoScrollerOptions}});function of(e){return e.current||$t(),e.current}function sG(e){const{contextId:t,setCallbacks:n,sensors:r,nonce:s,dragHandleUsageInstructions:i}=e,l=b.useRef(null),c=jA(e),u=Dn(()=>nG(c.current),[c]),f=Dn(()=>rG(c.current),[c]),p=pz(t),g=xz({contextId:t,text:i}),y=az(t,s),v=Dn(q=>{of(l).dispatch(q)},[]),S=Qr(()=>s3({publishWhileDragging:YH,updateDroppableScroll:XH,updateDroppableIsEnabled:ZH,updateDroppableIsCombineEnabled:JH,collectionStarting:KH},v),[v]),A=dz(),T=Qr(()=>OU(A,S),[A,S]),L=Qr(()=>nz({scrollWindow:QU,scrollDroppable:T.scrollDroppable,getAutoScrollerOptions:f,...s3({move:vA},v)}),[T.scrollDroppable,v,f]),I=cz(t),j=Qr(()=>jU({announce:p,autoScroller:L,dimensionMarshal:T,focusMarshal:I,getResponders:u,styleMarshal:y}),[p,L,T,I,u,y]);l.current=j;const P=Dn(()=>{const q=of(l);q.getState().phase!=="IDLE"&&q.dispatch(Cy())},[]),F=Dn(()=>{const q=of(l).getState();return q.phase==="DROP_ANIMATING"?!0:q.phase==="IDLE"?!1:q.isDragging},[]),R=Qr(()=>({isDragging:F,tryAbort:P}),[F,P]);n(R);const C=Dn(q=>EA(of(l).getState(),q),[]),$=Dn(()=>Tu(of(l).getState()),[]),Q=Qr(()=>({marshal:T,focus:I,contextId:t,canLift:C,isMovementAllowed:$,dragHandleUsageInstructionsId:g,registry:A}),[t,T,g,I,C,$,A]);return tG({contextId:t,store:j,registry:A,customSensors:r||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>P,[P]),D.createElement(Lg.Provider,{value:Q},D.createElement(E$,{context:Ny,store:j},e.children))}function iG(){return D.useId()}function Um(e){const t=iG(),n=e.dragHandleUsageInstructions||cm.dragHandleUsageInstructions;return D.createElement(P$,null,r=>D.createElement(sG,{nonce:e.nonce,contextId:t,setCallbacks:r,dragHandleUsageInstructions:n,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const M3={dragging:5e3,dropAnimating:4500},oG=(e,t)=>t?jf.drop(t.duration):e?jf.snap:jf.fluid,aG=(e,t)=>{if(e)return t?Vf.opacity.drop:Vf.opacity.combining},lG=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function cG(e){const n=e.dimension.client,{offset:r,combineWith:s,dropping:i}=e,l=!!s,c=lG(e),u=!!i,f=u?Zb.drop(r,l):Zb.moveTo(r);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:oG(c,i),transform:f,opacity:aG(l,u),zIndex:u?M3.dropAnimating:M3.dragging,pointerEvents:"none"}}function uG(e){return{transform:Zb.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function dG(e){return e.type==="DRAGGING"?cG(e):uG(e)}function fG(e,t,n=Fi){const r=window.getComputedStyle(t),s=t.getBoundingClientRect(),i=qS(s,r),l=Bm(i,n),c={client:i,tagName:t.tagName.toLowerCase(),display:r.display},u={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:e,placeholder:c,displaceBy:u,client:i,page:l}}function hG(e){const t=My("draggable"),{descriptor:n,registry:r,getDraggableRef:s,canDragInteractiveElements:i,shouldRespectForcePress:l,isEnabled:c}=e,u=Qr(()=>({canDragInteractiveElements:i,shouldRespectForcePress:l,isEnabled:c}),[i,c,l]),f=Dn(v=>{const S=s();return S||$t(),fG(n,S,v)},[n,s]),p=Qr(()=>({uniqueId:t,descriptor:n,options:u,getDimension:f}),[n,f,u,t]),g=b.useRef(p),y=b.useRef(!0);_a(()=>(r.draggable.register(g.current),()=>r.draggable.unregister(g.current)),[r.draggable]),_a(()=>{if(y.current){y.current=!1;return}const v=g.current;g.current=p,r.draggable.update(p,v)},[p,r.draggable])}var jy=D.createContext(null);function zm(e){const t=b.useContext(e);return t||$t(),t}function pG(e){e.preventDefault()}const mG=e=>{const t=b.useRef(null),n=Dn((R=null)=>{t.current=R},[]),r=Dn(()=>t.current,[]),{contextId:s,dragHandleUsageInstructionsId:i,registry:l}=zm(Lg),{type:c,droppableId:u}=zm(jy),f=Qr(()=>({id:e.draggableId,index:e.index,type:c,droppableId:u}),[e.draggableId,e.index,c,u]),{children:p,draggableId:g,isEnabled:y,shouldRespectForcePress:v,canDragInteractiveElements:S,isClone:A,mapped:T,dropAnimationFinished:L}=e;if(!A){const R=Qr(()=>({descriptor:f,registry:l,getDraggableRef:r,canDragInteractiveElements:S,shouldRespectForcePress:v,isEnabled:y}),[f,l,r,S,v,y]);hG(R)}const I=Qr(()=>y?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":g,"data-rfd-drag-handle-context-id":s,draggable:!1,onDragStart:pG}:null,[s,i,g,y]),j=Dn(R=>{T.type==="DRAGGING"&&T.dropping&&R.propertyName==="transform"&&ia.flushSync(L)},[L,T]),P=Qr(()=>{const R=dG(T),C=T.type==="DRAGGING"&&T.dropping?j:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":s,"data-rfd-draggable-id":g,style:R,onTransitionEnd:C},dragHandleProps:I}},[s,I,g,T,j,n]),F=Qr(()=>({draggableId:f.id,type:f.type,source:{index:f.index,droppableId:f.droppableId}}),[f.droppableId,f.id,f.index,f.type]);return D.createElement(D.Fragment,null,p(P,T.snapshot,F))};var HA=(e,t)=>e===t,UA=e=>{const{combine:t,destination:n}=e;return n?n.droppableId:t?t.droppableId:null};const gG=e=>e.combine?e.combine.draggableId:null,xG=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function bG(){const e=Bi((s,i)=>({x:s,y:i})),t=Bi((s,i,l=null,c=null,u=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!u,dropAnimation:u,mode:s,draggingOver:l,combineWith:c,combineTargetFor:null})),n=Bi((s,i,l,c,u=null,f=null,p=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:u,combineWith:f,mode:i,offset:s,dimension:l,forceShouldAnimate:p,snapshot:t(i,c,u,f,null)}}));return(s,i)=>{if(Yf(s)){if(s.critical.draggable.id!==i.draggableId)return null;const l=s.current.client.offset,c=s.dimensions.draggables[i.draggableId],u=ka(s.impact),f=xG(s.impact),p=s.forceShouldAnimate;return n(e(l.x,l.y),s.movementMode,c,i.isClone,u,f,p)}if(s.phase==="DROP_ANIMATING"){const l=s.completed;if(l.result.draggableId!==i.draggableId)return null;const c=i.isClone,u=s.dimensions.draggables[i.draggableId],f=l.result,p=f.mode,g=UA(f),y=gG(f),S={duration:s.dropDuration,curve:_y.drop,moveTo:s.newHomeClientOffset,opacity:y?Vf.opacity.drop:null,scale:y?Vf.scale.drop:null};return{mapped:{type:"DRAGGING",offset:s.newHomeClientOffset,dimension:u,dropping:S,draggingOver:g,combineWith:y,mode:p,forceShouldAnimate:null,snapshot:t(p,c,g,y,S)}}}return null}}function zA(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const yG={mapped:{type:"SECONDARY",offset:Fi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:zA(null)}};function vG(){const e=Bi((l,c)=>({x:l,y:c})),t=Bi(zA),n=Bi((l,c=null,u)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:c,shouldAnimateDisplacement:u,snapshot:t(c)}})),r=l=>l?n(Fi,l,!0):null,s=(l,c,u,f)=>{const p=u.displaced.visible[l],g=!!(f.inVirtualList&&f.effected[l]),y=Tg(u),v=y&&y.draggableId===l?c:null;if(!p){if(!g)return r(v);if(u.displaced.invisible[l])return null;const T=p0(f.displacedBy.point),L=e(T.x,T.y);return n(L,v,!0)}if(g)return r(v);const S=u.displacedBy.point,A=e(S.x,S.y);return n(A,v,p.shouldAnimate)};return(l,c)=>{if(Yf(l))return l.critical.draggable.id===c.draggableId?null:s(c.draggableId,l.critical.draggable.id,l.impact,l.afterCritical);if(l.phase==="DROP_ANIMATING"){const u=l.completed;return u.result.draggableId===c.draggableId?null:s(c.draggableId,u.result.draggableId,u.impact,u.afterCritical)}return null}}const wG=()=>{const e=bG(),t=vG();return(r,s)=>e(r,s)||t(r,s)||yG},SG={dropAnimationFinished:SA},AG=VS(wG,SG,null,{context:Ny,areStatePropsEqual:HA})(mG);function GA(e){return zm(jy).isUsingCloneFor===e.draggableId&&!e.isClone?null:D.createElement(AG,e)}function Ru(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,n=!!e.disableInteractiveElementBlocking,r=!!e.shouldRespectForcePress;return D.createElement(GA,Fm({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const WA=e=>t=>e===t,TG=WA("scroll"),CG=WA("auto"),D3=(e,t)=>t(e.overflowX)||t(e.overflowY),kG=e=>{const t=window.getComputedStyle(e),n={overflowX:t.overflowX,overflowY:t.overflowY};return D3(n,TG)||D3(n,CG)},_G=()=>!1,VA=e=>e==null?null:e===document.body?_G()?e:null:e===document.documentElement?null:kG(e)?e:VA(e.parentElement);var t2=e=>({x:e.scrollLeft,y:e.scrollTop});const qA=e=>e?window.getComputedStyle(e).position==="fixed"?!0:qA(e.parentElement):!1;var LG=e=>{const t=VA(e),n=qA(e);return{closestScrollable:t,isFixedOnPage:n}},EG=({descriptor:e,isEnabled:t,isCombineEnabled:n,isFixedOnPage:r,direction:s,client:i,page:l,closest:c})=>{const u=(()=>{if(!c)return null;const{scrollSize:y,client:v}=c,S=kA({scrollHeight:y.scrollHeight,scrollWidth:y.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:c.page.marginBox,frameClient:v,scrollSize:y,shouldClipSubject:c.shouldClipSubject,scroll:{initial:c.scroll,current:c.scroll,max:S,diff:{value:Fi,displacement:Fi}}}})(),f=s==="vertical"?vy:iA,p=r0({page:l,withPlaceholder:null,axis:f,frame:u});return{descriptor:e,isCombineEnabled:n,isFixedOnPage:r,axis:f,isEnabled:t,client:i,page:l,frame:u,subject:p}};const IG=(e,t)=>{const n=YS(e);if(!t||e!==t)return n;const r=n.paddingBox.top-t.scrollTop,s=n.paddingBox.left-t.scrollLeft,i=r+t.scrollHeight,l=s+t.scrollWidth,u=gy({top:r,right:l,bottom:i,left:s},n.border);return xy({borderBox:u,margin:n.margin,border:n.border,padding:n.padding})};var RG=({ref:e,descriptor:t,env:n,windowScroll:r,direction:s,isDropDisabled:i,isCombineEnabled:l,shouldClipSubject:c})=>{const u=n.closestScrollable,f=IG(e,u),p=Bm(f,r),g=(()=>{if(!u)return null;const v=YS(u),S={scrollHeight:u.scrollHeight,scrollWidth:u.scrollWidth};return{client:v,page:Bm(v,r),scroll:t2(u),scrollSize:S,shouldClipSubject:c}})();return EG({descriptor:t,isEnabled:!i,isCombineEnabled:l,isFixedOnPage:n.isFixedOnPage,direction:s,client:f,page:p,closest:g})};const NG={passive:!1},MG={passive:!0};var j3=e=>e.shouldPublishImmediately?NG:MG;const Lp=e=>e&&e.env.closestScrollable||null;function DG(e){const t=b.useRef(null),n=zm(Lg),r=My("droppable"),{registry:s,marshal:i}=n,l=jA(e),c=Qr(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),u=b.useRef(c),f=Qr(()=>Bi((P,F)=>{t.current||$t();const R={x:P,y:F};i.updateDroppableScroll(c.id,R)}),[c.id,i]),p=Dn(()=>{const P=t.current;return!P||!P.env.closestScrollable?Fi:t2(P.env.closestScrollable)},[]),g=Dn(()=>{const P=p();f(P.x,P.y)},[p,f]),y=Qr(()=>Uf(g),[g]),v=Dn(()=>{const P=t.current,F=Lp(P);if(P&&F||$t(),P.scrollOptions.shouldPublishImmediately){g();return}y()},[y,g]),S=Dn((P,F)=>{t.current&&$t();const R=l.current,C=R.getDroppableRef();C||$t();const $=LG(C),Q={ref:C,descriptor:c,env:$,scrollOptions:F};t.current=Q;const q=RG({ref:C,descriptor:c,env:$,windowScroll:P,direction:R.direction,isDropDisabled:R.isDropDisabled,isCombineEnabled:R.isCombineEnabled,shouldClipSubject:!R.ignoreContainerClipping}),V=$.closestScrollable;return V&&(V.setAttribute(E3.contextId,n.contextId),V.addEventListener("scroll",v,j3(Q.scrollOptions))),q},[n.contextId,c,v,l]),A=Dn(()=>{const P=t.current,F=Lp(P);return P&&F||$t(),t2(F)},[]),T=Dn(()=>{const P=t.current;P||$t();const F=Lp(P);t.current=null,F&&(y.cancel(),F.removeAttribute(E3.contextId),F.removeEventListener("scroll",v,j3(P.scrollOptions)))},[v,y]),L=Dn(P=>{const F=t.current;F||$t();const R=Lp(F);R||$t(),R.scrollTop+=P.y,R.scrollLeft+=P.x},[]),I=Qr(()=>({getDimensionAndWatchScroll:S,getScrollWhileDragging:A,dragStopped:T,scroll:L}),[T,S,A,L]),j=Qr(()=>({uniqueId:r,descriptor:c,callbacks:I}),[I,c,r]);_a(()=>(u.current=j.descriptor,s.droppable.register(j),()=>{t.current&&T(),s.droppable.unregister(j)}),[I,c,T,j,i,s.droppable]),_a(()=>{t.current&&i.updateDroppableIsEnabled(u.current.id,!e.isDropDisabled)},[e.isDropDisabled,i]),_a(()=>{t.current&&i.updateDroppableIsCombineEnabled(u.current.id,e.isCombineEnabled)},[e.isCombineEnabled,i])}function wx(){}const P3={width:0,height:0,margin:U$},jG=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>e||n==="close"?P3:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},PG=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>{const r=jG({isAnimatingOpenOnMount:e,placeholder:t,animate:n});return{display:t.display,boxSizing:"border-box",width:r.width,height:r.height,marginTop:r.margin.top,marginRight:r.margin.right,marginBottom:r.margin.bottom,marginLeft:r.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?jf.placeholder:null}},BG=e=>{const t=b.useRef(null),n=Dn(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:r,onTransitionEnd:s,onClose:i,contextId:l}=e,[c,u]=b.useState(e.animate==="open");b.useEffect(()=>c?r!=="open"?(n(),u(!1),wx):t.current?wx:(t.current=setTimeout(()=>{t.current=null,u(!1)}),n):wx,[r,c,n]);const f=Dn(g=>{g.propertyName==="height"&&(s(),r==="close"&&i())},[r,i,s]),p=PG({isAnimatingOpenOnMount:c,animate:e.animate,placeholder:e.placeholder});return D.createElement(e.placeholder.tagName,{style:p,"data-rfd-placeholder-context-id":l,onTransitionEnd:f,ref:e.innerRef})};var FG=D.memo(BG);class OG extends D.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,n){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const QG=e=>{const t=b.useContext(Lg);t||$t();const{contextId:n,isMovementAllowed:r}=t,s=b.useRef(null),i=b.useRef(null),{children:l,droppableId:c,type:u,mode:f,direction:p,ignoreContainerClipping:g,isDropDisabled:y,isCombineEnabled:v,snapshot:S,useClone:A,updateViewportMaxScroll:T,getContainerForClone:L}=e,I=Dn(()=>s.current,[]),j=Dn((V=null)=>{s.current=V},[]);Dn(()=>i.current,[]);const P=Dn((V=null)=>{i.current=V},[]),F=Dn(()=>{r()&&T({maxScroll:LA()})},[r,T]);DG({droppableId:c,type:u,mode:f,direction:p,isDropDisabled:y,isCombineEnabled:v,ignoreContainerClipping:g,getDroppableRef:I});const R=Qr(()=>D.createElement(OG,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:V,data:fe,animate:X})=>D.createElement(FG,{placeholder:fe,onClose:V,innerRef:P,animate:X,contextId:n,onTransitionEnd:F})),[n,F,e.placeholder,e.shouldAnimatePlaceholder,P]),C=Qr(()=>({innerRef:j,placeholder:R,droppableProps:{"data-rfd-droppable-id":c,"data-rfd-droppable-context-id":n}}),[n,c,R,j]),$=A?A.dragging.draggableId:null,Q=Qr(()=>({droppableId:c,type:u,isUsingCloneFor:$}),[c,$,u]);function q(){if(!A)return null;const{dragging:V,render:fe}=A,X=D.createElement(GA,{draggableId:V.draggableId,index:V.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(he,me)=>fe(he,me,V));return Gk.createPortal(X,L())}return D.createElement(jy.Provider,{value:Q},l(C,S),q())};function $G(){return document.body||$t(),document.body}const B3={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:$G},YA=e=>{let t={...e},n;for(n in B3)e[n]===void 0&&(t={...t,[n]:B3[n]});return t},Sx=(e,t)=>e===t.droppable.type,F3=(e,t)=>t.draggables[e.draggable.id],HG=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},n=Bi(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),r=Bi((i,l,c,u,f,p)=>{const g=f.descriptor.id;if(f.descriptor.droppableId===i){const S=p?{render:p,dragging:n(f.descriptor)}:null,A={isDraggingOver:c,draggingOverWith:c?g:null,draggingFromThisWith:g,isUsingPlaceholder:!0};return{placeholder:f.placeholder,shouldAnimatePlaceholder:!1,snapshot:A,useClone:S}}if(!l)return t;if(!u)return e;const v={isDraggingOver:c,draggingOverWith:g,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:f.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(i,l)=>{const c=YA(l),u=c.droppableId,f=c.type,p=!c.isDropDisabled,g=c.renderClone;if(Yf(i)){const y=i.critical;if(!Sx(f,y))return t;const v=F3(y,i.dimensions),S=ka(i.impact)===u;return r(u,p,S,S,v,g)}if(i.phase==="DROP_ANIMATING"){const y=i.completed;if(!Sx(f,y.critical))return t;const v=F3(y.critical,i.dimensions);return r(u,p,UA(y.result)===u,ka(y.impact)===u,v,g)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){const y=i.completed;if(!Sx(f,y.critical))return t;const v=ka(y.impact)===u,S=!!(y.impact.at&&y.impact.at.type==="COMBINE"),A=y.critical.droppable.id===u;return v?S?e:t:A?e:t}return t}},UG={updateViewportMaxScroll:tU},Nu=VS(HG,UG,(e,t,n)=>({...YA(n),...e,...t}),{context:Ny,areStatePropsEqual:HA})(QG);function zG(){if(typeof window>"u")return Wd(void 0);try{const e=window.localStorage.getItem(Db);return Wd(e?JSON.parse(e):void 0)}catch{return Wd(void 0)}}function Ax(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(Db),n=t?JSON.parse(t):{},r=Wd({...n,...e});window.localStorage.setItem(Db,JSON.stringify(r))}catch{}}function GG(){const[e,t]=D.useState(zG);D.useEffect(()=>{Ax(e)},[e]);const n=D.useCallback(s=>{t(i=>{const l=Wd({...i,...s});return Ax(l),l})},[]),r=D.useCallback(()=>{const s=Wd(void 0);t(s),Ax(s)},[]);return{terminalSettings:e,updateTerminalSettings:n,resetTerminalSettings:r}}const n2="termdock-settings";function WG(e){return e==="shell"||e==="tmux"}function VG(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(n2);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),n=t.newSessionModeUserSelected===!0&&WG(t.newSessionMode)?t.newSessionMode:null,r=n??"shell",s=typeof t.newSessionTmuxName=="string"?t.newSessionTmuxName:"";return{mode:r,tmuxName:s,userSelectedMode:n}}catch{return{mode:"shell",tmuxName:"",userSelectedMode:null}}}function O3(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(n2),r={...t?JSON.parse(t):{},...e};window.localStorage.setItem(n2,JSON.stringify(r))}catch{}}function qG(){const[e,t]=D.useState(VG),n=D.useCallback((s,i)=>{const l=i?.userInitiated!==!1;t(c=>({...c,mode:s,userSelectedMode:l?s:c.userSelectedMode})),l&&O3({newSessionMode:s,newSessionModeUserSelected:!0})},[]),r=D.useCallback(s=>{t(i=>({...i,tmuxName:s})),O3({newSessionTmuxName:s})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:n,setNewSessionTmuxName:r}}const YG=550,KG=10;function KA(){const e=b.useRef(null),t=b.useRef(null),n=b.useRef(!1),r=b.useRef(!1),s=b.useRef(null),i=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),l=b.useCallback(()=>{i(),t.current=null},[i]);return b.useCallback(u=>({onPointerDown:f=>{f.pointerType!=="touch"&&f.pointerType!=="pen"||(l(),n.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startY:f.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(n.current=!0,u())},YG))},onPointerMove:f=>{const p=t.current;if(!p||p.pointerId!==f.pointerId||n.current)return;const g=f.clientX-p.startX,y=f.clientY-p.startY;Math.hypot(g,y)>KG&&l()},onPointerUp:f=>{n.current&&(f.preventDefault(),n.current=!1,r.current=!0,s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{r.current=!1,s.current=null},600)),l()},onPointerCancel:l,onPointerLeave:f=>{t.current?.pointerId===f.pointerId&&!n.current&&l()},onClickCapture:f=>{r.current&&(r.current=!1,s.current!=null&&(window.clearTimeout(s.current),s.current=null),f.preventDefault(),f.stopPropagation())}}),[l])}function XG({mode:e,activeProgram:t,promptState:n,shellNames:r}){return e!=="tmux"?!0:n==="running"?!1:n==="idle"?!0:t!==null&&r.has(t.toLowerCase())}function XA(e){const t=document.querySelector('meta[name="theme-color"]');t&&t.setAttribute("content",e==="light"?"#FFFCF0":"#1C1B1A")}function ZG(e,t,n){return!!(e&&t===e&&!n)}function JG(e,t,n){return Math.max(t,Math.min(e,n))}const Fs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function Q3(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function $3(e,t,n,r=.15){return r===0?JG(e,t,n):e<t?-Q3(t-e,n-t,r)+t:e>n?+Q3(e-n,n-t,r)+n:e}function eW(e,[t,n],[r,s]){const[[i,l],[c,u]]=e;return[$3(t,i,l,r),$3(n,c,u,s)]}function tW(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function nW(e){var t=tW(e,"string");return typeof t=="symbol"?t:String(t)}function fi(e,t,n){return t=nW(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Xs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?H3(Object(n),!0).forEach(function(r){fi(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H3(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const ZA={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function U3(e){return e?e[0].toUpperCase()+e.slice(1):""}const rW=["enter","leave"];function sW(e=!1,t){return e&&!rW.includes(t)}function iW(e,t="",n=!1){const r=ZA[e],s=r&&r[t]||t;return"on"+U3(e)+U3(s)+(sW(n,s)?"Capture":"")}const oW=["gotpointercapture","lostpointercapture"];function aW(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=oW.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(r);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:n}}function lW(e,t=""){const n=ZA[e],r=n&&n[t]||t;return e+r}function Ig(e){return"touches"in e}function JA(e){return Ig(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function cW(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function uW(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function e9(e){return Ig(e)?uW(e)[0]:e}function r2(e,t){try{const n=t.clientX-e.clientX,r=t.clientY-e.clientY,s=(t.clientX+e.clientX)/2,i=(t.clientY+e.clientY)/2,l=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:l,origin:[s,i]}}catch{}return null}function dW(e){return cW(e).map(t=>t.identifier)}function z3(e,t){const[n,r]=Array.from(e.touches).filter(s=>t.includes(s.identifier));return r2(n,r)}function Tx(e){const t=e9(e);return Ig(e)?t.identifier:t.pointerId}function o0(e){const t=e9(e);return[t.clientX,t.clientY]}const G3=40,W3=800;function t9(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=G3,n*=G3):r===2&&(t*=W3,n*=W3),[t,n]}function fW(e){var t,n;const{scrollX:r,scrollY:s,scrollLeft:i,scrollTop:l}=e.currentTarget;return[(t=r??i)!==null&&t!==void 0?t:0,(n=s??l)!==null&&n!==void 0?n:0]}function hW(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i})}return t}function Gm(e,...t){return typeof e=="function"?e(...t):e}function pW(){}function mW(...e){return e.length===0?pW:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function V3(e,t){return Object.assign({},t,e||{})}const gW=32;class n9{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:s}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?Gm(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:s}=this;n.args=this.args;let i=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,hW(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const R=n._delta.map(Math.abs);Fs.addTo(n._distance,R)}this.axisIntent&&this.axisIntent(t);const[l,c]=n._movement,[u,f]=r.threshold,{_step:p,values:g}=n;if(r.hasCustomTransform?(p[0]===!1&&(p[0]=Math.abs(l)>=u&&g[0]),p[1]===!1&&(p[1]=Math.abs(c)>=f&&g[1])):(p[0]===!1&&(p[0]=Math.abs(l)>=u&&Math.sign(l)*u),p[1]===!1&&(p[1]=Math.abs(c)>=f&&Math.sign(c)*f)),n.intentional=p[0]!==!1||p[1]!==!1,!n.intentional)return;const y=[0,0];if(r.hasCustomTransform){const[R,C]=g;y[0]=p[0]!==!1?R-p[0]:0,y[1]=p[1]!==!1?C-p[1]:0}else y[0]=p[0]!==!1?l-p[0]:0,y[1]=p[1]!==!1?c-p[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(y);const v=n.offset,S=n._active&&!n._blocked||n.active;S&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=Gm(r.bounds,n)),this.setup&&this.setup()),n.movement=y,this.computeOffset()));const[A,T]=n.offset,[[L,I],[j,P]]=n._bounds;n.overflow=[A<L?-1:A>I?1:0,T<j?-1:T>P?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const F=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=eW(n._bounds,n.offset,F),n.delta=Fs.sub(n.offset,v),this.computeMovement(),S&&(!n.last||i>gW)){n.delta=Fs.sub(n.offset,v);const R=n.delta.map(Math.abs);Fs.addTo(n.distance,R),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[R[0]/i,R[1]/i],n.timeDelta=i)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const s=this.handler(Xs(Xs(Xs({},n),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function xW([e,t],n){const r=Math.abs(e),s=Math.abs(t);if(r>s&&r>n)return"x";if(s>r&&s>n)return"y"}class ch extends n9{constructor(...t){super(...t),fi(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Fs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Fs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const s=typeof r.axisThreshold=="object"?r.axisThreshold[JA(t)]:r.axisThreshold;n.axis=xW(n._movement,s)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const bW=e=>e,q3=.15,r9={enabled(e=!0){return e},eventOptions(e,t,n){return Xs(Xs({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[q3,q3];case!1:return[0,0];default:return Fs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Fs.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||bW},threshold(e){return Fs.toVector(e,0)}},yW=0,Wu=Xs(Xs({},r9),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=yW){return e},bounds(e={}){if(typeof e=="function")return i=>Wu.bounds(e(i));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=e;return[[t,n],[r,s]]}}),Y3={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class vW extends ch{constructor(...t){super(...t),fi(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),s={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=Wu.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const s=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(s&&s.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=Tx(t),r._pointerActive=!0,this.computeValues(o0(t)),this.computeInitial(),n.preventScrollAxis&&JA(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive)return;const s=Tx(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;const i=o0(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Fs.sub(i,n._values),this.computeValues(i)),Fs.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const s=Tx(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,l]=n._distance;if(n.tap=i<=r.tapsThreshold&&l<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[c,u]=n._delta,[f,p]=n._movement,[g,y]=r.swipe.velocity,[v,S]=r.swipe.distance,A=r.swipe.duration;if(n.elapsedTime<A){const T=Math.abs(c/n.timeDelta),L=Math.abs(u/n.timeDelta);T>g&&Math.abs(f)>v&&(n.swipe[0]=Math.sign(c)),L>y&&Math.abs(p)>S&&(n.swipe[1]=Math.sign(u))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,wW(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=Y3[t.key];if(n){const r=this.state,s=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(this.config.keyboardDisplacement,s),r._keyboardActive=!0,Fs.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Y3&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function wW(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const uh=typeof window<"u"&&window.document&&window.document.createElement;function s9(){return uh&&"ontouchstart"in window}function SW(){return s9()||uh&&window.navigator.maxTouchPoints>1}function AW(){return uh&&"onpointerdown"in window}function TW(){return uh&&"exitPointerLock"in window.document}function CW(){try{return"constructor"in GestureEvent}catch{return!1}}const Ya={isBrowser:uh,gesture:CW(),touch:s9(),touchscreen:SW(),pointer:AW(),pointerLock:TW()},kW=250,_W=180,LW=.5,EW=50,IW=250,RW=10,K3={mouse:0,touch:0,pen:8},NW=Xs(Xs({},Wu),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&Ya.pointerLock,Ya.touch&&n?"touch":this.pointerLock?"mouse":Ya.pointer&&!s?"pointer":Ya.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?kW:void 0,!(!Ya.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const i=Fs.toVector(e,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,i},swipe({velocity:e=LW,distance:t=EW,duration:n=IW}={}){return{velocity:this.transform(Fs.toVector(e)),distance:this.transform(Fs.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return _W;case!1:return 0;default:return e}},axisThreshold(e){return e?Xs(Xs({},K3),e):K3},keyboardDisplacement(e=RW){return e}});function i9(e){const[t,n]=e.overflow,[r,s]=e._delta,[i,l]=e._direction;(t<0&&r>0&&i<0||t>0&&r<0&&i>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&s>0&&l<0||n>0&&s<0&&l>0)&&(e._movement[1]=e._movementBound[1])}const MW=30,DW=100;class jW extends n9{constructor(...t){super(...t),fi(this,"ingKey","pinching"),fi(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=Fs.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const s=Math.abs(n)*MW-Math.abs(r);s<0?t.axis="angle":s>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(i=>r.has(i))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const s=z3(t,n._touchIds);s&&this.pinchStart(t,s)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,s=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(l=>s.has(l))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const i=r2(...Array.from(r.values()));i&&this.pinchStart(t,i)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=z3(t,this.state._touchIds);n&&this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=r2(...Array.from(n.values()));r&&this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,s=r._values[1],i=n.angle-s;let l=0;Math.abs(i)>270&&(l+=Math.sign(i)),this.computeValues([n.distance,n.angle-360*l]),r.origin=n.origin,r.turns=l,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=Fs.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>t[r]):!t[n])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-t9(t)[1]/DW*r.offset[0],0],Fs.addTo(r._movement,r._delta),i9(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this)),t("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const PW=Xs(Xs({},r9),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!Ya.touch&&Ya.gesture)return"gesture";if(Ya.touch&&r)return"touch";if(Ya.touchscreen){if(Ya.pointer)return"pointer";if(Ya.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const s=l=>{const c=V3(Gm(n,l),{min:-1/0,max:1/0});return[c.min,c.max]},i=l=>{const c=V3(Gm(r,l),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof n!="function"&&typeof r!="function"?[s(),i()]:l=>[s(l),i(l)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Fs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class BW extends ch{constructor(...t){super(...t),fi(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(o0(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const n=o0(t),r=this.state;r._delta=Fs.sub(n,r._values),Fs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const FW=Xs(Xs({},Wu),{},{mouseOnly:(e=!0)=>e});class OW extends ch{constructor(...t){super(...t),fi(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const n=this.state,r=fW(t);n._delta=Fs.sub(r,n._values),Fs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const QW=Wu;class $W extends ch{constructor(...t){super(...t),fi(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=t9(t),Fs.addTo(n._movement,n._delta),i9(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const HW=Wu;class UW extends ch{constructor(...t){super(...t),fi(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(o0(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=o0(t);n._movement=n._delta=Fs.sub(r,n._values),this.computeValues(r),this.compute(t),n.delta=n.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const zW=Xs(Xs({},Wu),{},{mouseOnly:(e=!0)=>e}),Py=new Map,s2=new Map;function o9(e){Py.set(e.key,e.engine),s2.set(e.key,e.resolver)}const a9={key:"drag",engine:vW,resolver:NW},GW={key:"hover",engine:UW,resolver:zW},WW={key:"move",engine:BW,resolver:FW},VW={key:"pinch",engine:jW,resolver:PW},qW={key:"scroll",engine:OW,resolver:QW},YW={key:"wheel",engine:$W,resolver:HW};function KW(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function XW(e,t){if(e==null)return{};var n=KW(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const ZW={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=Ya.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},JW=["target","eventOptions","window","enabled","transform"];function um(e={},t){const n={};for(const[r,s]of Object.entries(t))switch(typeof s){case"function":n[r]=s.call(n,e[r],r,e);break;case"object":n[r]=um(e[r],s);break;case"boolean":s&&(n[r]=e[r]);break}return n}function eV(e,t,n={}){const r=e,{target:s,eventOptions:i,window:l,enabled:c,transform:u}=r,f=XW(r,JW);if(n.shared=um({target:s,eventOptions:i,window:l,enabled:c,transform:u},ZW),t){const p=s2.get(t);n[t]=um(Xs({shared:n.shared},f),p)}else for(const p in f){const g=s2.get(p);g&&(n[p]=um(Xs({shared:n.shared},f[p]),g))}return n}class l9{constructor(t,n){fi(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,s,i){const l=this._listeners,c=lW(n,r),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},f=Xs(Xs({},u),i);t.addEventListener(c,s,f);const p=()=>{t.removeEventListener(c,s,f),l.delete(p)};return l.add(p),p}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class tV{constructor(){fi(this,"_timeouts",new Map)}add(t,n,r=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...s))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class nV{constructor(t){fi(this,"gestures",new Set),fi(this,"_targetEventStore",new l9(this)),fi(this,"gestureEventStores",{}),fi(this,"gestureTimeoutStores",{}),fi(this,"handlers",{}),fi(this,"config",{}),fi(this,"pointerIds",new Set),fi(this,"touchIds",new Set),fi(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),rV(this,t)}setEventIds(t){if(Ig(t))return this.touchIds=new Set(dW(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=eV(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let s;if(!(n.target&&(s=n.target(),!s))){if(n.enabled){for(const l of this.gestures){const c=this.config[l],u=X3(r,c.eventOptions,!!s);if(c.enabled){const f=Py.get(l);new f(this,t,l).bind(u)}}const i=X3(r,n.eventOptions,!!s);for(const l in this.nativeHandlers)i(l,"",c=>this.nativeHandlers[l](Xs(Xs({},this.state.shared),{},{event:c,args:t})),void 0,!0)}for(const i in r)r[i]=mW(...r[i]);if(!s)return r;for(const i in r){const{device:l,capture:c,passive:u}=aW(i);this._targetEventStore.add(s,l,"",r[i],{capture:c,passive:u})}}}}function Ad(e,t){e.gestures.add(t),e.gestureEventStores[t]=new l9(e,t),e.gestureTimeoutStores[t]=new tV}function rV(e,t){t.drag&&Ad(e,"drag"),t.wheel&&Ad(e,"wheel"),t.scroll&&Ad(e,"scroll"),t.move&&Ad(e,"move"),t.pinch&&Ad(e,"pinch"),t.hover&&Ad(e,"hover")}const X3=(e,t,n)=>(r,s,i,l={},c=!1)=>{var u,f;const p=(u=l.capture)!==null&&u!==void 0?u:t.capture,g=(f=l.passive)!==null&&f!==void 0?f:t.passive;let y=c?r:iW(r,s,p);n&&g&&(y+="Passive"),e[y]=e[y]||[],e[y].push(i)},sV=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function iV(e){const t={},n={},r=new Set;for(let s in e)sV.test(s)?(r.add(RegExp.lastMatch),n[s]=e[s]):t[s]=e[s];return[n,t,r]}function Td(e,t,n,r,s,i){if(!e.has(n)||!Py.has(r))return;const l=n+"Start",c=n+"End",u=f=>{let p;return f.first&&l in t&&t[l](f),n in t&&(p=t[n](f)),f.last&&c in t&&t[c](f),p};s[r]=u,i[r]=i[r]||{}}function oV(e,t){const[n,r,s]=iV(e),i={};return Td(s,n,"onDrag","drag",i,t),Td(s,n,"onWheel","wheel",i,t),Td(s,n,"onScroll","scroll",i,t),Td(s,n,"onPinch","pinch",i,t),Td(s,n,"onMove","move",i,t),Td(s,n,"onHover","hover",i,t),{handlers:i,config:t,nativeHandlers:r}}function c9(e,t={},n,r){const s=D.useMemo(()=>new nV(e),[]);if(s.applyHandlers(e,r),s.applyConfig(t,n),D.useEffect(s.effect.bind(s)),D.useEffect(()=>s.clean.bind(s),[]),t.target===void 0)return s.bind.bind(s)}function Z3(e,t){return o9(a9),c9({drag:e},t||{},"drag")}function aV(e){return e.forEach(o9),function(n,r){const{handlers:s,nativeHandlers:i,config:l}=oV(n,r||{});return c9(s,l,void 0,i)}}function u9(e,t){return aV([a9,VW,qW,YW,WW,GW])(e,t||{})}const J3={dampingRatio:.8,response:.3},lV=.998;function cV(e,t,n,r){const s=2*Math.PI/Math.max(e.response,.001),i=t-r,l=n,c=e.dampingRatio;if(Math.abs(c-1)<1e-4){const v=i,S=l+s*i;return{value:A=>r+(v+S*A)*Math.exp(-s*A),velocity:A=>(S-s*(v+S*A))*Math.exp(-s*A)}}if(c<1){const v=s*Math.sqrt(1-c*c),S=i,A=(l+c*s*i)/v;return{value:T=>r+Math.exp(-c*s*T)*(S*Math.cos(v*T)+A*Math.sin(v*T)),velocity:T=>Math.exp(-c*s*T)*((A*v-c*s*S)*Math.cos(v*T)-(S*v+c*s*A)*Math.sin(v*T))}}const u=s*Math.sqrt(c*c-1),f=-c*s+u,p=-c*s-u,g=(l-p*i)/(f-p),y=i-g;return{value:v=>r+g*Math.exp(f*v)+y*Math.exp(p*v),velocity:v=>g*f*Math.exp(f*v)+y*p*Math.exp(p*v)}}function uV(e,t=lV){return e/1e3*(t/(1-t))}function e6(e,t,n=.55){return e*t*n/(t+n*Math.abs(e))}function dV(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const fV=.1,hV=5;function pV(e,t,n,r,s){const i=cV(e,t,n,r),l=1e3/60,c=240,u=[];for(let f=0;f<c;f++){const p=f*l/1e3,g=i.value(p),y=i.velocity(p);if(u.push(s?s(g):g),f>0&&Math.abs(g-r)<fV&&Math.abs(y)<hV)break}return u.push(s?s(r):r),{frames:u,durationMs:(u.length-1)*l,solver:i}}const mV="swiper",gV="pre.termdock-file-preview-horizontal-scroll",d9="swiper-no-swiping",f9="data-sidebar-gesture-ignore",Cx=1;function xV(e,t){const n=e.scrollWidth-e.clientWidth;return n<=Cx?!1:t>0?e.scrollLeft>Cx:e.scrollLeft<n-Cx}function bV(e){return e.matches(gV)?{element:e,startScrollLeft:e.scrollLeft}:null}function yV(e,t){e.element.scrollLeft=e.startScrollLeft-t}function vV(e,t){return t>0?!e.isBeginning:!e.isEnd}function wV(e,t){const n=[],r=[];if(!(e instanceof Element))return{scrollers:n,swipers:r};const s=!!e.closest(`.${d9}`);let i=e;for(;i&&i!==t;){if(!s&&i.classList.contains(mV)){const l=i.swiper;l&&!l.destroyed&&r.push(l)}if(i instanceof HTMLElement){const{overflowX:l}=getComputedStyle(i);(l==="auto"||l==="scroll")&&n.push(i)}i=i.parentElement}return{scrollers:n,swipers:r}}function SV(e,t,n){const r=t>=0?1:-1;for(const s of e.scrollers)if(xV(s,r))return{kind:"scroller",element:s};for(const s of e.swipers)if(vV(s,r))return{kind:"swiper",instance:s};return r===n?{kind:"drawer"}:e.swipers.length>0?{kind:"swiper",instance:e.swipers[0]}:e.scrollers.length>0?{kind:"scroller",element:e.scrollers[0]}:{kind:"drawer"}}function By(){if(typeof window>"u"||typeof window.getSelection!="function")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&String(e).length>0)}function AV(e){e.allowTouchMove=!0;let t=!1;const n=()=>{t||(t=!0,e.allowTouchMove=!1,window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n))};return window.addEventListener("touchend",n),window.addEventListener("touchcancel",n),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),n}const TV=18,t6=8,n6={touch:t6,pen:t6},CV=500,kx=200,r6=50,kV=`[${f9}]`;function _x(e,t,n){return Math.min(n,Math.max(t,e))}function s6(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function _V(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(kV)}function af(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const h9=D.forwardRef(function({side:t,isOpen:n,drawerWidthPx:r,onClose:s,onOpen:i,children:l,pinned:c=!1},u){const{t:f}=qn(),p=t==="left",g=p?-r:r,y=b.useRef(null),v=b.useRef(null),S=b.useRef(n?0:g),A=b.useRef(null),T=b.useRef(null),L=b.useRef(0),I=b.useRef(null),j=b.useRef(null),P=b.useRef(!1),F=b.useRef(null),R=b.useRef(!1),C=b.useRef([]),$=b.useRef(null),Q=b.useRef(S.current),q=b.useRef(n?1:0),V=b.useRef(n);V.current=n;const fe=b.useRef(g);fe.current=g;const X=b.useRef(r);X.current=r;const he=b.useRef(p);he.current=p;const me=b.useRef(s);me.current=s;const de=b.useRef(i);de.current=i;const le=b.useCallback(ae=>{y.current=ae,typeof u=="function"?u(ae):u&&(u.current=ae)},[u]),W=b.useCallback(()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),A.current=null},[]),z=b.useCallback(ae=>{const Ne=X.current;return he.current?(ae+Ne)/Ne:(Ne-ae)/Ne},[]),K=b.useCallback(ae=>{const Ne=v.current;Ne&&(Ne.style.opacity=String(_x(z(ae),0,1)))},[z]),se=b.useCallback(ae=>{S.current=ae;const Ne=y.current;Ne&&(Ne.style.transform=`translateX(${ae}px)`,K(ae))},[K]),ge=b.useCallback(ae=>{A.current=ae,T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null;const Ne=A.current;A.current=null,Ne!==null&&se(Ne)}))},[se]),Ee=b.useCallback(()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null);const ae=A.current;A.current=null,ae!==null&&se(ae)},[se]),pe=b.useCallback(ae=>{const Ne=fe.current;return _x(ae,Math.min(0,Ne),Math.max(0,Ne))},[]),xe=b.useCallback(()=>{const ae=I.current;if(!ae)return null;I.current=null;const Ne=(performance.now()-ae.startTime)/1e3,We={value:ae.solver.value(Ne),velocity:ae.solver.velocity(Ne)};return ae.animations.forEach(Ie=>Ie.cancel()),We},[]),be=b.useCallback(()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)},[]),J=b.useCallback(()=>{$.current?.(),$.current=null},[]),Ke=b.useCallback(()=>{Ee(),be();const ae=xe();ae&&se(pe(ae.value));const Ne=y.current,We=v.current;Ne?.getAnimations().forEach(Ie=>Ie.cancel()),Ne&&(Ne.style.transition="none",Ne.style.opacity="1"),We?.getAnimations().forEach(Ie=>Ie.cancel()),We&&(We.style.transition="none")},[se,be,pe,Ee,xe]),Xe=b.useCallback((ae,Ne)=>{Ee(),be();const We=y.current,Ie=v.current,He=ae?0:fe.current;Ie&&(Ie.style.pointerEvents=ae?"auto":"none");const gt=xe(),bt=gt?pe(gt.value):S.current,vt=Ne?.velocity??gt?.velocity??0;if(dV())return S.current=He,We&&(We.style.transition=`opacity ${kx}ms ease`,We.style.opacity=ae?"1":"0",We.style.transform=`translateX(${He}px)`),Ie&&(Ie.style.transition=`opacity ${kx}ms ease`,Ie.style.opacity=ae?"1":"0"),kx;We&&(We.style.transition="none",We.style.opacity="1"),Ie&&(Ie.style.transition="none");const rn=Math.abs(Ne?.velocity??0)>CV,{frames:Ot,durationMs:un,solver:gr}=pV({dampingRatio:rn?J3.dampingRatio:1,response:J3.response},bt,vt,He,pe);if(!We||Math.abs(bt-He)<.5&&Math.abs(vt)<5)return se(He),0;const dn=We.animate(Ot.map(we=>({transform:`translateX(${we}px)`})),{duration:un,easing:"linear",fill:"forwards"}),wt=[dn];return Ie&&wt.push(Ie.animate(Ot.map(we=>({opacity:String(_x(z(we),0,1))})),{duration:un,easing:"linear",fill:"forwards"})),I.current={solver:gr,startTime:performance.now(),target:He,animations:wt},af("spring start",{startX:bt,startVelocity:vt,targetX:He,frames:Ot.length,durationMs:un}),dn.onfinish=()=>{const we=I.current;!we||!we.animations.includes(dn)||(I.current=null,se(He),we.animations.forEach(rt=>rt.cancel()),af("spring finish",{targetX:He}))},un},[se,be,pe,Ee,z,xe]),nt=b.useCallback(ae=>{Ee();const Ne=ae,We=0,Ie=fe.current,He=S.current+uV(Ne),gt=Math.abs(He-We)<=Math.abs(He-Ie);af("decideSnap",{velocity:Ne,currentX:S.current,projected:He,shouldOpen:gt});const bt=Xe(gt,{velocity:Ne});gt&&!V.current?j.current=window.setTimeout(()=>{j.current=null,de.current?.()},bt+r6):!gt&&V.current&&(j.current=window.setTimeout(()=>{j.current=null,me.current()},bt+r6))},[Xe,Ee]),Se=b.useCallback(ae=>{const Ne=fe.current,We=Math.min(0,Ne),Ie=Math.max(0,Ne),He=X.current;return ae<We?We-e6(We-ae,He):ae>Ie?Ie+e6(ae-Ie,He):ae},[]),Fe=b.useCallback(ae=>{const Ne=C.current,We=performance.now();Ne.push({t:We,x:ae});const Ie=We-120;for(;Ne.length>0&&Ne[0].t<Ie;)Ne.shift()},[]),ue=b.useCallback(()=>{const ae=C.current;if(ae.length<2)return 0;const Ne=ae[ae.length-1];if(performance.now()-Ne.t>60)return 0;const We=ae[0],Ie=(Ne.t-We.t)/1e3;return Ie<.016?0:(Ne.x-We.x)/Ie},[]);b.useEffect(()=>{be();const ae=I.current,Ne=n?0:fe.current;ae&&ae.target===Ne||Xe(n)},[n,Xe,be]),b.useEffect(()=>{Ke(),ge(V.current?0:g)},[g,Ke,ge]),b.useEffect(()=>()=>{W(),be(),xe(),J()},[be,W,J,xe]);const Be=Z3(({active:ae,cancel:Ne,first:We,last:Ie,movement:[He],event:gt})=>{if(af("bindPanel",{active:ae,first:We,last:Ie,mx:He}),!s6(gt)){Ne();return}if(We){if(J(),P.current=!1,F.current=null,C.current=[],_V(gt)){Ne();return}const bt=y.current,vt=bt?wV(gt.target,bt):null;if(!vt||By()){Ne();return}const rn=SV(vt,He,he.current?-1:1);if(af("arbitrate",{owner:rn.kind,mx:He}),rn.kind==="swiper"){$.current=AV(rn.instance),Ne();return}if(rn.kind==="scroller"){const Ot=bV(rn.element);if(Ot)F.current=Ot;else{Ne();return}}F.current||(P.current=!0,Ke(),L.current=S.current)}if(!ae){F.current=null,P.current&&(P.current=!1,nt(ue()));return}if(F.current){yV(F.current,He);return}if(P.current){const bt=Se(L.current+He);Fe(bt),ge(bt)}},{axis:"x",axisThreshold:n6,filterTaps:!0,pointer:{touch:!0}}),$e=Z3(({active:ae,cancel:Ne,first:We,movement:[Ie],event:He})=>{if(!s6(He)){Ne();return}if(V.current){Ne();return}if(We&&(R.current=!0,C.current=[],Ke(),L.current=S.current),!ae){R.current&&(R.current=!1,nt(ue()));return}if(R.current){const gt=Se(L.current+Ie);Fe(gt),ge(gt)}},{axis:"x",axisThreshold:n6,filterTaps:!0,pointer:{touch:!0}}),tt=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),V.current||de.current?.()},[]);return c?o.jsx("aside",{ref:le,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:l}):o.jsxs(o.Fragment,{children:[o.jsx("div",{...$e(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...p?{left:0}:{right:0},width:TV,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:n?"none":"auto"},onClick:tt,"aria-label":f(p?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),o.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:q.current,pointerEvents:n?"auto":"none",transition:"none",willChange:"opacity"},onClick:s,"aria-label":f("sidebar.closeSidebar")}),o.jsx("aside",{...Be(),ref:le,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${p?"border-r border-border/15":"border-l border-border/15"}`,style:{...p?{left:0}:{right:0},width:r,maxWidth:"94vw",transform:`translateX(${Q.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:n?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...p?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})});function LV(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function EV(e,t,n,r="next"){if(e.length===0)return null;const s=t?e.findIndex(i=>i.sessionId===t):-1;for(let i=1;i<=e.length;i+=1){const l=r==="next"?i:-i,c=(s+l+e.length)%e.length,u=e[c];if(u&&n(u))return u.sessionId}return null}function IV(e,t,n="next"){return EV(e,t,LV,n)}const Ta=42,Wm=20,RV=10;function i2(e,t,n){return Math.min(n,Math.max(t,e))}function Rg(e){const t=Math.max(0,e.safeTop??0),n=Math.max(0,e.safeRight??0),r=Math.max(0,e.safeBottom??0),s=Math.max(0,e.safeLeft??0),i=Math.max(0,e.bottomClearance??72),l=s+Wm,c=Math.max(l,e.width-n-Wm-Ta),u=Math.max(t+12,52),f=Math.max(u,e.height-r-i-Ta);return{minX:l,maxX:c,minY:u,maxY:f}}function i6(e,t){const n=Rg(e),r=i2(t.yRatio,0,1);return{x:t.side==="left"?n.minX:n.maxX,y:n.minY+(n.maxY-n.minY)*r}}function Pu(e,t){const n=Rg(e);return{x:i2(t.x,n.minX,n.maxX),y:i2(t.y,n.minY,n.maxY)}}function o6(e,t){const n=Rg(e),r=Pu(e,t),s=(n.minX+n.maxX+Ta)/2,i=r.x+Ta/2<s?"left":"right",l=n.maxY-n.minY;return{position:{x:i==="left"?n.minX:n.maxX,y:r.y},preference:{side:i,yRatio:l>0?(r.y-n.minY)/l:0}}}function a6(e,t,n){const r=Pu(e,t),s=Ta+RV,i=f=>Math.abs(f.x-n.x)<s&&Math.abs(f.y-n.y)<s;if(!i(r))return r;const l=[{...r,y:n.y-s},{...r,y:n.y+s}].map(f=>Pu(e,f)).filter(f=>!i(f)).sort((f,p)=>Math.abs(f.y-r.y)-Math.abs(p.y-r.y));if(l[0])return l[0];const c=Rg(e);return[{...r,x:c.minX},{...r,x:c.maxX}].map(f=>Pu(e,f)).filter(f=>!i(f)).sort((f,p)=>Math.abs(f.x-r.x)-Math.abs(p.x-r.x))[0]??r}const Lx="var(--warning)",NV="var(--success)",l6="var(--tmux)",c6="termdock:mobile-attention-position:v1",u6="termdock:running-session-position:v1",MV={side:"right",yRatio:.68},DV={side:"right",yRatio:.54};function d6(e,t){if(typeof window>"u")return t;try{const n=JSON.parse(window.localStorage.getItem(e)??"null");if(n&&(n.side==="left"||n.side==="right")&&typeof n.yRatio=="number"&&Number.isFinite(n.yRatio))return{side:n.side,yRatio:Math.min(1,Math.max(0,n.yRatio))}}catch{}return t}function jV(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ep(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function lf(e,t){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,r=n?.width??window.innerWidth,s=n?.height??window.innerHeight,i=t?.getBoundingClientRect(),l=!!(i&&i.width>0&&i.height>0);return{width:r,height:s,safeTop:Math.max(Ep("--safe-top-inset"),l?Math.max(0,i.top):0),safeRight:Math.max(Ep("--safe-right-inset"),l?Math.max(0,r-i.right):0),safeBottom:Math.max(Ep("--safe-bottom-inset"),l?Math.max(0,s-i.bottom):0),safeLeft:Math.max(Ep("--safe-left-inset"),l?Math.max(0,i.left):0),bottomClearance:e?Wm:72}}function p9(){const e=ts.getState(),t=Array.from(e.sessions.values()),n=IV(t,e.activeSessionId);if(!n)return;const r=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;r?.agentNeedsReview&&e.clearAgentNeedsReview(r.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:n}))}function f6(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function m9(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function PV({indicator:e,tone:t,size:n}){const r=m9(t);switch(e){case"spinner":return o.jsx(Hn,{size:n,className:"shrink-0 animate-spin",style:{color:r}});case"question":return o.jsx(Tm,{size:n,className:"shrink-0 animate-bounce-y",style:{color:r}});case"badge":return o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:r}});case"terminal":return o.jsx(Sa,{size:n,className:"shrink-0",style:{color:r}});case"pulse":return o.jsx(KR,{size:n,className:"shrink-0 animate-pulse",style:{color:r}});case"ring":return o.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:n,height:n,borderColor:r}});case"dot":return o.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,n-4),height:Math.max(5,n-4),backgroundColor:r}})}}function Bu({agent:e,size:t=12}){const n=t-4;if(!e.icon)return o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:o.jsx(K2,{size:n,className:"text-white"})});let r;return e.isPlugin?(r=`/api/terminal/agent-plugin-icon/${e.slug}`,e.iconVersion&&(r+=`?v=${Math.floor(e.iconVersion)}`)):r=`/icons/agents/${e.icon}.svg`,e.iconMode==="native"?o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:o.jsx("img",{src:r,alt:e.displayName,style:{width:n,height:n}})}):o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:o.jsx("span",{className:"block bg-white",style:{width:n,height:n,WebkitMask:`url(${r}) center / contain no-repeat`,mask:`url(${r}) center / contain no-repeat`}})})}function BV({sessionMode:e,state:t,size:n=11}){const r=t?.agent?o.jsx(Bu,{agent:t.agent,size:n+1}):e==="tmux"?o.jsx(Mu,{size:n,className:"shrink-0"}):o.jsx(Sa,{size:n,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?o.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:o.jsx(PV,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:n})}):t?.agentStatus==="working"?o.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:o.jsx(Hn,{size:n,className:"shrink-0 animate-spin",style:{color:NV}})}):t?.agentStatus==="waiting"?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Tm,{size:n,className:"shrink-0 animate-bounce-y",style:{color:Lx}})}):t?.agentStatus==="done"&&t.agentNeedsReview?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:Lx}})}):t?.agentNeedsReview?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:Lx}})}):t?.inCopyMode?e==="tmux"?o.jsx(Mu,{size:n,className:"shrink-0 animate-pulse",style:{color:l6}}):o.jsx(Sa,{size:n,className:"shrink-0 animate-pulse",style:{color:l6}}):r}function FV({status:e,detail:t,needsReview:n,inCopyMode:r}){const{t:s}=qn();return t&&!n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:m9(t.tone)},title:t.label}):e==="working"?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:s("agent.aiRunning")}):e==="waiting"||n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:s(n?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:s("agent.finishedReview")}):r?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:s("agent.copyMode")}):null}function g9({count:e,tone:t,title:n}){const{t:r}=qn();if(e<=0)return null;const s=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",i=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=n??r("agent.jumpToNext");return o.jsxs("button",{type:"button",className:s,title:`${l} · ${r("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${r("agent.jumpToNext")}`,onClick:p9,children:[o.jsx(Yc,{size:11,className:"shrink-0"}),o.jsx("span",{children:r("agent.needsReview")}),o.jsx("span",{className:"tabular-nums",children:e})]})}return o.jsxs("span",{className:s,title:n,children:[o.jsx("span",{className:i}),e]})}function OV({runningCount:e,reviewCount:t,className:n=""}){const r=[];return e>0&&r.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&r.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),r.length===0?null:o.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${r.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${n}`,children:r.map(s=>o.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${s.className}`,children:s.count>9?"9+":s.count},s.key))})}const QV=380,h6=10,Ip=10,Ex=52,$V=104;function HV(e,t,n){const r=t.getBoundingClientRect(),s=window.visualViewport?.width??window.innerWidth,i=window.visualViewport?.height??window.innerHeight,l=r.width>0&&r.height>0,c=l?Math.max(0,r.left):0,u=l?Math.min(s,r.right):s,f=l?Math.max(0,r.top):0,p=l?Math.min(i,r.bottom):i,g=Wm,y=e.x+Ta/2>=c+(u-c)/2,v=y?e.x-Ip-c-g:u-g-e.x-Ta-Ip,S=Math.max(1,Math.min(Math.max(0,v),Math.max(168,n*$V))),A=y?e.x-Ip-S:e.x+Ta+Ip,T=Math.min(Math.max(A,c+g),Math.max(c+g,u-g-S)),L=e.y+Ta/2-Ex/2,I=Math.min(Math.max(L,f+g),Math.max(f+g,p-g-Ex));return{left:T,top:I,width:S,height:Ex,itemWidth:S/Math.max(1,n),side:y?"left":"right"}}function p6(e,t,n,r){return t<e.left||t>e.left+e.width||n<e.top-14||n>e.top+e.height+14?null:Math.min(r-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function UV(e,t){if(e.length===0)return null;const n=t?e.findIndex(r=>r.id===t):-1;return e[(n+1)%e.length]?.id??null}function zV({reviewCount:e,runningSessions:t,activeSessionId:n,runningButtonEnabled:r,isDesktopLayout:s,containerElement:i}){const{t:l}=qn(),c=xt(pe=>pe.leftOpen),u=xt(pe=>pe.rightOpen),{isOpen:f}=pS({enabled:!s}),p=s||!c&&!u&&!f,g=e>0&&p,y=t.length>1||t.length===1&&t[0]?.id!==n,v=r&&t.length>0&&y&&p,S=D.useRef({attention:d6(c6,MV),running:d6(u6,DV)}),A=D.useCallback(()=>{const pe=lf(s,i),xe=i6(pe,S.current.attention),be=i6(pe,S.current.running);return{attention:xe,running:g&&v?a6(pe,be,xe):be}},[g,i,s,v]),[T,L]=D.useState(()=>A()),I=D.useRef(T);I.current=T;const[j,P]=D.useState(null),F=D.useRef(null),[R,C]=D.useState("idle"),[$,Q]=D.useState(null),q=D.useRef(null),V=D.useRef({attention:!1,running:!1});D.useEffect(()=>()=>{const pe=q.current?.longPressTimer;pe!=null&&window.clearTimeout(pe)},[]),D.useEffect(()=>{if(v)return;const pe=q.current?.longPressTimer;pe!=null&&window.clearTimeout(pe),q.current=null,C("idle"),Q(null)},[v]),D.useLayoutEffect(()=>{const pe=()=>{const be=A();I.current=be,L(be)};pe(),window.addEventListener("resize",pe),window.addEventListener("orientationchange",pe),window.visualViewport?.addEventListener("resize",pe);const xe=typeof ResizeObserver>"u"?null:new ResizeObserver(pe);return i&&xe?.observe(i),()=>{window.removeEventListener("resize",pe),window.removeEventListener("orientationchange",pe),window.visualViewport?.removeEventListener("resize",pe),xe?.disconnect()}},[i,A]);const fe=D.useCallback(pe=>pe==="attention"?v:g,[g,v]),X=D.useCallback((pe,xe)=>{if(!fe(pe))return xe;const be=pe==="attention"?"running":"attention";return a6(lf(s,i),xe,I.current[be])},[i,s,fe]),he=D.useCallback((pe,xe,be,J)=>{const Ke=lf(s,i),Xe=xe.moved?Pu(Ke,{x:xe.startX+(be-xe.originX),y:xe.startY+(J-xe.originY)}):I.current[pe],nt=o6(Ke,Xe),Se=X(pe,nt.position),Fe=o6(Ke,Se);S.current[pe]=Fe.preference,jV(pe==="attention"?c6:u6,Fe.preference);const ue={...I.current,[pe]:Fe.position};I.current=ue,L(ue)},[X,i,s]),me=D.useCallback(pe=>{V.current[pe]=!0,window.setTimeout(()=>{V.current[pe]=!1},0)},[]),de=D.useCallback(pe=>{const xe=F.current;!xe||xe.kind!=="attention"||xe.pointerId!==pe.pointerId||(F.current=null,P(null),he("attention",xe,pe.clientX,pe.clientY),xe.moved&&me("attention"))},[he,me]),le={onPointerDown:pe=>{pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId),F.current={kind:"attention",pointerId:pe.pointerId,originX:pe.clientX,originY:pe.clientY,startX:T.attention.x,startY:T.attention.y,moved:!1}},onPointerMove:pe=>{const xe=F.current;if(!xe||xe.kind!=="attention"||xe.pointerId!==pe.pointerId)return;const be=pe.clientX-xe.originX,J=pe.clientY-xe.originY;if(!xe.moved&&Math.hypot(be,J)<5)return;xe.moved=!0,P("attention");const Ke=lf(s,i),Xe=X("attention",Pu(Ke,{x:xe.startX+be,y:xe.startY+J})),nt={...I.current,attention:Xe};I.current=nt,L(nt)},onPointerUp:de,onPointerCancel:de},W=i?HV(T.running,i,t.length):null,z=pe=>{pe.longPressTimer!==null&&(window.clearTimeout(pe.longPressTimer),pe.longPressTimer=null)},K={onPointerDown:pe=>{pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId);const xe=pe.pointerId,be={pointerId:xe,originX:pe.clientX,originY:pe.clientY,startX:T.running.x,startY:T.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};be.longPressTimer=window.setTimeout(()=>{const J=q.current;!J||J.pointerId!==xe||J.mode!=="pressing"||(J.longPressTimer=null,J.mode="dragging",V.current.running=!0,C("dragging"))},QV),q.current=be,C("pressing"),Q(null)},onPointerMove:pe=>{const xe=q.current;if(!xe||xe.pointerId!==pe.pointerId)return;const be=pe.clientX-xe.originX,J=pe.clientY-xe.originY;if(xe.mode==="pressing")if(Math.abs(be)>=h6&&Math.abs(be)>=Math.abs(J))z(xe),xe.mode="selecting",V.current.running=!0,C("selecting");else if(Math.hypot(be,J)>=h6){z(xe),xe.mode="cancelled",V.current.running=!0,C("idle");return}else return;if(xe.mode==="selecting"){const Se=W?p6(W,pe.clientX,pe.clientY,t.length):null;xe.selectedIndex=Se,Q(Se);return}if(xe.mode!=="dragging"||!xe.moved&&Math.hypot(be,J)<5)return;xe.moved=!0;const Ke=lf(s,i),Xe=X("running",Pu(Ke,{x:xe.startX+be,y:xe.startY+J})),nt={...I.current,running:Xe};I.current=nt,L(nt)},onPointerUp:pe=>{const xe=q.current;if(!xe||xe.pointerId!==pe.pointerId)return;z(xe);const be=xe.mode;if(be==="selecting"){const J=W?p6(W,pe.clientX,pe.clientY,t.length):xe.selectedIndex,Ke=J===null?null:t[J]?.id;Ke&&f6(Ke)}else be==="dragging"&&he("running",xe,pe.clientX,pe.clientY);q.current=null,C("idle"),Q(null),be!=="pressing"&&me("running")},onPointerCancel:pe=>{const xe=q.current;!xe||xe.pointerId!==pe.pointerId||(z(xe),q.current=null,C("idle"),Q(null),me("running"))}},se=(pe,xe)=>o.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${xe==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:pe>9?"9+":pe}),ge=()=>{const pe=l("agent.jumpToNext"),xe=T.attention,be=j==="attention";return o.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...le,onClick:J=>{J.stopPropagation(),!V.current.attention&&p9()},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${be?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:xe.x,top:xe.y,width:Ta,height:Ta,touchAction:"none"},"aria-label":`${pe}: ${e}`,title:pe,children:[o.jsx(Yc,{size:17,className:"shrink-0"}),se(e,"attention")]},"attention")},Ee=()=>{const pe=t.length,xe=T.running,be=R==="selecting",J=R==="dragging";return o.jsxs(D.Fragment,{children:[o.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":R,...K,onClick:Ke=>{if(Ke.stopPropagation(),V.current.running)return;const Xe=UV(t,n);Xe&&f6(Xe)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${J?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":be?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:xe.x,top:xe.y,width:Ta,height:Ta,touchAction:"none"},"aria-label":`${l("agent.jumpToNextRunning")}: ${pe}`,title:l("agent.runningSessionGestureHint"),children:[o.jsx(Hn,{size:18,className:"shrink-0 animate-spin"}),se(pe,"running")]}),be&&W&&o.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":W.side,"aria-label":l("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:W.left,top:W.top,width:W.width,height:W.height},children:t.map((Ke,Xe)=>{const nt=Xe===$,Se=Ke.id===n,Fe=`${Ke.label}${Ke.detail?` · ${Ke.detail}`:""}${Se?` · ${l("agent.currentSession")}`:""}`;return o.jsxs("div",{role:"option","aria-selected":nt,"data-running-session-option":Ke.id,"data-selected":nt?"true":"false",title:Fe,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${nt?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":Se?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[o.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${nt?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:Xe+1}),o.jsx("span",{className:"truncate text-[10px] font-medium",children:Ke.label})]},Ke.id)})})]},"running")};return!g&&!v||i===null||typeof document>"u"?null:ia.createPortal(o.jsxs(o.Fragment,{children:[g&&ge(),v&&Ee()]}),document.body)}const GV=450,WV=10,m6=88,g6=36,Rp=10,x6=14;function b6(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function VV(e,t){if(typeof window>"u")return{left:0,top:0};const n=window.visualViewport,r=n?.offsetLeft??0,s=n?.offsetTop??0,i=n?.width??window.innerWidth,l=n?.height??window.innerHeight,c=b6("--safe-top-inset"),u=b6("--safe-bottom-inset"),f=r+Rp,p=r+i-m6-Rp,g=s+c+Rp,y=s+l-u-g6-Rp,v=Math.max(f,Math.min(e-m6/2,Math.max(f,p))),S=t-g6-x6,A=t+x6,T=S>=g?S:A,L=Math.max(g,Math.min(T,Math.max(g,y)));return{left:Math.round(v),top:Math.round(L)}}async function y6(e){if(!e)return;if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>"u")return;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function x0(e){const t=b.useRef(null),n=b.useRef(null),r=b.useRef(!1),s=b.useRef(!1),i=b.useRef(!1),[l,c]=b.useState(null);b.useEffect(()=>{if(!l)return;const v=S=>{const A=S.target;A instanceof HTMLElement&&A.closest('[data-reference-copy-popover="true"]')||(c(null),r.current=!1,s.current=!1)};return document.addEventListener("pointerdown",v,{capture:!0}),()=>document.removeEventListener("pointerdown",v,!0)},[l]);const u=b.useCallback(()=>{t.current!=null&&(window.clearTimeout(t.current),t.current=null)},[]),f=b.useCallback(()=>{u(),n.current=null,r.current=!1},[u]),p=b.useCallback((v,S)=>({onPointerDown:A=>{A.pointerType==="mouse"&&A.button!==0||(f(),n.current={pointerId:A.pointerId,pointerType:A.pointerType,startX:A.clientX,startY:A.clientY,text:v,key:S},t.current=window.setTimeout(()=>{const T=n.current;if(T){if(r.current=!0,s.current=!0,i.current=!1,T.pointerType==="mouse"){y6(T.text).then(()=>e?.(T.key)),t.current=null;return}c({text:T.text,key:T.key,...VV(T.startX,T.startY)}),t.current=null}},GV))},onPointerMove:A=>{const T=n.current;if(!T||T.pointerId!==A.pointerId||r.current)return;const L=A.clientX-T.startX,I=A.clientY-T.startY;Math.hypot(L,I)>WV&&f()},onPointerUp:A=>{const T=n.current;if(!T||T.pointerId!==A.pointerId){f();return}r.current&&(A.preventDefault(),A.stopPropagation(),s.current=!0),f()},onPointerCancel:f,onPointerLeave:A=>{n.current?.pointerId===A.pointerId&&!r.current&&f()},onClickCapture:A=>{s.current&&(s.current=!1,A.preventDefault(),A.stopPropagation())},onContextMenu:A=>{!r.current&&!s.current||(A.preventDefault(),A.stopPropagation())}}),[e,f]),g=b.useCallback(v=>{if(v.preventDefault(),v.stopPropagation(),!l||i.current)return;i.current=!0;const S=l;c(null),r.current=!1,s.current=!1,y6(S.text).then(()=>e?.(S.key))},[e,l]),y=l&&typeof document<"u"?ia.createPortal(b.createElement("button",{type:"button","data-reference-copy-popover":"true",className:"fixed z-modal-backdrop inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:l.left,top:l.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:v=>{v.stopPropagation()},onPointerUp:g,onTouchStart:v=>{v.stopPropagation()},onTouchEnd:g,onClick:g},b.createElement(Z2,{size:14,strokeWidth:2.4}),b.createElement("span",null,"Copy")),document.body):null;return b.useMemo(()=>Object.assign(p,{popoverNode:y}),[p,y])}const qV=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),v6=120,w6=120,YV=new Set,KV={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function Fy(e,t){if(t==="directory")return null;if(W7(e))return o.jsx(jR,{size:14});if(z7(e))return o.jsx(GM,{size:14});const n=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return qV.has(n)?o.jsx(xN,{size:14}):o.jsx(u8,{size:14})}function x9({path:e}){const n=xt(s=>s.changedFiles.get(e))?.status;if(!n)return null;const r=KV[n]??{label:"?",className:"text-muted-foreground",title:n};return o.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${r.className}`,title:r.title,children:r.label})}function a0(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100"}function Oy(e){return a0(e)}const XV=b.memo(function({path:t}){const{t:n}=qn(),[r,s]=b.useState("idle"),[i,l]=b.useState(null),c=b.useCallback(async u=>{if(u.stopPropagation(),r!=="pending"){s("pending"),l(null);try{await W2(t),s("idle")}catch(f){s("error"),l(f instanceof Error?f.message:n("rightSidebar.downloadFailed"))}}},[t,r,n]);return o.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{c(u)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(r==="pending")} ${r==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:r==="error"?i??n("rightSidebar.downloadFailed"):n("rightSidebar.downloadFile"),children:r==="pending"?o.jsx(Hn,{size:12,className:"animate-spin"}):o.jsx(t0,{size:12})})});function b9(){const{t:e}=qn(),[t,n]=b.useState({status:"idle"}),r=b.useCallback(async s=>{n({status:"pending"});try{await W2(s),n({status:"idle"})}catch(i){n({status:"error",message:i instanceof Error?i.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:r}}function o2(e){return e instanceof DOMException&&e.name==="AbortError"}function Vm(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function ZV(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function Qy(e,t,n){if(!t||ZV(e,t))return!0;const r=n.get(e.path);return r?r.some(s=>Qy(s,t,n)):!1}function a2(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function l2(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const JV=b.memo(function e({node:t,depth:n,onFileSelect:r,directoriesOnly:s=!1,onPathReference:i,getReferenceText:l,onReferenceCopied:c,insertedReferenceKey:u,copiedReferenceKey:f,onDirectoryRoot:p,onDirectoryPinToggle:g,onFilePinToggle:y,onOpenInFileBrowser:v,canOpenInFileBrowser:S,pinnedPaths:A,selectedFilePath:T,queryLower:L,onDirectoryDropFiles:I,onFileDeleteRequest:j,deletingFilePath:P,revealedDirectoryPath:F}){const{t:R}=qn(),C=xt(wt=>wt.expandedPaths.has(t.path)),$=xt(wt=>wt.directoryCache.get(t.path)),Q=xt(wt=>wt.showHiddenFiles),q=xt(wt=>wt.toggleExpanded),V=xt(wt=>wt.setDirectoryCache),[fe,X]=b.useState(!1),[he,me]=b.useState(!1),[de,le]=b.useState(!1),W=b.useRef(0),z=b.useRef(null),K=b.useRef(null),se=t.path===T||t.path===F,ge=t.type==="directory"&&(C||!!L),Ee=t.type==="directory",pe=A.has(t.path),xe=!Ee&&!!y,be=!!(S&&v),J=`path:${t.path}`,Ke=u===J,Xe=f===J,nt=l?.(t.path)??t.path,Se=x0(c),{state:Fe,run:ue}=b9(),Be=P===t.path,$e=b.useMemo(()=>{if(!$)return;if(!L)return $;const wt=xt.getState().directoryCache;return $.filter(we=>(!s||we.type==="directory")&&Qy(we,L,wt))},[$,s,L]),tt=b.useCallback(async()=>{if(!xt.getState().directoryCache.has(t.path)&&!fe){const we=`file-tree:${t.path}`;z.current?.abort(),eo(we);const rt=new AbortController;z.current=rt,X(!0);try{const ht=await q7(t.path,rt.signal,Q,"expand_directory",we),Ye=a2(ht.entries);V(t.path,Ye)}catch(ht){o2(ht)}finally{z.current===rt&&(z.current=null),X(!1)}}},[t.path,fe,V,Q]),ae=b.useCallback(async()=>{if(t.type!=="directory"){r(t.path);return}if(s&&p){p(t.path);return}const wt=!xt.getState().expandedPaths.has(t.path);q(t.path),wt&&await tt()},[s,t.path,t.type,tt,p,q,r]);b.useEffect(()=>{t.type==="directory"&&C&&!$&&!fe&&tt()},[$,C,tt,fe,t.type]);const Ne=b.useCallback(wt=>{wt.stopPropagation(),i?.(t.path,J)},[i,t.path,J]),We=b.useCallback(wt=>{wt.stopPropagation(),p?.(t.path),me(!1)},[t.path,p]),Ie=b.useCallback(wt=>{wt.stopPropagation(),g?.(t.path),me(!1)},[t.path,g]),He=b.useCallback(wt=>{wt.stopPropagation(),y?.(t.path),me(!1)},[t.path,y]),gt=b.useCallback(wt=>{wt.stopPropagation(),me(!1),ue(t.path)},[t.path,ue]),bt=b.useCallback(wt=>{wt.stopPropagation(),me(!1),j(t)},[t,j]),vt=b.useCallback(wt=>{wt.stopPropagation(),v?.(t.path),me(!1)},[t.path,v]),rn=b.useCallback(wt=>{!Ee||!I||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),W.current+=1,le(!0))},[Ee,I]),Ot=b.useCallback(wt=>{!Ee||!I||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),wt.dataTransfer.dropEffect="copy",le(!0))},[Ee,I]),un=b.useCallback(wt=>{!Ee||!I||(wt.preventDefault(),wt.stopPropagation(),W.current-=1,W.current<=0&&(W.current=0,le(!1)))},[Ee,I]),gr=b.useCallback(wt=>{if(!Ee||!I)return;wt.preventDefault(),wt.stopPropagation(),W.current=0,le(!1);const we=Array.from(wt.dataTransfer.files);we.length>0&&I(t.path,we)},[Ee,t.path,I]),dn=b.useCallback(wt=>{wt.stopPropagation(),me(we=>!we)},[]);return b.useEffect(()=>{if(!he)return;const wt=rt=>{const ht=rt.target;ht instanceof Node&&K.current?.contains(ht)||me(!1)},we=rt=>{rt.key==="Escape"&&me(!1)};return document.addEventListener("pointerdown",wt),document.addEventListener("keydown",we),()=>{document.removeEventListener("pointerdown",wt),document.removeEventListener("keydown",we)}},[he]),b.useEffect(()=>()=>{z.current?.abort()},[]),o.jsxs("div",{children:[o.jsxs("div",{ref:K,className:"relative",children:[Se.popoverNode,o.jsxs("div",{"data-file-tree-path":t.path,role:"button",tabIndex:0,onClick:()=>{Vm()||ae()},onKeyDown:wt=>{wt.key!=="Enter"&&wt.key!==" "||(wt.preventDefault(),ae())},onDragEnter:rn,onDragOver:Ot,onDragLeave:un,onDrop:gr,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${de?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":se?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${n*14+8}px`},title:t.path,children:[de&&o.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:R("fileTree.dropToUploadHere")}),t.type==="directory"?o.jsxs(o.Fragment,{children:[ge?o.jsx(sa,{size:14,className:"shrink-0 text-muted-foreground/80"}):o.jsx(wl,{size:14,className:"shrink-0 text-muted-foreground/80"}),ge?o.jsx(Gd,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx("span",{className:se?"text-primary":"text-muted-foreground/80",children:Fy(t.name,t.type)})]}),o.jsxs("span",{className:`min-w-0 flex-1 select-text whitespace-normal break-all text-left leading-snug ${se?"font-medium":""}`,children:[t.name,t.isSymlink&&o.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:R("fileTree.symbolicLink"),children:o.jsx(Al,{size:11})})]}),fe&&o.jsx(Hn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),o.jsx(x9,{path:t.path}),t.type==="directory"&&!s&&(p||g||be)&&o.jsx("span",{onClick:dn,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(he)} ${he?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:R("fileTree.moreDirActions"),children:o.jsx(Kc,{size:13})}),!Ee&&o.jsx("span",{onClick:dn,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(he||Fe.status==="pending"||Be||pe)} ${he?"bg-surface-elevated text-foreground":pe?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:Fe.status==="error"?Fe.message??R("rightSidebar.downloadFailed"):R("fileTree.moreFileActions"),children:Fe.status==="pending"||Be?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Kc,{size:13})}),i&&o.jsx("span",{onClick:Ne,...Se(nt,J),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(Ke||Xe)} ${Ke||Xe?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":R(Xe?"rightSidebar.copied":Ke?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:R(Xe?"rightSidebar.copied":Ke?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:Xe||Ke?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),t.type==="directory"&&!s&&he&&(p||g||be)&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[be&&o.jsxs("button",{type:"button",onClick:vt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openInFileBrowserTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openInFileBrowser")})]}),p&&o.jsxs("button",{type:"button",onClick:We,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openDirRootTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openDirRoot")})]}),g&&o.jsxs("button",{type:"button",onClick:Ie,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${pe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R(pe?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[pe?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R(pe?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!Ee&&he&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[be&&o.jsxs("button",{type:"button",onClick:vt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openInFileBrowserTitle"),children:[o.jsx(u8,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openInFileBrowser")})]}),o.jsxs("button",{type:"button",onClick:gt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("rightSidebar.downloadFile"),children:[o.jsx(t0,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("rightSidebar.downloadFile")})]}),xe&&o.jsxs("button",{type:"button",onClick:He,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${pe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R(pe?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[pe?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R(pe?"fileTree.unpinFile":"fileTree.pinFile")})]}),o.jsxs("button",{type:"button",onClick:bt,disabled:Be,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:R("fileTree.deleteFile"),children:[Be?o.jsx(Hn,{size:13,className:"shrink-0 animate-spin"}):o.jsx(Pi,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.deleteFile")})]})]})]}),ge&&$e&&$e.length>0&&o.jsx("div",{className:n===0?"mt-0.5":"",children:$e.map(wt=>o.jsx(e,{node:wt,depth:n+1,onFileSelect:r,directoriesOnly:s,onPathReference:i,getReferenceText:l,onReferenceCopied:c,onDirectoryRoot:p,onDirectoryPinToggle:g,onFilePinToggle:y,onOpenInFileBrowser:v,canOpenInFileBrowser:S,pinnedPaths:A,selectedFilePath:T,queryLower:L,insertedReferenceKey:u,copiedReferenceKey:f,onDirectoryDropFiles:I,onFileDeleteRequest:j,deletingFilePath:P,revealedDirectoryPath:F},wt.path))})]})}),eq=b.memo(function({node:t,rootPath:n,onFileSelect:r,onPathReference:s,getReferenceText:i,onReferenceCopied:l,insertedReferenceKey:c,copiedReferenceKey:u,onDirectoryRoot:f,onDirectoryPinToggle:p,onFilePinToggle:g,pinnedPaths:y,selectedFilePath:v,onFileDeleteRequest:S,deletingFilePath:A}){const{t:T}=qn(),L=t.path===v,I=t.type==="directory",j=y.has(t.path),P=!I&&!!g,F=`path:${t.path}`,R=c===F,C=u===F,$=i?.(t.path)??t.path,Q=x0(l),{state:q,run:V}=b9(),[fe,X]=b.useState(!1),he=b.useRef(null),me=A===t.path,de=b.useCallback(()=>{Vm()||(t.type==="directory"?f?.(t.path):r(t.path))},[t.path,t.type,f,r]),le=b.useCallback(Ee=>{Ee.stopPropagation(),s?.(t.path,F)},[s,t.path,F]),W=b.useCallback(Ee=>{Ee.stopPropagation(),p?.(t.path),X(!1)},[t.path,p]),z=b.useCallback(Ee=>{Ee.stopPropagation(),g?.(t.path),X(!1)},[t.path,g]),K=b.useCallback(Ee=>{Ee.stopPropagation(),X(!1),V(t.path)},[t.path,V]),se=b.useCallback(Ee=>{Ee.stopPropagation(),X(!1),S(t)},[t,S]),ge=b.useCallback(Ee=>{Ee.stopPropagation(),X(pe=>!pe)},[]);return b.useEffect(()=>{if(!fe)return;const Ee=xe=>{const be=xe.target;be instanceof Node&&he.current?.contains(be)||X(!1)},pe=xe=>{xe.key==="Escape"&&X(!1)};return document.addEventListener("pointerdown",Ee),document.addEventListener("keydown",pe),()=>{document.removeEventListener("pointerdown",Ee),document.removeEventListener("keydown",pe)}},[fe]),o.jsxs("div",{ref:he,className:"relative",children:[Q.popoverNode,o.jsxs("div",{role:"button",tabIndex:0,onClick:de,onKeyDown:Ee=>{Ee.key!=="Enter"&&Ee.key!==" "||(Ee.preventDefault(),de())},className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:Fy(t.name,t.type)})]}),o.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[o.jsxs("span",{className:`block whitespace-normal break-all leading-snug ${L?"font-medium":""}`,children:[t.name,t.isSymlink&&o.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:T("fileTree.symbolicLink"),children:o.jsx(Al,{size:11})})]}),o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/70",children:l2(n,t.path)})]}),o.jsx(x9,{path:t.path}),t.type==="directory"&&p&&o.jsx("span",{onClick:ge,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(fe)} ${fe?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:T("fileTree.moreDirActions"),children:o.jsx(Kc,{size:13})}),!I&&o.jsx("span",{onClick:ge,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(fe||q.status==="pending"||me||j)} ${fe?"bg-surface-elevated text-foreground":j?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:q.status==="error"?q.message??T("rightSidebar.downloadFailed"):T("fileTree.moreFileActions"),children:q.status==="pending"||me?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Kc,{size:13})}),s&&o.jsx("span",{onClick:le,...Q($,F),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(R||C)} ${R||C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":T(C?"rightSidebar.copied":R?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:T(C?"rightSidebar.copied":R?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:C||R?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),t.type==="directory"&&fe&&(f||p)&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[f&&o.jsxs("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),f(t.path),X(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:T("fileTree.openDirRootTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("fileTree.openDirRoot")})]}),o.jsxs("button",{type:"button",onClick:W,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${j?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:T(j?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[j?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T(j?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!I&&fe&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[o.jsxs("button",{type:"button",onClick:K,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:T("rightSidebar.downloadFile"),children:[o.jsx(t0,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("rightSidebar.downloadFile")})]}),P&&o.jsxs("button",{type:"button",onClick:z,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${j?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:T(j?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[j?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T(j?"fileTree.unpinFile":"fileTree.pinFile")})]}),o.jsxs("button",{type:"button",onClick:se,disabled:me,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:T("fileTree.deleteFile"),children:[me?o.jsx(Hn,{size:13,className:"shrink-0 animate-spin"}):o.jsx(Pi,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("fileTree.deleteFile")})]})]})]})}),tq=60,S6=60,nq=20;function rq(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),s=[];let i=0,l=n.indexOf(r,i),c=0;for(;l>=0&&r;)l>i&&s.push(e.slice(i,l)),s.push(o.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(l,l+r.length)},`m-${c++}`)),i=l+r.length,l=n.indexOf(r,i);return i<e.length&&s.push(e.slice(i)),s.length>0?s:e}const sq=b.memo(function({entry:t,rootPath:n,selectedFilePath:r,query:s,onContentMatchSelect:i,onPathReference:l,getReferenceText:c,onReferenceCopied:u,insertedReferenceKey:f,copiedReferenceKey:p}){const{t:g}=qn(),[y,v]=b.useState(!0),S=t.path===r,A=y?t.matches.slice(0,nq):[],T=t.matches.length-A.length,L=`path:${t.path}`,I=f===L,j=p===L,P=c?.(t.path)??t.path,F=x0(u);return o.jsxs("div",{className:"rounded",children:[F.popoverNode,o.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Vm()||v(R=>!R)},onKeyDown:R=>{R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),v(C=>!C))},className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] ${S?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[y?o.jsx(sa,{size:14,className:"shrink-0 text-muted-foreground/80"}):o.jsx(wl,{size:14,className:"shrink-0 text-muted-foreground/80"}),o.jsx("span",{className:S?"text-primary":"text-muted-foreground/80",children:Fy(t.name,"file")}),o.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[o.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/70",children:l2(n,t.path)})]}),o.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),o.jsx(XV,{path:t.path}),l&&o.jsx("span",{onClick:R=>{R.stopPropagation(),l(t.path,L)},...F(P,L),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(I||j)} ${I||j?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":g(j?"rightSidebar.copied":I?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:g(j?"rightSidebar.copied":I?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:j||I?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),y&&o.jsxs("div",{className:"ml-3 border-l border-border/15 pl-1",children:[A.map((R,C)=>o.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Vm()||i?.(t.path,R.line)},onKeyDown:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),i?.(t.path,R.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${l2(n,t.path)}:${R.line}`,children:[o.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:R.line}),o.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:rq(R.text,s)})]},`${R.line}-${C}`)),T>0&&o.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:g("fileTree.moreMatches",{count:T})})]})]})});function c2({rootPath:e,onFileSelect:t,directoriesOnly:n=!1,onPathReference:r,getReferenceText:s,onReferenceCopied:i,insertedReferenceKey:l,copiedReferenceKey:c,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,onOpenInFileBrowser:g,canOpenInFileBrowser:y=!1,pinnedPaths:v=YV,selectedFilePath:S,query:A="",searchMode:T="name",onContentMatchSelect:L,onDirectoryDropFiles:I,revealDirectory:j}){const{t:P}=qn(),F=xt(ue=>e?ue.directoryCache.get(e):void 0),R=xt(ue=>ue.setDirectoryCache),C=xt(ue=>ue.showHiddenFiles),[$,Q]=b.useState(!1),[q,V]=b.useState(null),[fe,X]=b.useState(!1),[he,me]=b.useState(!1),[de,le]=b.useState(null),[W,z]=b.useState([]),[K,se]=b.useState(null),[ge,Ee]=b.useState(v6),[pe,xe]=b.useState([]),[be,J]=b.useState(null),Ke=b.useRef(null),Xe=A.trim().toLowerCase(),nt=T==="content";b.useEffect(()=>{const ue=j?.path;if(!ue||!ue.startsWith(`${e}/`)&&ue!==e)return;const Be=ue.slice(e.length).replace(/^\/+/,""),$e=Be?Be.split("/"):[],tt=$e.map((bt,vt)=>`${e}/${$e.slice(0,vt+1).join("/")}`),ae=xt.getState(),Ne=tt.filter(bt=>!ae.expandedPaths.has(bt));Ne.length>0&&xt.setState(bt=>({expandedPaths:new Set([...bt.expandedPaths,...Ne])}));let We=!1,Ie=0;const He=()=>{if(We)return;const bt=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(vt=>vt.dataset.fileTreePath===ue);if(bt){bt.scrollIntoView({block:"center",behavior:"smooth"});return}Ie+=1,Ie<80&&window.setTimeout(He,50)},gt=window.requestAnimationFrame(He);return()=>{We=!0,window.cancelAnimationFrame(gt)}},[j?.nonce,j?.path,e]);const Se=b.useCallback(async ue=>{if(!(be||ue.type==="directory")&&window.confirm(P("fileTree.deleteFileConfirm",{name:ue.name}))){J(ue.path);try{await fI(ue.path),xt.getState().applyFileWatchEvents([{type:"deleted",path:ue.path}]),z(Be=>Be.filter($e=>$e.path!==ue.path)),xe(Be=>Be.filter($e=>$e.path!==ue.path)),v.has(ue.path)&&p?.(ue.path)}catch(Be){const $e=Be instanceof Error?Be.message:String(Be);window.alert(P("fileTree.deleteFileFailed",{message:$e}))}finally{J(null)}}},[be,p,v,P]);b.useEffect(()=>{if(!e)return;if(Xe){Q(!1);return}if(xt.getState().directoryCache.has(e)){Q(!1);return}let ue=!1;const Be=new AbortController;return Q(!0),V(null),q7(e,Be.signal,C,"load_file_tree_root",`file-tree-root:${e}`).then($e=>{if(ue)return;const tt=a2($e.entries);X(!!$e.truncated),R(e,tt)}).catch($e=>{ue||o2($e)||V($e instanceof Error?$e.message:"Failed to load directory")}).finally(()=>{ue||Q(!1)}),()=>{ue=!0,Be.abort(),eo(`file-tree-root:${e}`)}},[Xe,F,e,R,C]),b.useEffect(()=>{if(!e||!Xe){me(!1),le(null),z([]),xe([]),se(null);return}let ue=!1;const Be=new AbortController,$e=new Set;me(!0),le(null),z([]),xe([]),Ee(nt?tq:v6),se({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const tt=`file-search:${e}`;return iI(e,A.trim(),ae=>{if(!ue){if(ae.engine&&se(Ne=>({truncated:Ne?.truncated??!1,total:Ne?.total??0,engine:ae.engine,limited:ae.limited??Ne?.limited??!1,done:Ne?.done??!1})),ae.entries?.length){const Ne=ae.entries.filter(We=>$e.has(We.path)?!1:($e.add(We.path),!0));Ne.length>0&&(z(We=>[...We,...a2(Ne)]),se(We=>We?{...We,total:$e.size}:{truncated:!1,total:$e.size,engine:"rg",limited:!1,done:!1}))}if(ae.contentEntries?.length){const Ne=ae.contentEntries.filter(We=>$e.has(We.path)?!1:($e.add(We.path),!0));Ne.length>0&&(xe(We=>[...We,...Ne]),se(We=>We?{...We,total:$e.size}:{truncated:!1,total:$e.size,engine:"rg",limited:!1,done:!1}))}ae.done&&se(Ne=>({truncated:!!ae.truncated,total:typeof ae.total=="number"?ae.total:$e.size,engine:ae.engine??Ne?.engine??"rg",limited:!!ae.limited,done:!0}))}},Be.signal,C,T,tt).catch(ae=>{ue||o2(ae)||(le(ae instanceof Error?ae.message:"Failed to search files"),z([]),xe([]),se(null))}).finally(()=>{ue||me(!1)}),()=>{ue=!0,Be.abort(),eo(tt)}},[A,Xe,e,C,T,nt]),b.useEffect(()=>{if(!Xe)return;const ue=Ke.current;if(!ue)return;const Be=nt?pe.length:W.length,$e=nt?S6:w6,tt=new IntersectionObserver(ae=>{ae.some(Ne=>Ne.isIntersecting)&&Ee(Ne=>Math.min(Ne+$e,Be))},{rootMargin:"160px 0px"});return tt.observe(ue),()=>tt.disconnect()},[Xe,W.length,pe.length,nt]);const Fe=b.useMemo(()=>{if(!F)return;if(!Xe)return n?F.filter(Be=>Be.type==="directory"):F;const ue=xt.getState().directoryCache;return F.filter(Be=>(!n||Be.type==="directory")&&Qy(Be,Xe,ue))},[n,Xe,F]);if(!e)return o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noWorkingDir")});if($)return o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})});if(Xe&&nt){const ue=K?.total??pe.length,Be=pe.slice(0,ge),$e=ge<pe.length;return o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1 text-[10px] text-muted-foreground",children:[o.jsx("span",{children:he?P("fileTree.searchingWithCount",{count:ue}):P("fileTree.contentMatchesCount",{count:ue})}),K&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 uppercase tracking-[0.12em]",children:[he&&o.jsx(Hn,{size:9,className:"animate-spin"}),K.engine,K.limited?" · limited":""]})]}),de?o.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[P("fileTree.contentSearchNeedsRipgrep"),o.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:de})]}):he&&pe.length===0?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})}):pe.length===0?o.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noContentMatches")}):o.jsxs(o.Fragment,{children:[K?.limited&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.searchTruncatedHint",{count:K.total})}),Be.map(tt=>o.jsx(sq,{entry:tt,rootPath:e,selectedFilePath:S,query:A.trim(),onContentMatchSelect:L,onPathReference:r,getReferenceText:s,onReferenceCopied:i,insertedReferenceKey:l,copiedReferenceKey:c},tt.path)),o.jsx("div",{ref:Ke,className:"py-2 text-center text-[11px] text-muted-foreground",children:$e?o.jsx("button",{type:"button",onClick:()=>Ee(tt=>Math.min(tt+S6,pe.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:P("fileTree.loadMoreSearchResults",{shown:Be.length,total:pe.length})}):he?o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Hn,{size:10,className:"animate-spin"}),P("fileTree.searchStillRunning")]}):Be.length>0?o.jsx("span",{children:P("fileTree.showingSearchResults",{shown:Be.length,total:ue})}):null})]})]})}if(Xe){const ue=K?.total??W.length,Be=W.slice(0,ge),$e=ge<W.length;return o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1 text-[10px] text-muted-foreground",children:[o.jsx("span",{children:he?P("fileTree.searchingWithCount",{count:ue}):P("fileTree.searchResults",{count:ue})}),K&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 uppercase tracking-[0.12em]",children:[he&&o.jsx(Hn,{size:9,className:"animate-spin"}),K.engine,K.limited?" · limited":""]})]}),he&&W.length===0?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})}):de?o.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:de}):W.length===0?o.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noMatchingFiles")}):o.jsxs(o.Fragment,{children:[K?.limited&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.searchTruncatedHint",{count:K.total})}),Be.map(tt=>o.jsx(eq,{node:tt,rootPath:e,onFileSelect:t,onPathReference:r,getReferenceText:s,onReferenceCopied:i,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,pinnedPaths:v,selectedFilePath:S,insertedReferenceKey:l,copiedReferenceKey:c,onFileDeleteRequest:Se,deletingFilePath:be},tt.path)),o.jsx("div",{ref:Ke,className:"py-2 text-center text-[11px] text-muted-foreground",children:$e?o.jsx("button",{type:"button",onClick:()=>Ee(tt=>Math.min(tt+w6,W.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:P("fileTree.loadMoreSearchResults",{shown:Be.length,total:W.length})}):he?o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Hn,{size:10,className:"animate-spin"}),P("fileTree.searchStillRunning")]}):Be.length>0?o.jsx("span",{children:P("fileTree.showingSearchResults",{shown:Be.length,total:ue})}):null})]})]})}return q?o.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:q}):!F||F.length===0?o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.emptyDir")}):!Fe||Fe.length===0?o.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noMatchingFiles")}):o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[fe&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.truncatedHint")}),Fe.map(ue=>o.jsx(JV,{node:ue,depth:0,onFileSelect:t,directoriesOnly:n,onPathReference:r,getReferenceText:s,onReferenceCopied:i,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,onOpenInFileBrowser:g,canOpenInFileBrowser:y,pinnedPaths:v,selectedFilePath:S,queryLower:Xe,insertedReferenceKey:l,copiedReferenceKey:c,onDirectoryDropFiles:I,onFileDeleteRequest:Se,deletingFilePath:be,revealedDirectoryPath:j?.path},ue.path))]})}function u2(e){return e.trim().replace(/\/+$/,"")||"/"}function iq(e){const t=u2(e);if(t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function y9({open:e,initialPath:t,title:n,labels:r,onCancel:s,onConfirm:i}){const{t:l}=qn(),c={hint:r?.hint??l("sidebar.directoryPickerHint"),cancel:r?.cancel??l("common.cancel"),confirm:r?.confirm??l("sidebar.useThisFolder"),close:r?.close??l("common.close"),parent:r?.parent??l("rightSidebar.parentFolder")},[u,f]=b.useState(()=>u2(t));return b.useEffect(()=>{e&&f(u2(t))},[t,e]),b.useEffect(()=>{if(!e)return;const p=document.body.style.overflow,g=y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),s())};return document.body.style.overflow="hidden",document.addEventListener("keydown",g,!0),()=>{document.body.style.overflow=p,document.removeEventListener("keydown",g,!0)}},[s,e]),e?ia.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:s,"aria-label":c.cancel}),o.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[o.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[o.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:o.jsx(SN,{size:15})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:n}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:c.hint})]}),o.jsx("button",{type:"button",autoFocus:!0,onClick:s,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":c.close,children:o.jsx(ns,{size:15})})]}),o.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[o.jsx("button",{type:"button",disabled:u==="/",onClick:()=>f(iq(u)),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-30","aria-label":c.parent,children:o.jsx(xg,{size:14})}),o.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-foreground",title:u,children:u})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",children:o.jsx(c2,{rootPath:u,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:f,selectedFilePath:t||null})}),o.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[o.jsx("button",{type:"button",onClick:s,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:c.cancel}),o.jsxs("button",{type:"button",onClick:()=>i(u),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[o.jsx(Ea,{size:13}),c.confirm]})]})]})]}),document.body):null}function oq({directories:e,tmuxAvailable:t,options:n,agents:r,selectedAgent:s,detecting:i,resumeHistory:l,resumeHistoryLoading:c,resumeHistoryPendingId:u,resumeHistoryError:f,onRefreshAgents:p,onSelectAgent:g,onLaunchAgent:y,onResumeHistory:v,onRemoveResumeHistory:S,onClose:A,onOptionsChange:T}){const{t:L,locale:I}=qn(),[j,P]=b.useState(s),[F,R]=b.useState(!1),C=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),$=j?.displayName??"Terminal",Q=s?.displayName??"Terminal",q=j===null?s===null:s?.slug===j.slug;b.useEffect(()=>{const X=he=>{he.key==="Escape"&&(F||A())};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[F,A]);const V=X=>{T({...n,cwd:X}),R(!1)},fe=X=>new Intl.DateTimeFormat(I==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(X));return o.jsxs("section",{className:"relative z-20 flex max-h-[min(56svh,36rem)] shrink-0 flex-col overflow-hidden border-t border-border/25 bg-surface-elevated shadow-[0_-18px_42px_var(--app-shadow-soft)] animate-slide-down","aria-label":L("sidebar.newSessionComposerTitle"),children:[o.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 pb-2 pt-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[o.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:o.jsx(Sa,{size:14})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:L("sidebar.newSessionComposerTitle")}),o.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:L("sidebar.newSessionHint")})]})]}),o.jsx("button",{type:"button",onClick:A,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":L("common.close"),children:o.jsx(ns,{size:14})})]}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 pb-3",children:[o.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:L("sidebar.sessionMode")}),n.mode==="tmux"&&o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L("sidebar.tmuxKeepsRunning")})]}),o.jsx("div",{className:"mt-1.5 grid grid-cols-2 gap-1 rounded-lg bg-surface-2 p-1",children:["shell","tmux"].map(X=>o.jsx("button",{type:"button",disabled:X==="tmux"&&!t,onClick:()=>T({...n,mode:X}),"aria-pressed":n.mode===X,title:X==="tmux"&&!t?L("sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-2 py-1.5 text-[11px] font-medium transition ${n.mode===X?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:L(X==="shell"?"sidebar.newShell":"sidebar.newTmux")},X))}),o.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:"Agent"}),o.jsxs("button",{type:"button",onClick:p,disabled:i,className:"inline-flex min-h-8 items-center gap-1 px-1 text-[10px] text-muted-foreground transition hover:text-foreground disabled:opacity-50",title:L("sidebar.detectAgents"),children:[o.jsx(si,{size:10,className:i?"animate-spin":""}),L("sidebar.detectAgents")]})]}),o.jsxs("label",{className:"relative mt-1 flex min-h-11 cursor-pointer items-center gap-2.5 rounded-lg border border-border/30 bg-surface px-3 text-foreground transition hover:bg-surface-2 focus-within:border-primary/50",children:[j?o.jsx(Bu,{agent:j,size:16}):o.jsx(Sa,{size:14,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",children:$}),q&&o.jsx("span",{className:"shrink-0 text-[9.5px] text-muted-foreground",children:L("sidebar.defaultAgent")}),i?o.jsx(Hn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}):o.jsx(sa,{size:13,className:"shrink-0 text-muted-foreground"}),o.jsxs("select",{"aria-label":"Agent",value:j?.slug??"__terminal__",onChange:X=>{const he=X.target.value;P(he==="__terminal__"?null:r.find(me=>me.slug===he)??null)},className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",children:[o.jsx("option",{value:"__terminal__",children:"Terminal"}),r.map(X=>o.jsx("option",{value:X.slug,children:X.displayName},X.slug))]})]}),!q&&o.jsxs("div",{className:"mt-1 flex min-h-8 items-center justify-between gap-2 px-0.5 text-[10px]",children:[o.jsx("span",{className:"truncate text-muted-foreground",children:L("sidebar.currentDefaultAgent",{name:Q})}),o.jsx("button",{type:"button",onClick:()=>g(j),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:L("sidebar.makeDefault")})]}),o.jsx("label",{htmlFor:"new-session-directory",className:"mt-2.5 block text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:L("sidebar.workingDirectory")}),o.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>R(!0),className:"mt-1 flex h-9 w-full items-center gap-2 rounded-lg border border-border/25 bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary/50",children:[o.jsx(Xc,{size:12,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${n.cwd?"":"text-muted-foreground"}`,children:n.cwd||L("sidebar.directoryPlaceholder")})]}),C.length>0&&o.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":L("sidebar.recentDirectories"),children:C.map(X=>o.jsx("button",{type:"button",onClick:()=>V(X),title:X,className:"min-h-8 shrink-0 rounded-md bg-surface-2 px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:yc(X)||X},X))}),(l.length>0||f)&&o.jsxs("details",{className:"mt-3 border-t border-border/15 pt-2",children:[o.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[o.jsx(gf,{size:11}),o.jsx("span",{className:"flex-1",children:L("sidebar.resumeHistory")}),c&&o.jsx(Hn,{size:10,className:"animate-spin"}),l.length>0&&o.jsx("span",{className:"normal-case tracking-normal",children:L("sidebar.resumeHistoryCount",{n:l.length})}),o.jsx(sa,{size:11})]}),l.length>0&&o.jsx("div",{className:"mt-1 divide-y divide-border/10 overflow-hidden rounded-lg border border-border/15 bg-surface",children:l.slice(0,6).map(X=>{const he=u===X.id;return o.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[o.jsxs("button",{type:"button",disabled:u!==null,onClick:()=>v(X),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":L("sidebar.resumeHistoryAction",{title:X.title}),children:[o.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:he?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Bu,{agent:X.agent,size:14})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:X.title}),o.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[X.agent.displayName," · ",fe(X.closedAt)]})]}),o.jsx(m8,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),o.jsxs("button",{type:"button",disabled:u!==null,onClick:()=>S(X.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":L("sidebar.resumeHistoryRemove",{title:X.title}),children:[o.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),o.jsx(Pi,{size:12})]})]},X.id)})}),f&&o.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:f})]})]}),o.jsx("div",{className:"shrink-0 border-t border-border/15 bg-surface-elevated p-3",children:o.jsxs("button",{type:"button",onClick:()=>y(j),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground shadow-md shadow-primary/20 transition hover:bg-primary/90 active:scale-[0.99]","aria-label":L("sidebar.launchSessionWith",{name:$}),children:[j?o.jsx(Bu,{agent:j,size:15}):o.jsx(Sa,{size:14}),o.jsx("span",{className:"truncate",children:L("sidebar.launchSessionWith",{name:$})})]})}),o.jsx(y9,{open:F,initialPath:n.cwd?.trim()||C[0]||"/",title:L("sidebar.chooseDirectory"),onCancel:()=>R(!1),onConfirm:V})]})}const v9="termdock:new-session-agent:v1";function aq(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(v9)||"null");return!e||typeof e.slug!="string"||typeof e.command!="string"?null:{slug:e.slug,command:e.command,displayName:typeof e.displayName=="string"?e.displayName:e.slug,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(t=>typeof t=="string"):void 0,accentColor:typeof e.accentColor=="string"?e.accentColor:"var(--muted-foreground)",icon:typeof e.icon=="string"?e.icon:null,isPlugin:e.isPlugin===!0,iconMode:e.iconMode==="native"?"native":e.iconMode==="mask"?"mask":void 0,iconVersion:typeof e.iconVersion=="number"?e.iconVersion:void 0}}catch{return null}}function Ix(e){if(!(typeof window>"u"))try{window.localStorage.setItem(v9,JSON.stringify(e))}catch{}}function lq(e,t){return e?t.find(n=>n.slug===e)??null:null}function cq(){const[e,t]=b.useState(aq),[n,r]=b.useState([]),[s,i]=b.useState(!0),l=b.useCallback(async()=>{i(!0);try{const[u,f]=await Promise.all([ug(),Q7()]),p=lq(u.newSessionAgentSlug,f);r(f),t(p),Ix(p)}finally{i(!1)}},[]);b.useEffect(()=>{l().catch(()=>{})},[l]);const c=b.useCallback(async u=>{const f=e;t(u),Ix(u);try{await Va({newSessionAgentSlug:u?.slug??null})}catch(p){throw t(f),Ix(f),p}},[e]);return{preference:e,agents:n,detecting:s,refresh:l,selectAgent:c}}const Ka="w-full rounded-lg border border-border/20 bg-surface-2 px-3 py-2 text-[12px] text-foreground outline-none transition focus:border-primary/60",Gs="inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-40";function uq({activeSessionId:e,onClose:t,onNewSession:n}){const[r,s]=b.useState("automation"),[i,l]=b.useState([]),[c,u]=b.useState([]),[f,p]=b.useState([]),[g,y]=b.useState([]),[v,S]=b.useState([]),[A,T]=b.useState(null),[L,I]=b.useState(null),[j,P]=b.useState(null),F=b.useCallback(async(R={})=>{R.silent||I(null);try{const[C,$,Q]=await Promise.all([TI(),EI(),Q7()]);l(C.automations),u(C.runs),y($.groups),S($.sessions),p(Q)}catch(C){R.silent||I(C instanceof Error?C.message:"加载失败")}},[]);return b.useEffect(()=>{F();const R=window.setInterval(()=>{F({silent:!0})},1e4);return()=>window.clearInterval(R)},[F]),b.useEffect(()=>{const R=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t]),ia.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t,"aria-label":"关闭 Agent 工作台"}),o.jsxs("section",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[8%] sm:bottom-auto sm:max-h-[84vh]",children:[o.jsxs("header",{className:"flex items-center gap-2 border-b border-border/15 px-4 py-3",children:[o.jsx(K2,{size:17,className:"text-primary"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:"Agent 工作台"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"自动任务、会话协作与全文恢复"})]}),o.jsx("button",{className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:t,"aria-label":"关闭",children:o.jsx(ns,{size:16})})]}),o.jsx("nav",{className:"flex gap-1 border-b border-border/15 px-3 py-2",children:[["automation",X2,"自动任务"],["collaboration",Al,"会话协作"],["search",ql,"全文搜索"]].map(([R,C,$])=>o.jsxs("button",{onClick:()=>s(R),className:`${Gs} ${r===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[o.jsx(C,{size:14}),$]},R))}),L&&o.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:L}),j&&o.jsxs("div",{className:"mx-4 mt-3 flex items-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-[11px] text-primary",children:[o.jsx(Ea,{size:13}),j]}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[r==="automation"&&o.jsx(dq,{automations:i,runs:c,agents:f,sessions:v,activeSessionId:e,busy:A,setBusy:T,setError:I,setNotice:P,refresh:F,onClose:t}),r==="collaboration"&&o.jsx(hq,{groups:g,sessions:v,activeSessionId:e,busy:A,setBusy:T,setError:I,setNotice:P,refresh:F}),r==="search"&&o.jsx(gq,{onClose:t,onNewSession:n,setError:I})]})]})]}),document.body)}function dq({automations:e,runs:t,agents:n,sessions:r,activeSessionId:s,busy:i,setBusy:l,setError:c,setNotice:u,refresh:f,onClose:p}){const[g,y]=b.useState(null),[v,S]=b.useState(!1),[A,T]=b.useState(null),L=async(I,j,P)=>{l(I),c(null),u(null);try{await j(),await f(),u(P)}catch(F){c(F instanceof Error?F.message:"操作失败")}finally{l(null)}};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"自动任务"}),o.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"按计划把任务交给 Agent。每次运行都有独立会话和结果入口。"})]}),!v&&e.length>0&&o.jsxs("button",{className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{y(null),S(!0),u(null)},children:[o.jsx(Oo,{size:13}),"新建任务"]})]}),v&&o.jsx(fq,{agents:n,sessions:r,activeSessionId:s,initial:g,onCancel:()=>{y(null),S(!1)},onSaved:async I=>{y(null),S(!1),await f(),u(g?`“${I}”已更新`:`“${I}”已创建,将按计划自动运行`)},setError:c}),e.length===0&&!v&&o.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[o.jsx(OR,{size:24,className:"mx-auto text-primary"}),o.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"把重复工作交给 Agent"}),o.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[11px] leading-relaxed text-muted-foreground",children:"选择运行会话、写清任务内容,再设定时间。创建后可以先手动运行一次确认效果。"}),o.jsxs("button",{className:`${Gs} mt-4 bg-primary text-primary-foreground`,onClick:()=>S(!0),children:[o.jsx(Oo,{size:13}),"创建第一个任务"]})]}),o.jsx("div",{className:"space-y-2",children:e.map(I=>{const j=t.find(F=>F.automationId===I.id),P=n.find(F=>F.command===I.command);return o.jsxs("article",{className:"rounded-xl border border-border/15 bg-surface-2/40 p-3 transition hover:border-border/30",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:I.name}),o.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${I.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:I.enabled?"已启用":"已停用"}),I.lastRunStatus&&o.jsx("span",{className:`text-[10px] ${wq(I.lastRunStatus)}`,children:vq(I.lastRunStatus)})]}),o.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-muted-foreground",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(X2,{size:11}),bq(I)]}),o.jsx("span",{children:I.enabled&&I.nextRunAt?`下次 ${Ym(I.nextRunAt)}`:"不会自动运行"})]}),o.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:I.targetSessionId?`发送到 ${r.find(F=>F.sessionId===I.targetSessionId)?.name??"指定会话"}`:`新建 ${P?.displayName??"Agent"} 会话 · ${I.cwd}`}),o.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:I.prompt}),I.lastRunAt&&o.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",Ym(I.lastRunAt),I.lastRunMessage?` · ${I.lastRunMessage}`:""]})]}),o.jsx("button",{"aria-label":`编辑 ${I.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{y(I),S(!0),u(null)},children:o.jsx(p8,{size:13})})]}),o.jsx("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border/10 pt-3",children:A===I.id?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),o.jsx("button",{className:`${Gs} bg-surface-elevated text-foreground`,onClick:()=>T(null),children:"取消"}),o.jsxs("button",{disabled:i!==null,className:`${Gs} bg-destructive text-destructive-foreground`,onClick:()=>{L(`delete:${I.id}`,()=>LI(I.id),`“${I.name}”已删除`).then(()=>T(null))},children:[i===`delete:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Pi,{size:13}),"确认删除"]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:`${Gs} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>T(I.id),children:[o.jsx(Pi,{size:13}),"删除"]}),o.jsxs("button",{disabled:i!==null,className:`${Gs} ${I.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{L(`toggle:${I.id}`,()=>_I(I.id,!I.enabled),I.enabled?`“${I.name}”已暂停,不会自动运行`:`“${I.name}”已恢复,将按原计划运行`)},children:[i===`toggle:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):I.enabled?o.jsx(f8,{size:13}):o.jsx(Sb,{size:13}),I.enabled?"暂停":"恢复"]}),j?.frontendSessionId&&o.jsxs("button",{className:`${Gs} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j.frontendSessionId})),p()},children:[o.jsx(fN,{size:13}),"打开上次会话"]}),o.jsxs("button",{disabled:i!==null,className:`${Gs} bg-primary/15 text-primary`,onClick:()=>{L(`run:${I.id}`,()=>kI(I.id),`“${I.name}”已投递,可打开会话查看进度`)},children:[i===`run:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Sb,{size:13}),"立即运行"]})]})})]},I.id)})})]})}function fq({agents:e,sessions:t,activeSessionId:n,initial:r,onCancel:s,onSaved:i,setError:l}){const[c,u]=b.useState(r?.name??""),f=t.find(J=>J.sessionId===n),p=r?.cwd??f?.cwd??t[0]?.cwd??"",[g,y]=b.useState(p),[v,S]=b.useState(!1),[A,T]=b.useState(()=>e.find(J=>J.command===r?.command)?.slug??""),[L,I]=b.useState(r?.prompt??""),[j,P]=b.useState(r?.targetSessionId??""),[F,R]=b.useState(r?.targetSessionId?"existing":"new"),[C,$]=b.useState(r?.schedule.kind??"interval"),[Q,q]=b.useState(r?.schedule.kind==="interval"?r.schedule.everyMinutes:60),[V,fe]=b.useState(r?.schedule.kind==="daily"?r.schedule.time:"09:00"),[X,he]=b.useState(r?.schedule.kind==="daily"?r.schedule.weekdays:[1,2,3,4,5]),[me,de]=b.useState(r?.enabled??!0),[le,W]=b.useState(!1),K=(e.find(J=>J.slug===A)??null)?.command??r?.command??"";b.useEffect(()=>{!r&&!A&&e[0]&&T(e[0].slug)},[e,r,A]);const se=async()=>{W(!0),l(null);try{await CI({id:r?.id,name:c,cwd:g,command:F==="new"?K:"",prompt:L,targetSessionId:F==="existing"&&j||null,enabled:me,schedule:C==="interval"?{kind:C,everyMinutes:Q}:{kind:C,time:V,weekdays:X}}),await i(c.trim())}catch(J){l(J instanceof Error?J.message:"保存失败")}finally{W(!1)}},ge=C==="interval"?{kind:C,everyMinutes:Q}:{kind:C,time:V,weekdays:X},[Ee,pe]=V.split(":"),xe=(J,Ke)=>fe(`${J}:${Ke}`),be=!!(c.trim()&&L.trim()&&(F==="existing"?j:K)&&(C==="interval"?Q>=1:X.length>0));return o.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/25 bg-primary/5",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-primary/15 px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-[13px] font-medium text-foreground",children:r?"编辑自动任务":"创建自动任务"}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"三步完成,保存后可立即试跑"})]}),o.jsx("button",{className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:s,"aria-label":"关闭任务表单",children:o.jsx(ns,{size:14})})]}),o.jsxs("div",{className:"space-y-5 p-4",children:[o.jsxs("fieldset",{className:"space-y-3",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"1"}),"要做什么"]}),o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务名称",o.jsx("input",{autoFocus:!0,className:Ka,value:c,onChange:J=>u(J.target.value),placeholder:"例如:每日代码巡检"})]}),o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务内容",o.jsx("textarea",{className:`${Ka} min-h-24 resize-y`,value:L,onChange:J=>I(J.target.value),placeholder:"说明目标、检查范围和期望产出,例如:检查当前分支的测试与待办,修复可安全处理的问题并总结结果。"})]})]}),o.jsxs("fieldset",{className:"space-y-3 border-t border-border/10 pt-4",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"2"}),"在哪里运行"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button","aria-pressed":F==="new",className:`${Gs} justify-start border px-3 text-left ${F==="new"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>R("new"),children:"每次新建会话"}),o.jsx("button",{type:"button","aria-pressed":F==="existing",disabled:t.length===0,className:`${Gs} justify-start border px-3 text-left ${F==="existing"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>{R("existing"),j||P(n??t[0]?.sessionId??"")},children:"发送到现有会话"})]}),F==="new"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[o.jsxs("label",{className:"space-y-1 text-[10px] text-muted-foreground",children:["Agent / Plugin",o.jsxs("select",{className:Ka,value:A,onChange:J=>T(J.target.value),children:[r&&!e.some(J=>J.command===r.command)&&o.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(J=>o.jsxs("option",{value:J.slug,children:[J.displayName,J.isPlugin?" · Plugin":""]},J.slug))]})]}),o.jsxs("label",{className:"space-y-1 text-[10px] text-muted-foreground",children:["工作目录",o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:Ka,value:g,onChange:J=>y(J.target.value),placeholder:"默认使用当前目录"}),o.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${Gs} shrink-0 bg-surface-2 text-foreground`,onClick:()=>S(!0),children:[o.jsx(Gd,{size:13}),"选择"]})]})]})]}),e.length===0&&o.jsx("p",{className:"text-[10px] text-destructive",children:"没有检测到可启动的 Agent。请先在 Plugin 设置中安装或配置 Agent。"})]}):o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["目标会话",o.jsx("select",{className:Ka,value:j,onChange:J=>P(J.target.value),children:t.map(J=>o.jsxs("option",{value:J.sessionId,children:[J.name," · ",J.status]},J.sessionId))}),o.jsx("span",{className:"block leading-relaxed",children:"运行时该会话需要在线,并且 Agent 处于可接收任务的状态。"})]})]}),o.jsxs("fieldset",{className:"space-y-3 border-t border-border/10 pt-4",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"3"}),"什么时候运行"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button","aria-pressed":C==="interval",className:`${Gs} border ${C==="interval"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>$("interval"),children:"固定间隔"}),o.jsx("button",{type:"button","aria-pressed":C==="daily",className:`${Gs} border ${C==="daily"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>$("daily"),children:"指定日期与时间"})]}),C==="interval"?o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["每隔多少分钟",o.jsx("input",{className:Ka,type:"number",min:1,max:43200,value:Q,onChange:J=>q(Number(J.target.value))}),o.jsx("span",{className:"block",children:"例如 60 = 每小时,1440 = 每天。始终按任务创建时间计算,之后编辑不会重置节奏。"})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"运行时间"}),o.jsxs("div",{className:"mt-1 flex items-center rounded-xl border border-border/20 bg-surface-2 px-3 py-2.5 focus-within:border-primary/60",children:[o.jsx(X2,{size:15,className:"mr-3 shrink-0 text-primary"}),o.jsx(A6,{label:"小时",value:Ee,options:24,onChange:J=>xe(J,pe)}),o.jsx("span",{"aria-hidden":"true",className:"px-2 text-[18px] font-medium text-muted-foreground",children:":"}),o.jsx(A6,{label:"分钟",value:pe,options:60,onChange:J=>xe(Ee,J)}),o.jsx("span",{className:"ml-3 shrink-0 rounded-md bg-surface-elevated px-2 py-1 text-[9px] font-medium text-muted-foreground",children:"24 小时制"})]})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"运行日期"}),o.jsx("div",{className:"mt-1 grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((J,Ke)=>{const Xe=X.includes(Ke);return o.jsx("button",{type:"button","aria-pressed":Xe,"aria-label":`星期${J}`,className:`rounded-lg py-2.5 text-[10px] transition ${Xe?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>he(nt=>Xe?nt.filter(Se=>Se!==Ke):[...nt,Ke].sort()),children:J},Ke)})}),X.length===0&&o.jsx("p",{className:"mt-1 text-[10px] text-destructive",children:"至少选择一天"})]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-3 border-t border-primary/15 bg-surface/50 px-4 py-3 sm:flex-row sm:items-center",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[o.jsx("input",{type:"checkbox",checked:me,onChange:J=>de(J.target.checked)}),"保存后启用"]}),o.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:me&&be?`${r?"下次运行":"首次运行"}:${Ym(yq(ge,Date.now(),r?.createdAt))}`:me?"填写完整后显示首次运行时间":"任务会保存,但不会自动运行"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{className:`${Gs} bg-surface-2 text-foreground`,onClick:s,children:"取消"}),o.jsx("button",{disabled:le||!be,className:`${Gs} bg-primary text-primary-foreground`,onClick:()=>{se()},children:le?"保存中…":r?"保存修改":"创建任务"})]})]}),o.jsx(y9,{open:v,initialPath:g||p||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>S(!1),onConfirm:J=>{y(J),S(!1)}})]})}function A6({label:e,value:t,options:n,onChange:r}){return o.jsxs("label",{className:"relative min-w-0 flex-1",children:[o.jsx("span",{className:"sr-only",children:e}),o.jsx("select",{"aria-label":e,className:"w-full appearance-none bg-transparent py-1 pl-1 pr-7 text-center text-[18px] font-semibold tabular-nums text-foreground outline-none",value:t,onChange:s=>r(s.target.value),children:Array.from({length:n},(s,i)=>{const l=String(i).padStart(2,"0");return o.jsx("option",{value:l,children:l},l)})}),o.jsx(sa,{"aria-hidden":"true",size:13,className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground"})]})}function hq({groups:e,sessions:t,activeSessionId:n,busy:r,setBusy:s,setError:i,setNotice:l,refresh:c}){const[u,f]=b.useState(""),[p,g]=b.useState(()=>new Set(n?[n]:[])),[y,v]=b.useState(e[0]?.id??null),[S,A]=b.useState(""),[T,L]=b.useState(!1),[I,j]=b.useState([]),[P,F]=b.useState("*"),[R,C]=b.useState("message"),[$,Q]=b.useState(""),q=y==="new"?null:e.find(z=>z.id===y)??e[0]??null,V=new Set(t.map(z=>z.sessionId)),fe=[...p].filter(z=>V.has(z)).length,X=S.trim().toLocaleLowerCase(),he=t.filter(z=>!X||[z.name,z.cwd,Rx(z.currentTask)].some(K=>K.toLocaleLowerCase().includes(X)));b.useEffect(()=>{!y&&e[0]&&v(e[0].id)},[e,y]),b.useEffect(()=>{if(!q){j([]);return}let z=!1;const K=()=>{i5(q.id).then(ge=>{z||j(ge.messages)}).catch(ge=>{z||i(ge instanceof Error?ge.message:"消息加载失败")})};K();const se=window.setInterval(K,3e3);return()=>{z=!0,window.clearInterval(se)}},[q?.id,i]);const me=async()=>{s("create-group"),i(null),l(null);try{const z=[...p].filter(se=>V.has(se)),K=await II({name:u,sessionIds:z});f(""),A(""),v(K.group.id),await c(),l(`“${K.group.name}”已创建,${K.group.sessionIds.length} 个会话可以开始协作`)}catch(z){i(z instanceof Error?z.message:"创建失败")}finally{s(null)}},de=async()=>{if(q){s("send-message"),i(null),l(null);try{const z=await NI(q.id,{fromSessionId:null,toSessionIds:P==="*"?void 0:[P],kind:R,content:$});Q(""),j((await i5(q.id)).messages),l(`消息已发送给 ${z.messages.length} 个会话`)}catch(z){i(z instanceof Error?z.message:"发送失败")}finally{s(null)}}},le=async()=>{if(!q)return;s(`delete:${q.id}`),i(null),l(null);const z=q.name;try{await RI(q.id),v(null),L(!1),await c(),l(`“${z}”已删除`)}catch(K){i(K instanceof Error?K.message:"删除失败")}finally{s(null)}},W=mq(I,t);return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"会话协作"}),o.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"创建协作组后,一个 Agent 会话可以把任务直接交给另一个会话。比如“开发”写完代码后通知“测试”检查,测试结果再回复回来;你也可以给单个会话或全组发任务,所有交接和进展都记录在这里。"})]}),q&&o.jsxs("button",{className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{v("new"),L(!1),l(null)},children:[o.jsx(Oo,{size:13}),"新建组"]})]}),e.length>0&&o.jsx("div",{className:"flex gap-2 overflow-x-auto border-b border-border/15 pb-3",children:e.map(z=>o.jsxs("button",{onClick:()=>v(z.id),className:`${Gs} shrink-0 ${q?.id===z.id?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:[z.name,o.jsx("span",{className:"text-[9px] opacity-70",children:z.sessionIds.length})]},z.id))}),!q&&o.jsxs("section",{className:"border-y border-border/15 py-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),o.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"至少选择两个会话。离线成员会在重新上线后收到消息;已从列表移除的会话不会提交。"})]}),o.jsxs("span",{className:`shrink-0 text-[10px] ${fe>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",fe," 个"]})]}),o.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",o.jsx("input",{className:Ka,value:u,onChange:z=>f(z.target.value),placeholder:"例如:发布准备"})]}),t.length>5&&o.jsxs("label",{className:"relative mt-3 block",children:[o.jsx("span",{className:"sr-only",children:"筛选会话"}),o.jsx(ql,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{className:`${Ka} pl-8`,value:S,onChange:z=>A(z.target.value),placeholder:"按名称、目录或当前任务筛选"})]}),o.jsxs("div",{className:"mt-3 max-h-64 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[he.map(z=>o.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-2 py-2.5 transition hover:bg-surface-2",children:[o.jsx("input",{className:"mt-0.5",type:"checkbox",checked:p.has(z.sessionId),onChange:()=>g(K=>{const se=new Set(K);return se.has(z.sessionId)?se.delete(z.sessionId):se.add(z.sessionId),se})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"truncate text-[12px] text-foreground",children:z.name}),o.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:T6(z.status)})]}),o.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[Rx(z.currentTask)," · ",z.cwd]})]})]},z.sessionId)),t.length===0&&o.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"暂无可选会话,请先打开两个会话"}),t.length>0&&he.length===0&&o.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]}),o.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[o.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${fe<2?"text-muted-foreground":"text-primary"}`,children:fe<2?`还需选择 ${2-fe} 个会话`:"成员已满足要求,可以创建"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[e.length>0&&o.jsx("button",{className:`${Gs} bg-surface-2 text-foreground`,onClick:()=>v(e[0]?.id??null),children:"取消"}),o.jsxs("button",{disabled:r!==null||!u.trim()||fe<2,className:`${Gs} bg-primary text-primary-foreground`,onClick:()=>{me()},children:[r==="create-group"?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Oo,{size:13}),"创建协作组"]})]})]})]}),q&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"border-y border-border/15 py-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:q.name}),o.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[q.sessionIds.length," 个成员 · 离线成员会在重新上线后收到未读消息"]})]}),T?o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("button",{className:`${Gs} bg-surface-2 px-2 text-foreground`,onClick:()=>L(!1),children:"取消"}),o.jsxs("button",{disabled:r!==null,className:`${Gs} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{le()},children:[r===`delete:${q.id}`?o.jsx(si,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):o.jsx("button",{"aria-label":`删除协作组 ${q.name}`,title:"删除协作组",disabled:r!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>L(!0),children:o.jsx(Pi,{size:14})})]}),o.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:q.sessionIds.map(z=>{const K=t.find(se=>se.sessionId===z);return o.jsxs("button",{disabled:!K,onClick:()=>K&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:z})),className:"min-w-0 px-3 py-2.5 text-left transition hover:bg-surface-2 disabled:cursor-default",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${K?.status==="working"?"bg-primary":K?"bg-[var(--success)]":"bg-muted-foreground"}`}),o.jsx("span",{className:"truncate text-[11px] text-foreground",children:K?.name??z}),o.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:K?T6(K.status):"已离线"})]}),o.jsx("span",{className:"mt-1 block truncate text-[9px] text-muted-foreground",children:K?Rx(K.currentTask):"重新上线后可继续接收消息"})]},z)})})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[W.length," 条"]})]}),o.jsxs("div",{className:"max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[W.map(z=>o.jsxs("div",{className:"px-2 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[o.jsx("span",{className:"font-medium text-primary",children:pq(z.kind)}),o.jsx("span",{children:z.fromName}),o.jsx("span",{children:"→"}),o.jsx("span",{className:"truncate",children:z.toNames.join("、")}),o.jsx("span",{className:"ml-auto shrink-0",children:new Date(z.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),o.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:z.content}),o.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:z.status==="pending"?"等待 Agent 空闲":z.status==="read"?"已读取":"已投递"})]},z.key)),W.length===0&&o.jsx(Sq,{text:"还没有消息。可以先发一个任务或问题。"})]})]}),o.jsxs("section",{className:"border-t border-primary/20 bg-primary/5 px-3 py-3",children:[o.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"发送给成员"}),o.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[o.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["接收人",o.jsxs("select",{className:Ka,value:P,onChange:z=>F(z.target.value),children:[o.jsx("option",{value:"*",children:"全组成员"}),q.sessionIds.map(z=>o.jsx("option",{value:z,children:t.find(K=>K.sessionId===z)?.name??`${z.slice(0,8)}(离线)`},z))]})]}),o.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["消息类型",o.jsxs("select",{className:Ka,value:R,onChange:z=>C(z.target.value),children:[o.jsx("option",{value:"message",children:"普通消息"}),o.jsx("option",{value:"ask",children:"需要回答的问题"}),o.jsx("option",{value:"task",children:"需要执行的任务"}),o.jsx("option",{value:"handoff",children:"工作交接"}),o.jsx("option",{value:"done",children:"完成通知"})]})]})]}),o.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["内容",o.jsx("textarea",{className:`${Ka} min-h-20 resize-y`,value:$,onChange:z=>Q(z.target.value),placeholder:"说明背景、期望产出,以及对方需要回复或完成什么…"})]}),o.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[o.jsx("p",{className:"text-[9px] leading-relaxed text-muted-foreground",children:"消息会保留;成员忙碌或离线时稍后送达。"}),o.jsxs("button",{disabled:r!==null||!$.trim(),className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{de()},children:[r==="send-message"?o.jsx(si,{size:13,className:"animate-spin"}):null,"发送"]})]})]})]})]})}function T6(e){return e==="working"?"处理中":e==="idle"||e==="done"?"可接收":e==="offline"?"已离线":"在线"}function Rx(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return qm(t.prompt)||"暂无任务摘要"}catch{}return qm(e)||"暂无任务摘要"}function pq(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function mq(e,t){const n=new Map(t.map(s=>[s.sessionId,s.name])),r=new Map;for(const s of e){const i=`${s.threadId}:${s.createdAt}:${s.fromSessionId??"user"}:${s.kind}:${s.content}`,l=r.get(i),c=n.get(s.toSessionId)??s.toSessionId.slice(0,8);if(l){l.toNames.push(c);const u={pending:0,delivered:1,read:2};u[s.status]<u[l.status]&&(l.status=s.status);continue}r.set(i,{key:i,kind:s.kind,content:s.content,createdAt:s.createdAt,fromName:s.fromSessionId?n.get(s.fromSessionId)??s.fromSessionId.slice(0,8):"你",toNames:[c],status:s.status})}return[...r.values()].sort((s,i)=>s.createdAt-i.createdAt)}function gq({onClose:e,onNewSession:t,setError:n}){const[r,s]=b.useState(""),[i,l]=b.useState([]),[c,u]=b.useState(!1),f=b.useRef(0);b.useEffect(()=>{const g=r.trim(),y=++f.current;if(l([]),!g){u(!1);return}u(!0);const v=window.setTimeout(()=>{MI(g).then(S=>{y===f.current&&l(S.results)}).catch(S=>{y===f.current&&n(S instanceof Error?S.message:"搜索失败")}).finally(()=>{y===f.current&&u(!1)})},250);return()=>window.clearTimeout(v)},[r,n]);const p=async g=>{if(g.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:g.sessionId})),e();return}if(g.resumeHistoryId)try{const y=await $7(g.resumeHistoryId);t({mode:"shell",cwd:y.cwd,command:y.command}),e()}catch(y){n(y instanceof Error?y.message:"恢复失败")}};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"全文搜索"}),o.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"搜索会话标题、项目目录、任务内容和终端记录"})]}),o.jsxs("label",{className:"relative mt-3 block",children:[o.jsx("span",{className:"sr-only",children:"搜索全部会话"}),o.jsx(ql,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{autoFocus:!0,className:`${Ka} pl-9 pr-9`,value:r,onChange:g=>{n(null),s(g.target.value)},placeholder:"输入你记得的关键词"}),c?o.jsx(si,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):r&&o.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>s(""),children:o.jsx(ns,{size:13})})]})]}),!r.trim()&&o.jsxs("div",{className:"border-y border-border/15 py-10 text-center",children:[o.jsx(ql,{size:24,className:"mx-auto text-primary"}),o.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"找回之前做过的事"}),o.jsx("p",{className:"mx-auto mt-1 max-w-md text-[11px] leading-relaxed text-muted-foreground",children:"可以输入任务名、报错片段或目录名,例如“自动任务”“web-terminal”“构建失败”。搜索索引只保存在本机。"})]}),r.trim()&&!c&&i.length>0&&o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("p",{className:"text-[11px] text-foreground",children:["显示 ",i.length," 个会话"]}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"在线可打开 · 已关闭可恢复"})]}),o.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:i.map(g=>{const y=g.live||!!g.resumeHistoryId,v=g.live?"打开会话":g.resumeHistoryId?"恢复会话":"仅供查阅",S=o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-[12px] font-medium text-foreground",children:g.title}),o.jsx("p",{className:"mt-0.5 truncate text-[9px] text-muted-foreground",children:g.cwd})]}),o.jsx("span",{className:`shrink-0 text-[10px] ${g.live?"text-[var(--success)]":g.resumeHistoryId?"text-primary":"text-muted-foreground"}`,children:v})]}),o.jsx("p",{className:"mt-2 line-clamp-3 text-[10px] leading-relaxed text-foreground/75",children:xq(g)||"匹配内容来自标题、目录或终端控制信息"}),o.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Ym(g.updatedAt)," · ",g.matchCount," 处匹配",y?"":" · 没有可恢复记录"]})]});return y?o.jsx("button",{onClick:()=>{p(g)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:S},g.sessionId):o.jsx("article",{className:"px-2 py-3",children:S},g.sessionId)})}),r.trim()&&!c&&i.length===0&&o.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[o.jsxs("p",{className:"text-[12px] text-foreground",children:["没有找到“",r.trim(),"”"]}),o.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"试试更短的关键词、目录名或报错中的一小段。"}),o.jsx("button",{className:`${Gs} mt-3 bg-surface-2 text-foreground`,onClick:()=>s(""),children:"清空后重试"})]})]})}function qm(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function xq(e){let t=qm(e.snippet);for(const n of[e.title,e.cwd,e.agentSlug])n&&(t=t.split(n).join(" "));return qm(t)}function bq(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(r=>`周${t[r]}`).join("、")} ${e.schedule.time}`}function yq(e,t=Date.now(),n=t){if(e.kind==="interval"){const i=e.everyMinutes*6e4,l=Math.max(0,t-n);return n+(Math.floor(l/i)+1)*i}const[r,s]=e.time.split(":").map(Number);for(let i=0;i<=7;i+=1){const l=new Date(t);if(l.setDate(l.getDate()+i),l.setHours(r,s,0,0),l.getTime()>t&&e.weekdays.includes(l.getDay()))return l.getTime()}return t}function Ym(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function vq(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function wq(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function Sq({text:e}){return o.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}function Nx(e,t,n){const r=new Map,s=new Set(e.map(c=>c.id));for(const c of t)if(!(c.sessionIds.length<2||!c.sessionIds.every(u=>s.has(u))))for(const u of c.sessionIds)r.set(u,c);const i=new Set,l=[];for(const c of e){const u=r.get(c.id);if(!u){l.push({kind:"session",id:`session:${c.id}`,session:c,sessionIds:[c.id]});continue}if(i.has(u.id))continue;i.add(u.id);const f=u.sessionIds.flatMap(p=>{const g=n.get(p);return g?[g]:[]});l.push({kind:"workspace",id:`workspace:${u.id}`,workspace:u,members:f,sessionIds:u.sessionIds})}return l}function Aq({status:e,detail:t,needsReview:n,inCopyMode:r}){return o.jsx(FV,{status:e,detail:t,needsReview:n,inCopyMode:r})}function C6({isOpen:e,drawerWidthPx:t,onClose:n,onOpen:r,sessions:s,activeSessionId:i,sessionStates:l,onNewSession:c,onCloseSession:u,onSplitSession:f,onCloseSplit:p,onRemoveFromSplit:g,splitWorkspaces:y,onSetSplitLayout:v,onReorderSplitWorkspace:S,onRenameSplitWorkspace:A,onCombineSplitSessions:T,onReorderSessions:L,onSessionMenu:I,onOpenSettings:j,onOpenQuota:P,updateState:F,updateActionPending:R=!1,onConfirmUpdateRestart:C,onRetryUpdate:$,tmuxAvailable:Q=!0,defaultSessionMode:q="shell",push:V,pinned:fe,runningSessionButtonEnabled:X=!1,onRunningSessionButtonEnabledChange:he,onTogglePinned:me}){const{t:de}=qn(),[le,W]=b.useState(null),[z,K]=b.useState(new Set),[se,ge]=b.useState(null),[Ee,pe]=b.useState(!1),[xe,be]=b.useState(!1),[J,Ke]=b.useState(!1),[Xe,nt]=b.useState([]),[Se,Fe]=b.useState(!1),[ue,Be]=b.useState(null),[$e,tt]=b.useState(null),[ae,Ne]=b.useState({mode:q}),{preference:We,agents:Ie,detecting:He,refresh:gt,selectAgent:bt}=cq(),vt=b.useRef(null),rn=!!(F?.latestVersion&&["installing","ready","restarting","error"].includes(F.status)),Ot=xt(_e=>_e.groupByFolder),un=xt(_e=>_e.collapsedGroups),gr=xt(_e=>_e.toggleGroupCollapsed),dn=b.useRef(null),wt=b.useRef(new Set),we=b.useRef(null),rt=b.useMemo(()=>new Set(y.flatMap(_e=>_e.sessionIds)),[y]),ht=b.useMemo(()=>new Map(s.map(_e=>[_e.id,_e])),[s]),Ye=b.useMemo(()=>s.filter(_e=>!rt.has(_e.id)),[s,rt]),ot=b.useMemo(()=>{let _e=0;for(const Ue of s)l.get(Ue.id)?.agentStatus==="working"&&(_e+=1);return _e},[s,l]);b.useEffect(()=>{e&&dn.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[i,e,Ye.length,un]);const Sn=b.useMemo(()=>{if(!Ot||!i)return null;const _e=l.get(i)?.cwd??null;return Cw(_e)},[Ot,i,l]);b.useEffect(()=>{if(!Ot){we.current=null,wt.current.clear();return}if(!i){we.current=null;return}const _e=xt.getState(),Ue=wt.current,mt=we.current,Ct=Sn;mt!==null&&mt!==Ct&&Ue.has(mt)&&(_e.collapsedGroups.has(mt)||_e.toggleGroupCollapsed(mt),Ue.delete(mt)),Ct!==null&&Ct!==""&&_e.collapsedGroups.has(Ct)&&(_e.toggleGroupCollapsed(Ct),Ue.add(Ct)),we.current=Ct},[Ot,i,Sn]),b.useEffect(()=>{e||(pe(!1),be(!1))},[e]),b.useEffect(()=>{Ne(_e=>({..._e,command:We?.command}))},[We]),b.useEffect(()=>{if(!xe)return;let _e=!1;return Fe(!0),tt(null),Xv().then(Ue=>{_e||nt(Ue)}).catch(()=>{_e||tt(de("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{_e||Fe(!1)}),()=>{_e=!0}},[xe,de]),b.useEffect(()=>{if(!Ee)return;const _e=Ue=>{Ue instanceof KeyboardEvent&&Ue.key!=="Escape"||Ue instanceof MouseEvent&&Ue.target instanceof Node&&vt.current?.contains(Ue.target)||pe(!1)};return window.addEventListener("mousedown",_e),window.addEventListener("keydown",_e),()=>{window.removeEventListener("mousedown",_e),window.removeEventListener("keydown",_e)}},[Ee]);const Vt=()=>{!V&&!fe&&n()},Ve=q==="tmux"&&!Q?"shell":q,ir=()=>{c({mode:Ve}),Vt()},Wn=()=>{We&&(c({mode:Ve,command:We.command}),Vt())},Kt=_e=>{c({...ae,cwd:ae.cwd?.trim()||void 0,command:_e?.command}),be(!1),Vt()},Jn=async _e=>{Be(_e.id),tt(null);try{const Ue=await $7(_e.id);c({mode:"shell",cwd:Ue.cwd,command:Ue.command}),be(!1),Vt()}catch(Ue){const mt=Ue&&typeof Ue=="object"&&"code"in Ue?String(Ue.code??""):"";tt(de(mt==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Be(null)}},Ht=async _e=>{nt(Ue=>Ue.filter(mt=>mt.id!==_e));try{await WE(_e)}catch{tt(de("sidebar.resumeHistoryRemoveFailed")),Xv().then(nt).catch(()=>{})}},Sr=()=>{if(xe){be(!1);return}Ne({mode:q==="tmux"&&!Q?"shell":q,cwd:i?l.get(i)?.cwd??void 0:void 0,command:We?.command}),be(!0)},ar=b.useCallback(_e=>{const Ue=l.get(_e);return Ue?.agentStatus==="waiting"||Ue?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Ue?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Ue?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),ln=KA(),Ar=b.useCallback((_e,Ue,mt,Ct)=>{const jt=_e.id===i,Jt=rt.has(_e.id),Mt=l.get(_e.id),hn=yc(Mt?.cwd??null),Nn=Tw(_e,Mt?.activeProgram??null,Mt?.cwd??null,Im,Mt?.shellTitle??u5(_e.id),Mt?.promptState??null),lr=hn&&hn!==Nn?hn:null,Tn=!!(Mt?.tuiProgress&&Mt.tuiProgress.state!=="remove"),cn=Mt?.promptState==="running"||Mt?.agentStatus==="working"||Tn?"bg-[var(--success)]":Mt?.agentStatus==="waiting"||Mt?.agentNeedsReview?"bg-[var(--warning)]":Mt?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return o.jsxs(o.Fragment,{children:[o.jsxs("button",{ref:jt?dn:null,type:"button",...Ue??{},onContextMenu:cr=>{I&&(cr.preventDefault(),I(_e.id,{x:cr.clientX,y:cr.clientY}))},onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_e.id})),Vt()},className:"relative min-w-0 flex flex-1 items-center gap-2 overflow-hidden py-1.5 pl-2 pr-1 text-left",title:Mt?.cwd??_e.name,children:[jt&&o.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${cn}`}),o.jsxs("span",{className:`relative inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md ${jt?_e.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":_e.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[Mt?.isConnecting||Tn&&!Mt?.agentStatus?o.jsx(Hn,{size:12,className:"animate-spin"}):Mt?.agent??d5(_e.id)?o.jsx(Bu,{agent:Mt?.agent??d5(_e.id),size:16}):_e.mode==="tmux"?o.jsx(Mu,{size:12}):o.jsx(Sa,{size:12}),o.jsx(Aq,{status:Mt?.agentStatus??null,detail:Mt?.agentStatusDetail,needsReview:Mt?.agentNeedsReview,inCopyMode:Mt?.inCopyMode})]}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:`block truncate text-[13px] leading-tight ${jt?"font-medium text-foreground":""} ${Mt?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:Nn}),(lr||Mt?.gitStatus)&&o.jsxs("span",{className:"block truncate text-[10.5px] leading-tight text-muted-foreground/75",children:[lr,Mt?.gitStatus&&o.jsxs("span",{className:lr?"ml-1.5":"",title:Mt.gitStatus.branch,children:["⎇ ",Mt.gitStatus.branch.length>14?`${Mt.gitStatus.branch.slice(0,14)}…`:Mt.gitStatus.branch,!mt&&(Mt.gitStatus.added>0||Mt.gitStatus.removed>0)&&o.jsxs("span",{className:"ml-1",children:[o.jsxs("span",{className:"text-[color:var(--success)]",children:["+",Mt.gitStatus.added]})," ",o.jsxs("span",{className:"text-[rgb(var(--warning-rgb))]",children:["−",Mt.gitStatus.removed]})]})]})]})]})]}),o.jsx("button",{type:"button",onClick:cr=>{cr.stopPropagation(),Ct?g(_e.id):Jt?p(_e.id):f(_e.id)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Jt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${de(Ct?"tab.splitRemovePane":Jt?"tab.splitClose":"tab.split")} ${Nn}`,title:de(Ct?"tab.splitRemovePane":Jt?"tab.splitClose":"tab.split"),children:o.jsx(zd,{size:13})}),o.jsx("button",{type:"button",onClick:cr=>{cr.stopPropagation(),u(_e.id,cr)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95","aria-label":de("sidebar.closeSession",{name:Nn}),title:de("common.close"),children:o.jsx(ns,{size:13})})]})},[i,rt,l,u,f,p,g,I,de]),Yn=b.useMemo(()=>{if(!Ot)return[];const _e=uy(s,mt=>l.get(mt.id)?.cwd??null,de("sidebar.ungrouped")),Ue=new Map;for(const mt of y){const Ct=mt.sessionIds[0];if(!Ct)continue;const jt=Cw(l.get(Ct)?.cwd??null),Jt=Ue.get(jt)??new Set;mt.sessionIds.forEach(Mt=>Jt.add(Mt)),Ue.set(jt,Jt)}return _e.flatMap(mt=>{const Ct=new Set(mt.sessions.filter(Jt=>!rt.has(Jt.id)).map(Jt=>Jt.id));Ue.get(mt.key)?.forEach(Jt=>Ct.add(Jt));const jt=s.filter(Jt=>Ct.has(Jt.id));return jt.length>0?[{...mt,sessions:jt}]:[]})},[Ot,s,l,rt,y,de]),Kn=b.useMemo(()=>Nx(s,y,ht),[s,ht,y]),$r=b.useCallback((_e,Ue,mt)=>{const Ct=Ue.find(hn=>hn.id===_e.draggableId);if(!Ct)return;if(_e.combine){const hn=Ue.find(cn=>cn.id===_e.combine?.draggableId);if(!hn)return;const Nn=hn.kind==="workspace"?hn:Ct.kind==="workspace"?Ct:hn,lr=Nn===Ct?hn:Ct,Tn=Nn.sessionIds[0],jn=lr.sessionIds[0];Tn&&jn&&Tn!==jn&&T(Tn,jn);return}if(!_e.destination||_e.source.index===_e.destination.index)return;const jt=[...Ue],[Jt]=jt.splice(_e.source.index,1);if(!Jt)return;jt.splice(_e.destination.index,0,Jt);const Mt=jt.flatMap(hn=>hn.sessionIds);if(mt===void 0){L(Mt);return}L(Yn.flatMap(hn=>hn.key===mt?Mt:hn.sessions.map(Nn=>Nn.id)))},[Yn,T,L]),ve=b.useCallback(_e=>{if(_e.type==="group"){if(!_e.destination||_e.source.index===_e.destination.index)return;L(tS(Yn,_e.source.index,_e.destination.index));return}const Ue=_e.source.droppableId.replace(/^group-sessions:/,""),mt=Yn.find(jt=>jt.key===Ue);if(!mt)return;const Ct=Nx(mt.sessions,y,ht);if(_e.combine){$r(_e,Ct,Ue);return}!_e.destination||_e.destination.droppableId!==_e.source.droppableId||$r(_e,Ct,Ue)},[Yn,ht,y,$r,L]),ne=(_e,Ue,mt,Ct=!1,jt=!1)=>{if(Ue.length<2)return null;const Jt=Ue.some(Pt=>Pt.id===i),Mt=z.has(_e.id),hn=[],Nn=[],lr=[];for(const Pt of Ue){const Wt=l.get(Pt.id);Wt?.agentStatus==="waiting"||Wt?.agentNeedsReview?hn.push(Pt):Wt?.agentStatus==="working"?Nn.push(Pt):Wt?.inCopyMode&&lr.push(Pt)}const Tn=Pt=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Pt})),Vt()},jn=`${de("tab.splitWorkspace")} ${y.findIndex(Pt=>Pt.id===_e.id)+1}`,cn=_e.name||jn,cr=[{layout:"horizontal",icon:o.jsx(zd,{size:12}),label:de("tab.splitHorizontal")},{layout:"vertical",icon:o.jsx(p5,{size:12}),label:de("tab.splitVertical")},{layout:"grid",icon:o.jsx(Mu,{size:12}),label:de("tab.splitGrid")}],on=Pt=>{A(_e.id,Pt),W(null)},Pn=()=>{K(Pt=>{const Wt=new Set(Pt);return Wt.has(_e.id)?Wt.delete(_e.id):Wt.add(_e.id),Wt})},er=(Pt,Wt)=>{if(!se||se.workspaceId!==_e.id||se.sessionId===Pt)return;const yt=_e.sessionIds.filter(Ze=>Ze!==se.sessionId),Xt=yt.indexOf(Pt);Xt<0||(yt.splice(Xt+(Wt?1:0),0,se.sessionId),S(_e.id,yt),ge(null))};return o.jsxs("section",{className:`group/split overflow-hidden rounded-md transition-colors ${jt?"bg-primary/15 ring-1 ring-primary/40":Ct?"bg-surface-elevated opacity-90 shadow-lg":hn.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Nn.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":lr.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":Jt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[o.jsxs("header",{className:"flex h-10 items-center gap-0.5 px-0.5",children:[o.jsx("button",{type:"button",onClick:Pn,className:"inline-flex h-8 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-expanded":Mt,"aria-label":cn,children:o.jsx(wl,{size:13,className:`transition-transform ${Mt?"rotate-90":""}`})}),o.jsx("span",{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${hn.length>0?"text-[color:var(--warning)]":Nn.length>0?"text-[color:var(--success)]":Jt?"text-primary":"text-muted-foreground"}`,children:_e.layout==="vertical"?o.jsx(p5,{size:13}):_e.layout==="grid"?o.jsx(Mu,{size:13}):o.jsx(zd,{size:13})}),le===_e.id?o.jsx("input",{autoFocus:!0,defaultValue:_e.name??"",placeholder:jn,className:"h-7 min-w-0 flex-1 rounded-md bg-surface-elevated px-1.5 text-[11.5px] font-semibold text-foreground outline-none ring-1 ring-primary/40",onKeyDown:Pt=>{Pt.key==="Enter"&&on(Pt.currentTarget.value),Pt.key==="Escape"&&W(null)},onBlur:Pt=>on(Pt.currentTarget.value)}):o.jsxs("button",{type:"button",...mt??{},onClick:()=>{const Pt=Ue.find(Wt=>Wt.id===i)??hn[0]??Ue[0];Pt&&Tn(Pt.id)},className:`min-w-0 flex-1 px-1 text-left ${mt?"cursor-grab active:cursor-grabbing":""}`,title:`${cn} · ${de("tab.sessionCount",{count:Ue.length})}`,children:[o.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:cn}),o.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground/70",children:Ue.map(Pt=>Tw(Pt,l.get(Pt.id)?.activeProgram??null,l.get(Pt.id)?.cwd??null,Im,l.get(Pt.id)?.shellTitle??u5(Pt.id))).join(" · ")})]}),hn.length>0&&o.jsxs("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),Tn(hn[0].id)},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-1.5 text-[9px] font-semibold tabular-nums text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.22)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)]",title:de("agent.needsReview"),"aria-label":`${de("agent.needsReview")}: ${hn.length}`,children:[o.jsx(o8,{size:9}),hn.length]}),Nn.length>0&&o.jsxs("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),Tn(Nn[0].id)},className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.10)] px-1.5 text-[9px] font-medium tabular-nums text-[color:var(--success)] transition hover:bg-[rgb(var(--success-rgb)_/_0.16)]",title:de("agent.aiRunning"),"aria-label":`${de("agent.aiRunning")}: ${Nn.length}`,children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse"}),Nn.length]}),lr.length>0&&hn.length===0&&Nn.length===0&&o.jsx("span",{className:"h-2 w-2 shrink-0 rounded-[2px] bg-[var(--tmux)]",title:de("agent.copyMode")}),o.jsx("span",{className:"shrink-0 px-1 text-[10px] tabular-nums text-muted-foreground/60",children:Ue.length}),o.jsx("button",{type:"button",onClick:()=>W(_e.id),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 opacity-0 transition hover:bg-surface-elevated hover:text-foreground group-hover/split:opacity-100 focus:opacity-100","aria-label":de("tab.splitRename"),title:de("tab.splitRename"),children:o.jsx(p8,{size:11})})]}),Mt&&o.jsxs("div",{className:"border-t border-border/10 pb-0.5",children:[o.jsxs("div",{className:"flex items-center gap-0.5 px-1 py-0.5",children:[cr.map(Pt=>o.jsx("button",{type:"button",onClick:()=>v(Ue[0].id,Pt.layout),className:`inline-flex h-6 w-7 items-center justify-center rounded-md transition ${_e.layout===Pt.layout?"bg-primary/15 font-medium text-primary":"text-muted-foreground/70 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":Pt.label,title:Pt.label,children:Pt.icon},Pt.layout)),o.jsx("span",{className:"min-w-0 flex-1"}),o.jsx("button",{type:"button",onClick:()=>f((Ue.find(Pt=>Pt.id===i)??Ue[0]).id),className:"inline-flex h-6 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-primary/15 hover:text-primary","aria-label":de("tab.split"),title:de("tab.split"),children:o.jsx(Oo,{size:12})}),o.jsx("button",{type:"button",onClick:()=>p(Ue[0].id),className:"inline-flex h-6 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":de("tab.splitClose"),title:de("tab.splitClose"),children:o.jsx(ns,{size:12})})]}),o.jsx("div",{className:"px-0.5",children:Ue.map(Pt=>o.jsxs("div",{onDragOver:Wt=>{se?.workspaceId===_e.id&&Wt.preventDefault()},onDrop:Wt=>{Wt.preventDefault(),Wt.stopPropagation();const yt=Wt.currentTarget.getBoundingClientRect();er(Pt.id,Wt.clientY>yt.top+yt.height/2)},...I?ln(()=>I(Pt.id)):{},className:`flex items-center rounded-md pr-1 transition-colors ${ar(Pt.id)??(Pt.id===i?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:[o.jsx("span",{draggable:!0,onDragStart:Wt=>{Wt.stopPropagation(),Wt.dataTransfer.effectAllowed="move",ge({workspaceId:_e.id,sessionId:Pt.id})},onDragEnd:()=>ge(null),className:"inline-flex h-8 w-5 shrink-0 cursor-grab items-center justify-center text-muted-foreground/50 active:cursor-grabbing",children:o.jsx(_N,{size:12})}),Ar(Pt,void 0,!0,!0)]},Pt.id))})]})]})},St=(_e,Ue,mt)=>o.jsx(Um,{onDragEnd:Ct=>$r(Ct,_e,mt),children:o.jsx(Nu,{droppableId:Ue,direction:"vertical",isCombineEnabled:!0,children:Ct=>o.jsxs("div",{ref:Ct.innerRef,...Ct.droppableProps,className:"space-y-0.5",children:[_e.map((jt,Jt)=>o.jsx(Ru,{draggableId:jt.id,index:Jt,disableInteractiveElementBlocking:!0,children:(Mt,hn)=>o.jsx("div",{ref:Mt.innerRef,...Mt.draggableProps,children:jt.kind==="workspace"?ne(jt.workspace,jt.members,Mt.dragHandleProps,hn.isDragging,!!hn.combineTargetFor):o.jsx("div",{...I?ln(()=>I(jt.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${hn.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":hn.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":ar(jt.session.id)??(jt.session.id===i?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Ar(jt.session,Mt.dragHandleProps,mt!==void 0)})})},jt.id)),Ct.placeholder]})})}),Me=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"shrink-0 border-b border-border/15 px-2 py-2",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"min-w-0 flex-1 px-1",children:o.jsxs("div",{className:"flex items-baseline gap-1.5",children:[o.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:de("sidebar.sessions")}),o.jsx("span",{className:"text-[11px] text-muted-foreground",children:s.length}),ot>0&&o.jsx("span",{className:"ml-1 flex items-center gap-1.5",children:o.jsx(g9,{count:ot,tone:"running",title:de("agent.aiRunning")})})]})}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsxs("div",{ref:vt,className:Ee?"relative z-20":"relative",children:[o.jsxs("button",{type:"button",onClick:()=>pe(_e=>!_e),className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ee?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Ee,"aria-haspopup":"menu","aria-label":rn&&F?.latestVersion?`${de("sidebar.moreActions")}: ${de("sidebar.updateAvailable",{version:F.latestVersion})}`:de("sidebar.moreActions"),title:rn&&F?.latestVersion?`${de("sidebar.moreActions")}: ${de("sidebar.updateAvailable",{version:F.latestVersion})}`:de("sidebar.moreActions"),children:[o.jsx(Kc,{size:15}),rn&&o.jsx("span",{className:"absolute right-0.5 top-0.5 z-10 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"})]}),Ee&&o.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-60 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[rn&&F?.latestVersion&&o.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:o.jsx(si,{size:13,className:F.status==="installing"||F.status==="restarting"?"animate-spin":""})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block font-semibold",children:de("sidebar.updateAvailable",{version:F.latestVersion})}),o.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:F.status==="installing"?de("sidebar.updateInstalling"):F.status==="ready"?de("sidebar.updateReady"):F.status==="restarting"?de("sidebar.updateRestarting"):de("sidebar.updateFailed")})]})]}),F.status==="ready"&&C&&o.jsx("button",{type:"button",role:"menuitem",disabled:R,onClick:C,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:de("sidebar.updateRestart")}),F.status==="error"&&$&&o.jsx("button",{type:"button",role:"menuitem",disabled:R,onClick:$,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:de("sidebar.updateRetry")})]}),he&&o.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":X,onClick:()=>he(!X),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",title:de("sidebar.runningSessionButtonHint"),children:[o.jsx(Hn,{size:14,className:X?"text-[color:var(--success)]":"text-muted-foreground"}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block",children:de("sidebar.runningSessionButton")}),o.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:de("sidebar.runningSessionButtonHint")})]}),o.jsx(pc,{checked:X,size:"sm"})]}),P&&o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),P()},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx($R,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de("sidebar.subscriptionQuota")})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),Ke(!0)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx(YM,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:"Agent 工作台"})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),j()},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx(EM,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de("sidebar.settings")})]}),me&&o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),me()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${fe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[fe?o.jsx(Wc,{size:14}):o.jsx(gc,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de(fe?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]})]})]}),(!V||fe)&&o.jsx("button",{type:"button",onClick:n,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":de("common.close"),children:o.jsx(ns,{size:14})})]})]})}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 py-1.5",children:s.length===0?o.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[o.jsx(Sa,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),o.jsx("p",{className:"text-[12px] text-muted-foreground",children:de("sidebar.noSessions")})]}):Ye.length===0&&y.length===0?o.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:o.jsx("p",{className:"text-[12px] text-muted-foreground",children:de("sidebar.noMatchingSessions")})}):Ot?o.jsx("div",{className:"space-y-1.5",children:o.jsx(Um,{onDragEnd:ve,children:o.jsx(Nu,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:_e=>o.jsxs("div",{ref:_e.innerRef,..._e.droppableProps,className:"space-y-1.5",children:[Yn.map((Ue,mt)=>{const Ct=un.has(Ue.key),jt=Nx(Ue.sessions,y,ht);let Jt=0,Mt=0;for(const Nn of Ue.sessions){const lr=l.get(Nn.id);lr?.agentStatus==="working"&&(Jt+=1),(lr?.agentStatus==="waiting"||lr?.agentNeedsReview)&&(Mt+=1)}const hn=Ue.key==="";return o.jsx(Ru,{draggableId:`sidebar-group:${Ue.key||"__ungrouped__"}`,index:mt,isDragDisabled:hn,disableInteractiveElementBlocking:!0,children:(Nn,lr)=>o.jsxs("div",{ref:Nn.innerRef,...Nn.draggableProps,className:`rounded-md transition-colors ${lr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[o.jsxs("button",{type:"button",...hn?{}:Nn.dragHandleProps,onClick:()=>{gr(Ue.key),wt.current.delete(Ue.key)},className:`flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${hn?"":"cursor-grab active:cursor-grabbing"}`,title:Ue.key||Ue.label,children:[o.jsx(wl,{size:13,className:`shrink-0 transition-transform ${Ct?"":"rotate-90"}`}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Ue.label}),Jt>0&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Mt>0&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),o.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Ue.sessions.length})]}),!Ct&&o.jsx("div",{className:"mt-0.5 pl-2",children:o.jsx(Nu,{droppableId:`group-sessions:${Ue.key}`,type:"session",direction:"vertical",isCombineEnabled:!0,children:Tn=>o.jsxs("div",{ref:Tn.innerRef,...Tn.droppableProps,className:"space-y-0.5",children:[jt.map((jn,cn)=>o.jsx(Ru,{draggableId:jn.id,index:cn,disableInteractiveElementBlocking:!0,children:(cr,on)=>o.jsx("div",{ref:cr.innerRef,...cr.draggableProps,children:jn.kind==="workspace"?ne(jn.workspace,jn.members,cr.dragHandleProps,on.isDragging,!!on.combineTargetFor):o.jsx("div",{...I?ln(()=>I(jn.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${on.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":on.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":ar(jn.session.id)??(jn.session.id===i?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Ar(jn.session,cr.dragHandleProps,!0)})})},jn.id)),Tn.placeholder]})})})]})},Ue.key||"__ungrouped__")}),_e.placeholder]})})})}):St(Kn,"sidebar-entities")}),xe&&o.jsx(oq,{directories:s.flatMap(_e=>{const Ue=l.get(_e.id)?.cwd;return Ue?[Ue]:[]}),tmuxAvailable:Q,options:ae,agents:Ie,selectedAgent:We,detecting:He,resumeHistory:Xe,resumeHistoryLoading:Se,resumeHistoryPendingId:ue,resumeHistoryError:$e,onRefreshAgents:()=>{gt().catch(()=>{})},onSelectAgent:_e=>{bt(_e).catch(()=>{})},onLaunchAgent:Kt,onResumeHistory:_e=>{Jn(_e)},onRemoveResumeHistory:_e=>{Ht(_e)},onClose:()=>be(!1),onOptionsChange:Ne}),J&&o.jsx(uq,{activeSessionId:i,onClose:()=>Ke(!1),onNewSession:_e=>c(_e)}),!xe&&o.jsx("div",{className:"relative z-10 shrink-0 border-t border-border/15 bg-[var(--chrome-bg)] p-2",children:o.jsxs("div",{className:`grid gap-1.5 ${We?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[o.jsxs("button",{type:"button",onClick:ir,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${We?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:de("sidebar.newSession"),"aria-label":de("sidebar.newSession"),children:[o.jsx(Sa,{size:15,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:"Terminal"})]}),We&&o.jsxs("button",{type:"button",onClick:Wn,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:de("sidebar.newSessionWithAgent",{agent:We.displayName}),"aria-label":de("sidebar.newSessionWithAgent",{agent:We.displayName}),children:[o.jsx(Bu,{agent:We,size:15}),o.jsx("span",{className:"truncate",children:We.displayName})]}),o.jsx("button",{type:"button",onClick:Sr,className:"inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/20 transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:de("sidebar.moreLaunchOptions"),"aria-label":de("sidebar.moreLaunchOptions"),"aria-expanded":!1,children:o.jsx(sa,{size:15,className:"transition-transform duration-200"})})]})})]});return fe?o.jsx("div",{className:"h-full flex flex-col app-chrome-bg border-r border-border/15",children:Me}):o.jsx(h9,{side:"left",isOpen:e,drawerWidthPx:t,onClose:n,onOpen:r,push:V,children:Me})}const Tq="modulepreload",Cq=function(e){return"/"+e},k6={},l0=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=u(n.map(f=>{if(f=Cq(f),f in k6)return;k6[f]=!0;const p=f.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const y=document.createElement("link");if(y.rel=p?"stylesheet":Tq,p||(y.as="script"),y.crossOrigin="",y.href=f,c&&y.setAttribute("nonce",c),document.head.appendChild(y),p)return new Promise((v,S)=>{y.addEventListener("load",v),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function w9({selected:e,depth:t=0,title:n,leading:r,children:s,trailing:i,role:l,tabIndex:c,ariaExpanded:u,onClick:f,onKeyDown:p,onPointerDown:g,onPointerUp:y,onPointerCancel:v,dataAttributes:S}){return o.jsxs("div",{role:l,tabIndex:c,"aria-expanded":u,title:n,onClick:f,onKeyDown:p,onPointerDown:g,onPointerUp:y,onPointerCancel:v,...S,className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] transition active:scale-[0.99] ${e?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${t*14+8}px`},children:[o.jsx("span",{className:"flex min-w-[14px] shrink-0 items-center justify-center text-muted-foreground/80",children:r}),o.jsx("span",{className:"min-w-0 flex-1",children:s}),i]})}function S9(e){return e.path.replace(/^\/+/,"")}function kq(e){if(e.displayName!==void 0||e.displayDir!==void 0)return{name:e.displayName||e.path,dir:e.displayDir||""};const t=e.path.split("/").filter(Boolean);return{name:t.pop()||e.path,dir:t.join("/")}}function A9(e,t){const n=new Map,r=(i,l,c,u)=>{const f=i.get(l);if(f)return f;const p={path:c,name:l,childCount:0,directories:[],files:[]};return i.set(l,p),u?.directories.push(p),p};for(const i of e){const l=t(i).split("/").filter(Boolean);if(l.length<=1)continue;let c=n,u=null,f="";for(const p of l.slice(0,-1)){f=f?`${f}/${p}`:p;const g=r(c,p,f,u);u=g,c=new Map(g.directories.map(y=>[y.name,y]))}u?.files.push(i)}const s=i=>{const l=i.directories.map(s).sort((u,f)=>u.name.localeCompare(f.name)),c=i.files.sort((u,f)=>u.path.localeCompare(f.path));return{...i,directories:l,files:c,childCount:l.reduce((u,f)=>u+f.childCount,0)+c.length}};return Array.from(n.values()).map(s).sort((i,l)=>i.name.localeCompare(l.name))}function $y(e,t,n=0){const r=t.selectedKey===e.key||t.selectedKey===e.path||t.selectedKey===e.absolutePath,s=kq(e);return o.jsx(w9,{selected:r,role:"button",tabIndex:0,title:e.title??e.absolutePath??e.path,onClick:()=>{By()||t.onSelectFile(e)},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t.onSelectFile(e))},leading:t.renderLeading(e),depth:n,trailing:t.renderTrailing?.(e),dataAttributes:{"data-diff-selection-path":e.key,"data-diff-file-path":e.path,"data-diff-absolute-path":e.absolutePath??"","data-diff-status":e.status},children:o.jsxs("span",{className:"select-text","data-sidebar-selectable":!0,children:[o.jsx("span",{className:`block truncate leading-snug ${r?"font-medium":""}`,children:s.name}),t.mode!=="tree"&&s.dir&&o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/75",children:s.dir}),t.renderSubtitle?.(e)]})},e.key)}function T9(e,t,n,r,s){let i=e;const l=[e.name];for(;i.files.length===0&&i.directories.length===1;)i=i.directories[0],l.push(i.name);const c=l.join("/"),u=`${t}:${i.path}`,f=n.collapsedDirectoryKeys.has(u);return o.jsxs("div",{className:"space-y-px",children:[o.jsx(w9,{role:"button",tabIndex:0,onClick:()=>{By()||n.onToggleDirectory(u)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),n.onToggleDirectory(u))},ariaExpanded:!f,depth:r,title:i.path,leading:f?o.jsx(wl,{size:13}):o.jsx(sa,{size:13}),trailing:o.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/60 transition group-hover:text-muted-foreground",children:i.childCount}),n.renderDirectoryTrailing?.(i.path,s)]}),children:o.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate leading-snug select-text","data-sidebar-selectable":!0,children:c})]})}),!f&&o.jsxs("div",{className:"space-y-px",children:[i.directories.map(p=>T9(p,t,n,r+1,s)),i.files.length>0&&o.jsx("div",{className:"space-y-px",children:i.files.map(p=>$y(p,n,r+1))})]})]},u)}function _q(e,t){const n=t.getFileTreePath??S9,r=e.files.filter(i=>n(i).split("/").filter(Boolean).length<=1),s=A9(e.files,n);return o.jsxs("div",{className:"space-y-px",children:[s.map(i=>T9(i,e.key,t,0,e)),r.length>0&&o.jsx("div",{className:"space-y-px",children:r.map(i=>$y(i,t))})]})}function C9(e,t=S9){const n=[],r=i=>{for(const l of i.directories)r(l);n.push(...i.files)};for(const i of A9(e,t))r(i);const s=new Set(n.map(i=>i.key));return n.push(...e.filter(i=>!s.has(i.key))),n}function Lq(e){return o.jsx("div",{className:e.mode==="tree"?"space-y-px pt-1":"space-y-2",children:e.groups.map(t=>{const n=!!t.header,r=!!t.collapsed;return o.jsxs("section",{className:n?"overflow-hidden rounded-lg border border-border/15 bg-surface/60":"",children:[t.header,!r&&o.jsx("div",{className:e.mode==="tree"?n?"space-y-px bg-surface/60 p-1":"space-y-px":n?"space-y-px bg-surface/60 p-1.5":"space-y-px",children:e.mode==="tree"?_q(t,e):t.files.map(s=>$y(s,e))})]},t.key)})})}const dm="termdock:diff-review:list-width:v1",Eq=120,d2=320,_6=220,Iq=560;function Rq(e){return typeof e=="number"&&Number.isFinite(e)}function L6(e,t){const n=Math.max(_6,t-360),r=Math.min(Iq,n);return Math.min(r,Math.max(_6,e))}function Nq(){return Or(dm,Rq)??d2}function Mq({list:e,detail:t,mobile:n,mobileListHeader:r,mobileDetailHeader:s,desktopListHeader:i,backLabel:l,onMobileSlideChange:c,externalSwiperRef:u,desktopLayout:f="split",onDetailScroll:p,desktopSidePanel:g,desktopListClassName:y,detailOwnsScroll:v=!1}){const{t:S}=qn(),A=b.useRef(null),T=b.useRef(null),L=b.useRef(null),[I,j]=b.useState(Nq);b.useEffect(()=>{if(n||f!=="split")return;const $=T.current;$&&j(Q=>L6(Q,$.clientWidth))},[f,n]);const P=b.useCallback($=>{n||f!=="split"||($.preventDefault(),L.current={startX:$.clientX,startWidth:I,pointerId:$.pointerId},$.currentTarget.setPointerCapture($.pointerId))},[f,I,n]),F=b.useCallback($=>{const Q=L.current;if(!Q||Q.pointerId!==$.pointerId)return;const q=T.current?.clientWidth??window.innerWidth,V=L6(Q.startWidth+$.clientX-Q.startX,q);j(V),qd(dm,V,Eq)},[]),R=b.useCallback($=>{const Q=L.current;if(!(!Q||Q.pointerId!==$.pointerId)){L.current=null,Nd(dm);try{$.currentTarget.releasePointerCapture($.pointerId)}catch{}}},[]);if(n){const $=()=>{const fe=A.current;fe&&fe.slideTo(1)},Q=()=>{const fe=A.current;fe&&fe.slideTo(0)},q=typeof e=="function"?e({slideToDetail:$}):e,V=typeof s=="function"?s({slideToList:Q,slideToDetail:$}):s;return o.jsxs(sh,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:fe=>{A.current=fe,u&&(u.current=fe)},onSlideChange:fe=>{c?.(fe.activeIndex)},children:[o.jsx(Qu,{className:"h-full min-h-0",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[r&&o.jsx("div",{className:"shrink-0 border-b border-border/15 px-3 py-2",children:r}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:q})]})}),o.jsx(Qu,{className:"h-full min-h-0",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[o.jsx("div",{className:"shrink-0 border-b border-border/15 px-3 py-2",children:V??o.jsxs("button",{type:"button",onClick:Q,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[o.jsx(e0,{size:14}),l]})}),o.jsx("div",{className:v?"min-h-0 flex-1 overflow-hidden":"termdock-diff-stream-scroller min-h-0 flex-1 overflow-y-auto overscroll-contain",onScroll:v?void 0:fe=>p?.(fe.currentTarget),children:t})]})})]})}const C=typeof e=="function"?e({slideToDetail:()=>{}}):e;return f==="stacked"?v?o.jsxs("div",{className:"termdock-native-select min-h-0 flex-1 overflow-hidden px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C,o.jsx("div",{className:"mt-3 h-[calc(100%-3rem)] min-h-0 overflow-hidden rounded-xl border border-border/15 bg-surface",children:t})]}):o.jsxs("div",{className:"termdock-native-select termdock-diff-stream-scroller min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",onScroll:$=>p?.($.currentTarget),children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C,o.jsx("div",{className:"mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface",children:t})]}):o.jsxs("div",{ref:T,className:"flex h-full min-h-0 overflow-hidden",children:[g,o.jsxs("div",{className:y??"shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",style:{width:I},children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C]}),o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":S("diffViewer.resizeNavigation"),title:S("diffViewer.resizeNavigation"),className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-r border-border/15 bg-surface",onPointerDown:P,onPointerMove:F,onPointerUp:R,onPointerCancel:R,onDoubleClick:()=>{j(d2),Gn(dm,d2)},children:o.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border/30 transition group-hover:bg-primary/60"})}),o.jsx("div",{className:v?"min-w-0 flex-1 overflow-hidden":"termdock-diff-stream-scroller min-w-0 flex-1 overflow-y-auto overscroll-contain",onScroll:v?void 0:$=>p?.($.currentTarget),children:t})]})}function Dq({mode:e,onModeChange:t,showAi:n=!1}){return o.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>t("list"),"aria-pressed":e==="list",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="list"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx($N,{size:13})}),o.jsx("button",{type:"button",onClick:()=>t("tree"),"aria-pressed":e==="tree",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="tree"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx(J2,{size:13})}),n&&o.jsx("button",{type:"button",onClick:()=>t("ai"),"aria-pressed":e==="ai",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="ai"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx(Zc,{size:13})})]})}function jq({groups:e,mode:t,onModeChange:n,selectedKey:r,collapsedDirectoryKeys:s,onToggleDirectory:i,onSelectFile:l,renderLeading:c,renderTrailing:u,renderDirectoryTrailing:f,renderSubtitle:p,detail:g,mobile:y,backLabel:v,compact:S=!1,emptyContent:A,listPrefix:T,aiContent:L,listContainerClassName:I="px-2 py-2",detailContainerClassName:j="termdock-native-select termdock-diff-stream-scroller min-h-0",renderListHeader:P,renderMobileDetailHeader:F,externalSwiperRef:R,onMobileSlideChange:C,slideToDetailOnMobile:$=!0,desktopLayout:Q="split",onDetailScroll:q,desktopSidePanel:V,desktopListClassName:fe,detailOwnsScroll:X}){const[he,me]=b.useState(!1);b.useEffect(()=>{if(!he)return;const se=ge=>{ge.key==="Escape"&&me(!1)};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[he]);const de=o.jsx(Dq,{mode:t,onModeChange:n,showAi:!!L}),le=t==="tree"?"tree":"list",W=P?P(de):o.jsx("div",{className:"flex justify-end",children:de}),z=e.some(se=>se.files.length>0),K=o.jsx(Mq,{mobile:he?!1:y,backLabel:v,externalSwiperRef:R,onMobileSlideChange:C,desktopLayout:he?"split":Q,onDetailScroll:q,desktopSidePanel:V,desktopListClassName:fe,detailOwnsScroll:X,mobileListHeader:y?W:void 0,desktopListHeader:y?void 0:W,mobileDetailHeader:F,list:({slideToDetail:se})=>o.jsx("div",{className:I,children:t==="ai"?typeof L=="function"?L({slideToDetail:se,fullscreen:he,toggleFullscreen:()=>me(ge=>!ge)}):L??A:o.jsxs(o.Fragment,{children:[T,z?o.jsx(Lq,{groups:e,selectedKey:r,mode:le,mobile:y,compact:S,collapsedDirectoryKeys:s,onToggleDirectory:i,onSelectFile:ge=>{l(ge),y&&$&&window.requestAnimationFrame(se)},renderLeading:c,renderTrailing:u,renderDirectoryTrailing:f,renderSubtitle:p}):A]})}),detail:o.jsx("div",{className:X?"h-full min-h-0":j,children:g})});return!he||typeof document>"u"?K:ia.createPortal(o.jsxs("div",{className:"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface text-foreground",children:[o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(Zc,{size:15,className:"shrink-0 text-primary"}),o.jsx("span",{className:"truncate text-[12px] font-semibold",children:"DAG Review"}),o.jsx("span",{className:"hidden text-[10px] text-muted-foreground sm:inline",children:"Select a step to inspect its exact change"})]}),o.jsx("button",{type:"button",onClick:()=>me(!1),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground active:scale-95",title:"Exit full-screen DAG review (Esc)","aria-label":"Exit full-screen DAG review",children:o.jsx(ns,{size:16})})]}),o.jsx("div",{className:"min-h-0 flex-1",children:K})]}),document.body)}function E6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),n.push.apply(n,r)}return n}function ro(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?E6(Object(n),!0).forEach((function(r){f2(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E6(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function f2(e,t,n){return(t=(function(r){var s=(function(i,l){if(typeof i!="object"||i===null)return i;var c=i[Symbol.toPrimitive];if(c!==void 0){var u=c.call(i,l);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(i)})(r,"string");return typeof s=="symbol"?s:String(s)})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c0(e,t){if(e==null)return{};var n,r,s=(function(l,c){if(l==null)return{};var u,f,p={},g=Object.keys(l);for(f=0;f<g.length;f++)u=g[f],c.indexOf(u)>=0||(p[u]=l[u]);return p})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Ac(e,t){return Bq(e)||(function(n,r){var s=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(s!=null){var i,l,c,u,f=[],p=!0,g=!1;try{if(c=(s=s.call(n)).next,r===0){if(Object(s)!==s)return;p=!1}else for(;!(p=(i=c.call(s)).done)&&(f.push(i.value),f.length!==r);p=!0);}catch(y){g=!0,l=y}finally{try{if(!p&&s.return!=null&&(u=s.return(),Object(u)!==u))return}finally{if(g)throw l}}return f}})(e,t)||Hy(e,t)||Oq()}function Pq(e){return(function(t){if(Array.isArray(t))return h2(t)})(e)||Fq(e)||Hy(e)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
135
+ `}}];return{always:sf(l,"always"),resting:sf(l,"resting"),dragging:sf(l,"dragging"),dropAnimating:sf(l,"dropAnimating"),userCancel:sf(l,"userCancel")}};const _a=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,yx=()=>{const e=document.querySelector("head");return e||$t(),e},I3=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function az(e,t){const n=Qr(()=>oz(e),[e]),r=b.useRef(null),s=b.useRef(null),i=Dn(Bi(g=>{const y=s.current;y||$t(),y.textContent=g}),[]),l=Dn(g=>{const y=r.current;y||$t(),y.textContent=g},[]);_a(()=>{!r.current&&!s.current||$t();const g=I3(t),y=I3(t);return r.current=g,s.current=y,g.setAttribute(`${s0}-always`,e),y.setAttribute(`${s0}-dynamic`,e),yx().appendChild(g),yx().appendChild(y),l(n.always),i(n.resting),()=>{const v=S=>{const A=S.current;A||$t(),yx().removeChild(A),S.current=null};v(r),v(s)}},[t,l,i,n.always,n.resting,e]);const c=Dn(()=>i(n.dragging),[i,n.dragging]),u=Dn(g=>{if(g==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),f=Dn(()=>{s.current&&i(n.resting)},[i,n.resting]);return Qr(()=>({dragging:c,dropping:u,resting:f}),[c,u,f])}function MA(e,t){return Array.from(e.querySelectorAll(t))}var DA=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function _g(e){return e instanceof DA(e).HTMLElement}function lz(e,t){const n=`[${i0.contextId}="${e}"]`,r=MA(document,n);if(!r.length)return null;const s=r.find(i=>i.getAttribute(i0.draggableId)===t);return!s||!_g(s)?null:s}function cz(e){const t=b.useRef({}),n=b.useRef(null),r=b.useRef(null),s=b.useRef(!1),i=Dn(function(y,v){const S={id:y,focus:v};return t.current[y]=S,function(){const T=t.current;T[y]!==S&&delete T[y]}},[]),l=Dn(function(y){const v=lz(e,y);v&&v!==document.activeElement&&v.focus()},[e]),c=Dn(function(y,v){n.current===y&&(n.current=v)},[]),u=Dn(function(){r.current||s.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const y=n.current;y&&l(y)}))},[l]),f=Dn(function(y){n.current=null;const v=document.activeElement;v&&v.getAttribute(i0.draggableId)===y&&(n.current=y)},[]);return _a(()=>(s.current=!0,function(){s.current=!1;const y=r.current;y&&cancelAnimationFrame(y)}),[]),Qr(()=>({register:i,tryRecordFocus:f,tryRestoreFocusRecorded:u,tryShiftRecord:c}),[i,f,u,c])}function uz(){const e={draggables:{},droppables:{}},t=[];function n(g){return t.push(g),function(){const v=t.indexOf(g);v!==-1&&t.splice(v,1)}}function r(g){t.length&&t.forEach(y=>y(g))}function s(g){return e.draggables[g]||null}function i(g){const y=s(g);return y||$t(),y}const l={register:g=>{e.draggables[g.descriptor.id]=g,r({type:"ADDITION",value:g})},update:(g,y)=>{const v=e.draggables[y.descriptor.id];v&&v.uniqueId===g.uniqueId&&(delete e.draggables[y.descriptor.id],e.draggables[g.descriptor.id]=g)},unregister:g=>{const y=g.descriptor.id,v=s(y);v&&g.uniqueId===v.uniqueId&&(delete e.draggables[y],e.droppables[g.descriptor.droppableId]&&r({type:"REMOVAL",value:g}))},getById:i,findById:s,exists:g=>!!s(g),getAllByType:g=>Object.values(e.draggables).filter(y=>y.descriptor.type===g)};function c(g){return e.droppables[g]||null}function u(g){const y=c(g);return y||$t(),y}const f={register:g=>{e.droppables[g.descriptor.id]=g},unregister:g=>{const y=c(g.descriptor.id);y&&g.uniqueId===y.uniqueId&&delete e.droppables[g.descriptor.id]},getById:u,findById:c,exists:g=>!!c(g),getAllByType:g=>Object.values(e.droppables).filter(y=>y.descriptor.type===g)};function p(){e.draggables={},e.droppables={},t.length=0}return{draggable:l,droppable:f,subscribe:n,clean:p}}function dz(){const e=Qr(uz,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var Ny=D.createContext(null),Hm=()=>{const e=document.body;return e||$t(),e};const fz={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},hz=e=>`rfd-announcement-${e}`;function pz(e){const t=Qr(()=>hz(e),[e]),n=b.useRef(null);return b.useEffect(function(){const i=document.createElement("div");return n.current=i,i.id=t,i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),Fm(i.style,fz),Hm().appendChild(i),function(){setTimeout(function(){const u=Hm();u.contains(i)&&u.removeChild(i),i===n.current&&(n.current=null)})}},[t]),Dn(s=>{const i=n.current;if(i){i.textContent=s;return}},[])}const mz={separator:"::"};function My(e,t=mz){const n=D.useId();return Qr(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function gz({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function xz({contextId:e,text:t}){const n=My("hidden-text",{separator:"-"}),r=Qr(()=>gz({contextId:e,uniqueId:n}),[n,e]);return b.useEffect(function(){const i=document.createElement("div");return i.id=r,i.textContent=t,i.style.display="none",Hm().appendChild(i),function(){const c=Hm();c.contains(i)&&c.removeChild(i)}},[r,t]),r}var Lg=D.createContext(null);function jA(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function bz(){let e=null;function t(){return!!e}function n(l){return l===e}function r(l){e&&$t();const c={abandon:l};return e=c,c}function s(){e||$t(),e=null}function i(){e&&(e.abandon(),s())}return{isClaimed:t,isActive:n,claim:r,release:s,tryAbandon:i}}function Yf(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const yz=9,vz=13,Dy=27,PA=32,wz=33,Sz=34,Az=35,Tz=36,Cz=37,kz=38,_z=39,Lz=40,Ez={[vz]:!0,[yz]:!0};var BA=e=>{Ez[e.keyCode]&&e.preventDefault()};const Eg=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(r=>`on${r}`in document)||e})(),FA=0,R3=5;function Iz(e,t){return Math.abs(t.x-e.x)>=R3||Math.abs(t.y-e.y)>=R3}const N3={type:"IDLE"};function Rz({cancel:e,completed:t,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:s=>{const{button:i,clientX:l,clientY:c}=s;if(i!==FA)return;const u={x:l,y:c},f=n();if(f.type==="DRAGGING"){s.preventDefault(),f.actions.move(u);return}f.type!=="PENDING"&&$t();const p=f.point;if(!Iz(p,u))return;s.preventDefault();const g=f.actions.fluidLift(u);r({type:"DRAGGING",actions:g})}},{eventName:"mouseup",fn:s=>{const i=n();if(i.type!=="DRAGGING"){e();return}s.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:s=>{n().type==="DRAGGING"&&s.preventDefault(),e()}},{eventName:"keydown",fn:s=>{if(n().type==="PENDING"){e();return}if(s.keyCode===Dy){s.preventDefault(),e();return}BA(s)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:s=>{const i=n();if(i.type==="IDLE"&&$t(),i.actions.shouldRespectForcePress()){e();return}s.preventDefault()}},{eventName:Eg,fn:e}]}function Nz(e){const t=b.useRef(N3),n=b.useRef(Vc),r=Qr(()=>({eventName:"mousedown",fn:function(g){if(g.defaultPrevented||g.button!==FA||g.ctrlKey||g.metaKey||g.shiftKey||g.altKey)return;const y=e.findClosestDraggableId(g);if(!y)return;const v=e.tryGetLock(y,l,{sourceEvent:g});if(!v)return;g.preventDefault();const S={x:g.clientX,y:g.clientY};n.current(),f(v,S)}}),[e]),s=Qr(()=>({eventName:"webkitmouseforcewillbegin",fn:p=>{if(p.defaultPrevented)return;const g=e.findClosestDraggableId(p);if(!g)return;const y=e.findOptionsForDraggable(g);y&&(y.shouldRespectForcePress||e.canGetLock(g)&&p.preventDefault())}}),[e]),i=Dn(function(){const g={passive:!1,capture:!0};n.current=Xa(window,[s,r],g)},[s,r]),l=Dn(()=>{t.current.type!=="IDLE"&&(t.current=N3,n.current(),i())},[i]),c=Dn(()=>{const p=t.current;l(),p.type==="DRAGGING"&&p.actions.cancel({shouldBlockNextClick:!0}),p.type==="PENDING"&&p.actions.abort()},[l]),u=Dn(function(){const g={capture:!0,passive:!1},y=Rz({cancel:c,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});n.current=Xa(window,y,g)},[c,l]),f=Dn(function(g,y){t.current.type!=="IDLE"&&$t(),t.current={type:"PENDING",point:y,actions:g},u()},[u]);_a(function(){return i(),function(){n.current()}},[i])}function Mz(){}const Dz={[Sz]:!0,[wz]:!0,[Tz]:!0,[Az]:!0};function jz(e,t){function n(){t(),e.cancel()}function r(){t(),e.drop()}return[{eventName:"keydown",fn:s=>{if(s.keyCode===Dy){s.preventDefault(),n();return}if(s.keyCode===PA){s.preventDefault(),r();return}if(s.keyCode===Lz){s.preventDefault(),e.moveDown();return}if(s.keyCode===kz){s.preventDefault(),e.moveUp();return}if(s.keyCode===_z){s.preventDefault(),e.moveRight();return}if(s.keyCode===Cz){s.preventDefault(),e.moveLeft();return}if(Dz[s.keyCode]){s.preventDefault();return}BA(s)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:Eg,fn:n}]}function Pz(e){const t=b.useRef(Mz),n=Qr(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==PA)return;const l=e.findClosestDraggableId(i);if(!l)return;const c=e.tryGetLock(l,p,{sourceEvent:i});if(!c)return;i.preventDefault();let u=!0;const f=c.snapLift();t.current();function p(){u||$t(),u=!1,t.current(),r()}t.current=Xa(window,jz(f,p),{capture:!0,passive:!1})}}),[e]),r=Dn(function(){const i={passive:!1,capture:!0};t.current=Xa(window,[n],i)},[n]);_a(function(){return r(),function(){t.current()}},[r])}const vx={type:"IDLE"},Bz=120,Fz=.15;function Oz({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(t().type!=="DRAGGING"){e();return}n.keyCode===Dy&&n.preventDefault(),e()}},{eventName:Eg,fn:e}]}function Qz({cancel:e,completed:t,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:r=>{const s=n();if(s.type!=="DRAGGING"){e();return}s.hasMoved=!0;const{clientX:i,clientY:l}=r.touches[0],c={x:i,y:l};r.preventDefault(),s.actions.move(c)}},{eventName:"touchend",fn:r=>{const s=n();if(s.type!=="DRAGGING"){e();return}r.preventDefault(),s.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:r=>{if(n().type!=="DRAGGING"){e();return}r.preventDefault(),e()}},{eventName:"touchforcechange",fn:r=>{const s=n();s.type==="IDLE"&&$t();const i=r.touches[0];if(!i||!(i.force>=Fz))return;const c=s.actions.shouldRespectForcePress();if(s.type==="PENDING"){c&&e();return}if(c){if(s.hasMoved){r.preventDefault();return}e();return}r.preventDefault()}},{eventName:Eg,fn:e}]}function $z(e){const t=b.useRef(vx),n=b.useRef(Vc),r=Dn(function(){return t.current},[]),s=Dn(function(v){t.current=v},[]),i=Qr(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const S=e.findClosestDraggableId(v);if(!S)return;const A=e.tryGetLock(S,c,{sourceEvent:v});if(!A)return;const T=v.touches[0],{clientX:L,clientY:I}=T,j={x:L,y:I};n.current(),g(A,j)}}),[e]),l=Dn(function(){const v={capture:!0,passive:!1};n.current=Xa(window,[i],v)},[i]),c=Dn(()=>{const y=t.current;y.type!=="IDLE"&&(y.type==="PENDING"&&clearTimeout(y.longPressTimerId),s(vx),n.current(),l())},[l,s]),u=Dn(()=>{const y=t.current;c(),y.type==="DRAGGING"&&y.actions.cancel({shouldBlockNextClick:!0}),y.type==="PENDING"&&y.actions.abort()},[c]),f=Dn(function(){const v={capture:!0,passive:!1},S={cancel:u,completed:c,getPhase:r},A=Xa(window,Qz(S),v),T=Xa(window,Oz(S),v);n.current=function(){A(),T()}},[u,r,c]),p=Dn(function(){const v=r();v.type!=="PENDING"&&$t();const S=v.actions.fluidLift(v.point);s({type:"DRAGGING",actions:S,hasMoved:!1})},[r,s]),g=Dn(function(v,S){r().type!=="IDLE"&&$t();const A=setTimeout(p,Bz);s({type:"PENDING",point:S,actions:v,longPressTimerId:A}),f()},[f,r,s,p]);_a(function(){return l(),function(){n.current();const S=r();S.type==="PENDING"&&(clearTimeout(S.longPressTimerId),s(vx))}},[r,l,s]),_a(function(){return Xa(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const Hz=["input","button","textarea","select","option","optgroup","video","audio"];function OA(e,t){if(t==null)return!1;if(Hz.includes(t.tagName.toLowerCase()))return!0;const r=t.getAttribute("contenteditable");return r==="true"||r===""?!0:t===e?!1:OA(e,t.parentElement)}function Uz(e,t){const n=t.target;return _g(n)?OA(e,n):!1}var zz=e=>Sl(e.getBoundingClientRect()).center;function Gz(e){return e instanceof DA(e).Element}const Wz=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||e})();function QA(e,t){return e==null?null:e[Wz](t)?e:QA(e.parentElement,t)}function Vz(e,t){return e.closest?e.closest(t):QA(e,t)}function qz(e){return`[${i0.contextId}="${e}"]`}function Yz(e,t){const n=t.target;if(!Gz(n))return null;const r=qz(e),s=Vz(n,r);return!s||!_g(s)?null:s}function Kz(e,t){const n=Yz(e,t);return n?n.getAttribute(i0.draggableId):null}function Xz(e,t){const n=`[${e2.contextId}="${e}"]`,s=MA(document,n).find(i=>i.getAttribute(e2.id)===t);return!s||!_g(s)?null:s}function Zz(e){e.preventDefault()}function _p({expected:e,phase:t,isLockActive:n,shouldWarn:r}){return!(!n()||e!==t)}function $A({lockAPI:e,store:t,registry:n,draggableId:r}){if(e.isClaimed())return!1;const s=n.draggable.findById(r);return!(!s||!s.options.isEnabled||!EA(t.getState(),r))}function Jz({lockAPI:e,contextId:t,store:n,registry:r,draggableId:s,forceSensorStop:i,sourceEvent:l}){if(!$A({lockAPI:e,store:n,registry:r,draggableId:s}))return null;const u=r.draggable.getById(s),f=Xz(t,u.descriptor.id);if(!f||l&&!u.options.canDragInteractiveElements&&Uz(f,l))return null;const p=e.claim(i||Vc);let g="PRE_DRAG";function y(){return u.options.shouldRespectForcePress}function v(){return e.isActive(p)}function S(F,R){_p({expected:F,phase:g,isLockActive:v,shouldWarn:!0})&&n.dispatch(R())}const A=S.bind(null,"DRAGGING");function T(F){function R(){e.release(),g="COMPLETED"}g!=="PRE_DRAG"&&(R(),$t()),n.dispatch(VH(F.liftActionArgs)),g="DRAGGING";function C($,Q={shouldBlockNextClick:!1}){if(F.cleanup(),Q.shouldBlockNextClick){const q=Xa(window,[{eventName:"click",fn:Zz,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(q)}R(),n.dispatch(wA({reason:$}))}return{isActive:()=>_p({expected:"DRAGGING",phase:g,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:y,drop:$=>C("DROP",$),cancel:$=>C("CANCEL",$),...F.actions}}function L(F){const R=Uf($=>{A(()=>vA({client:$}))});return{...T({liftActionArgs:{id:s,clientSelection:F,movementMode:"FLUID"},cleanup:()=>R.cancel(),actions:{move:R}}),move:R}}function I(){const F={moveUp:()=>A(nU),moveRight:()=>A(sU),moveDown:()=>A(rU),moveLeft:()=>A(iU)};return T({liftActionArgs:{id:s,clientSelection:zz(f),movementMode:"SNAP"},cleanup:Vc,actions:F})}function j(){_p({expected:"PRE_DRAG",phase:g,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>_p({expected:"PRE_DRAG",phase:g,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:y,fluidLift:L,snapLift:I,abort:j}}const eG=[Nz,Pz,$z];function tG({contextId:e,store:t,registry:n,customSensors:r,enableDefaultSensors:s}){const i=[...s?eG:[],...r||[]],l=b.useState(()=>bz())[0],c=Dn(function(T,L){Yf(T)&&!Yf(L)&&l.tryAbandon()},[l]);_a(function(){let T=t.getState();return t.subscribe(()=>{const I=t.getState();c(T,I),T=I})},[l,t,c]),_a(()=>l.tryAbandon,[l.tryAbandon]);const u=Dn(A=>$A({lockAPI:l,registry:n,store:t,draggableId:A}),[l,n,t]),f=Dn((A,T,L)=>Jz({lockAPI:l,registry:n,contextId:e,store:t,draggableId:A,forceSensorStop:T||null,sourceEvent:L&&L.sourceEvent?L.sourceEvent:null}),[e,l,n,t]),p=Dn(A=>Kz(e,A),[e]),g=Dn(A=>{const T=n.draggable.findById(A);return T?T.options:null},[n.draggable]),y=Dn(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(Cy()))},[l,t]),v=Dn(()=>l.isClaimed(),[l]),S=Qr(()=>({canGetLock:u,tryGetLock:f,findClosestDraggableId:p,findOptionsForDraggable:g,tryReleaseLock:y,isLockClaimed:v}),[u,f,p,g,y,v]);for(let A=0;A<i.length;A++)i[A](S)}const nG=e=>({onBeforeCapture:t=>{const n=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};ia.flushSync(n)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),rG=e=>({...qf,...e.autoScrollerOptions,durationDampening:{...qf.durationDampening,...e.autoScrollerOptions}});function of(e){return e.current||$t(),e.current}function sG(e){const{contextId:t,setCallbacks:n,sensors:r,nonce:s,dragHandleUsageInstructions:i}=e,l=b.useRef(null),c=jA(e),u=Dn(()=>nG(c.current),[c]),f=Dn(()=>rG(c.current),[c]),p=pz(t),g=xz({contextId:t,text:i}),y=az(t,s),v=Dn(q=>{of(l).dispatch(q)},[]),S=Qr(()=>s3({publishWhileDragging:YH,updateDroppableScroll:XH,updateDroppableIsEnabled:ZH,updateDroppableIsCombineEnabled:JH,collectionStarting:KH},v),[v]),A=dz(),T=Qr(()=>OU(A,S),[A,S]),L=Qr(()=>nz({scrollWindow:QU,scrollDroppable:T.scrollDroppable,getAutoScrollerOptions:f,...s3({move:vA},v)}),[T.scrollDroppable,v,f]),I=cz(t),j=Qr(()=>jU({announce:p,autoScroller:L,dimensionMarshal:T,focusMarshal:I,getResponders:u,styleMarshal:y}),[p,L,T,I,u,y]);l.current=j;const P=Dn(()=>{const q=of(l);q.getState().phase!=="IDLE"&&q.dispatch(Cy())},[]),F=Dn(()=>{const q=of(l).getState();return q.phase==="DROP_ANIMATING"?!0:q.phase==="IDLE"?!1:q.isDragging},[]),R=Qr(()=>({isDragging:F,tryAbort:P}),[F,P]);n(R);const C=Dn(q=>EA(of(l).getState(),q),[]),$=Dn(()=>Tu(of(l).getState()),[]),Q=Qr(()=>({marshal:T,focus:I,contextId:t,canLift:C,isMovementAllowed:$,dragHandleUsageInstructionsId:g,registry:A}),[t,T,g,I,C,$,A]);return tG({contextId:t,store:j,registry:A,customSensors:r||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>P,[P]),D.createElement(Lg.Provider,{value:Q},D.createElement(E$,{context:Ny,store:j},e.children))}function iG(){return D.useId()}function Um(e){const t=iG(),n=e.dragHandleUsageInstructions||cm.dragHandleUsageInstructions;return D.createElement(P$,null,r=>D.createElement(sG,{nonce:e.nonce,contextId:t,setCallbacks:r,dragHandleUsageInstructions:n,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const M3={dragging:5e3,dropAnimating:4500},oG=(e,t)=>t?jf.drop(t.duration):e?jf.snap:jf.fluid,aG=(e,t)=>{if(e)return t?Vf.opacity.drop:Vf.opacity.combining},lG=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function cG(e){const n=e.dimension.client,{offset:r,combineWith:s,dropping:i}=e,l=!!s,c=lG(e),u=!!i,f=u?Zb.drop(r,l):Zb.moveTo(r);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:oG(c,i),transform:f,opacity:aG(l,u),zIndex:u?M3.dropAnimating:M3.dragging,pointerEvents:"none"}}function uG(e){return{transform:Zb.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function dG(e){return e.type==="DRAGGING"?cG(e):uG(e)}function fG(e,t,n=Fi){const r=window.getComputedStyle(t),s=t.getBoundingClientRect(),i=qS(s,r),l=Bm(i,n),c={client:i,tagName:t.tagName.toLowerCase(),display:r.display},u={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:e,placeholder:c,displaceBy:u,client:i,page:l}}function hG(e){const t=My("draggable"),{descriptor:n,registry:r,getDraggableRef:s,canDragInteractiveElements:i,shouldRespectForcePress:l,isEnabled:c}=e,u=Qr(()=>({canDragInteractiveElements:i,shouldRespectForcePress:l,isEnabled:c}),[i,c,l]),f=Dn(v=>{const S=s();return S||$t(),fG(n,S,v)},[n,s]),p=Qr(()=>({uniqueId:t,descriptor:n,options:u,getDimension:f}),[n,f,u,t]),g=b.useRef(p),y=b.useRef(!0);_a(()=>(r.draggable.register(g.current),()=>r.draggable.unregister(g.current)),[r.draggable]),_a(()=>{if(y.current){y.current=!1;return}const v=g.current;g.current=p,r.draggable.update(p,v)},[p,r.draggable])}var jy=D.createContext(null);function zm(e){const t=b.useContext(e);return t||$t(),t}function pG(e){e.preventDefault()}const mG=e=>{const t=b.useRef(null),n=Dn((R=null)=>{t.current=R},[]),r=Dn(()=>t.current,[]),{contextId:s,dragHandleUsageInstructionsId:i,registry:l}=zm(Lg),{type:c,droppableId:u}=zm(jy),f=Qr(()=>({id:e.draggableId,index:e.index,type:c,droppableId:u}),[e.draggableId,e.index,c,u]),{children:p,draggableId:g,isEnabled:y,shouldRespectForcePress:v,canDragInteractiveElements:S,isClone:A,mapped:T,dropAnimationFinished:L}=e;if(!A){const R=Qr(()=>({descriptor:f,registry:l,getDraggableRef:r,canDragInteractiveElements:S,shouldRespectForcePress:v,isEnabled:y}),[f,l,r,S,v,y]);hG(R)}const I=Qr(()=>y?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":g,"data-rfd-drag-handle-context-id":s,draggable:!1,onDragStart:pG}:null,[s,i,g,y]),j=Dn(R=>{T.type==="DRAGGING"&&T.dropping&&R.propertyName==="transform"&&ia.flushSync(L)},[L,T]),P=Qr(()=>{const R=dG(T),C=T.type==="DRAGGING"&&T.dropping?j:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":s,"data-rfd-draggable-id":g,style:R,onTransitionEnd:C},dragHandleProps:I}},[s,I,g,T,j,n]),F=Qr(()=>({draggableId:f.id,type:f.type,source:{index:f.index,droppableId:f.droppableId}}),[f.droppableId,f.id,f.index,f.type]);return D.createElement(D.Fragment,null,p(P,T.snapshot,F))};var HA=(e,t)=>e===t,UA=e=>{const{combine:t,destination:n}=e;return n?n.droppableId:t?t.droppableId:null};const gG=e=>e.combine?e.combine.draggableId:null,xG=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function bG(){const e=Bi((s,i)=>({x:s,y:i})),t=Bi((s,i,l=null,c=null,u=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!u,dropAnimation:u,mode:s,draggingOver:l,combineWith:c,combineTargetFor:null})),n=Bi((s,i,l,c,u=null,f=null,p=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:u,combineWith:f,mode:i,offset:s,dimension:l,forceShouldAnimate:p,snapshot:t(i,c,u,f,null)}}));return(s,i)=>{if(Yf(s)){if(s.critical.draggable.id!==i.draggableId)return null;const l=s.current.client.offset,c=s.dimensions.draggables[i.draggableId],u=ka(s.impact),f=xG(s.impact),p=s.forceShouldAnimate;return n(e(l.x,l.y),s.movementMode,c,i.isClone,u,f,p)}if(s.phase==="DROP_ANIMATING"){const l=s.completed;if(l.result.draggableId!==i.draggableId)return null;const c=i.isClone,u=s.dimensions.draggables[i.draggableId],f=l.result,p=f.mode,g=UA(f),y=gG(f),S={duration:s.dropDuration,curve:_y.drop,moveTo:s.newHomeClientOffset,opacity:y?Vf.opacity.drop:null,scale:y?Vf.scale.drop:null};return{mapped:{type:"DRAGGING",offset:s.newHomeClientOffset,dimension:u,dropping:S,draggingOver:g,combineWith:y,mode:p,forceShouldAnimate:null,snapshot:t(p,c,g,y,S)}}}return null}}function zA(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const yG={mapped:{type:"SECONDARY",offset:Fi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:zA(null)}};function vG(){const e=Bi((l,c)=>({x:l,y:c})),t=Bi(zA),n=Bi((l,c=null,u)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:c,shouldAnimateDisplacement:u,snapshot:t(c)}})),r=l=>l?n(Fi,l,!0):null,s=(l,c,u,f)=>{const p=u.displaced.visible[l],g=!!(f.inVirtualList&&f.effected[l]),y=Tg(u),v=y&&y.draggableId===l?c:null;if(!p){if(!g)return r(v);if(u.displaced.invisible[l])return null;const T=p0(f.displacedBy.point),L=e(T.x,T.y);return n(L,v,!0)}if(g)return r(v);const S=u.displacedBy.point,A=e(S.x,S.y);return n(A,v,p.shouldAnimate)};return(l,c)=>{if(Yf(l))return l.critical.draggable.id===c.draggableId?null:s(c.draggableId,l.critical.draggable.id,l.impact,l.afterCritical);if(l.phase==="DROP_ANIMATING"){const u=l.completed;return u.result.draggableId===c.draggableId?null:s(c.draggableId,u.result.draggableId,u.impact,u.afterCritical)}return null}}const wG=()=>{const e=bG(),t=vG();return(r,s)=>e(r,s)||t(r,s)||yG},SG={dropAnimationFinished:SA},AG=VS(wG,SG,null,{context:Ny,areStatePropsEqual:HA})(mG);function GA(e){return zm(jy).isUsingCloneFor===e.draggableId&&!e.isClone?null:D.createElement(AG,e)}function Ru(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,n=!!e.disableInteractiveElementBlocking,r=!!e.shouldRespectForcePress;return D.createElement(GA,Fm({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const WA=e=>t=>e===t,TG=WA("scroll"),CG=WA("auto"),D3=(e,t)=>t(e.overflowX)||t(e.overflowY),kG=e=>{const t=window.getComputedStyle(e),n={overflowX:t.overflowX,overflowY:t.overflowY};return D3(n,TG)||D3(n,CG)},_G=()=>!1,VA=e=>e==null?null:e===document.body?_G()?e:null:e===document.documentElement?null:kG(e)?e:VA(e.parentElement);var t2=e=>({x:e.scrollLeft,y:e.scrollTop});const qA=e=>e?window.getComputedStyle(e).position==="fixed"?!0:qA(e.parentElement):!1;var LG=e=>{const t=VA(e),n=qA(e);return{closestScrollable:t,isFixedOnPage:n}},EG=({descriptor:e,isEnabled:t,isCombineEnabled:n,isFixedOnPage:r,direction:s,client:i,page:l,closest:c})=>{const u=(()=>{if(!c)return null;const{scrollSize:y,client:v}=c,S=kA({scrollHeight:y.scrollHeight,scrollWidth:y.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:c.page.marginBox,frameClient:v,scrollSize:y,shouldClipSubject:c.shouldClipSubject,scroll:{initial:c.scroll,current:c.scroll,max:S,diff:{value:Fi,displacement:Fi}}}})(),f=s==="vertical"?vy:iA,p=r0({page:l,withPlaceholder:null,axis:f,frame:u});return{descriptor:e,isCombineEnabled:n,isFixedOnPage:r,axis:f,isEnabled:t,client:i,page:l,frame:u,subject:p}};const IG=(e,t)=>{const n=YS(e);if(!t||e!==t)return n;const r=n.paddingBox.top-t.scrollTop,s=n.paddingBox.left-t.scrollLeft,i=r+t.scrollHeight,l=s+t.scrollWidth,u=gy({top:r,right:l,bottom:i,left:s},n.border);return xy({borderBox:u,margin:n.margin,border:n.border,padding:n.padding})};var RG=({ref:e,descriptor:t,env:n,windowScroll:r,direction:s,isDropDisabled:i,isCombineEnabled:l,shouldClipSubject:c})=>{const u=n.closestScrollable,f=IG(e,u),p=Bm(f,r),g=(()=>{if(!u)return null;const v=YS(u),S={scrollHeight:u.scrollHeight,scrollWidth:u.scrollWidth};return{client:v,page:Bm(v,r),scroll:t2(u),scrollSize:S,shouldClipSubject:c}})();return EG({descriptor:t,isEnabled:!i,isCombineEnabled:l,isFixedOnPage:n.isFixedOnPage,direction:s,client:f,page:p,closest:g})};const NG={passive:!1},MG={passive:!0};var j3=e=>e.shouldPublishImmediately?NG:MG;const Lp=e=>e&&e.env.closestScrollable||null;function DG(e){const t=b.useRef(null),n=zm(Lg),r=My("droppable"),{registry:s,marshal:i}=n,l=jA(e),c=Qr(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),u=b.useRef(c),f=Qr(()=>Bi((P,F)=>{t.current||$t();const R={x:P,y:F};i.updateDroppableScroll(c.id,R)}),[c.id,i]),p=Dn(()=>{const P=t.current;return!P||!P.env.closestScrollable?Fi:t2(P.env.closestScrollable)},[]),g=Dn(()=>{const P=p();f(P.x,P.y)},[p,f]),y=Qr(()=>Uf(g),[g]),v=Dn(()=>{const P=t.current,F=Lp(P);if(P&&F||$t(),P.scrollOptions.shouldPublishImmediately){g();return}y()},[y,g]),S=Dn((P,F)=>{t.current&&$t();const R=l.current,C=R.getDroppableRef();C||$t();const $=LG(C),Q={ref:C,descriptor:c,env:$,scrollOptions:F};t.current=Q;const q=RG({ref:C,descriptor:c,env:$,windowScroll:P,direction:R.direction,isDropDisabled:R.isDropDisabled,isCombineEnabled:R.isCombineEnabled,shouldClipSubject:!R.ignoreContainerClipping}),V=$.closestScrollable;return V&&(V.setAttribute(E3.contextId,n.contextId),V.addEventListener("scroll",v,j3(Q.scrollOptions))),q},[n.contextId,c,v,l]),A=Dn(()=>{const P=t.current,F=Lp(P);return P&&F||$t(),t2(F)},[]),T=Dn(()=>{const P=t.current;P||$t();const F=Lp(P);t.current=null,F&&(y.cancel(),F.removeAttribute(E3.contextId),F.removeEventListener("scroll",v,j3(P.scrollOptions)))},[v,y]),L=Dn(P=>{const F=t.current;F||$t();const R=Lp(F);R||$t(),R.scrollTop+=P.y,R.scrollLeft+=P.x},[]),I=Qr(()=>({getDimensionAndWatchScroll:S,getScrollWhileDragging:A,dragStopped:T,scroll:L}),[T,S,A,L]),j=Qr(()=>({uniqueId:r,descriptor:c,callbacks:I}),[I,c,r]);_a(()=>(u.current=j.descriptor,s.droppable.register(j),()=>{t.current&&T(),s.droppable.unregister(j)}),[I,c,T,j,i,s.droppable]),_a(()=>{t.current&&i.updateDroppableIsEnabled(u.current.id,!e.isDropDisabled)},[e.isDropDisabled,i]),_a(()=>{t.current&&i.updateDroppableIsCombineEnabled(u.current.id,e.isCombineEnabled)},[e.isCombineEnabled,i])}function wx(){}const P3={width:0,height:0,margin:U$},jG=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>e||n==="close"?P3:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},PG=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>{const r=jG({isAnimatingOpenOnMount:e,placeholder:t,animate:n});return{display:t.display,boxSizing:"border-box",width:r.width,height:r.height,marginTop:r.margin.top,marginRight:r.margin.right,marginBottom:r.margin.bottom,marginLeft:r.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?jf.placeholder:null}},BG=e=>{const t=b.useRef(null),n=Dn(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:r,onTransitionEnd:s,onClose:i,contextId:l}=e,[c,u]=b.useState(e.animate==="open");b.useEffect(()=>c?r!=="open"?(n(),u(!1),wx):t.current?wx:(t.current=setTimeout(()=>{t.current=null,u(!1)}),n):wx,[r,c,n]);const f=Dn(g=>{g.propertyName==="height"&&(s(),r==="close"&&i())},[r,i,s]),p=PG({isAnimatingOpenOnMount:c,animate:e.animate,placeholder:e.placeholder});return D.createElement(e.placeholder.tagName,{style:p,"data-rfd-placeholder-context-id":l,onTransitionEnd:f,ref:e.innerRef})};var FG=D.memo(BG);class OG extends D.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,n){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const QG=e=>{const t=b.useContext(Lg);t||$t();const{contextId:n,isMovementAllowed:r}=t,s=b.useRef(null),i=b.useRef(null),{children:l,droppableId:c,type:u,mode:f,direction:p,ignoreContainerClipping:g,isDropDisabled:y,isCombineEnabled:v,snapshot:S,useClone:A,updateViewportMaxScroll:T,getContainerForClone:L}=e,I=Dn(()=>s.current,[]),j=Dn((V=null)=>{s.current=V},[]);Dn(()=>i.current,[]);const P=Dn((V=null)=>{i.current=V},[]),F=Dn(()=>{r()&&T({maxScroll:LA()})},[r,T]);DG({droppableId:c,type:u,mode:f,direction:p,isDropDisabled:y,isCombineEnabled:v,ignoreContainerClipping:g,getDroppableRef:I});const R=Qr(()=>D.createElement(OG,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:V,data:fe,animate:X})=>D.createElement(FG,{placeholder:fe,onClose:V,innerRef:P,animate:X,contextId:n,onTransitionEnd:F})),[n,F,e.placeholder,e.shouldAnimatePlaceholder,P]),C=Qr(()=>({innerRef:j,placeholder:R,droppableProps:{"data-rfd-droppable-id":c,"data-rfd-droppable-context-id":n}}),[n,c,R,j]),$=A?A.dragging.draggableId:null,Q=Qr(()=>({droppableId:c,type:u,isUsingCloneFor:$}),[c,$,u]);function q(){if(!A)return null;const{dragging:V,render:fe}=A,X=D.createElement(GA,{draggableId:V.draggableId,index:V.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(he,me)=>fe(he,me,V));return Gk.createPortal(X,L())}return D.createElement(jy.Provider,{value:Q},l(C,S),q())};function $G(){return document.body||$t(),document.body}const B3={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:$G},YA=e=>{let t={...e},n;for(n in B3)e[n]===void 0&&(t={...t,[n]:B3[n]});return t},Sx=(e,t)=>e===t.droppable.type,F3=(e,t)=>t.draggables[e.draggable.id],HG=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},n=Bi(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),r=Bi((i,l,c,u,f,p)=>{const g=f.descriptor.id;if(f.descriptor.droppableId===i){const S=p?{render:p,dragging:n(f.descriptor)}:null,A={isDraggingOver:c,draggingOverWith:c?g:null,draggingFromThisWith:g,isUsingPlaceholder:!0};return{placeholder:f.placeholder,shouldAnimatePlaceholder:!1,snapshot:A,useClone:S}}if(!l)return t;if(!u)return e;const v={isDraggingOver:c,draggingOverWith:g,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:f.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(i,l)=>{const c=YA(l),u=c.droppableId,f=c.type,p=!c.isDropDisabled,g=c.renderClone;if(Yf(i)){const y=i.critical;if(!Sx(f,y))return t;const v=F3(y,i.dimensions),S=ka(i.impact)===u;return r(u,p,S,S,v,g)}if(i.phase==="DROP_ANIMATING"){const y=i.completed;if(!Sx(f,y.critical))return t;const v=F3(y.critical,i.dimensions);return r(u,p,UA(y.result)===u,ka(y.impact)===u,v,g)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){const y=i.completed;if(!Sx(f,y.critical))return t;const v=ka(y.impact)===u,S=!!(y.impact.at&&y.impact.at.type==="COMBINE"),A=y.critical.droppable.id===u;return v?S?e:t:A?e:t}return t}},UG={updateViewportMaxScroll:tU},Nu=VS(HG,UG,(e,t,n)=>({...YA(n),...e,...t}),{context:Ny,areStatePropsEqual:HA})(QG);function zG(){if(typeof window>"u")return Wd(void 0);try{const e=window.localStorage.getItem(Db);return Wd(e?JSON.parse(e):void 0)}catch{return Wd(void 0)}}function Ax(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(Db),n=t?JSON.parse(t):{},r=Wd({...n,...e});window.localStorage.setItem(Db,JSON.stringify(r))}catch{}}function GG(){const[e,t]=D.useState(zG);D.useEffect(()=>{Ax(e)},[e]);const n=D.useCallback(s=>{t(i=>{const l=Wd({...i,...s});return Ax(l),l})},[]),r=D.useCallback(()=>{const s=Wd(void 0);t(s),Ax(s)},[]);return{terminalSettings:e,updateTerminalSettings:n,resetTerminalSettings:r}}const n2="termdock-settings";function WG(e){return e==="shell"||e==="tmux"}function VG(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(n2);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),n=t.newSessionModeUserSelected===!0&&WG(t.newSessionMode)?t.newSessionMode:null,r=n??"shell",s=typeof t.newSessionTmuxName=="string"?t.newSessionTmuxName:"";return{mode:r,tmuxName:s,userSelectedMode:n}}catch{return{mode:"shell",tmuxName:"",userSelectedMode:null}}}function O3(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(n2),r={...t?JSON.parse(t):{},...e};window.localStorage.setItem(n2,JSON.stringify(r))}catch{}}function qG(){const[e,t]=D.useState(VG),n=D.useCallback((s,i)=>{const l=i?.userInitiated!==!1;t(c=>({...c,mode:s,userSelectedMode:l?s:c.userSelectedMode})),l&&O3({newSessionMode:s,newSessionModeUserSelected:!0})},[]),r=D.useCallback(s=>{t(i=>({...i,tmuxName:s})),O3({newSessionTmuxName:s})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:n,setNewSessionTmuxName:r}}const YG=550,KG=10;function KA(){const e=b.useRef(null),t=b.useRef(null),n=b.useRef(!1),r=b.useRef(!1),s=b.useRef(null),i=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),l=b.useCallback(()=>{i(),t.current=null},[i]);return b.useCallback(u=>({onPointerDown:f=>{f.pointerType!=="touch"&&f.pointerType!=="pen"||(l(),n.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startY:f.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(n.current=!0,u())},YG))},onPointerMove:f=>{const p=t.current;if(!p||p.pointerId!==f.pointerId||n.current)return;const g=f.clientX-p.startX,y=f.clientY-p.startY;Math.hypot(g,y)>KG&&l()},onPointerUp:f=>{n.current&&(f.preventDefault(),n.current=!1,r.current=!0,s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{r.current=!1,s.current=null},600)),l()},onPointerCancel:l,onPointerLeave:f=>{t.current?.pointerId===f.pointerId&&!n.current&&l()},onClickCapture:f=>{r.current&&(r.current=!1,s.current!=null&&(window.clearTimeout(s.current),s.current=null),f.preventDefault(),f.stopPropagation())}}),[l])}function XG({mode:e,activeProgram:t,promptState:n,shellNames:r}){return e!=="tmux"?!0:n==="running"?!1:n==="idle"?!0:t!==null&&r.has(t.toLowerCase())}function XA(e){const t=document.querySelector('meta[name="theme-color"]');t&&t.setAttribute("content",e==="light"?"#FFFCF0":"#1C1B1A")}function ZG(e,t,n){return!!(e&&t===e&&!n)}function JG(e,t,n){return Math.max(t,Math.min(e,n))}const Fs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function Q3(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function $3(e,t,n,r=.15){return r===0?JG(e,t,n):e<t?-Q3(t-e,n-t,r)+t:e>n?+Q3(e-n,n-t,r)+n:e}function eW(e,[t,n],[r,s]){const[[i,l],[c,u]]=e;return[$3(t,i,l,r),$3(n,c,u,s)]}function tW(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function nW(e){var t=tW(e,"string");return typeof t=="symbol"?t:String(t)}function fi(e,t,n){return t=nW(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Xs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?H3(Object(n),!0).forEach(function(r){fi(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):H3(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const ZA={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function U3(e){return e?e[0].toUpperCase()+e.slice(1):""}const rW=["enter","leave"];function sW(e=!1,t){return e&&!rW.includes(t)}function iW(e,t="",n=!1){const r=ZA[e],s=r&&r[t]||t;return"on"+U3(e)+U3(s)+(sW(n,s)?"Capture":"")}const oW=["gotpointercapture","lostpointercapture"];function aW(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=oW.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(r);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:n}}function lW(e,t=""){const n=ZA[e],r=n&&n[t]||t;return e+r}function Ig(e){return"touches"in e}function JA(e){return Ig(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function cW(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function uW(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function e9(e){return Ig(e)?uW(e)[0]:e}function r2(e,t){try{const n=t.clientX-e.clientX,r=t.clientY-e.clientY,s=(t.clientX+e.clientX)/2,i=(t.clientY+e.clientY)/2,l=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:l,origin:[s,i]}}catch{}return null}function dW(e){return cW(e).map(t=>t.identifier)}function z3(e,t){const[n,r]=Array.from(e.touches).filter(s=>t.includes(s.identifier));return r2(n,r)}function Tx(e){const t=e9(e);return Ig(e)?t.identifier:t.pointerId}function o0(e){const t=e9(e);return[t.clientX,t.clientY]}const G3=40,W3=800;function t9(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=G3,n*=G3):r===2&&(t*=W3,n*=W3),[t,n]}function fW(e){var t,n;const{scrollX:r,scrollY:s,scrollLeft:i,scrollTop:l}=e.currentTarget;return[(t=r??i)!==null&&t!==void 0?t:0,(n=s??l)!==null&&n!==void 0?n:0]}function hW(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i})}return t}function Gm(e,...t){return typeof e=="function"?e(...t):e}function pW(){}function mW(...e){return e.length===0?pW:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function V3(e,t){return Object.assign({},t,e||{})}const gW=32;class n9{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:s}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?Gm(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:s}=this;n.args=this.args;let i=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,hW(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const R=n._delta.map(Math.abs);Fs.addTo(n._distance,R)}this.axisIntent&&this.axisIntent(t);const[l,c]=n._movement,[u,f]=r.threshold,{_step:p,values:g}=n;if(r.hasCustomTransform?(p[0]===!1&&(p[0]=Math.abs(l)>=u&&g[0]),p[1]===!1&&(p[1]=Math.abs(c)>=f&&g[1])):(p[0]===!1&&(p[0]=Math.abs(l)>=u&&Math.sign(l)*u),p[1]===!1&&(p[1]=Math.abs(c)>=f&&Math.sign(c)*f)),n.intentional=p[0]!==!1||p[1]!==!1,!n.intentional)return;const y=[0,0];if(r.hasCustomTransform){const[R,C]=g;y[0]=p[0]!==!1?R-p[0]:0,y[1]=p[1]!==!1?C-p[1]:0}else y[0]=p[0]!==!1?l-p[0]:0,y[1]=p[1]!==!1?c-p[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(y);const v=n.offset,S=n._active&&!n._blocked||n.active;S&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=Gm(r.bounds,n)),this.setup&&this.setup()),n.movement=y,this.computeOffset()));const[A,T]=n.offset,[[L,I],[j,P]]=n._bounds;n.overflow=[A<L?-1:A>I?1:0,T<j?-1:T>P?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const F=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=eW(n._bounds,n.offset,F),n.delta=Fs.sub(n.offset,v),this.computeMovement(),S&&(!n.last||i>gW)){n.delta=Fs.sub(n.offset,v);const R=n.delta.map(Math.abs);Fs.addTo(n.distance,R),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[R[0]/i,R[1]/i],n.timeDelta=i)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const s=this.handler(Xs(Xs(Xs({},n),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function xW([e,t],n){const r=Math.abs(e),s=Math.abs(t);if(r>s&&r>n)return"x";if(s>r&&s>n)return"y"}class ch extends n9{constructor(...t){super(...t),fi(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Fs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Fs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const s=typeof r.axisThreshold=="object"?r.axisThreshold[JA(t)]:r.axisThreshold;n.axis=xW(n._movement,s)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const bW=e=>e,q3=.15,r9={enabled(e=!0){return e},eventOptions(e,t,n){return Xs(Xs({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[q3,q3];case!1:return[0,0];default:return Fs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Fs.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||bW},threshold(e){return Fs.toVector(e,0)}},yW=0,Wu=Xs(Xs({},r9),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=yW){return e},bounds(e={}){if(typeof e=="function")return i=>Wu.bounds(e(i));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=e;return[[t,n],[r,s]]}}),Y3={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class vW extends ch{constructor(...t){super(...t),fi(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),s={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=Wu.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const s=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(s&&s.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=Tx(t),r._pointerActive=!0,this.computeValues(o0(t)),this.computeInitial(),n.preventScrollAxis&&JA(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive)return;const s=Tx(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;const i=o0(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Fs.sub(i,n._values),this.computeValues(i)),Fs.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const s=Tx(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,l]=n._distance;if(n.tap=i<=r.tapsThreshold&&l<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[c,u]=n._delta,[f,p]=n._movement,[g,y]=r.swipe.velocity,[v,S]=r.swipe.distance,A=r.swipe.duration;if(n.elapsedTime<A){const T=Math.abs(c/n.timeDelta),L=Math.abs(u/n.timeDelta);T>g&&Math.abs(f)>v&&(n.swipe[0]=Math.sign(c)),L>y&&Math.abs(p)>S&&(n.swipe[1]=Math.sign(u))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,wW(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=Y3[t.key];if(n){const r=this.state,s=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(this.config.keyboardDisplacement,s),r._keyboardActive=!0,Fs.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Y3&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function wW(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const uh=typeof window<"u"&&window.document&&window.document.createElement;function s9(){return uh&&"ontouchstart"in window}function SW(){return s9()||uh&&window.navigator.maxTouchPoints>1}function AW(){return uh&&"onpointerdown"in window}function TW(){return uh&&"exitPointerLock"in window.document}function CW(){try{return"constructor"in GestureEvent}catch{return!1}}const Ya={isBrowser:uh,gesture:CW(),touch:s9(),touchscreen:SW(),pointer:AW(),pointerLock:TW()},kW=250,_W=180,LW=.5,EW=50,IW=250,RW=10,K3={mouse:0,touch:0,pen:8},NW=Xs(Xs({},Wu),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&Ya.pointerLock,Ya.touch&&n?"touch":this.pointerLock?"mouse":Ya.pointer&&!s?"pointer":Ya.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?kW:void 0,!(!Ya.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const i=Fs.toVector(e,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,i},swipe({velocity:e=LW,distance:t=EW,duration:n=IW}={}){return{velocity:this.transform(Fs.toVector(e)),distance:this.transform(Fs.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return _W;case!1:return 0;default:return e}},axisThreshold(e){return e?Xs(Xs({},K3),e):K3},keyboardDisplacement(e=RW){return e}});function i9(e){const[t,n]=e.overflow,[r,s]=e._delta,[i,l]=e._direction;(t<0&&r>0&&i<0||t>0&&r<0&&i>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&s>0&&l<0||n>0&&s<0&&l>0)&&(e._movement[1]=e._movementBound[1])}const MW=30,DW=100;class jW extends n9{constructor(...t){super(...t),fi(this,"ingKey","pinching"),fi(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=Fs.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const s=Math.abs(n)*MW-Math.abs(r);s<0?t.axis="angle":s>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(i=>r.has(i))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const s=z3(t,n._touchIds);s&&this.pinchStart(t,s)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,s=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(l=>s.has(l))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const i=r2(...Array.from(r.values()));i&&this.pinchStart(t,i)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=z3(t,this.state._touchIds);n&&this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=r2(...Array.from(n.values()));r&&this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,s=r._values[1],i=n.angle-s;let l=0;Math.abs(i)>270&&(l+=Math.sign(i)),this.computeValues([n.distance,n.angle-360*l]),r.origin=n.origin,r.turns=l,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=Fs.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>t[r]):!t[n])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-t9(t)[1]/DW*r.offset[0],0],Fs.addTo(r._movement,r._delta),i9(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this)),t("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const PW=Xs(Xs({},r9),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!Ya.touch&&Ya.gesture)return"gesture";if(Ya.touch&&r)return"touch";if(Ya.touchscreen){if(Ya.pointer)return"pointer";if(Ya.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const s=l=>{const c=V3(Gm(n,l),{min:-1/0,max:1/0});return[c.min,c.max]},i=l=>{const c=V3(Gm(r,l),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof n!="function"&&typeof r!="function"?[s(),i()]:l=>[s(l),i(l)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Fs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class BW extends ch{constructor(...t){super(...t),fi(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(o0(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const n=o0(t),r=this.state;r._delta=Fs.sub(n,r._values),Fs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const FW=Xs(Xs({},Wu),{},{mouseOnly:(e=!0)=>e});class OW extends ch{constructor(...t){super(...t),fi(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const n=this.state,r=fW(t);n._delta=Fs.sub(r,n._values),Fs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const QW=Wu;class $W extends ch{constructor(...t){super(...t),fi(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=t9(t),Fs.addTo(n._movement,n._delta),i9(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const HW=Wu;class UW extends ch{constructor(...t){super(...t),fi(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(o0(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=o0(t);n._movement=n._delta=Fs.sub(r,n._values),this.computeValues(r),this.compute(t),n.delta=n.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const zW=Xs(Xs({},Wu),{},{mouseOnly:(e=!0)=>e}),Py=new Map,s2=new Map;function o9(e){Py.set(e.key,e.engine),s2.set(e.key,e.resolver)}const a9={key:"drag",engine:vW,resolver:NW},GW={key:"hover",engine:UW,resolver:zW},WW={key:"move",engine:BW,resolver:FW},VW={key:"pinch",engine:jW,resolver:PW},qW={key:"scroll",engine:OW,resolver:QW},YW={key:"wheel",engine:$W,resolver:HW};function KW(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function XW(e,t){if(e==null)return{};var n=KW(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const ZW={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=Ya.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},JW=["target","eventOptions","window","enabled","transform"];function um(e={},t){const n={};for(const[r,s]of Object.entries(t))switch(typeof s){case"function":n[r]=s.call(n,e[r],r,e);break;case"object":n[r]=um(e[r],s);break;case"boolean":s&&(n[r]=e[r]);break}return n}function eV(e,t,n={}){const r=e,{target:s,eventOptions:i,window:l,enabled:c,transform:u}=r,f=XW(r,JW);if(n.shared=um({target:s,eventOptions:i,window:l,enabled:c,transform:u},ZW),t){const p=s2.get(t);n[t]=um(Xs({shared:n.shared},f),p)}else for(const p in f){const g=s2.get(p);g&&(n[p]=um(Xs({shared:n.shared},f[p]),g))}return n}class l9{constructor(t,n){fi(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,s,i){const l=this._listeners,c=lW(n,r),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},f=Xs(Xs({},u),i);t.addEventListener(c,s,f);const p=()=>{t.removeEventListener(c,s,f),l.delete(p)};return l.add(p),p}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class tV{constructor(){fi(this,"_timeouts",new Map)}add(t,n,r=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...s))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class nV{constructor(t){fi(this,"gestures",new Set),fi(this,"_targetEventStore",new l9(this)),fi(this,"gestureEventStores",{}),fi(this,"gestureTimeoutStores",{}),fi(this,"handlers",{}),fi(this,"config",{}),fi(this,"pointerIds",new Set),fi(this,"touchIds",new Set),fi(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),rV(this,t)}setEventIds(t){if(Ig(t))return this.touchIds=new Set(dW(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=eV(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let s;if(!(n.target&&(s=n.target(),!s))){if(n.enabled){for(const l of this.gestures){const c=this.config[l],u=X3(r,c.eventOptions,!!s);if(c.enabled){const f=Py.get(l);new f(this,t,l).bind(u)}}const i=X3(r,n.eventOptions,!!s);for(const l in this.nativeHandlers)i(l,"",c=>this.nativeHandlers[l](Xs(Xs({},this.state.shared),{},{event:c,args:t})),void 0,!0)}for(const i in r)r[i]=mW(...r[i]);if(!s)return r;for(const i in r){const{device:l,capture:c,passive:u}=aW(i);this._targetEventStore.add(s,l,"",r[i],{capture:c,passive:u})}}}}function Ad(e,t){e.gestures.add(t),e.gestureEventStores[t]=new l9(e,t),e.gestureTimeoutStores[t]=new tV}function rV(e,t){t.drag&&Ad(e,"drag"),t.wheel&&Ad(e,"wheel"),t.scroll&&Ad(e,"scroll"),t.move&&Ad(e,"move"),t.pinch&&Ad(e,"pinch"),t.hover&&Ad(e,"hover")}const X3=(e,t,n)=>(r,s,i,l={},c=!1)=>{var u,f;const p=(u=l.capture)!==null&&u!==void 0?u:t.capture,g=(f=l.passive)!==null&&f!==void 0?f:t.passive;let y=c?r:iW(r,s,p);n&&g&&(y+="Passive"),e[y]=e[y]||[],e[y].push(i)},sV=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function iV(e){const t={},n={},r=new Set;for(let s in e)sV.test(s)?(r.add(RegExp.lastMatch),n[s]=e[s]):t[s]=e[s];return[n,t,r]}function Td(e,t,n,r,s,i){if(!e.has(n)||!Py.has(r))return;const l=n+"Start",c=n+"End",u=f=>{let p;return f.first&&l in t&&t[l](f),n in t&&(p=t[n](f)),f.last&&c in t&&t[c](f),p};s[r]=u,i[r]=i[r]||{}}function oV(e,t){const[n,r,s]=iV(e),i={};return Td(s,n,"onDrag","drag",i,t),Td(s,n,"onWheel","wheel",i,t),Td(s,n,"onScroll","scroll",i,t),Td(s,n,"onPinch","pinch",i,t),Td(s,n,"onMove","move",i,t),Td(s,n,"onHover","hover",i,t),{handlers:i,config:t,nativeHandlers:r}}function c9(e,t={},n,r){const s=D.useMemo(()=>new nV(e),[]);if(s.applyHandlers(e,r),s.applyConfig(t,n),D.useEffect(s.effect.bind(s)),D.useEffect(()=>s.clean.bind(s),[]),t.target===void 0)return s.bind.bind(s)}function Z3(e,t){return o9(a9),c9({drag:e},t||{},"drag")}function aV(e){return e.forEach(o9),function(n,r){const{handlers:s,nativeHandlers:i,config:l}=oV(n,r||{});return c9(s,l,void 0,i)}}function u9(e,t){return aV([a9,VW,qW,YW,WW,GW])(e,t||{})}const J3={dampingRatio:.8,response:.3},lV=.998;function cV(e,t,n,r){const s=2*Math.PI/Math.max(e.response,.001),i=t-r,l=n,c=e.dampingRatio;if(Math.abs(c-1)<1e-4){const v=i,S=l+s*i;return{value:A=>r+(v+S*A)*Math.exp(-s*A),velocity:A=>(S-s*(v+S*A))*Math.exp(-s*A)}}if(c<1){const v=s*Math.sqrt(1-c*c),S=i,A=(l+c*s*i)/v;return{value:T=>r+Math.exp(-c*s*T)*(S*Math.cos(v*T)+A*Math.sin(v*T)),velocity:T=>Math.exp(-c*s*T)*((A*v-c*s*S)*Math.cos(v*T)-(S*v+c*s*A)*Math.sin(v*T))}}const u=s*Math.sqrt(c*c-1),f=-c*s+u,p=-c*s-u,g=(l-p*i)/(f-p),y=i-g;return{value:v=>r+g*Math.exp(f*v)+y*Math.exp(p*v),velocity:v=>g*f*Math.exp(f*v)+y*p*Math.exp(p*v)}}function uV(e,t=lV){return e/1e3*(t/(1-t))}function e6(e,t,n=.55){return e*t*n/(t+n*Math.abs(e))}function dV(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const fV=.1,hV=5;function pV(e,t,n,r,s){const i=cV(e,t,n,r),l=1e3/60,c=240,u=[];for(let f=0;f<c;f++){const p=f*l/1e3,g=i.value(p),y=i.velocity(p);if(u.push(s?s(g):g),f>0&&Math.abs(g-r)<fV&&Math.abs(y)<hV)break}return u.push(s?s(r):r),{frames:u,durationMs:(u.length-1)*l,solver:i}}const mV="swiper",gV="pre.termdock-file-preview-horizontal-scroll",d9="swiper-no-swiping",f9="data-sidebar-gesture-ignore",Cx=1;function xV(e,t){const n=e.scrollWidth-e.clientWidth;return n<=Cx?!1:t>0?e.scrollLeft>Cx:e.scrollLeft<n-Cx}function bV(e){return e.matches(gV)?{element:e,startScrollLeft:e.scrollLeft}:null}function yV(e,t){e.element.scrollLeft=e.startScrollLeft-t}function vV(e,t){return t>0?!e.isBeginning:!e.isEnd}function wV(e,t){const n=[],r=[];if(!(e instanceof Element))return{scrollers:n,swipers:r};const s=!!e.closest(`.${d9}`);let i=e;for(;i&&i!==t;){if(!s&&i.classList.contains(mV)){const l=i.swiper;l&&!l.destroyed&&r.push(l)}if(i instanceof HTMLElement){const{overflowX:l}=getComputedStyle(i);(l==="auto"||l==="scroll")&&n.push(i)}i=i.parentElement}return{scrollers:n,swipers:r}}function SV(e,t,n){const r=t>=0?1:-1;for(const s of e.scrollers)if(xV(s,r))return{kind:"scroller",element:s};for(const s of e.swipers)if(vV(s,r))return{kind:"swiper",instance:s};return r===n?{kind:"drawer"}:e.swipers.length>0?{kind:"swiper",instance:e.swipers[0]}:e.scrollers.length>0?{kind:"scroller",element:e.scrollers[0]}:{kind:"drawer"}}function By(){if(typeof window>"u"||typeof window.getSelection!="function")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&String(e).length>0)}function AV(e){e.allowTouchMove=!0;let t=!1;const n=()=>{t||(t=!0,e.allowTouchMove=!1,window.removeEventListener("touchend",n),window.removeEventListener("touchcancel",n),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n))};return window.addEventListener("touchend",n),window.addEventListener("touchcancel",n),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),n}const TV=18,t6=8,n6={touch:t6,pen:t6},CV=500,kx=200,r6=50,kV=`[${f9}]`;function _x(e,t,n){return Math.min(n,Math.max(t,e))}function s6(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function _V(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(kV)}function af(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const h9=D.forwardRef(function({side:t,isOpen:n,drawerWidthPx:r,onClose:s,onOpen:i,children:l,pinned:c=!1},u){const{t:f}=qn(),p=t==="left",g=p?-r:r,y=b.useRef(null),v=b.useRef(null),S=b.useRef(n?0:g),A=b.useRef(null),T=b.useRef(null),L=b.useRef(0),I=b.useRef(null),j=b.useRef(null),P=b.useRef(!1),F=b.useRef(null),R=b.useRef(!1),C=b.useRef([]),$=b.useRef(null),Q=b.useRef(S.current),q=b.useRef(n?1:0),V=b.useRef(n);V.current=n;const fe=b.useRef(g);fe.current=g;const X=b.useRef(r);X.current=r;const he=b.useRef(p);he.current=p;const me=b.useRef(s);me.current=s;const de=b.useRef(i);de.current=i;const le=b.useCallback(ae=>{y.current=ae,typeof u=="function"?u(ae):u&&(u.current=ae)},[u]),W=b.useCallback(()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),A.current=null},[]),z=b.useCallback(ae=>{const Ne=X.current;return he.current?(ae+Ne)/Ne:(Ne-ae)/Ne},[]),K=b.useCallback(ae=>{const Ne=v.current;Ne&&(Ne.style.opacity=String(_x(z(ae),0,1)))},[z]),se=b.useCallback(ae=>{S.current=ae;const Ne=y.current;Ne&&(Ne.style.transform=`translateX(${ae}px)`,K(ae))},[K]),ge=b.useCallback(ae=>{A.current=ae,T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null;const Ne=A.current;A.current=null,Ne!==null&&se(Ne)}))},[se]),Ee=b.useCallback(()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null);const ae=A.current;A.current=null,ae!==null&&se(ae)},[se]),pe=b.useCallback(ae=>{const Ne=fe.current;return _x(ae,Math.min(0,Ne),Math.max(0,Ne))},[]),xe=b.useCallback(()=>{const ae=I.current;if(!ae)return null;I.current=null;const Ne=(performance.now()-ae.startTime)/1e3,We={value:ae.solver.value(Ne),velocity:ae.solver.velocity(Ne)};return ae.animations.forEach(Ie=>Ie.cancel()),We},[]),be=b.useCallback(()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)},[]),J=b.useCallback(()=>{$.current?.(),$.current=null},[]),Ke=b.useCallback(()=>{Ee(),be();const ae=xe();ae&&se(pe(ae.value));const Ne=y.current,We=v.current;Ne?.getAnimations().forEach(Ie=>Ie.cancel()),Ne&&(Ne.style.transition="none",Ne.style.opacity="1"),We?.getAnimations().forEach(Ie=>Ie.cancel()),We&&(We.style.transition="none")},[se,be,pe,Ee,xe]),Xe=b.useCallback((ae,Ne)=>{Ee(),be();const We=y.current,Ie=v.current,He=ae?0:fe.current;Ie&&(Ie.style.pointerEvents=ae?"auto":"none");const gt=xe(),bt=gt?pe(gt.value):S.current,vt=Ne?.velocity??gt?.velocity??0;if(dV())return S.current=He,We&&(We.style.transition=`opacity ${kx}ms ease`,We.style.opacity=ae?"1":"0",We.style.transform=`translateX(${He}px)`),Ie&&(Ie.style.transition=`opacity ${kx}ms ease`,Ie.style.opacity=ae?"1":"0"),kx;We&&(We.style.transition="none",We.style.opacity="1"),Ie&&(Ie.style.transition="none");const rn=Math.abs(Ne?.velocity??0)>CV,{frames:Ot,durationMs:un,solver:gr}=pV({dampingRatio:rn?J3.dampingRatio:1,response:J3.response},bt,vt,He,pe);if(!We||Math.abs(bt-He)<.5&&Math.abs(vt)<5)return se(He),0;const dn=We.animate(Ot.map(we=>({transform:`translateX(${we}px)`})),{duration:un,easing:"linear",fill:"forwards"}),wt=[dn];return Ie&&wt.push(Ie.animate(Ot.map(we=>({opacity:String(_x(z(we),0,1))})),{duration:un,easing:"linear",fill:"forwards"})),I.current={solver:gr,startTime:performance.now(),target:He,animations:wt},af("spring start",{startX:bt,startVelocity:vt,targetX:He,frames:Ot.length,durationMs:un}),dn.onfinish=()=>{const we=I.current;!we||!we.animations.includes(dn)||(I.current=null,se(He),we.animations.forEach(rt=>rt.cancel()),af("spring finish",{targetX:He}))},un},[se,be,pe,Ee,z,xe]),nt=b.useCallback(ae=>{Ee();const Ne=ae,We=0,Ie=fe.current,He=S.current+uV(Ne),gt=Math.abs(He-We)<=Math.abs(He-Ie);af("decideSnap",{velocity:Ne,currentX:S.current,projected:He,shouldOpen:gt});const bt=Xe(gt,{velocity:Ne});gt&&!V.current?j.current=window.setTimeout(()=>{j.current=null,de.current?.()},bt+r6):!gt&&V.current&&(j.current=window.setTimeout(()=>{j.current=null,me.current()},bt+r6))},[Xe,Ee]),Se=b.useCallback(ae=>{const Ne=fe.current,We=Math.min(0,Ne),Ie=Math.max(0,Ne),He=X.current;return ae<We?We-e6(We-ae,He):ae>Ie?Ie+e6(ae-Ie,He):ae},[]),Fe=b.useCallback(ae=>{const Ne=C.current,We=performance.now();Ne.push({t:We,x:ae});const Ie=We-120;for(;Ne.length>0&&Ne[0].t<Ie;)Ne.shift()},[]),ue=b.useCallback(()=>{const ae=C.current;if(ae.length<2)return 0;const Ne=ae[ae.length-1];if(performance.now()-Ne.t>60)return 0;const We=ae[0],Ie=(Ne.t-We.t)/1e3;return Ie<.016?0:(Ne.x-We.x)/Ie},[]);b.useEffect(()=>{be();const ae=I.current,Ne=n?0:fe.current;ae&&ae.target===Ne||Xe(n)},[n,Xe,be]),b.useEffect(()=>{Ke(),ge(V.current?0:g)},[g,Ke,ge]),b.useEffect(()=>()=>{W(),be(),xe(),J()},[be,W,J,xe]);const Be=Z3(({active:ae,cancel:Ne,first:We,last:Ie,movement:[He],event:gt})=>{if(af("bindPanel",{active:ae,first:We,last:Ie,mx:He}),!s6(gt)){Ne();return}if(We){if(J(),P.current=!1,F.current=null,C.current=[],_V(gt)){Ne();return}const bt=y.current,vt=bt?wV(gt.target,bt):null;if(!vt||By()){Ne();return}const rn=SV(vt,He,he.current?-1:1);if(af("arbitrate",{owner:rn.kind,mx:He}),rn.kind==="swiper"){$.current=AV(rn.instance),Ne();return}if(rn.kind==="scroller"){const Ot=bV(rn.element);if(Ot)F.current=Ot;else{Ne();return}}F.current||(P.current=!0,Ke(),L.current=S.current)}if(!ae){F.current=null,P.current&&(P.current=!1,nt(ue()));return}if(F.current){yV(F.current,He);return}if(P.current){const bt=Se(L.current+He);Fe(bt),ge(bt)}},{axis:"x",axisThreshold:n6,filterTaps:!0,pointer:{touch:!0}}),$e=Z3(({active:ae,cancel:Ne,first:We,movement:[Ie],event:He})=>{if(!s6(He)){Ne();return}if(V.current){Ne();return}if(We&&(R.current=!0,C.current=[],Ke(),L.current=S.current),!ae){R.current&&(R.current=!1,nt(ue()));return}if(R.current){const gt=Se(L.current+Ie);Fe(gt),ge(gt)}},{axis:"x",axisThreshold:n6,filterTaps:!0,pointer:{touch:!0}}),tt=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),V.current||de.current?.()},[]);return c?o.jsx("aside",{ref:le,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:l}):o.jsxs(o.Fragment,{children:[o.jsx("div",{...$e(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...p?{left:0}:{right:0},width:TV,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:n?"none":"auto"},onClick:tt,"aria-label":f(p?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),o.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:q.current,pointerEvents:n?"auto":"none",transition:"none",willChange:"opacity"},onClick:s,"aria-label":f("sidebar.closeSidebar")}),o.jsx("aside",{...Be(),ref:le,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${p?"border-r border-border/15":"border-l border-border/15"}`,style:{...p?{left:0}:{right:0},width:r,maxWidth:"94vw",transform:`translateX(${Q.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:n?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...p?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})});function LV(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function EV(e,t,n,r="next"){if(e.length===0)return null;const s=t?e.findIndex(i=>i.sessionId===t):-1;for(let i=1;i<=e.length;i+=1){const l=r==="next"?i:-i,c=(s+l+e.length)%e.length,u=e[c];if(u&&n(u))return u.sessionId}return null}function IV(e,t,n="next"){return EV(e,t,LV,n)}const Ta=42,Wm=20,RV=10;function i2(e,t,n){return Math.min(n,Math.max(t,e))}function Rg(e){const t=Math.max(0,e.safeTop??0),n=Math.max(0,e.safeRight??0),r=Math.max(0,e.safeBottom??0),s=Math.max(0,e.safeLeft??0),i=Math.max(0,e.bottomClearance??72),l=s+Wm,c=Math.max(l,e.width-n-Wm-Ta),u=Math.max(t+12,52),f=Math.max(u,e.height-r-i-Ta);return{minX:l,maxX:c,minY:u,maxY:f}}function i6(e,t){const n=Rg(e),r=i2(t.yRatio,0,1);return{x:t.side==="left"?n.minX:n.maxX,y:n.minY+(n.maxY-n.minY)*r}}function Pu(e,t){const n=Rg(e);return{x:i2(t.x,n.minX,n.maxX),y:i2(t.y,n.minY,n.maxY)}}function o6(e,t){const n=Rg(e),r=Pu(e,t),s=(n.minX+n.maxX+Ta)/2,i=r.x+Ta/2<s?"left":"right",l=n.maxY-n.minY;return{position:{x:i==="left"?n.minX:n.maxX,y:r.y},preference:{side:i,yRatio:l>0?(r.y-n.minY)/l:0}}}function a6(e,t,n){const r=Pu(e,t),s=Ta+RV,i=f=>Math.abs(f.x-n.x)<s&&Math.abs(f.y-n.y)<s;if(!i(r))return r;const l=[{...r,y:n.y-s},{...r,y:n.y+s}].map(f=>Pu(e,f)).filter(f=>!i(f)).sort((f,p)=>Math.abs(f.y-r.y)-Math.abs(p.y-r.y));if(l[0])return l[0];const c=Rg(e);return[{...r,x:c.minX},{...r,x:c.maxX}].map(f=>Pu(e,f)).filter(f=>!i(f)).sort((f,p)=>Math.abs(f.x-r.x)-Math.abs(p.x-r.x))[0]??r}const Lx="var(--warning)",NV="var(--success)",l6="var(--tmux)",c6="termdock:mobile-attention-position:v1",u6="termdock:running-session-position:v1",MV={side:"right",yRatio:.68},DV={side:"right",yRatio:.54};function d6(e,t){if(typeof window>"u")return t;try{const n=JSON.parse(window.localStorage.getItem(e)??"null");if(n&&(n.side==="left"||n.side==="right")&&typeof n.yRatio=="number"&&Number.isFinite(n.yRatio))return{side:n.side,yRatio:Math.min(1,Math.max(0,n.yRatio))}}catch{}return t}function jV(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ep(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function lf(e,t){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,r=n?.width??window.innerWidth,s=n?.height??window.innerHeight,i=t?.getBoundingClientRect(),l=!!(i&&i.width>0&&i.height>0);return{width:r,height:s,safeTop:Math.max(Ep("--safe-top-inset"),l?Math.max(0,i.top):0),safeRight:Math.max(Ep("--safe-right-inset"),l?Math.max(0,r-i.right):0),safeBottom:Math.max(Ep("--safe-bottom-inset"),l?Math.max(0,s-i.bottom):0),safeLeft:Math.max(Ep("--safe-left-inset"),l?Math.max(0,i.left):0),bottomClearance:e?Wm:72}}function p9(){const e=ts.getState(),t=Array.from(e.sessions.values()),n=IV(t,e.activeSessionId);if(!n)return;const r=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;r?.agentNeedsReview&&e.clearAgentNeedsReview(r.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:n}))}function f6(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function m9(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function PV({indicator:e,tone:t,size:n}){const r=m9(t);switch(e){case"spinner":return o.jsx(Hn,{size:n,className:"shrink-0 animate-spin",style:{color:r}});case"question":return o.jsx(Tm,{size:n,className:"shrink-0 animate-bounce-y",style:{color:r}});case"badge":return o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:r}});case"terminal":return o.jsx(Sa,{size:n,className:"shrink-0",style:{color:r}});case"pulse":return o.jsx(KR,{size:n,className:"shrink-0 animate-pulse",style:{color:r}});case"ring":return o.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:n,height:n,borderColor:r}});case"dot":return o.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,n-4),height:Math.max(5,n-4),backgroundColor:r}})}}function Bu({agent:e,size:t=12}){const n=t-4;if(!e.icon)return o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:o.jsx(K2,{size:n,className:"text-white"})});let r;return e.isPlugin?(r=`/api/terminal/agent-plugin-icon/${e.slug}`,e.iconVersion&&(r+=`?v=${Math.floor(e.iconVersion)}`)):r=`/icons/agents/${e.icon}.svg`,e.iconMode==="native"?o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:o.jsx("img",{src:r,alt:e.displayName,style:{width:n,height:n}})}):o.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:o.jsx("span",{className:"block bg-white",style:{width:n,height:n,WebkitMask:`url(${r}) center / contain no-repeat`,mask:`url(${r}) center / contain no-repeat`}})})}function BV({sessionMode:e,state:t,size:n=11}){const r=t?.agent?o.jsx(Bu,{agent:t.agent,size:n+1}):e==="tmux"?o.jsx(Mu,{size:n,className:"shrink-0"}):o.jsx(Sa,{size:n,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?o.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:o.jsx(PV,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:n})}):t?.agentStatus==="working"?o.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:o.jsx(Hn,{size:n,className:"shrink-0 animate-spin",style:{color:NV}})}):t?.agentStatus==="waiting"?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Tm,{size:n,className:"shrink-0 animate-bounce-y",style:{color:Lx}})}):t?.agentStatus==="done"&&t.agentNeedsReview?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:Lx}})}):t?.agentNeedsReview?o.jsx("span",{title:t.agentMessage??void 0,children:o.jsx(Yc,{size:n+1,className:"shrink-0 animate-pulse",style:{color:Lx}})}):t?.inCopyMode?e==="tmux"?o.jsx(Mu,{size:n,className:"shrink-0 animate-pulse",style:{color:l6}}):o.jsx(Sa,{size:n,className:"shrink-0 animate-pulse",style:{color:l6}}):r}function FV({status:e,detail:t,needsReview:n,inCopyMode:r}){const{t:s}=qn();return t&&!n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:m9(t.tone)},title:t.label}):e==="working"?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:s("agent.aiRunning")}):e==="waiting"||n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:s(n?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&n?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:s("agent.finishedReview")}):r?o.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:s("agent.copyMode")}):null}function g9({count:e,tone:t,title:n}){const{t:r}=qn();if(e<=0)return null;const s=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",i=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=n??r("agent.jumpToNext");return o.jsxs("button",{type:"button",className:s,title:`${l} · ${r("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${r("agent.jumpToNext")}`,onClick:p9,children:[o.jsx(Yc,{size:11,className:"shrink-0"}),o.jsx("span",{children:r("agent.needsReview")}),o.jsx("span",{className:"tabular-nums",children:e})]})}return o.jsxs("span",{className:s,title:n,children:[o.jsx("span",{className:i}),e]})}function OV({runningCount:e,reviewCount:t,className:n=""}){const r=[];return e>0&&r.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&r.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),r.length===0?null:o.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${r.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${n}`,children:r.map(s=>o.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${s.className}`,children:s.count>9?"9+":s.count},s.key))})}const QV=380,h6=10,Ip=10,Ex=52,$V=104;function HV(e,t,n){const r=t.getBoundingClientRect(),s=window.visualViewport?.width??window.innerWidth,i=window.visualViewport?.height??window.innerHeight,l=r.width>0&&r.height>0,c=l?Math.max(0,r.left):0,u=l?Math.min(s,r.right):s,f=l?Math.max(0,r.top):0,p=l?Math.min(i,r.bottom):i,g=Wm,y=e.x+Ta/2>=c+(u-c)/2,v=y?e.x-Ip-c-g:u-g-e.x-Ta-Ip,S=Math.max(1,Math.min(Math.max(0,v),Math.max(168,n*$V))),A=y?e.x-Ip-S:e.x+Ta+Ip,T=Math.min(Math.max(A,c+g),Math.max(c+g,u-g-S)),L=e.y+Ta/2-Ex/2,I=Math.min(Math.max(L,f+g),Math.max(f+g,p-g-Ex));return{left:T,top:I,width:S,height:Ex,itemWidth:S/Math.max(1,n),side:y?"left":"right"}}function p6(e,t,n,r){return t<e.left||t>e.left+e.width||n<e.top-14||n>e.top+e.height+14?null:Math.min(r-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function UV(e,t){if(e.length===0)return null;const n=t?e.findIndex(r=>r.id===t):-1;return e[(n+1)%e.length]?.id??null}function zV({reviewCount:e,runningSessions:t,activeSessionId:n,runningButtonEnabled:r,isDesktopLayout:s,containerElement:i}){const{t:l}=qn(),c=xt(pe=>pe.leftOpen),u=xt(pe=>pe.rightOpen),{isOpen:f}=pS({enabled:!s}),p=s||!c&&!u&&!f,g=e>0&&p,y=t.length>1||t.length===1&&t[0]?.id!==n,v=r&&t.length>0&&y&&p,S=D.useRef({attention:d6(c6,MV),running:d6(u6,DV)}),A=D.useCallback(()=>{const pe=lf(s,i),xe=i6(pe,S.current.attention),be=i6(pe,S.current.running);return{attention:xe,running:g&&v?a6(pe,be,xe):be}},[g,i,s,v]),[T,L]=D.useState(()=>A()),I=D.useRef(T);I.current=T;const[j,P]=D.useState(null),F=D.useRef(null),[R,C]=D.useState("idle"),[$,Q]=D.useState(null),q=D.useRef(null),V=D.useRef({attention:!1,running:!1});D.useEffect(()=>()=>{const pe=q.current?.longPressTimer;pe!=null&&window.clearTimeout(pe)},[]),D.useEffect(()=>{if(v)return;const pe=q.current?.longPressTimer;pe!=null&&window.clearTimeout(pe),q.current=null,C("idle"),Q(null)},[v]),D.useLayoutEffect(()=>{const pe=()=>{const be=A();I.current=be,L(be)};pe(),window.addEventListener("resize",pe),window.addEventListener("orientationchange",pe),window.visualViewport?.addEventListener("resize",pe);const xe=typeof ResizeObserver>"u"?null:new ResizeObserver(pe);return i&&xe?.observe(i),()=>{window.removeEventListener("resize",pe),window.removeEventListener("orientationchange",pe),window.visualViewport?.removeEventListener("resize",pe),xe?.disconnect()}},[i,A]);const fe=D.useCallback(pe=>pe==="attention"?v:g,[g,v]),X=D.useCallback((pe,xe)=>{if(!fe(pe))return xe;const be=pe==="attention"?"running":"attention";return a6(lf(s,i),xe,I.current[be])},[i,s,fe]),he=D.useCallback((pe,xe,be,J)=>{const Ke=lf(s,i),Xe=xe.moved?Pu(Ke,{x:xe.startX+(be-xe.originX),y:xe.startY+(J-xe.originY)}):I.current[pe],nt=o6(Ke,Xe),Se=X(pe,nt.position),Fe=o6(Ke,Se);S.current[pe]=Fe.preference,jV(pe==="attention"?c6:u6,Fe.preference);const ue={...I.current,[pe]:Fe.position};I.current=ue,L(ue)},[X,i,s]),me=D.useCallback(pe=>{V.current[pe]=!0,window.setTimeout(()=>{V.current[pe]=!1},0)},[]),de=D.useCallback(pe=>{const xe=F.current;!xe||xe.kind!=="attention"||xe.pointerId!==pe.pointerId||(F.current=null,P(null),he("attention",xe,pe.clientX,pe.clientY),xe.moved&&me("attention"))},[he,me]),le={onPointerDown:pe=>{pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId),F.current={kind:"attention",pointerId:pe.pointerId,originX:pe.clientX,originY:pe.clientY,startX:T.attention.x,startY:T.attention.y,moved:!1}},onPointerMove:pe=>{const xe=F.current;if(!xe||xe.kind!=="attention"||xe.pointerId!==pe.pointerId)return;const be=pe.clientX-xe.originX,J=pe.clientY-xe.originY;if(!xe.moved&&Math.hypot(be,J)<5)return;xe.moved=!0,P("attention");const Ke=lf(s,i),Xe=X("attention",Pu(Ke,{x:xe.startX+be,y:xe.startY+J})),nt={...I.current,attention:Xe};I.current=nt,L(nt)},onPointerUp:de,onPointerCancel:de},W=i?HV(T.running,i,t.length):null,z=pe=>{pe.longPressTimer!==null&&(window.clearTimeout(pe.longPressTimer),pe.longPressTimer=null)},K={onPointerDown:pe=>{pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId);const xe=pe.pointerId,be={pointerId:xe,originX:pe.clientX,originY:pe.clientY,startX:T.running.x,startY:T.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};be.longPressTimer=window.setTimeout(()=>{const J=q.current;!J||J.pointerId!==xe||J.mode!=="pressing"||(J.longPressTimer=null,J.mode="dragging",V.current.running=!0,C("dragging"))},QV),q.current=be,C("pressing"),Q(null)},onPointerMove:pe=>{const xe=q.current;if(!xe||xe.pointerId!==pe.pointerId)return;const be=pe.clientX-xe.originX,J=pe.clientY-xe.originY;if(xe.mode==="pressing")if(Math.abs(be)>=h6&&Math.abs(be)>=Math.abs(J))z(xe),xe.mode="selecting",V.current.running=!0,C("selecting");else if(Math.hypot(be,J)>=h6){z(xe),xe.mode="cancelled",V.current.running=!0,C("idle");return}else return;if(xe.mode==="selecting"){const Se=W?p6(W,pe.clientX,pe.clientY,t.length):null;xe.selectedIndex=Se,Q(Se);return}if(xe.mode!=="dragging"||!xe.moved&&Math.hypot(be,J)<5)return;xe.moved=!0;const Ke=lf(s,i),Xe=X("running",Pu(Ke,{x:xe.startX+be,y:xe.startY+J})),nt={...I.current,running:Xe};I.current=nt,L(nt)},onPointerUp:pe=>{const xe=q.current;if(!xe||xe.pointerId!==pe.pointerId)return;z(xe);const be=xe.mode;if(be==="selecting"){const J=W?p6(W,pe.clientX,pe.clientY,t.length):xe.selectedIndex,Ke=J===null?null:t[J]?.id;Ke&&f6(Ke)}else be==="dragging"&&he("running",xe,pe.clientX,pe.clientY);q.current=null,C("idle"),Q(null),be!=="pressing"&&me("running")},onPointerCancel:pe=>{const xe=q.current;!xe||xe.pointerId!==pe.pointerId||(z(xe),q.current=null,C("idle"),Q(null),me("running"))}},se=(pe,xe)=>o.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${xe==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:pe>9?"9+":pe}),ge=()=>{const pe=l("agent.jumpToNext"),xe=T.attention,be=j==="attention";return o.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...le,onClick:J=>{J.stopPropagation(),!V.current.attention&&p9()},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${be?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:xe.x,top:xe.y,width:Ta,height:Ta,touchAction:"none"},"aria-label":`${pe}: ${e}`,title:pe,children:[o.jsx(Yc,{size:17,className:"shrink-0"}),se(e,"attention")]},"attention")},Ee=()=>{const pe=t.length,xe=T.running,be=R==="selecting",J=R==="dragging";return o.jsxs(D.Fragment,{children:[o.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":R,...K,onClick:Ke=>{if(Ke.stopPropagation(),V.current.running)return;const Xe=UV(t,n);Xe&&f6(Xe)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${J?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":be?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:xe.x,top:xe.y,width:Ta,height:Ta,touchAction:"none"},"aria-label":`${l("agent.jumpToNextRunning")}: ${pe}`,title:l("agent.runningSessionGestureHint"),children:[o.jsx(Hn,{size:18,className:"shrink-0 animate-spin"}),se(pe,"running")]}),be&&W&&o.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":W.side,"aria-label":l("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:W.left,top:W.top,width:W.width,height:W.height},children:t.map((Ke,Xe)=>{const nt=Xe===$,Se=Ke.id===n,Fe=`${Ke.label}${Ke.detail?` · ${Ke.detail}`:""}${Se?` · ${l("agent.currentSession")}`:""}`;return o.jsxs("div",{role:"option","aria-selected":nt,"data-running-session-option":Ke.id,"data-selected":nt?"true":"false",title:Fe,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${nt?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":Se?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[o.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${nt?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:Xe+1}),o.jsx("span",{className:"truncate text-[10px] font-medium",children:Ke.label})]},Ke.id)})})]},"running")};return!g&&!v||i===null||typeof document>"u"?null:ia.createPortal(o.jsxs(o.Fragment,{children:[g&&ge(),v&&Ee()]}),document.body)}const GV=450,WV=10,m6=88,g6=36,Rp=10,x6=14;function b6(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function VV(e,t){if(typeof window>"u")return{left:0,top:0};const n=window.visualViewport,r=n?.offsetLeft??0,s=n?.offsetTop??0,i=n?.width??window.innerWidth,l=n?.height??window.innerHeight,c=b6("--safe-top-inset"),u=b6("--safe-bottom-inset"),f=r+Rp,p=r+i-m6-Rp,g=s+c+Rp,y=s+l-u-g6-Rp,v=Math.max(f,Math.min(e-m6/2,Math.max(f,p))),S=t-g6-x6,A=t+x6,T=S>=g?S:A,L=Math.max(g,Math.min(T,Math.max(g,y)));return{left:Math.round(v),top:Math.round(L)}}async function y6(e){if(!e)return;if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>"u")return;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function x0(e){const t=b.useRef(null),n=b.useRef(null),r=b.useRef(!1),s=b.useRef(!1),i=b.useRef(!1),[l,c]=b.useState(null);b.useEffect(()=>{if(!l)return;const v=S=>{const A=S.target;A instanceof HTMLElement&&A.closest('[data-reference-copy-popover="true"]')||(c(null),r.current=!1,s.current=!1)};return document.addEventListener("pointerdown",v,{capture:!0}),()=>document.removeEventListener("pointerdown",v,!0)},[l]);const u=b.useCallback(()=>{t.current!=null&&(window.clearTimeout(t.current),t.current=null)},[]),f=b.useCallback(()=>{u(),n.current=null,r.current=!1},[u]),p=b.useCallback((v,S)=>({onPointerDown:A=>{A.pointerType==="mouse"&&A.button!==0||(f(),n.current={pointerId:A.pointerId,pointerType:A.pointerType,startX:A.clientX,startY:A.clientY,text:v,key:S},t.current=window.setTimeout(()=>{const T=n.current;if(T){if(r.current=!0,s.current=!0,i.current=!1,T.pointerType==="mouse"){y6(T.text).then(()=>e?.(T.key)),t.current=null;return}c({text:T.text,key:T.key,...VV(T.startX,T.startY)}),t.current=null}},GV))},onPointerMove:A=>{const T=n.current;if(!T||T.pointerId!==A.pointerId||r.current)return;const L=A.clientX-T.startX,I=A.clientY-T.startY;Math.hypot(L,I)>WV&&f()},onPointerUp:A=>{const T=n.current;if(!T||T.pointerId!==A.pointerId){f();return}r.current&&(A.preventDefault(),A.stopPropagation(),s.current=!0),f()},onPointerCancel:f,onPointerLeave:A=>{n.current?.pointerId===A.pointerId&&!r.current&&f()},onClickCapture:A=>{s.current&&(s.current=!1,A.preventDefault(),A.stopPropagation())},onContextMenu:A=>{!r.current&&!s.current||(A.preventDefault(),A.stopPropagation())}}),[e,f]),g=b.useCallback(v=>{if(v.preventDefault(),v.stopPropagation(),!l||i.current)return;i.current=!0;const S=l;c(null),r.current=!1,s.current=!1,y6(S.text).then(()=>e?.(S.key))},[e,l]),y=l&&typeof document<"u"?ia.createPortal(b.createElement("button",{type:"button","data-reference-copy-popover":"true",className:"fixed z-modal-backdrop inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:l.left,top:l.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:v=>{v.stopPropagation()},onPointerUp:g,onTouchStart:v=>{v.stopPropagation()},onTouchEnd:g,onClick:g},b.createElement(Z2,{size:14,strokeWidth:2.4}),b.createElement("span",null,"Copy")),document.body):null;return b.useMemo(()=>Object.assign(p,{popoverNode:y}),[p,y])}const qV=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),v6=120,w6=120,YV=new Set,KV={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function Fy(e,t){if(t==="directory")return null;if(W7(e))return o.jsx(jR,{size:14});if(z7(e))return o.jsx(GM,{size:14});const n=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return qV.has(n)?o.jsx(xN,{size:14}):o.jsx(u8,{size:14})}function x9({path:e}){const n=xt(s=>s.changedFiles.get(e))?.status;if(!n)return null;const r=KV[n]??{label:"?",className:"text-muted-foreground",title:n};return o.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${r.className}`,title:r.title,children:r.label})}function a0(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100"}function Oy(e){return a0(e)}const XV=b.memo(function({path:t}){const{t:n}=qn(),[r,s]=b.useState("idle"),[i,l]=b.useState(null),c=b.useCallback(async u=>{if(u.stopPropagation(),r!=="pending"){s("pending"),l(null);try{await W2(t),s("idle")}catch(f){s("error"),l(f instanceof Error?f.message:n("rightSidebar.downloadFailed"))}}},[t,r,n]);return o.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{c(u)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(r==="pending")} ${r==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:r==="error"?i??n("rightSidebar.downloadFailed"):n("rightSidebar.downloadFile"),children:r==="pending"?o.jsx(Hn,{size:12,className:"animate-spin"}):o.jsx(t0,{size:12})})});function b9(){const{t:e}=qn(),[t,n]=b.useState({status:"idle"}),r=b.useCallback(async s=>{n({status:"pending"});try{await W2(s),n({status:"idle"})}catch(i){n({status:"error",message:i instanceof Error?i.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:r}}function o2(e){return e instanceof DOMException&&e.name==="AbortError"}function Vm(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function ZV(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function Qy(e,t,n){if(!t||ZV(e,t))return!0;const r=n.get(e.path);return r?r.some(s=>Qy(s,t,n)):!1}function a2(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function l2(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const JV=b.memo(function e({node:t,depth:n,onFileSelect:r,directoriesOnly:s=!1,onPathReference:i,getReferenceText:l,onReferenceCopied:c,insertedReferenceKey:u,copiedReferenceKey:f,onDirectoryRoot:p,onDirectoryPinToggle:g,onFilePinToggle:y,onOpenInFileBrowser:v,canOpenInFileBrowser:S,pinnedPaths:A,selectedFilePath:T,queryLower:L,onDirectoryDropFiles:I,onFileDeleteRequest:j,deletingFilePath:P,revealedDirectoryPath:F}){const{t:R}=qn(),C=xt(wt=>wt.expandedPaths.has(t.path)),$=xt(wt=>wt.directoryCache.get(t.path)),Q=xt(wt=>wt.showHiddenFiles),q=xt(wt=>wt.toggleExpanded),V=xt(wt=>wt.setDirectoryCache),[fe,X]=b.useState(!1),[he,me]=b.useState(!1),[de,le]=b.useState(!1),W=b.useRef(0),z=b.useRef(null),K=b.useRef(null),se=t.path===T||t.path===F,ge=t.type==="directory"&&(C||!!L),Ee=t.type==="directory",pe=A.has(t.path),xe=!Ee&&!!y,be=!!(S&&v),J=`path:${t.path}`,Ke=u===J,Xe=f===J,nt=l?.(t.path)??t.path,Se=x0(c),{state:Fe,run:ue}=b9(),Be=P===t.path,$e=b.useMemo(()=>{if(!$)return;if(!L)return $;const wt=xt.getState().directoryCache;return $.filter(we=>(!s||we.type==="directory")&&Qy(we,L,wt))},[$,s,L]),tt=b.useCallback(async()=>{if(!xt.getState().directoryCache.has(t.path)&&!fe){const we=`file-tree:${t.path}`;z.current?.abort(),eo(we);const rt=new AbortController;z.current=rt,X(!0);try{const ht=await q7(t.path,rt.signal,Q,"expand_directory",we),Ye=a2(ht.entries);V(t.path,Ye)}catch(ht){o2(ht)}finally{z.current===rt&&(z.current=null),X(!1)}}},[t.path,fe,V,Q]),ae=b.useCallback(async()=>{if(t.type!=="directory"){r(t.path);return}if(s&&p){p(t.path);return}const wt=!xt.getState().expandedPaths.has(t.path);q(t.path),wt&&await tt()},[s,t.path,t.type,tt,p,q,r]);b.useEffect(()=>{t.type==="directory"&&C&&!$&&!fe&&tt()},[$,C,tt,fe,t.type]);const Ne=b.useCallback(wt=>{wt.stopPropagation(),i?.(t.path,J)},[i,t.path,J]),We=b.useCallback(wt=>{wt.stopPropagation(),p?.(t.path),me(!1)},[t.path,p]),Ie=b.useCallback(wt=>{wt.stopPropagation(),g?.(t.path),me(!1)},[t.path,g]),He=b.useCallback(wt=>{wt.stopPropagation(),y?.(t.path),me(!1)},[t.path,y]),gt=b.useCallback(wt=>{wt.stopPropagation(),me(!1),ue(t.path)},[t.path,ue]),bt=b.useCallback(wt=>{wt.stopPropagation(),me(!1),j(t)},[t,j]),vt=b.useCallback(wt=>{wt.stopPropagation(),v?.(t.path),me(!1)},[t.path,v]),rn=b.useCallback(wt=>{!Ee||!I||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),W.current+=1,le(!0))},[Ee,I]),Ot=b.useCallback(wt=>{!Ee||!I||!wt.dataTransfer.types.includes("Files")||(wt.preventDefault(),wt.stopPropagation(),wt.dataTransfer.dropEffect="copy",le(!0))},[Ee,I]),un=b.useCallback(wt=>{!Ee||!I||(wt.preventDefault(),wt.stopPropagation(),W.current-=1,W.current<=0&&(W.current=0,le(!1)))},[Ee,I]),gr=b.useCallback(wt=>{if(!Ee||!I)return;wt.preventDefault(),wt.stopPropagation(),W.current=0,le(!1);const we=Array.from(wt.dataTransfer.files);we.length>0&&I(t.path,we)},[Ee,t.path,I]),dn=b.useCallback(wt=>{wt.stopPropagation(),me(we=>!we)},[]);return b.useEffect(()=>{if(!he)return;const wt=rt=>{const ht=rt.target;ht instanceof Node&&K.current?.contains(ht)||me(!1)},we=rt=>{rt.key==="Escape"&&me(!1)};return document.addEventListener("pointerdown",wt),document.addEventListener("keydown",we),()=>{document.removeEventListener("pointerdown",wt),document.removeEventListener("keydown",we)}},[he]),b.useEffect(()=>()=>{z.current?.abort()},[]),o.jsxs("div",{children:[o.jsxs("div",{ref:K,className:"relative",children:[Se.popoverNode,o.jsxs("div",{"data-file-tree-path":t.path,role:"button",tabIndex:0,onClick:()=>{Vm()||ae()},onKeyDown:wt=>{wt.key!=="Enter"&&wt.key!==" "||(wt.preventDefault(),ae())},onDragEnter:rn,onDragOver:Ot,onDragLeave:un,onDrop:gr,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${de?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":se?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${n*14+8}px`},title:t.path,children:[de&&o.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:R("fileTree.dropToUploadHere")}),t.type==="directory"?o.jsxs(o.Fragment,{children:[ge?o.jsx(sa,{size:14,className:"shrink-0 text-muted-foreground/80"}):o.jsx(wl,{size:14,className:"shrink-0 text-muted-foreground/80"}),ge?o.jsx(Gd,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx("span",{className:se?"text-primary":"text-muted-foreground/80",children:Fy(t.name,t.type)})]}),o.jsxs("span",{className:`min-w-0 flex-1 select-text whitespace-normal break-all text-left leading-snug ${se?"font-medium":""}`,children:[t.name,t.isSymlink&&o.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:R("fileTree.symbolicLink"),children:o.jsx(Al,{size:11})})]}),fe&&o.jsx(Hn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),o.jsx(x9,{path:t.path}),t.type==="directory"&&!s&&(p||g||be)&&o.jsx("span",{onClick:dn,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(he)} ${he?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:R("fileTree.moreDirActions"),children:o.jsx(Kc,{size:13})}),!Ee&&o.jsx("span",{onClick:dn,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(he||Fe.status==="pending"||Be||pe)} ${he?"bg-surface-elevated text-foreground":pe?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:Fe.status==="error"?Fe.message??R("rightSidebar.downloadFailed"):R("fileTree.moreFileActions"),children:Fe.status==="pending"||Be?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Kc,{size:13})}),i&&o.jsx("span",{onClick:Ne,...Se(nt,J),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(Ke||Xe)} ${Ke||Xe?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":R(Xe?"rightSidebar.copied":Ke?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:R(Xe?"rightSidebar.copied":Ke?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:Xe||Ke?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),t.type==="directory"&&!s&&he&&(p||g||be)&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[be&&o.jsxs("button",{type:"button",onClick:vt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openInFileBrowserTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openInFileBrowser")})]}),p&&o.jsxs("button",{type:"button",onClick:We,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openDirRootTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openDirRoot")})]}),g&&o.jsxs("button",{type:"button",onClick:Ie,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${pe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R(pe?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[pe?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R(pe?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!Ee&&he&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[be&&o.jsxs("button",{type:"button",onClick:vt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("fileTree.openInFileBrowserTitle"),children:[o.jsx(u8,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.openInFileBrowser")})]}),o.jsxs("button",{type:"button",onClick:gt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:R("rightSidebar.downloadFile"),children:[o.jsx(t0,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("rightSidebar.downloadFile")})]}),xe&&o.jsxs("button",{type:"button",onClick:He,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${pe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:R(pe?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[pe?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R(pe?"fileTree.unpinFile":"fileTree.pinFile")})]}),o.jsxs("button",{type:"button",onClick:bt,disabled:Be,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:R("fileTree.deleteFile"),children:[Be?o.jsx(Hn,{size:13,className:"shrink-0 animate-spin"}):o.jsx(Pi,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:R("fileTree.deleteFile")})]})]})]}),ge&&$e&&$e.length>0&&o.jsx("div",{className:n===0?"mt-0.5":"",children:$e.map(wt=>o.jsx(e,{node:wt,depth:n+1,onFileSelect:r,directoriesOnly:s,onPathReference:i,getReferenceText:l,onReferenceCopied:c,onDirectoryRoot:p,onDirectoryPinToggle:g,onFilePinToggle:y,onOpenInFileBrowser:v,canOpenInFileBrowser:S,pinnedPaths:A,selectedFilePath:T,queryLower:L,insertedReferenceKey:u,copiedReferenceKey:f,onDirectoryDropFiles:I,onFileDeleteRequest:j,deletingFilePath:P,revealedDirectoryPath:F},wt.path))})]})}),eq=b.memo(function({node:t,rootPath:n,onFileSelect:r,onPathReference:s,getReferenceText:i,onReferenceCopied:l,insertedReferenceKey:c,copiedReferenceKey:u,onDirectoryRoot:f,onDirectoryPinToggle:p,onFilePinToggle:g,pinnedPaths:y,selectedFilePath:v,onFileDeleteRequest:S,deletingFilePath:A}){const{t:T}=qn(),L=t.path===v,I=t.type==="directory",j=y.has(t.path),P=!I&&!!g,F=`path:${t.path}`,R=c===F,C=u===F,$=i?.(t.path)??t.path,Q=x0(l),{state:q,run:V}=b9(),[fe,X]=b.useState(!1),he=b.useRef(null),me=A===t.path,de=b.useCallback(()=>{Vm()||(t.type==="directory"?f?.(t.path):r(t.path))},[t.path,t.type,f,r]),le=b.useCallback(Ee=>{Ee.stopPropagation(),s?.(t.path,F)},[s,t.path,F]),W=b.useCallback(Ee=>{Ee.stopPropagation(),p?.(t.path),X(!1)},[t.path,p]),z=b.useCallback(Ee=>{Ee.stopPropagation(),g?.(t.path),X(!1)},[t.path,g]),K=b.useCallback(Ee=>{Ee.stopPropagation(),X(!1),V(t.path)},[t.path,V]),se=b.useCallback(Ee=>{Ee.stopPropagation(),X(!1),S(t)},[t,S]),ge=b.useCallback(Ee=>{Ee.stopPropagation(),X(pe=>!pe)},[]);return b.useEffect(()=>{if(!fe)return;const Ee=xe=>{const be=xe.target;be instanceof Node&&he.current?.contains(be)||X(!1)},pe=xe=>{xe.key==="Escape"&&X(!1)};return document.addEventListener("pointerdown",Ee),document.addEventListener("keydown",pe),()=>{document.removeEventListener("pointerdown",Ee),document.removeEventListener("keydown",pe)}},[fe]),o.jsxs("div",{ref:he,className:"relative",children:[Q.popoverNode,o.jsxs("div",{role:"button",tabIndex:0,onClick:de,onKeyDown:Ee=>{Ee.key!=="Enter"&&Ee.key!==" "||(Ee.preventDefault(),de())},className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-[14px] shrink-0"}),o.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:Fy(t.name,t.type)})]}),o.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[o.jsxs("span",{className:`block whitespace-normal break-all leading-snug ${L?"font-medium":""}`,children:[t.name,t.isSymlink&&o.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:T("fileTree.symbolicLink"),children:o.jsx(Al,{size:11})})]}),o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/70",children:l2(n,t.path)})]}),o.jsx(x9,{path:t.path}),t.type==="directory"&&p&&o.jsx("span",{onClick:ge,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(fe)} ${fe?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:T("fileTree.moreDirActions"),children:o.jsx(Kc,{size:13})}),!I&&o.jsx("span",{onClick:ge,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-muted-foreground transition active:scale-95 ${a0(fe||q.status==="pending"||me||j)} ${fe?"bg-surface-elevated text-foreground":j?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:q.status==="error"?q.message??T("rightSidebar.downloadFailed"):T("fileTree.moreFileActions"),children:q.status==="pending"||me?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Kc,{size:13})}),s&&o.jsx("span",{onClick:le,...Q($,F),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(R||C)} ${R||C?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":T(C?"rightSidebar.copied":R?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:T(C?"rightSidebar.copied":R?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:C||R?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),t.type==="directory"&&fe&&(f||p)&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[f&&o.jsxs("button",{type:"button",onClick:Ee=>{Ee.stopPropagation(),f(t.path),X(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:T("fileTree.openDirRootTitle"),children:[o.jsx(Gd,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("fileTree.openDirRoot")})]}),o.jsxs("button",{type:"button",onClick:W,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${j?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:T(j?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[j?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T(j?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!I&&fe&&o.jsxs("div",{className:"absolute right-2 top-[calc(100%+2px)] z-30 w-44 overflow-hidden rounded-xl border border-border/15 bg-surface/98 p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",children:[o.jsxs("button",{type:"button",onClick:K,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:T("rightSidebar.downloadFile"),children:[o.jsx(t0,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("rightSidebar.downloadFile")})]}),P&&o.jsxs("button",{type:"button",onClick:z,className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium transition active:scale-[0.99] ${j?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:T(j?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[j?o.jsx(Wc,{size:13,className:"shrink-0"}):o.jsx(gc,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T(j?"fileTree.unpinFile":"fileTree.pinFile")})]}),o.jsxs("button",{type:"button",onClick:se,disabled:me,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:T("fileTree.deleteFile"),children:[me?o.jsx(Hn,{size:13,className:"shrink-0 animate-spin"}):o.jsx(Pi,{size:13,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:T("fileTree.deleteFile")})]})]})]})}),tq=60,S6=60,nq=20;function rq(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),s=[];let i=0,l=n.indexOf(r,i),c=0;for(;l>=0&&r;)l>i&&s.push(e.slice(i,l)),s.push(o.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(l,l+r.length)},`m-${c++}`)),i=l+r.length,l=n.indexOf(r,i);return i<e.length&&s.push(e.slice(i)),s.length>0?s:e}const sq=b.memo(function({entry:t,rootPath:n,selectedFilePath:r,query:s,onContentMatchSelect:i,onPathReference:l,getReferenceText:c,onReferenceCopied:u,insertedReferenceKey:f,copiedReferenceKey:p}){const{t:g}=qn(),[y,v]=b.useState(!0),S=t.path===r,A=y?t.matches.slice(0,nq):[],T=t.matches.length-A.length,L=`path:${t.path}`,I=f===L,j=p===L,P=c?.(t.path)??t.path,F=x0(u);return o.jsxs("div",{className:"rounded",children:[F.popoverNode,o.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Vm()||v(R=>!R)},onKeyDown:R=>{R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),v(C=>!C))},className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] ${S?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[y?o.jsx(sa,{size:14,className:"shrink-0 text-muted-foreground/80"}):o.jsx(wl,{size:14,className:"shrink-0 text-muted-foreground/80"}),o.jsx("span",{className:S?"text-primary":"text-muted-foreground/80",children:Fy(t.name,"file")}),o.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[o.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/70",children:l2(n,t.path)})]}),o.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),o.jsx(XV,{path:t.path}),l&&o.jsx("span",{onClick:R=>{R.stopPropagation(),l(t.path,L)},...F(P,L),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-full text-[11px] font-semibold transition active:scale-95 ${Oy(I||j)} ${I||j?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":g(j?"rightSidebar.copied":I?"rightSidebar.inserted":"fileTree.insertRefTitle"),title:g(j?"rightSidebar.copied":I?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:j||I?o.jsx(Ea,{size:12}):o.jsx(Al,{size:12})})]}),y&&o.jsxs("div",{className:"ml-3 border-l border-border/15 pl-1",children:[A.map((R,C)=>o.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Vm()||i?.(t.path,R.line)},onKeyDown:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),i?.(t.path,R.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${l2(n,t.path)}:${R.line}`,children:[o.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:R.line}),o.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:rq(R.text,s)})]},`${R.line}-${C}`)),T>0&&o.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:g("fileTree.moreMatches",{count:T})})]})]})});function c2({rootPath:e,onFileSelect:t,directoriesOnly:n=!1,onPathReference:r,getReferenceText:s,onReferenceCopied:i,insertedReferenceKey:l,copiedReferenceKey:c,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,onOpenInFileBrowser:g,canOpenInFileBrowser:y=!1,pinnedPaths:v=YV,selectedFilePath:S,query:A="",searchMode:T="name",onContentMatchSelect:L,onDirectoryDropFiles:I,revealDirectory:j}){const{t:P}=qn(),F=xt(ue=>e?ue.directoryCache.get(e):void 0),R=xt(ue=>ue.setDirectoryCache),C=xt(ue=>ue.showHiddenFiles),[$,Q]=b.useState(!1),[q,V]=b.useState(null),[fe,X]=b.useState(!1),[he,me]=b.useState(!1),[de,le]=b.useState(null),[W,z]=b.useState([]),[K,se]=b.useState(null),[ge,Ee]=b.useState(v6),[pe,xe]=b.useState([]),[be,J]=b.useState(null),Ke=b.useRef(null),Xe=A.trim().toLowerCase(),nt=T==="content";b.useEffect(()=>{const ue=j?.path;if(!ue||!ue.startsWith(`${e}/`)&&ue!==e)return;const Be=ue.slice(e.length).replace(/^\/+/,""),$e=Be?Be.split("/"):[],tt=$e.map((bt,vt)=>`${e}/${$e.slice(0,vt+1).join("/")}`),ae=xt.getState(),Ne=tt.filter(bt=>!ae.expandedPaths.has(bt));Ne.length>0&&xt.setState(bt=>({expandedPaths:new Set([...bt.expandedPaths,...Ne])}));let We=!1,Ie=0;const He=()=>{if(We)return;const bt=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(vt=>vt.dataset.fileTreePath===ue);if(bt){bt.scrollIntoView({block:"center",behavior:"smooth"});return}Ie+=1,Ie<80&&window.setTimeout(He,50)},gt=window.requestAnimationFrame(He);return()=>{We=!0,window.cancelAnimationFrame(gt)}},[j?.nonce,j?.path,e]);const Se=b.useCallback(async ue=>{if(!(be||ue.type==="directory")&&window.confirm(P("fileTree.deleteFileConfirm",{name:ue.name}))){J(ue.path);try{await fI(ue.path),xt.getState().applyFileWatchEvents([{type:"deleted",path:ue.path}]),z(Be=>Be.filter($e=>$e.path!==ue.path)),xe(Be=>Be.filter($e=>$e.path!==ue.path)),v.has(ue.path)&&p?.(ue.path)}catch(Be){const $e=Be instanceof Error?Be.message:String(Be);window.alert(P("fileTree.deleteFileFailed",{message:$e}))}finally{J(null)}}},[be,p,v,P]);b.useEffect(()=>{if(!e)return;if(Xe){Q(!1);return}if(xt.getState().directoryCache.has(e)){Q(!1);return}let ue=!1;const Be=new AbortController;return Q(!0),V(null),q7(e,Be.signal,C,"load_file_tree_root",`file-tree-root:${e}`).then($e=>{if(ue)return;const tt=a2($e.entries);X(!!$e.truncated),R(e,tt)}).catch($e=>{ue||o2($e)||V($e instanceof Error?$e.message:"Failed to load directory")}).finally(()=>{ue||Q(!1)}),()=>{ue=!0,Be.abort(),eo(`file-tree-root:${e}`)}},[Xe,F,e,R,C]),b.useEffect(()=>{if(!e||!Xe){me(!1),le(null),z([]),xe([]),se(null);return}let ue=!1;const Be=new AbortController,$e=new Set;me(!0),le(null),z([]),xe([]),Ee(nt?tq:v6),se({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const tt=`file-search:${e}`;return iI(e,A.trim(),ae=>{if(!ue){if(ae.engine&&se(Ne=>({truncated:Ne?.truncated??!1,total:Ne?.total??0,engine:ae.engine,limited:ae.limited??Ne?.limited??!1,done:Ne?.done??!1})),ae.entries?.length){const Ne=ae.entries.filter(We=>$e.has(We.path)?!1:($e.add(We.path),!0));Ne.length>0&&(z(We=>[...We,...a2(Ne)]),se(We=>We?{...We,total:$e.size}:{truncated:!1,total:$e.size,engine:"rg",limited:!1,done:!1}))}if(ae.contentEntries?.length){const Ne=ae.contentEntries.filter(We=>$e.has(We.path)?!1:($e.add(We.path),!0));Ne.length>0&&(xe(We=>[...We,...Ne]),se(We=>We?{...We,total:$e.size}:{truncated:!1,total:$e.size,engine:"rg",limited:!1,done:!1}))}ae.done&&se(Ne=>({truncated:!!ae.truncated,total:typeof ae.total=="number"?ae.total:$e.size,engine:ae.engine??Ne?.engine??"rg",limited:!!ae.limited,done:!0}))}},Be.signal,C,T,tt).catch(ae=>{ue||o2(ae)||(le(ae instanceof Error?ae.message:"Failed to search files"),z([]),xe([]),se(null))}).finally(()=>{ue||me(!1)}),()=>{ue=!0,Be.abort(),eo(tt)}},[A,Xe,e,C,T,nt]),b.useEffect(()=>{if(!Xe)return;const ue=Ke.current;if(!ue)return;const Be=nt?pe.length:W.length,$e=nt?S6:w6,tt=new IntersectionObserver(ae=>{ae.some(Ne=>Ne.isIntersecting)&&Ee(Ne=>Math.min(Ne+$e,Be))},{rootMargin:"160px 0px"});return tt.observe(ue),()=>tt.disconnect()},[Xe,W.length,pe.length,nt]);const Fe=b.useMemo(()=>{if(!F)return;if(!Xe)return n?F.filter(Be=>Be.type==="directory"):F;const ue=xt.getState().directoryCache;return F.filter(Be=>(!n||Be.type==="directory")&&Qy(Be,Xe,ue))},[n,Xe,F]);if(!e)return o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noWorkingDir")});if($)return o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})});if(Xe&&nt){const ue=K?.total??pe.length,Be=pe.slice(0,ge),$e=ge<pe.length;return o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1 text-[10px] text-muted-foreground",children:[o.jsx("span",{children:he?P("fileTree.searchingWithCount",{count:ue}):P("fileTree.contentMatchesCount",{count:ue})}),K&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 uppercase tracking-[0.12em]",children:[he&&o.jsx(Hn,{size:9,className:"animate-spin"}),K.engine,K.limited?" · limited":""]})]}),de?o.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[P("fileTree.contentSearchNeedsRipgrep"),o.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:de})]}):he&&pe.length===0?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})}):pe.length===0?o.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noContentMatches")}):o.jsxs(o.Fragment,{children:[K?.limited&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.searchTruncatedHint",{count:K.total})}),Be.map(tt=>o.jsx(sq,{entry:tt,rootPath:e,selectedFilePath:S,query:A.trim(),onContentMatchSelect:L,onPathReference:r,getReferenceText:s,onReferenceCopied:i,insertedReferenceKey:l,copiedReferenceKey:c},tt.path)),o.jsx("div",{ref:Ke,className:"py-2 text-center text-[11px] text-muted-foreground",children:$e?o.jsx("button",{type:"button",onClick:()=>Ee(tt=>Math.min(tt+S6,pe.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:P("fileTree.loadMoreSearchResults",{shown:Be.length,total:pe.length})}):he?o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Hn,{size:10,className:"animate-spin"}),P("fileTree.searchStillRunning")]}):Be.length>0?o.jsx("span",{children:P("fileTree.showingSearchResults",{shown:Be.length,total:ue})}):null})]})]})}if(Xe){const ue=K?.total??W.length,Be=W.slice(0,ge),$e=ge<W.length;return o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1 text-[10px] text-muted-foreground",children:[o.jsx("span",{children:he?P("fileTree.searchingWithCount",{count:ue}):P("fileTree.searchResults",{count:ue})}),K&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 uppercase tracking-[0.12em]",children:[he&&o.jsx(Hn,{size:9,className:"animate-spin"}),K.engine,K.limited?" · limited":""]})]}),he&&W.length===0?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Hn,{size:20,className:"animate-spin text-muted-foreground"})}):de?o.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:de}):W.length===0?o.jsx("div",{className:"mx-1 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noMatchingFiles")}):o.jsxs(o.Fragment,{children:[K?.limited&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.searchTruncatedHint",{count:K.total})}),Be.map(tt=>o.jsx(eq,{node:tt,rootPath:e,onFileSelect:t,onPathReference:r,getReferenceText:s,onReferenceCopied:i,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,pinnedPaths:v,selectedFilePath:S,insertedReferenceKey:l,copiedReferenceKey:c,onFileDeleteRequest:Se,deletingFilePath:be},tt.path)),o.jsx("div",{ref:Ke,className:"py-2 text-center text-[11px] text-muted-foreground",children:$e?o.jsx("button",{type:"button",onClick:()=>Ee(tt=>Math.min(tt+w6,W.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:P("fileTree.loadMoreSearchResults",{shown:Be.length,total:W.length})}):he?o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(Hn,{size:10,className:"animate-spin"}),P("fileTree.searchStillRunning")]}):Be.length>0?o.jsx("span",{children:P("fileTree.showingSearchResults",{shown:Be.length,total:ue})}):null})]})]})}return q?o.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:q}):!F||F.length===0?o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.emptyDir")}):!Fe||Fe.length===0?o.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface-2 px-4 py-8 text-center text-sm text-muted-foreground",children:P("fileTree.noMatchingFiles")}):o.jsxs("div",{className:"termdock-native-select space-y-px px-2 py-2",children:[fe&&o.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:P("fileTree.truncatedHint")}),Fe.map(ue=>o.jsx(JV,{node:ue,depth:0,onFileSelect:t,directoriesOnly:n,onPathReference:r,getReferenceText:s,onReferenceCopied:i,onDirectoryRoot:u,onDirectoryPinToggle:f,onFilePinToggle:p,onOpenInFileBrowser:g,canOpenInFileBrowser:y,pinnedPaths:v,selectedFilePath:S,queryLower:Xe,insertedReferenceKey:l,copiedReferenceKey:c,onDirectoryDropFiles:I,onFileDeleteRequest:Se,deletingFilePath:be,revealedDirectoryPath:j?.path},ue.path))]})}function u2(e){return e.trim().replace(/\/+$/,"")||"/"}function iq(e){const t=u2(e);if(t==="/")return"/";const n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}function y9({open:e,initialPath:t,title:n,labels:r,onCancel:s,onConfirm:i}){const{t:l}=qn(),c={hint:r?.hint??l("sidebar.directoryPickerHint"),cancel:r?.cancel??l("common.cancel"),confirm:r?.confirm??l("sidebar.useThisFolder"),close:r?.close??l("common.close"),parent:r?.parent??l("rightSidebar.parentFolder")},[u,f]=b.useState(()=>u2(t));return b.useEffect(()=>{e&&f(u2(t))},[t,e]),b.useEffect(()=>{if(!e)return;const p=document.body.style.overflow,g=y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),s())};return document.body.style.overflow="hidden",document.addEventListener("keydown",g,!0),()=>{document.body.style.overflow=p,document.removeEventListener("keydown",g,!0)}},[s,e]),e?ia.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:s,"aria-label":c.cancel}),o.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[o.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[o.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:o.jsx(SN,{size:15})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:n}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:c.hint})]}),o.jsx("button",{type:"button",autoFocus:!0,onClick:s,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":c.close,children:o.jsx(ns,{size:15})})]}),o.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[o.jsx("button",{type:"button",disabled:u==="/",onClick:()=>f(iq(u)),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-30","aria-label":c.parent,children:o.jsx(xg,{size:14})}),o.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-foreground",title:u,children:u})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",children:o.jsx(c2,{rootPath:u,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:f,selectedFilePath:t||null})}),o.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[o.jsx("button",{type:"button",onClick:s,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:c.cancel}),o.jsxs("button",{type:"button",onClick:()=>i(u),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[o.jsx(Ea,{size:13}),c.confirm]})]})]})]}),document.body):null}function oq({directories:e,tmuxAvailable:t,options:n,agents:r,selectedAgent:s,detecting:i,resumeHistory:l,resumeHistoryLoading:c,resumeHistoryPendingId:u,resumeHistoryError:f,onRefreshAgents:p,onSelectAgent:g,onLaunchAgent:y,onResumeHistory:v,onRemoveResumeHistory:S,onClose:A,onOptionsChange:T}){const{t:L,locale:I}=qn(),[j,P]=b.useState(s),[F,R]=b.useState(!1),C=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),$=j?.displayName??"Terminal",Q=s?.displayName??"Terminal",q=j===null?s===null:s?.slug===j.slug;b.useEffect(()=>{const X=he=>{he.key==="Escape"&&(F||A())};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[F,A]);const V=X=>{T({...n,cwd:X}),R(!1)},fe=X=>new Intl.DateTimeFormat(I==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(X));return o.jsxs("section",{className:"relative z-20 flex max-h-[min(56svh,36rem)] shrink-0 flex-col overflow-hidden border-t border-border/25 bg-surface-elevated shadow-[0_-18px_42px_var(--app-shadow-soft)] animate-slide-down","aria-label":L("sidebar.newSessionComposerTitle"),children:[o.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 pb-2 pt-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[o.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:o.jsx(Sa,{size:14})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:L("sidebar.newSessionComposerTitle")}),o.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:L("sidebar.newSessionHint")})]})]}),o.jsx("button",{type:"button",onClick:A,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":L("common.close"),children:o.jsx(ns,{size:14})})]}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 pb-3",children:[o.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:L("sidebar.sessionMode")}),n.mode==="tmux"&&o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L("sidebar.tmuxKeepsRunning")})]}),o.jsx("div",{className:"mt-1.5 grid grid-cols-2 gap-1 rounded-lg bg-surface-2 p-1",children:["shell","tmux"].map(X=>o.jsx("button",{type:"button",disabled:X==="tmux"&&!t,onClick:()=>T({...n,mode:X}),"aria-pressed":n.mode===X,title:X==="tmux"&&!t?L("sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-2 py-1.5 text-[11px] font-medium transition ${n.mode===X?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:L(X==="shell"?"sidebar.newShell":"sidebar.newTmux")},X))}),o.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:"Agent"}),o.jsxs("button",{type:"button",onClick:p,disabled:i,className:"inline-flex min-h-8 items-center gap-1 px-1 text-[10px] text-muted-foreground transition hover:text-foreground disabled:opacity-50",title:L("sidebar.detectAgents"),children:[o.jsx(si,{size:10,className:i?"animate-spin":""}),L("sidebar.detectAgents")]})]}),o.jsxs("label",{className:"relative mt-1 flex min-h-11 cursor-pointer items-center gap-2.5 rounded-lg border border-border/30 bg-surface px-3 text-foreground transition hover:bg-surface-2 focus-within:border-primary/50",children:[j?o.jsx(Bu,{agent:j,size:16}):o.jsx(Sa,{size:14,className:"shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",children:$}),q&&o.jsx("span",{className:"shrink-0 text-[9.5px] text-muted-foreground",children:L("sidebar.defaultAgent")}),i?o.jsx(Hn,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}):o.jsx(sa,{size:13,className:"shrink-0 text-muted-foreground"}),o.jsxs("select",{"aria-label":"Agent",value:j?.slug??"__terminal__",onChange:X=>{const he=X.target.value;P(he==="__terminal__"?null:r.find(me=>me.slug===he)??null)},className:"absolute inset-0 h-full w-full cursor-pointer opacity-0",children:[o.jsx("option",{value:"__terminal__",children:"Terminal"}),r.map(X=>o.jsx("option",{value:X.slug,children:X.displayName},X.slug))]})]}),!q&&o.jsxs("div",{className:"mt-1 flex min-h-8 items-center justify-between gap-2 px-0.5 text-[10px]",children:[o.jsx("span",{className:"truncate text-muted-foreground",children:L("sidebar.currentDefaultAgent",{name:Q})}),o.jsx("button",{type:"button",onClick:()=>g(j),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:L("sidebar.makeDefault")})]}),o.jsx("label",{htmlFor:"new-session-directory",className:"mt-2.5 block text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:L("sidebar.workingDirectory")}),o.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>R(!0),className:"mt-1 flex h-9 w-full items-center gap-2 rounded-lg border border-border/25 bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary/50",children:[o.jsx(Xc,{size:12,className:"shrink-0 text-muted-foreground"}),o.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${n.cwd?"":"text-muted-foreground"}`,children:n.cwd||L("sidebar.directoryPlaceholder")})]}),C.length>0&&o.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":L("sidebar.recentDirectories"),children:C.map(X=>o.jsx("button",{type:"button",onClick:()=>V(X),title:X,className:"min-h-8 shrink-0 rounded-md bg-surface-2 px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:yc(X)||X},X))}),(l.length>0||f)&&o.jsxs("details",{className:"mt-3 border-t border-border/15 pt-2",children:[o.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[o.jsx(gf,{size:11}),o.jsx("span",{className:"flex-1",children:L("sidebar.resumeHistory")}),c&&o.jsx(Hn,{size:10,className:"animate-spin"}),l.length>0&&o.jsx("span",{className:"normal-case tracking-normal",children:L("sidebar.resumeHistoryCount",{n:l.length})}),o.jsx(sa,{size:11})]}),l.length>0&&o.jsx("div",{className:"mt-1 divide-y divide-border/10 overflow-hidden rounded-lg border border-border/15 bg-surface",children:l.slice(0,6).map(X=>{const he=u===X.id;return o.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[o.jsxs("button",{type:"button",disabled:u!==null,onClick:()=>v(X),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":L("sidebar.resumeHistoryAction",{title:X.title}),children:[o.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:he?o.jsx(Hn,{size:13,className:"animate-spin"}):o.jsx(Bu,{agent:X.agent,size:14})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:X.title}),o.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[X.agent.displayName," · ",fe(X.closedAt)]})]}),o.jsx(m8,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),o.jsxs("button",{type:"button",disabled:u!==null,onClick:()=>S(X.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":L("sidebar.resumeHistoryRemove",{title:X.title}),children:[o.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),o.jsx(Pi,{size:12})]})]},X.id)})}),f&&o.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:f})]})]}),o.jsx("div",{className:"shrink-0 border-t border-border/15 bg-surface-elevated p-3",children:o.jsxs("button",{type:"button",onClick:()=>y(j),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground shadow-md shadow-primary/20 transition hover:bg-primary/90 active:scale-[0.99]","aria-label":L("sidebar.launchSessionWith",{name:$}),children:[j?o.jsx(Bu,{agent:j,size:15}):o.jsx(Sa,{size:14}),o.jsx("span",{className:"truncate",children:L("sidebar.launchSessionWith",{name:$})})]})}),o.jsx(y9,{open:F,initialPath:n.cwd?.trim()||C[0]||"/",title:L("sidebar.chooseDirectory"),onCancel:()=>R(!1),onConfirm:V})]})}const v9="termdock:new-session-agent:v1";function aq(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(v9)||"null");return!e||typeof e.slug!="string"||typeof e.command!="string"?null:{slug:e.slug,command:e.command,displayName:typeof e.displayName=="string"?e.displayName:e.slug,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(t=>typeof t=="string"):void 0,accentColor:typeof e.accentColor=="string"?e.accentColor:"var(--muted-foreground)",icon:typeof e.icon=="string"?e.icon:null,isPlugin:e.isPlugin===!0,iconMode:e.iconMode==="native"?"native":e.iconMode==="mask"?"mask":void 0,iconVersion:typeof e.iconVersion=="number"?e.iconVersion:void 0}}catch{return null}}function Ix(e){if(!(typeof window>"u"))try{window.localStorage.setItem(v9,JSON.stringify(e))}catch{}}function lq(e,t){return e?t.find(n=>n.slug===e)??null:null}function cq(){const[e,t]=b.useState(aq),[n,r]=b.useState([]),[s,i]=b.useState(!0),l=b.useCallback(async()=>{i(!0);try{const[u,f]=await Promise.all([ug(),Q7()]),p=lq(u.newSessionAgentSlug,f);r(f),t(p),Ix(p)}finally{i(!1)}},[]);b.useEffect(()=>{l().catch(()=>{})},[l]);const c=b.useCallback(async u=>{const f=e;t(u),Ix(u);try{await Va({newSessionAgentSlug:u?.slug??null})}catch(p){throw t(f),Ix(f),p}},[e]);return{preference:e,agents:n,detecting:s,refresh:l,selectAgent:c}}const Ka="w-full rounded-lg border border-border/20 bg-surface-2 px-3 py-2 text-[12px] text-foreground outline-none transition focus:border-primary/60",Gs="inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[12px] font-medium transition disabled:cursor-not-allowed disabled:opacity-40";function uq({activeSessionId:e,onClose:t,onNewSession:n}){const[r,s]=b.useState("automation"),[i,l]=b.useState([]),[c,u]=b.useState([]),[f,p]=b.useState([]),[g,y]=b.useState([]),[v,S]=b.useState([]),[A,T]=b.useState(null),[L,I]=b.useState(null),[j,P]=b.useState(null),F=b.useCallback(async(R={})=>{R.silent||I(null);try{const[C,$,Q]=await Promise.all([TI(),EI(),Q7()]);l(C.automations),u(C.runs),y($.groups),S($.sessions),p(Q)}catch(C){R.silent||I(C instanceof Error?C.message:"加载失败")}},[]);return b.useEffect(()=>{F();const R=window.setInterval(()=>{F({silent:!0})},1e4);return()=>window.clearInterval(R)},[F]),b.useEffect(()=>{const R=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t]),ia.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t,"aria-label":"关闭 Agent 工作台"}),o.jsxs("section",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[8%] sm:bottom-auto sm:max-h-[84vh]",children:[o.jsxs("header",{className:"flex items-center gap-2 border-b border-border/15 px-4 py-3",children:[o.jsx(K2,{size:17,className:"text-primary"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:"Agent 工作台"}),o.jsx("p",{className:"text-[10px] text-muted-foreground",children:"自动任务、会话协作与全文恢复"})]}),o.jsx("button",{className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:t,"aria-label":"关闭",children:o.jsx(ns,{size:16})})]}),o.jsx("nav",{className:"flex gap-1 border-b border-border/15 px-3 py-2",children:[["automation",X2,"自动任务"],["collaboration",Al,"会话协作"],["search",ql,"全文搜索"]].map(([R,C,$])=>o.jsxs("button",{onClick:()=>s(R),className:`${Gs} ${r===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[o.jsx(C,{size:14}),$]},R))}),L&&o.jsx("div",{className:"mx-4 mt-3 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:L}),j&&o.jsxs("div",{className:"mx-4 mt-3 flex items-center gap-2 rounded-lg bg-primary/10 px-3 py-2 text-[11px] text-primary",children:[o.jsx(Ea,{size:13}),j]}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[r==="automation"&&o.jsx(dq,{automations:i,runs:c,agents:f,sessions:v,activeSessionId:e,busy:A,setBusy:T,setError:I,setNotice:P,refresh:F,onClose:t}),r==="collaboration"&&o.jsx(hq,{groups:g,sessions:v,activeSessionId:e,busy:A,setBusy:T,setError:I,setNotice:P,refresh:F}),r==="search"&&o.jsx(gq,{onClose:t,onNewSession:n,setError:I})]})]})]}),document.body)}function dq({automations:e,runs:t,agents:n,sessions:r,activeSessionId:s,busy:i,setBusy:l,setError:c,setNotice:u,refresh:f,onClose:p}){const[g,y]=b.useState(null),[v,S]=b.useState(!1),[A,T]=b.useState(null),L=async(I,j,P)=>{l(I),c(null),u(null);try{await j(),await f(),u(P)}catch(F){c(F instanceof Error?F.message:"操作失败")}finally{l(null)}};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"自动任务"}),o.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"按计划把任务交给 Agent。每次运行都有独立会话和结果入口。"})]}),!v&&e.length>0&&o.jsxs("button",{className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{y(null),S(!0),u(null)},children:[o.jsx(Oo,{size:13}),"新建任务"]})]}),v&&o.jsx(fq,{agents:n,sessions:r,activeSessionId:s,initial:g,onCancel:()=>{y(null),S(!1)},onSaved:async I=>{y(null),S(!1),await f(),u(g?`“${I}”已更新`:`“${I}”已创建,将按计划自动运行`)},setError:c}),e.length===0&&!v&&o.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[o.jsx(OR,{size:24,className:"mx-auto text-primary"}),o.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"把重复工作交给 Agent"}),o.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[11px] leading-relaxed text-muted-foreground",children:"选择运行会话、写清任务内容,再设定时间。创建后可以先手动运行一次确认效果。"}),o.jsxs("button",{className:`${Gs} mt-4 bg-primary text-primary-foreground`,onClick:()=>S(!0),children:[o.jsx(Oo,{size:13}),"创建第一个任务"]})]}),o.jsx("div",{className:"space-y-2",children:e.map(I=>{const j=t.find(F=>F.automationId===I.id),P=n.find(F=>F.command===I.command);return o.jsxs("article",{className:"rounded-xl border border-border/15 bg-surface-2/40 p-3 transition hover:border-border/30",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:I.name}),o.jsx("span",{className:`rounded-full px-2 py-0.5 text-[9px] ${I.enabled?"bg-primary/10 text-primary":"bg-surface-elevated text-muted-foreground"}`,children:I.enabled?"已启用":"已停用"}),I.lastRunStatus&&o.jsx("span",{className:`text-[10px] ${wq(I.lastRunStatus)}`,children:vq(I.lastRunStatus)})]}),o.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-muted-foreground",children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(X2,{size:11}),bq(I)]}),o.jsx("span",{children:I.enabled&&I.nextRunAt?`下次 ${Ym(I.nextRunAt)}`:"不会自动运行"})]}),o.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:I.targetSessionId?`发送到 ${r.find(F=>F.sessionId===I.targetSessionId)?.name??"指定会话"}`:`新建 ${P?.displayName??"Agent"} 会话 · ${I.cwd}`}),o.jsx("p",{className:"mt-2 line-clamp-2 text-[11px] leading-relaxed text-foreground/80",children:I.prompt}),I.lastRunAt&&o.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground",children:["上次 ",Ym(I.lastRunAt),I.lastRunMessage?` · ${I.lastRunMessage}`:""]})]}),o.jsx("button",{"aria-label":`编辑 ${I.name}`,title:"编辑",className:"rounded-lg p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",onClick:()=>{y(I),S(!0),u(null)},children:o.jsx(p8,{size:13})})]}),o.jsx("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border/10 pt-3",children:A===I.id?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mr-auto text-[10px] text-destructive",children:"删除后不会再自动运行"}),o.jsx("button",{className:`${Gs} bg-surface-elevated text-foreground`,onClick:()=>T(null),children:"取消"}),o.jsxs("button",{disabled:i!==null,className:`${Gs} bg-destructive text-destructive-foreground`,onClick:()=>{L(`delete:${I.id}`,()=>LI(I.id),`“${I.name}”已删除`).then(()=>T(null))},children:[i===`delete:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Pi,{size:13}),"确认删除"]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:`${Gs} mr-auto px-2 text-destructive hover:bg-destructive/10`,onClick:()=>T(I.id),children:[o.jsx(Pi,{size:13}),"删除"]}),o.jsxs("button",{disabled:i!==null,className:`${Gs} ${I.enabled?"bg-surface-elevated text-foreground":"bg-primary/15 text-primary"}`,onClick:()=>{L(`toggle:${I.id}`,()=>_I(I.id,!I.enabled),I.enabled?`“${I.name}”已暂停,不会自动运行`:`“${I.name}”已恢复,将按原计划运行`)},children:[i===`toggle:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):I.enabled?o.jsx(f8,{size:13}):o.jsx(Sb,{size:13}),I.enabled?"暂停":"恢复"]}),j?.frontendSessionId&&o.jsxs("button",{className:`${Gs} bg-surface-elevated text-foreground`,onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:j.frontendSessionId})),p()},children:[o.jsx(fN,{size:13}),"打开上次会话"]}),o.jsxs("button",{disabled:i!==null,className:`${Gs} bg-primary/15 text-primary`,onClick:()=>{L(`run:${I.id}`,()=>kI(I.id),`“${I.name}”已投递,可打开会话查看进度`)},children:[i===`run:${I.id}`?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Sb,{size:13}),"立即运行"]})]})})]},I.id)})})]})}function fq({agents:e,sessions:t,activeSessionId:n,initial:r,onCancel:s,onSaved:i,setError:l}){const[c,u]=b.useState(r?.name??""),f=t.find(J=>J.sessionId===n),p=r?.cwd??f?.cwd??t[0]?.cwd??"",[g,y]=b.useState(p),[v,S]=b.useState(!1),[A,T]=b.useState(()=>e.find(J=>J.command===r?.command)?.slug??""),[L,I]=b.useState(r?.prompt??""),[j,P]=b.useState(r?.targetSessionId??""),[F,R]=b.useState(r?.targetSessionId?"existing":"new"),[C,$]=b.useState(r?.schedule.kind??"interval"),[Q,q]=b.useState(r?.schedule.kind==="interval"?r.schedule.everyMinutes:60),[V,fe]=b.useState(r?.schedule.kind==="daily"?r.schedule.time:"09:00"),[X,he]=b.useState(r?.schedule.kind==="daily"?r.schedule.weekdays:[1,2,3,4,5]),[me,de]=b.useState(r?.enabled??!0),[le,W]=b.useState(!1),K=(e.find(J=>J.slug===A)??null)?.command??r?.command??"";b.useEffect(()=>{!r&&!A&&e[0]&&T(e[0].slug)},[e,r,A]);const se=async()=>{W(!0),l(null);try{await CI({id:r?.id,name:c,cwd:g,command:F==="new"?K:"",prompt:L,targetSessionId:F==="existing"&&j||null,enabled:me,schedule:C==="interval"?{kind:C,everyMinutes:Q}:{kind:C,time:V,weekdays:X}}),await i(c.trim())}catch(J){l(J instanceof Error?J.message:"保存失败")}finally{W(!1)}},ge=C==="interval"?{kind:C,everyMinutes:Q}:{kind:C,time:V,weekdays:X},[Ee,pe]=V.split(":"),xe=(J,Ke)=>fe(`${J}:${Ke}`),be=!!(c.trim()&&L.trim()&&(F==="existing"?j:K)&&(C==="interval"?Q>=1:X.length>0));return o.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/25 bg-primary/5",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-primary/15 px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-[13px] font-medium text-foreground",children:r?"编辑自动任务":"创建自动任务"}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"三步完成,保存后可立即试跑"})]}),o.jsx("button",{className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:s,"aria-label":"关闭任务表单",children:o.jsx(ns,{size:14})})]}),o.jsxs("div",{className:"space-y-5 p-4",children:[o.jsxs("fieldset",{className:"space-y-3",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"1"}),"要做什么"]}),o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务名称",o.jsx("input",{autoFocus:!0,className:Ka,value:c,onChange:J=>u(J.target.value),placeholder:"例如:每日代码巡检"})]}),o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["任务内容",o.jsx("textarea",{className:`${Ka} min-h-24 resize-y`,value:L,onChange:J=>I(J.target.value),placeholder:"说明目标、检查范围和期望产出,例如:检查当前分支的测试与待办,修复可安全处理的问题并总结结果。"})]})]}),o.jsxs("fieldset",{className:"space-y-3 border-t border-border/10 pt-4",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"2"}),"在哪里运行"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button","aria-pressed":F==="new",className:`${Gs} justify-start border px-3 text-left ${F==="new"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>R("new"),children:"每次新建会话"}),o.jsx("button",{type:"button","aria-pressed":F==="existing",disabled:t.length===0,className:`${Gs} justify-start border px-3 text-left ${F==="existing"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>{R("existing"),j||P(n??t[0]?.sessionId??"")},children:"发送到现有会话"})]}),F==="new"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[o.jsxs("label",{className:"space-y-1 text-[10px] text-muted-foreground",children:["Agent / Plugin",o.jsxs("select",{className:Ka,value:A,onChange:J=>T(J.target.value),children:[r&&!e.some(J=>J.command===r.command)&&o.jsx("option",{value:"",children:"原 Agent 当前不可用"}),e.map(J=>o.jsxs("option",{value:J.slug,children:[J.displayName,J.isPlugin?" · Plugin":""]},J.slug))]})]}),o.jsxs("label",{className:"space-y-1 text-[10px] text-muted-foreground",children:["工作目录",o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{className:Ka,value:g,onChange:J=>y(J.target.value),placeholder:"默认使用当前目录"}),o.jsxs("button",{type:"button","aria-haspopup":"dialog",className:`${Gs} shrink-0 bg-surface-2 text-foreground`,onClick:()=>S(!0),children:[o.jsx(Gd,{size:13}),"选择"]})]})]})]}),e.length===0&&o.jsx("p",{className:"text-[10px] text-destructive",children:"没有检测到可启动的 Agent。请先在 Plugin 设置中安装或配置 Agent。"})]}):o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["目标会话",o.jsx("select",{className:Ka,value:j,onChange:J=>P(J.target.value),children:t.map(J=>o.jsxs("option",{value:J.sessionId,children:[J.name," · ",J.status]},J.sessionId))}),o.jsx("span",{className:"block leading-relaxed",children:"运行时该会话需要在线,并且 Agent 处于可接收任务的状态。"})]})]}),o.jsxs("fieldset",{className:"space-y-3 border-t border-border/10 pt-4",children:[o.jsxs("legend",{className:"text-[11px] font-medium text-foreground",children:[o.jsx("span",{className:"mr-2 text-primary",children:"3"}),"什么时候运行"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button","aria-pressed":C==="interval",className:`${Gs} border ${C==="interval"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>$("interval"),children:"固定间隔"}),o.jsx("button",{type:"button","aria-pressed":C==="daily",className:`${Gs} border ${C==="daily"?"border-primary/40 bg-primary/10 text-primary":"border-border/15 bg-surface-2 text-muted-foreground"}`,onClick:()=>$("daily"),children:"指定日期与时间"})]}),C==="interval"?o.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["每隔多少分钟",o.jsx("input",{className:Ka,type:"number",min:1,max:43200,value:Q,onChange:J=>q(Number(J.target.value))}),o.jsx("span",{className:"block",children:"例如 60 = 每小时,1440 = 每天。始终按任务创建时间计算,之后编辑不会重置节奏。"})]}):o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"运行时间"}),o.jsxs("div",{className:"mt-1 flex items-center rounded-xl border border-border/20 bg-surface-2 px-3 py-2.5 focus-within:border-primary/60",children:[o.jsx(X2,{size:15,className:"mr-3 shrink-0 text-primary"}),o.jsx(A6,{label:"小时",value:Ee,options:24,onChange:J=>xe(J,pe)}),o.jsx("span",{"aria-hidden":"true",className:"px-2 text-[18px] font-medium text-muted-foreground",children:":"}),o.jsx(A6,{label:"分钟",value:pe,options:60,onChange:J=>xe(Ee,J)}),o.jsx("span",{className:"ml-3 shrink-0 rounded-md bg-surface-elevated px-2 py-1 text-[9px] font-medium text-muted-foreground",children:"24 小时制"})]})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"运行日期"}),o.jsx("div",{className:"mt-1 grid grid-cols-7 gap-1",children:["日","一","二","三","四","五","六"].map((J,Ke)=>{const Xe=X.includes(Ke);return o.jsx("button",{type:"button","aria-pressed":Xe,"aria-label":`星期${J}`,className:`rounded-lg py-2.5 text-[10px] transition ${Xe?"bg-primary text-primary-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,onClick:()=>he(nt=>Xe?nt.filter(Se=>Se!==Ke):[...nt,Ke].sort()),children:J},Ke)})}),X.length===0&&o.jsx("p",{className:"mt-1 text-[10px] text-destructive",children:"至少选择一天"})]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-3 border-t border-primary/15 bg-surface/50 px-4 py-3 sm:flex-row sm:items-center",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[o.jsx("input",{type:"checkbox",checked:me,onChange:J=>de(J.target.checked)}),"保存后启用"]}),o.jsx("p",{className:"mt-1 truncate text-[10px] text-muted-foreground",children:me&&be?`${r?"下次运行":"首次运行"}:${Ym(yq(ge,Date.now(),r?.createdAt))}`:me?"填写完整后显示首次运行时间":"任务会保存,但不会自动运行"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{className:`${Gs} bg-surface-2 text-foreground`,onClick:s,children:"取消"}),o.jsx("button",{disabled:le||!be,className:`${Gs} bg-primary text-primary-foreground`,onClick:()=>{se()},children:le?"保存中…":r?"保存修改":"创建任务"})]})]}),o.jsx(y9,{open:v,initialPath:g||p||"/",title:"选择工作目录",labels:{hint:"进入文件夹,确认后才会更改工作目录。",cancel:"取消",confirm:"使用此目录",close:"关闭",parent:"上一级目录"},onCancel:()=>S(!1),onConfirm:J=>{y(J),S(!1)}})]})}function A6({label:e,value:t,options:n,onChange:r}){return o.jsxs("label",{className:"relative min-w-0 flex-1",children:[o.jsx("span",{className:"sr-only",children:e}),o.jsx("select",{"aria-label":e,className:"w-full appearance-none bg-transparent py-1 pl-1 pr-7 text-center text-[18px] font-semibold tabular-nums text-foreground outline-none",value:t,onChange:s=>r(s.target.value),children:Array.from({length:n},(s,i)=>{const l=String(i).padStart(2,"0");return o.jsx("option",{value:l,children:l},l)})}),o.jsx(sa,{"aria-hidden":"true",size:13,className:"pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground"})]})}function hq({groups:e,sessions:t,activeSessionId:n,busy:r,setBusy:s,setError:i,setNotice:l,refresh:c}){const[u,f]=b.useState(""),[p,g]=b.useState(()=>new Set(n?[n]:[])),[y,v]=b.useState(e[0]?.id??null),[S,A]=b.useState(""),[T,L]=b.useState(!1),[I,j]=b.useState([]),[P,F]=b.useState("*"),[R,C]=b.useState("message"),[$,Q]=b.useState(""),q=y==="new"?null:e.find(z=>z.id===y)??e[0]??null,V=new Set(t.map(z=>z.sessionId)),fe=[...p].filter(z=>V.has(z)).length,X=S.trim().toLocaleLowerCase(),he=t.filter(z=>!X||[z.name,z.cwd,Rx(z.currentTask)].some(K=>K.toLocaleLowerCase().includes(X)));b.useEffect(()=>{!y&&e[0]&&v(e[0].id)},[e,y]),b.useEffect(()=>{if(!q){j([]);return}let z=!1;const K=()=>{i5(q.id).then(ge=>{z||j(ge.messages)}).catch(ge=>{z||i(ge instanceof Error?ge.message:"消息加载失败")})};K();const se=window.setInterval(K,3e3);return()=>{z=!0,window.clearInterval(se)}},[q?.id,i]);const me=async()=>{s("create-group"),i(null),l(null);try{const z=[...p].filter(se=>V.has(se)),K=await II({name:u,sessionIds:z});f(""),A(""),v(K.group.id),await c(),l(`“${K.group.name}”已创建,${K.group.sessionIds.length} 个会话可以开始协作`)}catch(z){i(z instanceof Error?z.message:"创建失败")}finally{s(null)}},de=async()=>{if(q){s("send-message"),i(null),l(null);try{const z=await NI(q.id,{fromSessionId:null,toSessionIds:P==="*"?void 0:[P],kind:R,content:$});Q(""),j((await i5(q.id)).messages),l(`消息已发送给 ${z.messages.length} 个会话`)}catch(z){i(z instanceof Error?z.message:"发送失败")}finally{s(null)}}},le=async()=>{if(!q)return;s(`delete:${q.id}`),i(null),l(null);const z=q.name;try{await RI(q.id),v(null),L(!1),await c(),l(`“${z}”已删除`)}catch(K){i(K instanceof Error?K.message:"删除失败")}finally{s(null)}},W=mq(I,t);return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"会话协作"}),o.jsx("p",{className:"mt-1 max-w-xl text-[11px] leading-relaxed text-muted-foreground",children:"创建协作组后,一个 Agent 会话可以把任务直接交给另一个会话。比如“开发”写完代码后通知“测试”检查,测试结果再回复回来;你也可以给单个会话或全组发任务,所有交接和进展都记录在这里。"})]}),q&&o.jsxs("button",{className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{v("new"),L(!1),l(null)},children:[o.jsx(Oo,{size:13}),"新建组"]})]}),e.length>0&&o.jsx("div",{className:"flex gap-2 overflow-x-auto border-b border-border/15 pb-3",children:e.map(z=>o.jsxs("button",{onClick:()=>v(z.id),className:`${Gs} shrink-0 ${q?.id===z.id?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:[z.name,o.jsx("span",{className:"text-[9px] opacity-70",children:z.sessionIds.length})]},z.id))}),!q&&o.jsxs("section",{className:"border-y border-border/15 py-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),o.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"至少选择两个会话。离线成员会在重新上线后收到消息;已从列表移除的会话不会提交。"})]}),o.jsxs("span",{className:`shrink-0 text-[10px] ${fe>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",fe," 个"]})]}),o.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",o.jsx("input",{className:Ka,value:u,onChange:z=>f(z.target.value),placeholder:"例如:发布准备"})]}),t.length>5&&o.jsxs("label",{className:"relative mt-3 block",children:[o.jsx("span",{className:"sr-only",children:"筛选会话"}),o.jsx(ql,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{className:`${Ka} pl-8`,value:S,onChange:z=>A(z.target.value),placeholder:"按名称、目录或当前任务筛选"})]}),o.jsxs("div",{className:"mt-3 max-h-64 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[he.map(z=>o.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-2 py-2.5 transition hover:bg-surface-2",children:[o.jsx("input",{className:"mt-0.5",type:"checkbox",checked:p.has(z.sessionId),onChange:()=>g(K=>{const se=new Set(K);return se.has(z.sessionId)?se.delete(z.sessionId):se.add(z.sessionId),se})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"truncate text-[12px] text-foreground",children:z.name}),o.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:T6(z.status)})]}),o.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[Rx(z.currentTask)," · ",z.cwd]})]})]},z.sessionId)),t.length===0&&o.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"暂无可选会话,请先打开两个会话"}),t.length>0&&he.length===0&&o.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]}),o.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[o.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${fe<2?"text-muted-foreground":"text-primary"}`,children:fe<2?`还需选择 ${2-fe} 个会话`:"成员已满足要求,可以创建"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[e.length>0&&o.jsx("button",{className:`${Gs} bg-surface-2 text-foreground`,onClick:()=>v(e[0]?.id??null),children:"取消"}),o.jsxs("button",{disabled:r!==null||!u.trim()||fe<2,className:`${Gs} bg-primary text-primary-foreground`,onClick:()=>{me()},children:[r==="create-group"?o.jsx(si,{size:13,className:"animate-spin"}):o.jsx(Oo,{size:13}),"创建协作组"]})]})]})]}),q&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"border-y border-border/15 py-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:q.name}),o.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[q.sessionIds.length," 个成员 · 离线成员会在重新上线后收到未读消息"]})]}),T?o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("button",{className:`${Gs} bg-surface-2 px-2 text-foreground`,onClick:()=>L(!1),children:"取消"}),o.jsxs("button",{disabled:r!==null,className:`${Gs} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{le()},children:[r===`delete:${q.id}`?o.jsx(si,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):o.jsx("button",{"aria-label":`删除协作组 ${q.name}`,title:"删除协作组",disabled:r!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>L(!0),children:o.jsx(Pi,{size:14})})]}),o.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:q.sessionIds.map(z=>{const K=t.find(se=>se.sessionId===z);return o.jsxs("button",{disabled:!K,onClick:()=>K&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:z})),className:"min-w-0 px-3 py-2.5 text-left transition hover:bg-surface-2 disabled:cursor-default",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${K?.status==="working"?"bg-primary":K?"bg-[var(--success)]":"bg-muted-foreground"}`}),o.jsx("span",{className:"truncate text-[11px] text-foreground",children:K?.name??z}),o.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:K?T6(K.status):"已离线"})]}),o.jsx("span",{className:"mt-1 block truncate text-[9px] text-muted-foreground",children:K?Rx(K.currentTask):"重新上线后可继续接收消息"})]},z)})})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),o.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[W.length," 条"]})]}),o.jsxs("div",{className:"max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[W.map(z=>o.jsxs("div",{className:"px-2 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[o.jsx("span",{className:"font-medium text-primary",children:pq(z.kind)}),o.jsx("span",{children:z.fromName}),o.jsx("span",{children:"→"}),o.jsx("span",{className:"truncate",children:z.toNames.join("、")}),o.jsx("span",{className:"ml-auto shrink-0",children:new Date(z.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),o.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:z.content}),o.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:z.status==="pending"?"等待 Agent 上线":z.status==="read"?"已读取":"已进入 Agent 队列"})]},z.key)),W.length===0&&o.jsx(Sq,{text:"还没有消息。可以先发一个任务或问题。"})]})]}),o.jsxs("section",{className:"border-t border-primary/20 bg-primary/5 px-3 py-3",children:[o.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"发送给成员"}),o.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[o.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["接收人",o.jsxs("select",{className:Ka,value:P,onChange:z=>F(z.target.value),children:[o.jsx("option",{value:"*",children:"全组成员"}),q.sessionIds.map(z=>o.jsx("option",{value:z,children:t.find(K=>K.sessionId===z)?.name??`${z.slice(0,8)}(离线)`},z))]})]}),o.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["消息类型",o.jsxs("select",{className:Ka,value:R,onChange:z=>C(z.target.value),children:[o.jsx("option",{value:"message",children:"普通消息"}),o.jsx("option",{value:"ask",children:"需要回答的问题"}),o.jsx("option",{value:"task",children:"需要执行的任务"}),o.jsx("option",{value:"handoff",children:"工作交接"}),o.jsx("option",{value:"done",children:"完成通知"})]})]})]}),o.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["内容",o.jsx("textarea",{className:`${Ka} min-h-20 resize-y`,value:$,onChange:z=>Q(z.target.value),placeholder:"说明背景、期望产出,以及对方需要回复或完成什么…"})]}),o.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[o.jsx("p",{className:"text-[9px] leading-relaxed text-muted-foreground",children:"在线成员立即入队;离线成员上线后送达。"}),o.jsxs("button",{disabled:r!==null||!$.trim(),className:`${Gs} shrink-0 bg-primary text-primary-foreground`,onClick:()=>{de()},children:[r==="send-message"?o.jsx(si,{size:13,className:"animate-spin"}):null,"发送"]})]})]})]})]})}function T6(e){return e==="working"?"处理中":e==="idle"||e==="done"?"可接收":e==="offline"?"已离线":"在线"}function Rx(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return qm(t.prompt)||"暂无任务摘要"}catch{}return qm(e)||"暂无任务摘要"}function pq(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function mq(e,t){const n=new Map(t.map(s=>[s.sessionId,s.name])),r=new Map;for(const s of e){const i=`${s.threadId}:${s.createdAt}:${s.fromSessionId??"user"}:${s.kind}:${s.content}`,l=r.get(i),c=n.get(s.toSessionId)??s.toSessionId.slice(0,8);if(l){l.toNames.push(c);const u={pending:0,delivered:1,read:2};u[s.status]<u[l.status]&&(l.status=s.status);continue}r.set(i,{key:i,kind:s.kind,content:s.content,createdAt:s.createdAt,fromName:s.fromSessionId?n.get(s.fromSessionId)??s.fromSessionId.slice(0,8):"你",toNames:[c],status:s.status})}return[...r.values()].sort((s,i)=>s.createdAt-i.createdAt)}function gq({onClose:e,onNewSession:t,setError:n}){const[r,s]=b.useState(""),[i,l]=b.useState([]),[c,u]=b.useState(!1),f=b.useRef(0);b.useEffect(()=>{const g=r.trim(),y=++f.current;if(l([]),!g){u(!1);return}u(!0);const v=window.setTimeout(()=>{MI(g).then(S=>{y===f.current&&l(S.results)}).catch(S=>{y===f.current&&n(S instanceof Error?S.message:"搜索失败")}).finally(()=>{y===f.current&&u(!1)})},250);return()=>window.clearTimeout(v)},[r,n]);const p=async g=>{if(g.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:g.sessionId})),e();return}if(g.resumeHistoryId)try{const y=await $7(g.resumeHistoryId);t({mode:"shell",cwd:y.cwd,command:y.command}),e()}catch(y){n(y instanceof Error?y.message:"恢复失败")}};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"全文搜索"}),o.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"搜索会话标题、项目目录、任务内容和终端记录"})]}),o.jsxs("label",{className:"relative mt-3 block",children:[o.jsx("span",{className:"sr-only",children:"搜索全部会话"}),o.jsx(ql,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{autoFocus:!0,className:`${Ka} pl-9 pr-9`,value:r,onChange:g=>{n(null),s(g.target.value)},placeholder:"输入你记得的关键词"}),c?o.jsx(si,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):r&&o.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>s(""),children:o.jsx(ns,{size:13})})]})]}),!r.trim()&&o.jsxs("div",{className:"border-y border-border/15 py-10 text-center",children:[o.jsx(ql,{size:24,className:"mx-auto text-primary"}),o.jsx("p",{className:"mt-3 text-[13px] font-medium text-foreground",children:"找回之前做过的事"}),o.jsx("p",{className:"mx-auto mt-1 max-w-md text-[11px] leading-relaxed text-muted-foreground",children:"可以输入任务名、报错片段或目录名,例如“自动任务”“web-terminal”“构建失败”。搜索索引只保存在本机。"})]}),r.trim()&&!c&&i.length>0&&o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("p",{className:"text-[11px] text-foreground",children:["显示 ",i.length," 个会话"]}),o.jsx("p",{className:"text-[9px] text-muted-foreground",children:"在线可打开 · 已关闭可恢复"})]}),o.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:i.map(g=>{const y=g.live||!!g.resumeHistoryId,v=g.live?"打开会话":g.resumeHistoryId?"恢复会话":"仅供查阅",S=o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-[12px] font-medium text-foreground",children:g.title}),o.jsx("p",{className:"mt-0.5 truncate text-[9px] text-muted-foreground",children:g.cwd})]}),o.jsx("span",{className:`shrink-0 text-[10px] ${g.live?"text-[var(--success)]":g.resumeHistoryId?"text-primary":"text-muted-foreground"}`,children:v})]}),o.jsx("p",{className:"mt-2 line-clamp-3 text-[10px] leading-relaxed text-foreground/75",children:xq(g)||"匹配内容来自标题、目录或终端控制信息"}),o.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Ym(g.updatedAt)," · ",g.matchCount," 处匹配",y?"":" · 没有可恢复记录"]})]});return y?o.jsx("button",{onClick:()=>{p(g)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:S},g.sessionId):o.jsx("article",{className:"px-2 py-3",children:S},g.sessionId)})}),r.trim()&&!c&&i.length===0&&o.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[o.jsxs("p",{className:"text-[12px] text-foreground",children:["没有找到“",r.trim(),"”"]}),o.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"试试更短的关键词、目录名或报错中的一小段。"}),o.jsx("button",{className:`${Gs} mt-3 bg-surface-2 text-foreground`,onClick:()=>s(""),children:"清空后重试"})]})]})}function qm(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function xq(e){let t=qm(e.snippet);for(const n of[e.title,e.cwd,e.agentSlug])n&&(t=t.split(n).join(" "));return qm(t)}function bq(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(r=>`周${t[r]}`).join("、")} ${e.schedule.time}`}function yq(e,t=Date.now(),n=t){if(e.kind==="interval"){const i=e.everyMinutes*6e4,l=Math.max(0,t-n);return n+(Math.floor(l/i)+1)*i}const[r,s]=e.time.split(":").map(Number);for(let i=0;i<=7;i+=1){const l=new Date(t);if(l.setDate(l.getDate()+i),l.setHours(r,s,0,0),l.getTime()>t&&e.weekdays.includes(l.getDay()))return l.getTime()}return t}function Ym(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function vq(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function wq(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function Sq({text:e}){return o.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}function Nx(e,t,n){const r=new Map,s=new Set(e.map(c=>c.id));for(const c of t)if(!(c.sessionIds.length<2||!c.sessionIds.every(u=>s.has(u))))for(const u of c.sessionIds)r.set(u,c);const i=new Set,l=[];for(const c of e){const u=r.get(c.id);if(!u){l.push({kind:"session",id:`session:${c.id}`,session:c,sessionIds:[c.id]});continue}if(i.has(u.id))continue;i.add(u.id);const f=u.sessionIds.flatMap(p=>{const g=n.get(p);return g?[g]:[]});l.push({kind:"workspace",id:`workspace:${u.id}`,workspace:u,members:f,sessionIds:u.sessionIds})}return l}function Aq({status:e,detail:t,needsReview:n,inCopyMode:r}){return o.jsx(FV,{status:e,detail:t,needsReview:n,inCopyMode:r})}function C6({isOpen:e,drawerWidthPx:t,onClose:n,onOpen:r,sessions:s,activeSessionId:i,sessionStates:l,onNewSession:c,onCloseSession:u,onSplitSession:f,onCloseSplit:p,onRemoveFromSplit:g,splitWorkspaces:y,onSetSplitLayout:v,onReorderSplitWorkspace:S,onRenameSplitWorkspace:A,onCombineSplitSessions:T,onReorderSessions:L,onSessionMenu:I,onOpenSettings:j,onOpenQuota:P,updateState:F,updateActionPending:R=!1,onConfirmUpdateRestart:C,onRetryUpdate:$,tmuxAvailable:Q=!0,defaultSessionMode:q="shell",push:V,pinned:fe,runningSessionButtonEnabled:X=!1,onRunningSessionButtonEnabledChange:he,onTogglePinned:me}){const{t:de}=qn(),[le,W]=b.useState(null),[z,K]=b.useState(new Set),[se,ge]=b.useState(null),[Ee,pe]=b.useState(!1),[xe,be]=b.useState(!1),[J,Ke]=b.useState(!1),[Xe,nt]=b.useState([]),[Se,Fe]=b.useState(!1),[ue,Be]=b.useState(null),[$e,tt]=b.useState(null),[ae,Ne]=b.useState({mode:q}),{preference:We,agents:Ie,detecting:He,refresh:gt,selectAgent:bt}=cq(),vt=b.useRef(null),rn=!!(F?.latestVersion&&["installing","ready","restarting","error"].includes(F.status)),Ot=xt(_e=>_e.groupByFolder),un=xt(_e=>_e.collapsedGroups),gr=xt(_e=>_e.toggleGroupCollapsed),dn=b.useRef(null),wt=b.useRef(new Set),we=b.useRef(null),rt=b.useMemo(()=>new Set(y.flatMap(_e=>_e.sessionIds)),[y]),ht=b.useMemo(()=>new Map(s.map(_e=>[_e.id,_e])),[s]),Ye=b.useMemo(()=>s.filter(_e=>!rt.has(_e.id)),[s,rt]),ot=b.useMemo(()=>{let _e=0;for(const Ue of s)l.get(Ue.id)?.agentStatus==="working"&&(_e+=1);return _e},[s,l]);b.useEffect(()=>{e&&dn.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[i,e,Ye.length,un]);const Sn=b.useMemo(()=>{if(!Ot||!i)return null;const _e=l.get(i)?.cwd??null;return Cw(_e)},[Ot,i,l]);b.useEffect(()=>{if(!Ot){we.current=null,wt.current.clear();return}if(!i){we.current=null;return}const _e=xt.getState(),Ue=wt.current,mt=we.current,Ct=Sn;mt!==null&&mt!==Ct&&Ue.has(mt)&&(_e.collapsedGroups.has(mt)||_e.toggleGroupCollapsed(mt),Ue.delete(mt)),Ct!==null&&Ct!==""&&_e.collapsedGroups.has(Ct)&&(_e.toggleGroupCollapsed(Ct),Ue.add(Ct)),we.current=Ct},[Ot,i,Sn]),b.useEffect(()=>{e||(pe(!1),be(!1))},[e]),b.useEffect(()=>{Ne(_e=>({..._e,command:We?.command}))},[We]),b.useEffect(()=>{if(!xe)return;let _e=!1;return Fe(!0),tt(null),Xv().then(Ue=>{_e||nt(Ue)}).catch(()=>{_e||tt(de("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{_e||Fe(!1)}),()=>{_e=!0}},[xe,de]),b.useEffect(()=>{if(!Ee)return;const _e=Ue=>{Ue instanceof KeyboardEvent&&Ue.key!=="Escape"||Ue instanceof MouseEvent&&Ue.target instanceof Node&&vt.current?.contains(Ue.target)||pe(!1)};return window.addEventListener("mousedown",_e),window.addEventListener("keydown",_e),()=>{window.removeEventListener("mousedown",_e),window.removeEventListener("keydown",_e)}},[Ee]);const Vt=()=>{!V&&!fe&&n()},Ve=q==="tmux"&&!Q?"shell":q,ir=()=>{c({mode:Ve}),Vt()},Wn=()=>{We&&(c({mode:Ve,command:We.command}),Vt())},Kt=_e=>{c({...ae,cwd:ae.cwd?.trim()||void 0,command:_e?.command}),be(!1),Vt()},Jn=async _e=>{Be(_e.id),tt(null);try{const Ue=await $7(_e.id);c({mode:"shell",cwd:Ue.cwd,command:Ue.command}),be(!1),Vt()}catch(Ue){const mt=Ue&&typeof Ue=="object"&&"code"in Ue?String(Ue.code??""):"";tt(de(mt==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Be(null)}},Ht=async _e=>{nt(Ue=>Ue.filter(mt=>mt.id!==_e));try{await WE(_e)}catch{tt(de("sidebar.resumeHistoryRemoveFailed")),Xv().then(nt).catch(()=>{})}},Sr=()=>{if(xe){be(!1);return}Ne({mode:q==="tmux"&&!Q?"shell":q,cwd:i?l.get(i)?.cwd??void 0:void 0,command:We?.command}),be(!0)},ar=b.useCallback(_e=>{const Ue=l.get(_e);return Ue?.agentStatus==="waiting"||Ue?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Ue?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Ue?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),ln=KA(),Ar=b.useCallback((_e,Ue,mt,Ct)=>{const jt=_e.id===i,Jt=rt.has(_e.id),Mt=l.get(_e.id),hn=yc(Mt?.cwd??null),Nn=Tw(_e,Mt?.activeProgram??null,Mt?.cwd??null,Im,Mt?.shellTitle??u5(_e.id),Mt?.promptState??null),lr=hn&&hn!==Nn?hn:null,Tn=!!(Mt?.tuiProgress&&Mt.tuiProgress.state!=="remove"),cn=Mt?.promptState==="running"||Mt?.agentStatus==="working"||Tn?"bg-[var(--success)]":Mt?.agentStatus==="waiting"||Mt?.agentNeedsReview?"bg-[var(--warning)]":Mt?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return o.jsxs(o.Fragment,{children:[o.jsxs("button",{ref:jt?dn:null,type:"button",...Ue??{},onContextMenu:cr=>{I&&(cr.preventDefault(),I(_e.id,{x:cr.clientX,y:cr.clientY}))},onClick:()=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_e.id})),Vt()},className:"relative min-w-0 flex flex-1 items-center gap-2 overflow-hidden py-1.5 pl-2 pr-1 text-left",title:Mt?.cwd??_e.name,children:[jt&&o.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${cn}`}),o.jsxs("span",{className:`relative inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md ${jt?_e.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":_e.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[Mt?.isConnecting||Tn&&!Mt?.agentStatus?o.jsx(Hn,{size:12,className:"animate-spin"}):Mt?.agent??d5(_e.id)?o.jsx(Bu,{agent:Mt?.agent??d5(_e.id),size:16}):_e.mode==="tmux"?o.jsx(Mu,{size:12}):o.jsx(Sa,{size:12}),o.jsx(Aq,{status:Mt?.agentStatus??null,detail:Mt?.agentStatusDetail,needsReview:Mt?.agentNeedsReview,inCopyMode:Mt?.inCopyMode})]}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:`block truncate text-[13px] leading-tight ${jt?"font-medium text-foreground":""} ${Mt?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:Nn}),(lr||Mt?.gitStatus)&&o.jsxs("span",{className:"block truncate text-[10.5px] leading-tight text-muted-foreground/75",children:[lr,Mt?.gitStatus&&o.jsxs("span",{className:lr?"ml-1.5":"",title:Mt.gitStatus.branch,children:["⎇ ",Mt.gitStatus.branch.length>14?`${Mt.gitStatus.branch.slice(0,14)}…`:Mt.gitStatus.branch,!mt&&(Mt.gitStatus.added>0||Mt.gitStatus.removed>0)&&o.jsxs("span",{className:"ml-1",children:[o.jsxs("span",{className:"text-[color:var(--success)]",children:["+",Mt.gitStatus.added]})," ",o.jsxs("span",{className:"text-[rgb(var(--warning-rgb))]",children:["−",Mt.gitStatus.removed]})]})]})]})]})]}),o.jsx("button",{type:"button",onClick:cr=>{cr.stopPropagation(),Ct?g(_e.id):Jt?p(_e.id):f(_e.id)},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Jt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${de(Ct?"tab.splitRemovePane":Jt?"tab.splitClose":"tab.split")} ${Nn}`,title:de(Ct?"tab.splitRemovePane":Jt?"tab.splitClose":"tab.split"),children:o.jsx(zd,{size:13})}),o.jsx("button",{type:"button",onClick:cr=>{cr.stopPropagation(),u(_e.id,cr)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95","aria-label":de("sidebar.closeSession",{name:Nn}),title:de("common.close"),children:o.jsx(ns,{size:13})})]})},[i,rt,l,u,f,p,g,I,de]),Yn=b.useMemo(()=>{if(!Ot)return[];const _e=uy(s,mt=>l.get(mt.id)?.cwd??null,de("sidebar.ungrouped")),Ue=new Map;for(const mt of y){const Ct=mt.sessionIds[0];if(!Ct)continue;const jt=Cw(l.get(Ct)?.cwd??null),Jt=Ue.get(jt)??new Set;mt.sessionIds.forEach(Mt=>Jt.add(Mt)),Ue.set(jt,Jt)}return _e.flatMap(mt=>{const Ct=new Set(mt.sessions.filter(Jt=>!rt.has(Jt.id)).map(Jt=>Jt.id));Ue.get(mt.key)?.forEach(Jt=>Ct.add(Jt));const jt=s.filter(Jt=>Ct.has(Jt.id));return jt.length>0?[{...mt,sessions:jt}]:[]})},[Ot,s,l,rt,y,de]),Kn=b.useMemo(()=>Nx(s,y,ht),[s,ht,y]),$r=b.useCallback((_e,Ue,mt)=>{const Ct=Ue.find(hn=>hn.id===_e.draggableId);if(!Ct)return;if(_e.combine){const hn=Ue.find(cn=>cn.id===_e.combine?.draggableId);if(!hn)return;const Nn=hn.kind==="workspace"?hn:Ct.kind==="workspace"?Ct:hn,lr=Nn===Ct?hn:Ct,Tn=Nn.sessionIds[0],jn=lr.sessionIds[0];Tn&&jn&&Tn!==jn&&T(Tn,jn);return}if(!_e.destination||_e.source.index===_e.destination.index)return;const jt=[...Ue],[Jt]=jt.splice(_e.source.index,1);if(!Jt)return;jt.splice(_e.destination.index,0,Jt);const Mt=jt.flatMap(hn=>hn.sessionIds);if(mt===void 0){L(Mt);return}L(Yn.flatMap(hn=>hn.key===mt?Mt:hn.sessions.map(Nn=>Nn.id)))},[Yn,T,L]),ve=b.useCallback(_e=>{if(_e.type==="group"){if(!_e.destination||_e.source.index===_e.destination.index)return;L(tS(Yn,_e.source.index,_e.destination.index));return}const Ue=_e.source.droppableId.replace(/^group-sessions:/,""),mt=Yn.find(jt=>jt.key===Ue);if(!mt)return;const Ct=Nx(mt.sessions,y,ht);if(_e.combine){$r(_e,Ct,Ue);return}!_e.destination||_e.destination.droppableId!==_e.source.droppableId||$r(_e,Ct,Ue)},[Yn,ht,y,$r,L]),ne=(_e,Ue,mt,Ct=!1,jt=!1)=>{if(Ue.length<2)return null;const Jt=Ue.some(Pt=>Pt.id===i),Mt=z.has(_e.id),hn=[],Nn=[],lr=[];for(const Pt of Ue){const Wt=l.get(Pt.id);Wt?.agentStatus==="waiting"||Wt?.agentNeedsReview?hn.push(Pt):Wt?.agentStatus==="working"?Nn.push(Pt):Wt?.inCopyMode&&lr.push(Pt)}const Tn=Pt=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:Pt})),Vt()},jn=`${de("tab.splitWorkspace")} ${y.findIndex(Pt=>Pt.id===_e.id)+1}`,cn=_e.name||jn,cr=[{layout:"horizontal",icon:o.jsx(zd,{size:12}),label:de("tab.splitHorizontal")},{layout:"vertical",icon:o.jsx(p5,{size:12}),label:de("tab.splitVertical")},{layout:"grid",icon:o.jsx(Mu,{size:12}),label:de("tab.splitGrid")}],on=Pt=>{A(_e.id,Pt),W(null)},Pn=()=>{K(Pt=>{const Wt=new Set(Pt);return Wt.has(_e.id)?Wt.delete(_e.id):Wt.add(_e.id),Wt})},er=(Pt,Wt)=>{if(!se||se.workspaceId!==_e.id||se.sessionId===Pt)return;const yt=_e.sessionIds.filter(Ze=>Ze!==se.sessionId),Xt=yt.indexOf(Pt);Xt<0||(yt.splice(Xt+(Wt?1:0),0,se.sessionId),S(_e.id,yt),ge(null))};return o.jsxs("section",{className:`group/split overflow-hidden rounded-md transition-colors ${jt?"bg-primary/15 ring-1 ring-primary/40":Ct?"bg-surface-elevated opacity-90 shadow-lg":hn.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Nn.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":lr.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":Jt?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[o.jsxs("header",{className:"flex h-10 items-center gap-0.5 px-0.5",children:[o.jsx("button",{type:"button",onClick:Pn,className:"inline-flex h-8 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-expanded":Mt,"aria-label":cn,children:o.jsx(wl,{size:13,className:`transition-transform ${Mt?"rotate-90":""}`})}),o.jsx("span",{className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md ${hn.length>0?"text-[color:var(--warning)]":Nn.length>0?"text-[color:var(--success)]":Jt?"text-primary":"text-muted-foreground"}`,children:_e.layout==="vertical"?o.jsx(p5,{size:13}):_e.layout==="grid"?o.jsx(Mu,{size:13}):o.jsx(zd,{size:13})}),le===_e.id?o.jsx("input",{autoFocus:!0,defaultValue:_e.name??"",placeholder:jn,className:"h-7 min-w-0 flex-1 rounded-md bg-surface-elevated px-1.5 text-[11.5px] font-semibold text-foreground outline-none ring-1 ring-primary/40",onKeyDown:Pt=>{Pt.key==="Enter"&&on(Pt.currentTarget.value),Pt.key==="Escape"&&W(null)},onBlur:Pt=>on(Pt.currentTarget.value)}):o.jsxs("button",{type:"button",...mt??{},onClick:()=>{const Pt=Ue.find(Wt=>Wt.id===i)??hn[0]??Ue[0];Pt&&Tn(Pt.id)},className:`min-w-0 flex-1 px-1 text-left ${mt?"cursor-grab active:cursor-grabbing":""}`,title:`${cn} · ${de("tab.sessionCount",{count:Ue.length})}`,children:[o.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:cn}),o.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground/70",children:Ue.map(Pt=>Tw(Pt,l.get(Pt.id)?.activeProgram??null,l.get(Pt.id)?.cwd??null,Im,l.get(Pt.id)?.shellTitle??u5(Pt.id))).join(" · ")})]}),hn.length>0&&o.jsxs("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),Tn(hn[0].id)},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-1.5 text-[9px] font-semibold tabular-nums text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.22)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)]",title:de("agent.needsReview"),"aria-label":`${de("agent.needsReview")}: ${hn.length}`,children:[o.jsx(o8,{size:9}),hn.length]}),Nn.length>0&&o.jsxs("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),Tn(Nn[0].id)},className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.10)] px-1.5 text-[9px] font-medium tabular-nums text-[color:var(--success)] transition hover:bg-[rgb(var(--success-rgb)_/_0.16)]",title:de("agent.aiRunning"),"aria-label":`${de("agent.aiRunning")}: ${Nn.length}`,children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse"}),Nn.length]}),lr.length>0&&hn.length===0&&Nn.length===0&&o.jsx("span",{className:"h-2 w-2 shrink-0 rounded-[2px] bg-[var(--tmux)]",title:de("agent.copyMode")}),o.jsx("span",{className:"shrink-0 px-1 text-[10px] tabular-nums text-muted-foreground/60",children:Ue.length}),o.jsx("button",{type:"button",onClick:()=>W(_e.id),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 opacity-0 transition hover:bg-surface-elevated hover:text-foreground group-hover/split:opacity-100 focus:opacity-100","aria-label":de("tab.splitRename"),title:de("tab.splitRename"),children:o.jsx(p8,{size:11})})]}),Mt&&o.jsxs("div",{className:"border-t border-border/10 pb-0.5",children:[o.jsxs("div",{className:"flex items-center gap-0.5 px-1 py-0.5",children:[cr.map(Pt=>o.jsx("button",{type:"button",onClick:()=>v(Ue[0].id,Pt.layout),className:`inline-flex h-6 w-7 items-center justify-center rounded-md transition ${_e.layout===Pt.layout?"bg-primary/15 font-medium text-primary":"text-muted-foreground/70 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":Pt.label,title:Pt.label,children:Pt.icon},Pt.layout)),o.jsx("span",{className:"min-w-0 flex-1"}),o.jsx("button",{type:"button",onClick:()=>f((Ue.find(Pt=>Pt.id===i)??Ue[0]).id),className:"inline-flex h-6 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-primary/15 hover:text-primary","aria-label":de("tab.split"),title:de("tab.split"),children:o.jsx(Oo,{size:12})}),o.jsx("button",{type:"button",onClick:()=>p(Ue[0].id),className:"inline-flex h-6 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":de("tab.splitClose"),title:de("tab.splitClose"),children:o.jsx(ns,{size:12})})]}),o.jsx("div",{className:"px-0.5",children:Ue.map(Pt=>o.jsxs("div",{onDragOver:Wt=>{se?.workspaceId===_e.id&&Wt.preventDefault()},onDrop:Wt=>{Wt.preventDefault(),Wt.stopPropagation();const yt=Wt.currentTarget.getBoundingClientRect();er(Pt.id,Wt.clientY>yt.top+yt.height/2)},...I?ln(()=>I(Pt.id)):{},className:`flex items-center rounded-md pr-1 transition-colors ${ar(Pt.id)??(Pt.id===i?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:[o.jsx("span",{draggable:!0,onDragStart:Wt=>{Wt.stopPropagation(),Wt.dataTransfer.effectAllowed="move",ge({workspaceId:_e.id,sessionId:Pt.id})},onDragEnd:()=>ge(null),className:"inline-flex h-8 w-5 shrink-0 cursor-grab items-center justify-center text-muted-foreground/50 active:cursor-grabbing",children:o.jsx(_N,{size:12})}),Ar(Pt,void 0,!0,!0)]},Pt.id))})]})]})},St=(_e,Ue,mt)=>o.jsx(Um,{onDragEnd:Ct=>$r(Ct,_e,mt),children:o.jsx(Nu,{droppableId:Ue,direction:"vertical",isCombineEnabled:!0,children:Ct=>o.jsxs("div",{ref:Ct.innerRef,...Ct.droppableProps,className:"space-y-0.5",children:[_e.map((jt,Jt)=>o.jsx(Ru,{draggableId:jt.id,index:Jt,disableInteractiveElementBlocking:!0,children:(Mt,hn)=>o.jsx("div",{ref:Mt.innerRef,...Mt.draggableProps,children:jt.kind==="workspace"?ne(jt.workspace,jt.members,Mt.dragHandleProps,hn.isDragging,!!hn.combineTargetFor):o.jsx("div",{...I?ln(()=>I(jt.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${hn.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":hn.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":ar(jt.session.id)??(jt.session.id===i?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Ar(jt.session,Mt.dragHandleProps,mt!==void 0)})})},jt.id)),Ct.placeholder]})})}),Me=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"shrink-0 border-b border-border/15 px-2 py-2",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"min-w-0 flex-1 px-1",children:o.jsxs("div",{className:"flex items-baseline gap-1.5",children:[o.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:de("sidebar.sessions")}),o.jsx("span",{className:"text-[11px] text-muted-foreground",children:s.length}),ot>0&&o.jsx("span",{className:"ml-1 flex items-center gap-1.5",children:o.jsx(g9,{count:ot,tone:"running",title:de("agent.aiRunning")})})]})}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsxs("div",{ref:vt,className:Ee?"relative z-20":"relative",children:[o.jsxs("button",{type:"button",onClick:()=>pe(_e=>!_e),className:`relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition active:scale-95 ${Ee?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,"aria-expanded":Ee,"aria-haspopup":"menu","aria-label":rn&&F?.latestVersion?`${de("sidebar.moreActions")}: ${de("sidebar.updateAvailable",{version:F.latestVersion})}`:de("sidebar.moreActions"),title:rn&&F?.latestVersion?`${de("sidebar.moreActions")}: ${de("sidebar.updateAvailable",{version:F.latestVersion})}`:de("sidebar.moreActions"),children:[o.jsx(Kc,{size:15}),rn&&o.jsx("span",{className:"absolute right-0.5 top-0.5 z-10 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"})]}),Ee&&o.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+4px)] z-30 w-60 overflow-hidden rounded-xl border border-border/15 bg-surface p-1 text-[12px] shadow-xl shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",children:[rn&&F?.latestVersion&&o.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:o.jsx(si,{size:13,className:F.status==="installing"||F.status==="restarting"?"animate-spin":""})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block font-semibold",children:de("sidebar.updateAvailable",{version:F.latestVersion})}),o.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:F.status==="installing"?de("sidebar.updateInstalling"):F.status==="ready"?de("sidebar.updateReady"):F.status==="restarting"?de("sidebar.updateRestarting"):de("sidebar.updateFailed")})]})]}),F.status==="ready"&&C&&o.jsx("button",{type:"button",role:"menuitem",disabled:R,onClick:C,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:de("sidebar.updateRestart")}),F.status==="error"&&$&&o.jsx("button",{type:"button",role:"menuitem",disabled:R,onClick:$,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:de("sidebar.updateRetry")})]}),he&&o.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":X,onClick:()=>he(!X),className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",title:de("sidebar.runningSessionButtonHint"),children:[o.jsx(Hn,{size:14,className:X?"text-[color:var(--success)]":"text-muted-foreground"}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block",children:de("sidebar.runningSessionButton")}),o.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:de("sidebar.runningSessionButtonHint")})]}),o.jsx(pc,{checked:X,size:"sm"})]}),P&&o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),P()},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx($R,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de("sidebar.subscriptionQuota")})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),Ke(!0)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx(YM,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:"Agent 工作台"})]}),o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),j()},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-foreground transition hover:bg-surface-2",children:[o.jsx(EM,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de("sidebar.settings")})]}),me&&o.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{pe(!1),me()},className:`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left transition ${fe?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,children:[fe?o.jsx(Wc,{size:14}):o.jsx(gc,{size:14,className:"text-muted-foreground"}),o.jsx("span",{children:de(fe?"sidebar.unpinSidebar":"sidebar.pinSidebar")})]})]})]}),(!V||fe)&&o.jsx("button",{type:"button",onClick:n,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":de("common.close"),children:o.jsx(ns,{size:14})})]})]})}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-1.5 py-1.5",children:s.length===0?o.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[o.jsx(Sa,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),o.jsx("p",{className:"text-[12px] text-muted-foreground",children:de("sidebar.noSessions")})]}):Ye.length===0&&y.length===0?o.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:o.jsx("p",{className:"text-[12px] text-muted-foreground",children:de("sidebar.noMatchingSessions")})}):Ot?o.jsx("div",{className:"space-y-1.5",children:o.jsx(Um,{onDragEnd:ve,children:o.jsx(Nu,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:_e=>o.jsxs("div",{ref:_e.innerRef,..._e.droppableProps,className:"space-y-1.5",children:[Yn.map((Ue,mt)=>{const Ct=un.has(Ue.key),jt=Nx(Ue.sessions,y,ht);let Jt=0,Mt=0;for(const Nn of Ue.sessions){const lr=l.get(Nn.id);lr?.agentStatus==="working"&&(Jt+=1),(lr?.agentStatus==="waiting"||lr?.agentNeedsReview)&&(Mt+=1)}const hn=Ue.key==="";return o.jsx(Ru,{draggableId:`sidebar-group:${Ue.key||"__ungrouped__"}`,index:mt,isDragDisabled:hn,disableInteractiveElementBlocking:!0,children:(Nn,lr)=>o.jsxs("div",{ref:Nn.innerRef,...Nn.draggableProps,className:`rounded-md transition-colors ${lr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[o.jsxs("button",{type:"button",...hn?{}:Nn.dragHandleProps,onClick:()=>{gr(Ue.key),wt.current.delete(Ue.key)},className:`flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${hn?"":"cursor-grab active:cursor-grabbing"}`,title:Ue.key||Ue.label,children:[o.jsx(wl,{size:13,className:`shrink-0 transition-transform ${Ct?"":"rotate-90"}`}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Ue.label}),Jt>0&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Mt>0&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),o.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Ue.sessions.length})]}),!Ct&&o.jsx("div",{className:"mt-0.5 pl-2",children:o.jsx(Nu,{droppableId:`group-sessions:${Ue.key}`,type:"session",direction:"vertical",isCombineEnabled:!0,children:Tn=>o.jsxs("div",{ref:Tn.innerRef,...Tn.droppableProps,className:"space-y-0.5",children:[jt.map((jn,cn)=>o.jsx(Ru,{draggableId:jn.id,index:cn,disableInteractiveElementBlocking:!0,children:(cr,on)=>o.jsx("div",{ref:cr.innerRef,...cr.draggableProps,children:jn.kind==="workspace"?ne(jn.workspace,jn.members,cr.dragHandleProps,on.isDragging,!!on.combineTargetFor):o.jsx("div",{...I?ln(()=>I(jn.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${on.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":on.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":ar(jn.session.id)??(jn.session.id===i?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Ar(jn.session,cr.dragHandleProps,!0)})})},jn.id)),Tn.placeholder]})})})]})},Ue.key||"__ungrouped__")}),_e.placeholder]})})})}):St(Kn,"sidebar-entities")}),xe&&o.jsx(oq,{directories:s.flatMap(_e=>{const Ue=l.get(_e.id)?.cwd;return Ue?[Ue]:[]}),tmuxAvailable:Q,options:ae,agents:Ie,selectedAgent:We,detecting:He,resumeHistory:Xe,resumeHistoryLoading:Se,resumeHistoryPendingId:ue,resumeHistoryError:$e,onRefreshAgents:()=>{gt().catch(()=>{})},onSelectAgent:_e=>{bt(_e).catch(()=>{})},onLaunchAgent:Kt,onResumeHistory:_e=>{Jn(_e)},onRemoveResumeHistory:_e=>{Ht(_e)},onClose:()=>be(!1),onOptionsChange:Ne}),J&&o.jsx(uq,{activeSessionId:i,onClose:()=>Ke(!1),onNewSession:_e=>c(_e)}),!xe&&o.jsx("div",{className:"relative z-10 shrink-0 border-t border-border/15 bg-[var(--chrome-bg)] p-2",children:o.jsxs("div",{className:`grid gap-1.5 ${We?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[o.jsxs("button",{type:"button",onClick:ir,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${We?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:de("sidebar.newSession"),"aria-label":de("sidebar.newSession"),children:[o.jsx(Sa,{size:15,className:"shrink-0"}),o.jsx("span",{className:"truncate",children:"Terminal"})]}),We&&o.jsxs("button",{type:"button",onClick:Wn,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:de("sidebar.newSessionWithAgent",{agent:We.displayName}),"aria-label":de("sidebar.newSessionWithAgent",{agent:We.displayName}),children:[o.jsx(Bu,{agent:We,size:15}),o.jsx("span",{className:"truncate",children:We.displayName})]}),o.jsx("button",{type:"button",onClick:Sr,className:"inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/20 transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:de("sidebar.moreLaunchOptions"),"aria-label":de("sidebar.moreLaunchOptions"),"aria-expanded":!1,children:o.jsx(sa,{size:15,className:"transition-transform duration-200"})})]})})]});return fe?o.jsx("div",{className:"h-full flex flex-col app-chrome-bg border-r border-border/15",children:Me}):o.jsx(h9,{side:"left",isOpen:e,drawerWidthPx:t,onClose:n,onOpen:r,push:V,children:Me})}const Tq="modulepreload",Cq=function(e){return"/"+e},k6={},l0=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=u(n.map(f=>{if(f=Cq(f),f in k6)return;k6[f]=!0;const p=f.endsWith(".css"),g=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const y=document.createElement("link");if(y.rel=p?"stylesheet":Tq,p||(y.as="script"),y.crossOrigin="",y.href=f,c&&y.setAttribute("nonce",c),document.head.appendChild(y),p)return new Promise((v,S)=>{y.addEventListener("load",v),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};function w9({selected:e,depth:t=0,title:n,leading:r,children:s,trailing:i,role:l,tabIndex:c,ariaExpanded:u,onClick:f,onKeyDown:p,onPointerDown:g,onPointerUp:y,onPointerCancel:v,dataAttributes:S}){return o.jsxs("div",{role:l,tabIndex:c,"aria-expanded":u,title:n,onClick:f,onKeyDown:p,onPointerDown:g,onPointerUp:y,onPointerCancel:v,...S,className:`group flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1.5 text-left text-[13px] transition active:scale-[0.99] ${e?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,style:{paddingLeft:`${t*14+8}px`},children:[o.jsx("span",{className:"flex min-w-[14px] shrink-0 items-center justify-center text-muted-foreground/80",children:r}),o.jsx("span",{className:"min-w-0 flex-1",children:s}),i]})}function S9(e){return e.path.replace(/^\/+/,"")}function kq(e){if(e.displayName!==void 0||e.displayDir!==void 0)return{name:e.displayName||e.path,dir:e.displayDir||""};const t=e.path.split("/").filter(Boolean);return{name:t.pop()||e.path,dir:t.join("/")}}function A9(e,t){const n=new Map,r=(i,l,c,u)=>{const f=i.get(l);if(f)return f;const p={path:c,name:l,childCount:0,directories:[],files:[]};return i.set(l,p),u?.directories.push(p),p};for(const i of e){const l=t(i).split("/").filter(Boolean);if(l.length<=1)continue;let c=n,u=null,f="";for(const p of l.slice(0,-1)){f=f?`${f}/${p}`:p;const g=r(c,p,f,u);u=g,c=new Map(g.directories.map(y=>[y.name,y]))}u?.files.push(i)}const s=i=>{const l=i.directories.map(s).sort((u,f)=>u.name.localeCompare(f.name)),c=i.files.sort((u,f)=>u.path.localeCompare(f.path));return{...i,directories:l,files:c,childCount:l.reduce((u,f)=>u+f.childCount,0)+c.length}};return Array.from(n.values()).map(s).sort((i,l)=>i.name.localeCompare(l.name))}function $y(e,t,n=0){const r=t.selectedKey===e.key||t.selectedKey===e.path||t.selectedKey===e.absolutePath,s=kq(e);return o.jsx(w9,{selected:r,role:"button",tabIndex:0,title:e.title??e.absolutePath??e.path,onClick:()=>{By()||t.onSelectFile(e)},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t.onSelectFile(e))},leading:t.renderLeading(e),depth:n,trailing:t.renderTrailing?.(e),dataAttributes:{"data-diff-selection-path":e.key,"data-diff-file-path":e.path,"data-diff-absolute-path":e.absolutePath??"","data-diff-status":e.status},children:o.jsxs("span",{className:"select-text","data-sidebar-selectable":!0,children:[o.jsx("span",{className:`block truncate leading-snug ${r?"font-medium":""}`,children:s.name}),t.mode!=="tree"&&s.dir&&o.jsx("span",{className:"block truncate text-[10px] text-muted-foreground/75",children:s.dir}),t.renderSubtitle?.(e)]})},e.key)}function T9(e,t,n,r,s){let i=e;const l=[e.name];for(;i.files.length===0&&i.directories.length===1;)i=i.directories[0],l.push(i.name);const c=l.join("/"),u=`${t}:${i.path}`,f=n.collapsedDirectoryKeys.has(u);return o.jsxs("div",{className:"space-y-px",children:[o.jsx(w9,{role:"button",tabIndex:0,onClick:()=>{By()||n.onToggleDirectory(u)},onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),n.onToggleDirectory(u))},ariaExpanded:!f,depth:r,title:i.path,leading:f?o.jsx(wl,{size:13}):o.jsx(sa,{size:13}),trailing:o.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("span",{className:"shrink-0 rounded bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground/60 transition group-hover:text-muted-foreground",children:i.childCount}),n.renderDirectoryTrailing?.(i.path,s)]}),children:o.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[o.jsx(Xc,{size:14,className:"shrink-0 text-[color:var(--folder)]"}),o.jsx("span",{className:"min-w-0 flex-1 truncate leading-snug select-text","data-sidebar-selectable":!0,children:c})]})}),!f&&o.jsxs("div",{className:"space-y-px",children:[i.directories.map(p=>T9(p,t,n,r+1,s)),i.files.length>0&&o.jsx("div",{className:"space-y-px",children:i.files.map(p=>$y(p,n,r+1))})]})]},u)}function _q(e,t){const n=t.getFileTreePath??S9,r=e.files.filter(i=>n(i).split("/").filter(Boolean).length<=1),s=A9(e.files,n);return o.jsxs("div",{className:"space-y-px",children:[s.map(i=>T9(i,e.key,t,0,e)),r.length>0&&o.jsx("div",{className:"space-y-px",children:r.map(i=>$y(i,t))})]})}function C9(e,t=S9){const n=[],r=i=>{for(const l of i.directories)r(l);n.push(...i.files)};for(const i of A9(e,t))r(i);const s=new Set(n.map(i=>i.key));return n.push(...e.filter(i=>!s.has(i.key))),n}function Lq(e){return o.jsx("div",{className:e.mode==="tree"?"space-y-px pt-1":"space-y-2",children:e.groups.map(t=>{const n=!!t.header,r=!!t.collapsed;return o.jsxs("section",{className:n?"overflow-hidden rounded-lg border border-border/15 bg-surface/60":"",children:[t.header,!r&&o.jsx("div",{className:e.mode==="tree"?n?"space-y-px bg-surface/60 p-1":"space-y-px":n?"space-y-px bg-surface/60 p-1.5":"space-y-px",children:e.mode==="tree"?_q(t,e):t.files.map(s=>$y(s,e))})]},t.key)})})}const dm="termdock:diff-review:list-width:v1",Eq=120,d2=320,_6=220,Iq=560;function Rq(e){return typeof e=="number"&&Number.isFinite(e)}function L6(e,t){const n=Math.max(_6,t-360),r=Math.min(Iq,n);return Math.min(r,Math.max(_6,e))}function Nq(){return Or(dm,Rq)??d2}function Mq({list:e,detail:t,mobile:n,mobileListHeader:r,mobileDetailHeader:s,desktopListHeader:i,backLabel:l,onMobileSlideChange:c,externalSwiperRef:u,desktopLayout:f="split",onDetailScroll:p,desktopSidePanel:g,desktopListClassName:y,detailOwnsScroll:v=!1}){const{t:S}=qn(),A=b.useRef(null),T=b.useRef(null),L=b.useRef(null),[I,j]=b.useState(Nq);b.useEffect(()=>{if(n||f!=="split")return;const $=T.current;$&&j(Q=>L6(Q,$.clientWidth))},[f,n]);const P=b.useCallback($=>{n||f!=="split"||($.preventDefault(),L.current={startX:$.clientX,startWidth:I,pointerId:$.pointerId},$.currentTarget.setPointerCapture($.pointerId))},[f,I,n]),F=b.useCallback($=>{const Q=L.current;if(!Q||Q.pointerId!==$.pointerId)return;const q=T.current?.clientWidth??window.innerWidth,V=L6(Q.startWidth+$.clientX-Q.startX,q);j(V),qd(dm,V,Eq)},[]),R=b.useCallback($=>{const Q=L.current;if(!(!Q||Q.pointerId!==$.pointerId)){L.current=null,Nd(dm);try{$.currentTarget.releasePointerCapture($.pointerId)}catch{}}},[]);if(n){const $=()=>{const fe=A.current;fe&&fe.slideTo(1)},Q=()=>{const fe=A.current;fe&&fe.slideTo(0)},q=typeof e=="function"?e({slideToDetail:$}):e,V=typeof s=="function"?s({slideToList:Q,slideToDetail:$}):s;return o.jsxs(sh,{className:"h-full min-h-0 w-full",slidesPerView:1,resistanceRatio:.45,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:".swiper-no-swiping",allowTouchMove:!1,touchAngle:75,touchStartPreventDefault:!1,onSwiper:fe=>{A.current=fe,u&&(u.current=fe)},onSlideChange:fe=>{c?.(fe.activeIndex)},children:[o.jsx(Qu,{className:"h-full min-h-0",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[r&&o.jsx("div",{className:"shrink-0 border-b border-border/15 px-3 py-2",children:r}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:q})]})}),o.jsx(Qu,{className:"h-full min-h-0",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[o.jsx("div",{className:"shrink-0 border-b border-border/15 px-3 py-2",children:V??o.jsxs("button",{type:"button",onClick:Q,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-surface-2 px-3 text-xs font-semibold text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:[o.jsx(e0,{size:14}),l]})}),o.jsx("div",{className:v?"min-h-0 flex-1 overflow-hidden":"termdock-diff-stream-scroller min-h-0 flex-1 overflow-y-auto overscroll-contain",onScroll:v?void 0:fe=>p?.(fe.currentTarget),children:t})]})})]})}const C=typeof e=="function"?e({slideToDetail:()=>{}}):e;return f==="stacked"?v?o.jsxs("div",{className:"termdock-native-select min-h-0 flex-1 overflow-hidden px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C,o.jsx("div",{className:"mt-3 h-[calc(100%-3rem)] min-h-0 overflow-hidden rounded-xl border border-border/15 bg-surface",children:t})]}):o.jsxs("div",{className:"termdock-native-select termdock-diff-stream-scroller min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-[calc(env(safe-area-inset-bottom)+4.5rem)]",onScroll:$=>p?.($.currentTarget),children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C,o.jsx("div",{className:"mt-3 overflow-hidden rounded-xl border border-border/15 bg-surface",children:t})]}):o.jsxs("div",{ref:T,className:"flex h-full min-h-0 overflow-hidden",children:[g,o.jsxs("div",{className:y??"shrink-0 overflow-y-auto overscroll-contain border-r border-border/15 bg-surface",style:{width:I},children:[i&&o.jsx("div",{className:"sticky top-0 z-10 border-b border-border/15 bg-surface px-2 py-2",children:i}),C]}),o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":S("diffViewer.resizeNavigation"),title:S("diffViewer.resizeNavigation"),className:"group relative z-10 w-2 shrink-0 cursor-col-resize touch-none border-r border-border/15 bg-surface",onPointerDown:P,onPointerMove:F,onPointerUp:R,onPointerCancel:R,onDoubleClick:()=>{j(d2),Gn(dm,d2)},children:o.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border/30 transition group-hover:bg-primary/60"})}),o.jsx("div",{className:v?"min-w-0 flex-1 overflow-hidden":"termdock-diff-stream-scroller min-w-0 flex-1 overflow-y-auto overscroll-contain",onScroll:v?void 0:$=>p?.($.currentTarget),children:t})]})}function Dq({mode:e,onModeChange:t,showAi:n=!1}){return o.jsxs("div",{className:"inline-flex h-7 shrink-0 overflow-hidden rounded-full bg-surface-2 p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>t("list"),"aria-pressed":e==="list",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="list"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx($N,{size:13})}),o.jsx("button",{type:"button",onClick:()=>t("tree"),"aria-pressed":e==="tree",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="tree"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx(J2,{size:13})}),n&&o.jsx("button",{type:"button",onClick:()=>t("ai"),"aria-pressed":e==="ai",className:`inline-flex h-6 w-7 items-center justify-center rounded-full transition active:scale-95 ${e==="ai"?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:o.jsx(Zc,{size:13})})]})}function jq({groups:e,mode:t,onModeChange:n,selectedKey:r,collapsedDirectoryKeys:s,onToggleDirectory:i,onSelectFile:l,renderLeading:c,renderTrailing:u,renderDirectoryTrailing:f,renderSubtitle:p,detail:g,mobile:y,backLabel:v,compact:S=!1,emptyContent:A,listPrefix:T,aiContent:L,listContainerClassName:I="px-2 py-2",detailContainerClassName:j="termdock-native-select termdock-diff-stream-scroller min-h-0",renderListHeader:P,renderMobileDetailHeader:F,externalSwiperRef:R,onMobileSlideChange:C,slideToDetailOnMobile:$=!0,desktopLayout:Q="split",onDetailScroll:q,desktopSidePanel:V,desktopListClassName:fe,detailOwnsScroll:X}){const[he,me]=b.useState(!1);b.useEffect(()=>{if(!he)return;const se=ge=>{ge.key==="Escape"&&me(!1)};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[he]);const de=o.jsx(Dq,{mode:t,onModeChange:n,showAi:!!L}),le=t==="tree"?"tree":"list",W=P?P(de):o.jsx("div",{className:"flex justify-end",children:de}),z=e.some(se=>se.files.length>0),K=o.jsx(Mq,{mobile:he?!1:y,backLabel:v,externalSwiperRef:R,onMobileSlideChange:C,desktopLayout:he?"split":Q,onDetailScroll:q,desktopSidePanel:V,desktopListClassName:fe,detailOwnsScroll:X,mobileListHeader:y?W:void 0,desktopListHeader:y?void 0:W,mobileDetailHeader:F,list:({slideToDetail:se})=>o.jsx("div",{className:I,children:t==="ai"?typeof L=="function"?L({slideToDetail:se,fullscreen:he,toggleFullscreen:()=>me(ge=>!ge)}):L??A:o.jsxs(o.Fragment,{children:[T,z?o.jsx(Lq,{groups:e,selectedKey:r,mode:le,mobile:y,compact:S,collapsedDirectoryKeys:s,onToggleDirectory:i,onSelectFile:ge=>{l(ge),y&&$&&window.requestAnimationFrame(se)},renderLeading:c,renderTrailing:u,renderDirectoryTrailing:f,renderSubtitle:p}):A]})}),detail:o.jsx("div",{className:X?"h-full min-h-0":j,children:g})});return!he||typeof document>"u"?K:ia.createPortal(o.jsxs("div",{className:"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface text-foreground",children:[o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(Zc,{size:15,className:"shrink-0 text-primary"}),o.jsx("span",{className:"truncate text-[12px] font-semibold",children:"DAG Review"}),o.jsx("span",{className:"hidden text-[10px] text-muted-foreground sm:inline",children:"Select a step to inspect its exact change"})]}),o.jsx("button",{type:"button",onClick:()=>me(!1),className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-2 hover:text-foreground active:scale-95",title:"Exit full-screen DAG review (Esc)","aria-label":"Exit full-screen DAG review",children:o.jsx(ns,{size:16})})]}),o.jsx("div",{className:"min-h-0 flex-1",children:K})]}),document.body)}function E6(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),n.push.apply(n,r)}return n}function ro(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?E6(Object(n),!0).forEach((function(r){f2(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E6(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function f2(e,t,n){return(t=(function(r){var s=(function(i,l){if(typeof i!="object"||i===null)return i;var c=i[Symbol.toPrimitive];if(c!==void 0){var u=c.call(i,l);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(i)})(r,"string");return typeof s=="symbol"?s:String(s)})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c0(e,t){if(e==null)return{};var n,r,s=(function(l,c){if(l==null)return{};var u,f,p={},g=Object.keys(l);for(f=0;f<g.length;f++)u=g[f],c.indexOf(u)>=0||(p[u]=l[u]);return p})(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Ac(e,t){return Bq(e)||(function(n,r){var s=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(s!=null){var i,l,c,u,f=[],p=!0,g=!1;try{if(c=(s=s.call(n)).next,r===0){if(Object(s)!==s)return;p=!1}else for(;!(p=(i=c.call(s)).done)&&(f.push(i.value),f.length!==r);p=!0);}catch(y){g=!0,l=y}finally{try{if(!p&&s.return!=null&&(u=s.return(),Object(u)!==u))return}finally{if(g)throw l}}return f}})(e,t)||Hy(e,t)||Oq()}function Pq(e){return(function(t){if(Array.isArray(t))return h2(t)})(e)||Fq(e)||Hy(e)||(function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
136
136
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function Bq(e){if(Array.isArray(e))return e}function Fq(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Hy(e,t){if(e){if(typeof e=="string")return h2(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h2(e,t):void 0}}function h2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Oq(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
137
137
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qq(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Hy(e))||t){n&&(e=n);var r=0,s=function(){};return{s,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(u){throw u},f:s}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
138
138
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,l=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var u=n.next();return l=u.done,u},e:function(u){c=!0,i=u},f:function(){try{l||n.return==null||n.return()}finally{if(c)throw i}}}}var Np=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dh(e,t){return e(t={exports:{}},t.exports),t.exports}var Ca=dh((function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var l=typeof i;if(l==="string"||l==="number")r.push(i);else if(Array.isArray(i)){if(i.length){var c=n.apply(null,i);c&&r.push(c)}}else if(l==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){r.push(i.toString());continue}for(var u in i)t.call(i,u)&&i[u]&&r.push(u)}}}return r.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})),ra={hunkClassName:"",lineClassName:"",gutterClassName:"",codeClassName:"",monotonous:!1,gutterType:"default",viewType:"split",widgets:{},hideGutter:!1,selectedChanges:[],generateAnchorID:function(){},generateLineClassName:function(){},renderGutter:function(e){var t=e.renderDefault;return(0,e.wrapInAnchor)(t())},codeEvents:{},gutterEvents:{}},k9=b.createContext(ra),$q=k9.Provider,Hq=function(){return b.useContext(k9)};dh((function(e,t){(function(n){function r(i){var l=i.slice(11),c=null,u=null;switch(l.indexOf('"')){case-1:c=(g=l.split(" "))[0].slice(2),u=g[1].slice(2);break;case 0:var f=l.indexOf('"',2);c=l.slice(3,f);var p=l.indexOf('"',f+1);u=p<0?l.slice(f+4):l.slice(p+3,-1);break;default:var g;c=(g=l.split(" "))[0].slice(2),u=g[1].slice(3,-1)}return{oldPath:c,newPath:u}}var s={parse:function(i){for(var l,c,u,f,p,g=[],y=2,v=i.split(`
@@ -176,12 +176,12 @@ ${z.desc}`:""}`,"aria-pressed":T===z.key,onPointerEnter:()=>A(z.key),onPointerLe
176
176
 
177
177
  `;return`${e}${r}${n}`}function WZ(e,t){const n=e.trim();return n?t?`${n}\r`:/\s$/.test(e)?e:`${n} `:""}const C2="termdock:right-sidebar:html-view-mode-by-file:v1";function VZ(e){return e==="preview"||e==="source"}function mT(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(VZ)}function gT(e,t){if(!t)return null;const n=e&&!t.startsWith("/")?`${e}/${t}`:t;return e?`${e}::${n}`:n}function g4(e,t){const n=gT(e,t);return n?Or(C2,mT)?.[n]??"source":"source"}function qZ(e,t,n){const r=gT(e,t);if(!r)return;const s=Or(C2,mT)??{};Gn(C2,{...s,[r]:n})}function Hx(e){const t=Number.isFinite(e)&&e>0?Math.floor(e):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),s=t%60,i=String(r).padStart(2,"0"),l=String(s).padStart(2,"0");return n>0?`${n}:${i}:${l}`:`${i}:${l}`}function YZ(e,t,n){return!Number.isFinite(n)||n<=0||!t.width?0:Math.min(1,Math.max(0,(e-t.left)/t.width))*n}const KZ=350,XZ=12,ZZ=90;function JZ({url:e,onLoadError:t}){const{t:n}=qn(),r=b.useRef(null),s=b.useRef(null),i=b.useRef(null),l=b.useRef(null),c=b.useRef(!1),u=b.useRef(null),f=b.useRef(null),p=b.useRef(0),g=b.useRef(!1),y=b.useRef(!1),v=b.useRef(!1),S=b.useRef(null),A=b.useRef(null),T=b.useRef(!1),L=b.useRef(1),I=b.useRef(!1),[j,P]=b.useState(0),[F,R]=b.useState(0),[C,$]=b.useState(!1),[Q,q]=b.useState(!1),[V,fe]=b.useState(null),[X,he]=b.useState(!1),[me,de]=b.useState(0),[le,W]=b.useState(!1),[z,K]=b.useState({width:0,height:0}),se=b.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),ge=b.useCallback(()=>{if(se(),A.current=null,!T.current)return!1;const Ie=i.current;return Ie&&(Ie.playbackRate=L.current),T.current=!1,he(!1),!0},[se]);b.useEffect(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),f.current!==null&&clearTimeout(f.current),se();const Ie=i.current;Ie&&T.current&&(Ie.playbackRate=L.current)},[se]),b.useEffect(()=>{const Ie=s.current;if(!Ie||typeof ResizeObserver>"u")return;const He=new ResizeObserver(([gt])=>{gt&&K({width:gt.contentRect.width,height:gt.contentRect.height})});return He.observe(Ie),()=>He.disconnect()},[]),b.useEffect(()=>{const Ie=()=>W(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",Ie),()=>document.removeEventListener("fullscreenchange",Ie)},[]);const Ee=b.useCallback((Ie,He=!1)=>{const gt=i.current;if(!gt)return!1;const bt=Number.isFinite(gt.duration)?gt.duration:Ie,vt=Math.min(Math.max(Ie,0),bt);if(R(vt),Math.abs(gt.currentTime-vt)<1/120)return!1;const rn=gt.fastSeek;return He&&typeof rn=="function"?rn.call(gt,vt):gt.currentTime=vt,!0},[]),pe=b.useCallback(()=>{u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null;const Ie=i.current;if(!Ie||!g.current||y.current||Ie.seeking)return;const He=v.current;v.current=!1,y.current=Ee(p.current,!He)}))},[Ee]),xe=b.useCallback(Ie=>{const He=l.current,gt=i.current;if(!He||!gt)return;const bt=He.getBoundingClientRect(),vt=YZ(Ie,bt,gt.duration);p.current=vt,fe(vt),v.current=!1,pe(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,v.current=!0,pe()},ZZ)},[pe]),be=b.useCallback(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),f.current!==null&&(clearTimeout(f.current),f.current=null),v.current=!1,y.current=!1,Ee(p.current)},[Ee]),J=b.useCallback(Ie=>{const He=i.current;if(!(!He||!Number.isFinite(He.duration)||He.duration<=0)){c.current=!He.paused,He.pause(),g.current=!0,q(!0);try{Ie.currentTarget.setPointerCapture(Ie.pointerId)}catch{}xe(Ie.clientX)}},[xe]),Ke=b.useCallback(()=>{g.current=!1,be(),q(!1),fe(null);const Ie=i.current;Ie&&c.current&&!Ie.ended&&Ie.play().catch(()=>{}),c.current=!1},[be]),Xe=b.useCallback(()=>{const Ie=i.current;if(Ie){if(I.current){I.current=!1;return}Ie.paused?Ie.play().catch(()=>{}):Ie.pause()}},[]),nt=b.useCallback(Ie=>{const He=i.current;!He||He.paused||Ie.button!==0||(se(),A.current={id:Ie.pointerId,x:Ie.clientX,y:Ie.clientY},S.current=setTimeout(()=>{S.current=null,L.current=He.playbackRate,He.playbackRate=2,T.current=!0,he(!0)},KZ))},[se]),Se=b.useCallback(Ie=>{const He=A.current;!He||He.id!==Ie.pointerId||T.current||Math.hypot(Ie.clientX-He.x,Ie.clientY-He.y)>XZ&&(se(),A.current=null)},[se]),Fe=b.useCallback(()=>{ge()&&(I.current=!0)},[ge]);b.useEffect(()=>(window.addEventListener("pointerup",Fe),window.addEventListener("pointercancel",Fe),window.addEventListener("blur",Fe),()=>{window.removeEventListener("pointerup",Fe),window.removeEventListener("pointercancel",Fe),window.removeEventListener("blur",Fe)}),[Fe]);const ue=b.useCallback(async()=>{const Ie=r.current,He=i.current;if(!(!Ie||!He))try{document.fullscreenElement===Ie?await document.exitFullscreen():Ie.requestFullscreen?await Ie.requestFullscreen():He.webkitEnterFullscreen?.()}catch{He.webkitEnterFullscreen?.()}},[]),Be=b.useCallback(()=>de(Ie=>(Ie+90)%360),[]),$e=b.useCallback(Ie=>{const He=i.current;if(!He||!Number.isFinite(He.duration))return;const gt=Ie.shiftKey?10:5;let bt=null;Ie.key==="ArrowLeft"?bt=He.currentTime-gt:Ie.key==="ArrowRight"?bt=He.currentTime+gt:Ie.key==="Home"?bt=0:Ie.key==="End"&&(bt=He.duration),bt!==null&&(Ie.preventDefault(),Ee(bt))},[Ee]),tt=Q&&V!==null?V:F,ae=j>0?Math.min(1,Math.max(0,tt/j)):0,We=(me===90||me===270)&&z.width>0&&z.height>0?{width:`${z.height}px`,height:`${z.width}px`}:{width:"100%",height:"100%"};return o.jsxs("div",{ref:r,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-background fullscreen:h-screen fullscreen:w-screen fullscreen:rounded-none","data-testid":"file-preview-video-player","data-rotation":me,children:[o.jsxs("div",{ref:s,className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[o.jsx("video",{ref:i,"data-testid":"file-preview-video",className:"absolute left-1/2 top-1/2 max-w-none object-contain transition-transform duration-200",style:{...We,transform:`translate(-50%, -50%) rotate(${me}deg)`},src:e,preload:"auto",playsInline:!0,onClick:Xe,onPointerDown:nt,onPointerMove:Se,onPointerUp:Fe,onPointerCancel:Fe,onContextMenu:Ie=>{T.current&&Ie.preventDefault()},onPlay:()=>$(!0),onPause:()=>$(!1),onTimeUpdate:Ie=>R(Ie.currentTarget.currentTime),onSeeked:Ie=>{const He=Ie.currentTarget;if(R(He.currentTime),y.current=!1,!g.current)return;const gt=He.requestVideoFrameCallback;typeof gt=="function"?gt.call(He,()=>{g.current&&pe()}):requestAnimationFrame(()=>{g.current&&pe()})},onLoadedMetadata:Ie=>P(Number.isFinite(Ie.currentTarget.duration)?Ie.currentTarget.duration:0),onDurationChange:Ie=>P(Number.isFinite(Ie.currentTarget.duration)?Ie.currentTarget.duration:0),onError:t,children:n("rightSidebar.videoUnsupported")}),X&&o.jsx("div",{className:"pointer-events-none absolute left-1/2 top-3 z-10 -translate-x-1/2 rounded-full bg-surface-elevated px-3 py-1 text-xs font-semibold tabular-nums text-foreground shadow-md",children:n("rightSidebar.videoLongPressSpeed")}),Q&&V!==null&&o.jsx("div",{className:"pointer-events-none absolute bottom-1 z-10 -translate-x-1/2 rounded-md bg-surface-elevated px-2 py-1 text-[11px] font-medium text-foreground shadow-md",style:{left:`${ae*100}%`},"data-testid":"file-preview-video-scrub-time",children:Hx(V)})]}),o.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${d9}`,[f9]:"",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:Xe,"aria-label":n(C?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:n(C?"rightSidebar.videoPause":"rightSidebar.videoPlay"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-play",children:C?o.jsx(f8,{size:14}):o.jsx(Sb,{size:14})}),o.jsxs("div",{ref:l,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(j),"aria-valuenow":Math.floor(tt),tabIndex:0,className:"group relative h-5 min-w-0 flex-1 cursor-pointer touch-none py-2","data-testid":"file-preview-video-track",onPointerDown:J,onPointerMove:Ie=>{Q&&xe(Ie.clientX)},onPointerUp:Ke,onPointerCancel:Ke,onKeyDown:$e,children:[o.jsx("div",{className:"h-1 w-full rounded-full bg-surface-elevated"}),o.jsx("div",{className:"absolute inset-y-0 left-0 my-auto h-1 rounded-full bg-primary",style:{width:`${ae*100}%`}}),o.jsx("div",{className:"absolute top-1/2 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow",style:{left:`${ae*100}%`}})]}),o.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Hx(tt)," / ",Hx(j)]}),o.jsx("button",{type:"button",onClick:Be,"aria-label":n("rightSidebar.videoRotate"),title:n("rightSidebar.videoRotate"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-rotate",children:o.jsx(yM,{size:14})}),o.jsx("button",{type:"button",onClick:()=>{ue()},"aria-label":n(le?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:n(le?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-foreground transition hover:bg-surface-elevated active:scale-95","data-testid":"file-preview-video-fullscreen",children:le?o.jsx(KN,{size:14}):o.jsx(GN,{size:14})})]})})]})}function eJ(e){const t=Math.max(0,Math.min(100,e.xPercent)),n=Math.max(0,Math.min(100,e.yPercent));return{...t<=50?{left:`calc(${t}% + 8px)`}:{right:`calc(${100-t}% + 8px)`},...n<=50?{top:`calc(${n}% + 8px)`}:{bottom:`calc(${100-n}% + 8px)`}}}function Fg({anchor:e,children:t,disabled:n=!1,onClick:r,title:s}){return o.jsxs("button",{type:"button","data-floating-annotation-button":!0,disabled:n,onClick:i=>{i.stopPropagation(),r()},title:s,style:eJ(e),className:"absolute z-30 inline-flex h-7 items-center gap-1 rounded-full bg-primary px-3 text-[11px] font-semibold text-primary-foreground shadow-lg ring-1 ring-primary/30 transition hover:bg-primary/90 active:scale-95 disabled:cursor-wait disabled:opacity-50",children:[o.jsx(Al,{size:11}),t]})}function tJ(e,t,n,r){if(n.width<=0||n.height<=0||r.width<=0||r.height<=0)return null;const s=Math.min(n.width/r.width,n.height/r.height);if(!Number.isFinite(s)||s<=0)return null;const i=r.width*s,l=r.height*s,c=n.left+(n.width-i)/2,u=n.top+(n.height-l)/2,f=e-c,p=t-u;if(f<0||p<0||f>i||p>l)return null;const g=f/i*100,y=p/l*100;return{x:r.x+r.width*g/100,y:r.y+r.height*y/100,xPercent:g,yPercent:y}}function nJ(e,t,n){const r=[`SVG标注: ${e}`,`视图: ${t}`,`SVG坐标: (${n.x.toFixed(2)},${n.y.toFixed(2)}) [viewBox坐标]`,`图片位置: (${n.xPercent.toFixed(1)}%,${n.yPercent.toFixed(1)}%) [相对内容边界左上角]`];return n.nearestText&&r.push(`最近文字: ${n.nearestText}`),`"${r.join(" / ")}"`}function rJ(e){const t=new DOMParser().parseFromString(e,"image/svg+xml"),n=t.documentElement;if(n.nodeName.toLowerCase()!=="svg"||t.querySelector("parsererror"))throw new Error("Invalid SVG document");return t.querySelectorAll("script,foreignObject,iframe,object,embed").forEach(r=>r.remove()),t.querySelectorAll("*").forEach(r=>{for(const s of Array.from(r.attributes)){const i=s.name.toLowerCase(),l=s.value.trim();(i.startsWith("on")||(i==="href"||i.endsWith(":href"))&&l&&!l.startsWith("#"))&&r.removeAttribute(s.name)}}),n.removeAttribute("width"),n.removeAttribute("height"),n.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(n)}function sJ(e,t,n){let r=null;for(const s of Array.from(e.querySelectorAll("text"))){const i=(s.textContent??"").replace(/\s+/g," ").trim();if(!i)continue;const l=Number(s.getAttribute("x")),c=Number(s.getAttribute("y"));if(!Number.isFinite(l)||!Number.isFinite(c))continue;const u=Math.hypot(l-t,c-n);(!r||u<r.distance)&&(r={text:i,distance:u})}return r?.text.slice(0,120)}function xT({blobUrl:e,filePath:t,viewLabel:n,onInsertAnnotation:r}){const s=b.useRef(null),i=b.useRef(null),[l,c]=b.useState(null),[u,f]=b.useState(null),[p,g]=b.useState(1),[y,v]=b.useState(!1),[S,A]=b.useState(null),T=b.useRef(new Map),L=b.useRef(null),I=b.useRef(!1),j=b.useRef(null),P=b.useRef(p);P.current=p,b.useEffect(()=>{const le=new AbortController;return c(null),f(null),A(null),g(1),fetch(e,{signal:le.signal}).then(W=>W.text()).then(W=>c(rJ(W))).catch(W=>{le.signal.aborted||f(W instanceof Error?W.message:"SVG preview failed")}),()=>le.abort()},[e]),b.useEffect(()=>{if(!y)return;const le=W=>{W.key==="Escape"&&v(!1)};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[y]),b.useLayoutEffect(()=>{const le=i.current,W=le?.querySelector("[data-svg-document] > svg");if(!le||!W)return;let z;try{z=W.getBBox()}catch{return}if(!z.width||!z.height)return;const K=Math.max(2,Math.min(z.width,z.height)*.025);W.setAttribute("viewBox",`${z.x-K} ${z.y-K} ${z.width+2*K} ${z.height+2*K}`),W.style.width=`${p*100}%`,W.style.height=`${p*100}%`,W.style.minWidth=`${p*100}%`,W.style.minHeight=`${p*100}%`,W.style.display="block"},[l,p]);const F=b.useMemo(()=>S?nJ(t,n,S):null,[t,S,n]),R=le=>{if(I.current){I.current=!1;return}const W=i.current,z=W?.querySelector("[data-svg-document] > svg"),K=s.current;if(!W||!z||!K)return;const se=z.viewBox.baseVal,ge=tJ(le.clientX,le.clientY,z.getBoundingClientRect(),se);if(!ge)return;const Ee=K.getBoundingClientRect();A({...ge,nearestText:sJ(z,ge.x,ge.y),stageX:le.clientX-Ee.left,stageY:le.clientY-Ee.top,stageXPercent:(le.clientX-Ee.left)/Ee.width*100,stageYPercent:(le.clientY-Ee.top)/Ee.height*100})},C=le=>Math.max(1,Math.min(12,le)),$=(le,W)=>{const z=C(W),K=le.querySelector("[data-svg-document] > svg");if(!K)return z;const se=`${z*100}%`;return K.style.width=se,K.style.height=se,K.style.minWidth=se,K.style.minHeight=se,P.current=z,z},Q=(le,W,z,K)=>{const se=P.current,ge=le.getBoundingClientRect(),Ee=z-ge.left,pe=K-ge.top,xe=(le.scrollLeft+Ee)/se,be=(le.scrollTop+pe)/se,J=$(le,W);return le.scrollLeft=xe*J-Ee,le.scrollTop=be*J-pe,J},q=()=>{const le=Array.from(T.current.values());return le.length>=2?Math.hypot(le[0].x-le[1].x,le[0].y-le[1].y):0},V=le=>{if(le.pointerType==="mouse"&&le.button!==0)return;const W=i.current;W&&(T.current.set(le.pointerId,{x:le.clientX,y:le.clientY}),W.setPointerCapture?.(le.pointerId),T.current.size>=2?(L.current={kind:"pinch",startX:le.clientX,startY:le.clientY,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startDistance:q(),startZoom:P.current,moved:!1},I.current=!0):P.current>1&&(L.current={kind:"pan",startX:le.clientX,startY:le.clientY,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startZoom:P.current,moved:!1}))},fe=le=>{if(!T.current.has(le.pointerId))return;T.current.set(le.pointerId,{x:le.clientX,y:le.clientY});const W=i.current,z=L.current;if(!(!W||!z)){if(T.current.size>=2&&z.kind==="pinch"){const K=q();if(!z.startDistance||!K)return;const se=C(z.startZoom*K/z.startDistance);if(Math.abs(se-P.current)<.01)return;const ge=Array.from(T.current.values()),Ee=(ge[0].x+ge[1].x)/2,pe=(ge[0].y+ge[1].y)/2;z.moved=!0,I.current=!0,Q(W,se,Ee,pe),le.preventDefault();return}if(z.kind==="pan"&&T.current.size===1){const K=le.clientX-z.startX,se=le.clientY-z.startY;if(!z.moved&&Math.hypot(K,se)<6)return;z.moved=!0,I.current=!0,W.scrollLeft=z.startScrollLeft-K,W.scrollTop=z.startScrollTop-se,le.preventDefault()}}},X=le=>{const W=i.current,z=L.current,K=T.current.size===1&&!z?.moved;T.current.delete(le.pointerId);try{W?.releasePointerCapture?.(le.pointerId)}catch{}if(T.current.size===1&&z?.kind==="pinch"){const Ee=Array.from(T.current.values())[0];L.current=W?{kind:"pan",startX:Ee.x,startY:Ee.y,startScrollLeft:W.scrollLeft,startScrollTop:W.scrollTop,startZoom:P.current,moved:!1}:null;return}if(T.current.size>0||(L.current=null,z?.kind==="pinch"&&g(P.current),!K||I.current))return;const se=Date.now(),ge=j.current;ge&&se-ge.time<350&&Math.hypot(le.clientX-ge.x,le.clientY-ge.y)<24?(j.current=null,I.current=!0,g(Ee=>Ee>1?1:2.5)):j.current={time:se,x:le.clientX,y:le.clientY}},he=le=>{if(!le.ctrlKey&&!le.metaKey)return;const W=i.current;if(!W)return;le.preventDefault();const z=Q(W,P.current*Math.exp(-le.deltaY*.01),le.clientX,le.clientY);g(z)},me=()=>{g(1),P.current=1,i.current&&(i.current.scrollLeft=0,i.current.scrollTop=0)},de=o.jsxs("div",{className:y?"fixed inset-0 z-modal-panel flex min-h-0 flex-col bg-surface pt-[env(safe-area-inset-top,0px)]":"flex h-full min-h-0 flex-col bg-surface",children:[o.jsxs("div",{ref:s,className:"relative min-h-0 flex-1",children:[o.jsx("div",{ref:i,role:"button",tabIndex:0,onClick:R,onDoubleClick:le=>{le.preventDefault(),g(W=>W>1?1:2.5)},onPointerDown:V,onPointerMove:fe,onPointerUp:X,onPointerCancel:X,onWheel:he,onScroll:()=>A(null),className:"h-full touch-none cursor-crosshair overflow-auto bg-white p-3 text-slate-900",children:u?o.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):l?o.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:l}}):o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading SVG…"})}),S&&o.jsx("span",{"data-svg-pick-marker":!0,className:"pointer-events-none absolute z-10 h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm",style:{left:S.stageX,top:S.stageY}}),S&&F&&o.jsx(Fg,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:()=>{r?.(F,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`),A(null)},children:"引用 SVG 标注"}),o.jsxs("div",{"data-svg-toolbar":!0,className:"absolute right-2 top-2 z-20 flex gap-1",children:[p>1.001&&o.jsx("button",{type:"button","aria-label":"适合窗口",title:"适合窗口",onClick:le=>{le.stopPropagation(),me()},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:o.jsx(SM,{size:14})}),o.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:le=>{le.stopPropagation(),v(W=>!W)},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-slate-200 bg-white/95 text-slate-600 shadow-sm backdrop-blur transition active:scale-95",children:y?o.jsx(ty,{size:14}):o.jsx(ey,{size:14})})]})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:S?`SVG (${S.x.toFixed(2)}, ${S.y.toFixed(2)}) · ${S.nearestText??"附近无文字"}`:"点击 SVG 的问题位置生成精确引用"})})]});return y?ia.createPortal(de,document.body):de}function xm(e){switch(e){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function iJ(e,t,n,r){const s=[`电子标注: ${e}`,`视图: ${xm(t)}`,`图片位置: (${n.xPercent.toFixed(1)}%,${n.yPercent.toFixed(1)}%) [相对渲染图左上角]`];if(r?.available&&r.xMm!==void 0&&r.yMm!==void 0&&(s.push(`PCB坐标: (${r.xMm.toFixed(2)},${r.yMm.toFixed(2)})mm [KiCad板坐标]`),r.layer&&s.push(`显示层: ${r.layer}`),r.nearest)){const i=[r.nearest.net?`网络 ${r.nearest.net}`:null,`对象层 ${r.nearest.layer}`,`距离 ${r.nearest.distanceMm.toFixed(2)}mm`].filter(Boolean).join(",");s.push(`最近对象: ${r.nearest.label}${i?`(${i})`:""}`)}return`"${s.join(" / ")}"`}function oJ({blobUrl:e,filePath:t,view:n,board:r,onViewChange:s,onInsertAnnotation:i,onRefresh:l,interactive3d:c}){const{t:u}=qn(),f=b.useRef(null),p=b.useRef(null),g=b.useRef(null),[y,v]=b.useState(null),[S,A]=b.useState(!1);b.useEffect(()=>(g.current?.abort(),v(null),A(!1),()=>g.current?.abort()),[e,n]);const T=b.useMemo(()=>y?iJ(t,n,y,y.inspection):null,[t,y,n]),L=j=>{const P=f.current,F=p.current;if(!P||!F||!F.naturalWidth||!F.naturalHeight)return;const R=P.getBoundingClientRect(),C=Math.min(R.width/F.naturalWidth,R.height/F.naturalHeight),$=F.naturalWidth*C,Q=F.naturalHeight*C,q=R.left+(R.width-$)/2,V=R.top+(R.height-Q)/2,fe=j.clientX-q,X=j.clientY-V;if(fe<0||X<0||fe>$||X>Q)return;const he={xPercent:Math.max(0,Math.min(100,fe/$*100)),yPercent:Math.max(0,Math.min(100,X/Q*100)),stageXPercent:(j.clientX-R.left)/R.width*100,stageYPercent:(j.clientY-R.top)/R.height*100,inspecting:r&&n!=="pcb-3d"};if(v(he),g.current?.abort(),!he.inspecting)return;const me=new AbortController;g.current=me,cI(t,n,he.xPercent,he.yPercent,me.signal).then(de=>v(le=>le===he?{...le,inspection:de,inspecting:!1}:le)).catch(()=>{me.signal.aborted||v(de=>de===he?{...de,inspection:{available:!1},inspecting:!1}:de)})},I=r?["pcb-front","pcb-back","pcb-3d"]:["schematic"];return o.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-surface",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 px-3 py-2",children:[o.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:I.map(j=>o.jsx("button",{type:"button",onClick:()=>s(j),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${j===n?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:xm(j)},j))}),o.jsx("button",{type:"button",onClick:l,className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",title:u("rightSidebar.edaRefresh"),"aria-label":u("rightSidebar.edaRefresh"),children:o.jsx(si,{size:13})})]}),r&&c?o.jsx("div",{className:n==="pcb-3d"?"flex min-h-0 flex-1 flex-col overflow-hidden":"hidden",children:c}):null,r?n==="pcb-3d"?c?null:o.jsx("div",{className:"min-h-0 flex-1"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{ref:f,role:"button",tabIndex:0,onClick:L,onKeyDown:j=>{j.key!=="Enter"&&j.key!==" "||(j.preventDefault(),v({xPercent:50,yPercent:50,stageXPercent:50,stageYPercent:50}))},className:"relative min-h-0 flex-1 cursor-crosshair overflow-hidden bg-surface p-3 outline-none",title:u("rightSidebar.edaPickHint"),children:[o.jsx("img",{ref:p,src:e,alt:`${t} ${xm(n)}`,onLoad:()=>A(!0),className:`pointer-events-none h-full w-full object-contain transition-opacity ${S?"opacity-100":"opacity-0"}`}),y&&o.jsx("span",{className:"pointer-events-none absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-surface shadow-sm",style:{left:`${y.stageXPercent}%`,top:`${y.stageYPercent}%`}}),y&&T&&o.jsx(Fg,{anchor:{xPercent:y.stageXPercent,yPercent:y.stageYPercent},disabled:y.inspecting,title:u("rightSidebar.edaInsertAnnotation"),onClick:()=>{i?.(T,`eda:${n}:${y.xPercent.toFixed(1)}:${y.yPercent.toFixed(1)}`),v(null)},children:u("rightSidebar.edaInsertAnnotation")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:y?y.inspecting?u("rightSidebar.edaInspecting"):y.inspection?.available?u("rightSidebar.edaPickedBoardPosition",{x:y.inspection.xMm?.toFixed(2)??"—",y:y.inspection.yMm?.toFixed(2)??"—",object:y.inspection.nearest?.label??u("rightSidebar.edaNoNearbyObject")}):u("rightSidebar.edaPickedPosition",{x:y.xPercent.toFixed(1),y:y.yPercent.toFixed(1)}):u("rightSidebar.edaPickHint")})})]}):o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:o.jsx(xT,{blobUrl:e,filePath:t,viewLabel:xm(n),onInsertAnnotation:i})})]})}function aJ(e){const t=[];let n=[],r="",s=!1;for(let i=0;i<e.length;i+=1){const l=e[i];s?l==='"'&&e[i+1]==='"'?(r+='"',i+=1):l==='"'?s=!1:r+=l:l==='"'?s=!0:l===","?(n.push(r),r=""):l===`
178
178
  `?(n.push(r.replace(/\r$/,"")),t.push(n),n=[],r=""):r+=l}return(r||n.length>0)&&(n.push(r.replace(/\r$/,"")),t.push(n)),t}function lJ(e,t,n,r,s){const i=t[s]||`第${s+1}列`,l=n[s]??"",c=t.map((u,f)=>`${u||`第${f+1}列`}=${n[f]??""}`).join(";");return`"表格标注: ${e} / 数据行: ${r+1} / 列: ${i} / 值: ${l} / 记录: ${c}"`}function cJ({content:e,filePath:t,onInsertAnnotation:n}){const{t:r}=qn(),s=b.useMemo(()=>aJ(e),[e]),i=s[0]??[],l=s.slice(1),c=b.useRef(null),[u,f]=b.useState(null),p=u?l[u.row]:null,g=u&&p?lJ(t,i,p,u.row+1,u.column):null;return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[o.jsxs("div",{ref:c,className:"relative min-h-0 flex-1",children:[o.jsx("div",{className:"h-full overflow-auto",children:o.jsxs("table",{className:"min-w-full border-separate border-spacing-0 text-left text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"sticky left-0 top-0 z-20 border-b border-r border-border/20 bg-surface-elevated px-2 py-2 text-[10px] font-semibold text-muted-foreground",children:"#"}),i.map((y,v)=>o.jsx("th",{className:"sticky top-0 z-10 min-w-28 border-b border-r border-border/20 bg-surface-elevated px-3 py-2 font-semibold text-foreground",children:y||r("rightSidebar.csvUnnamedColumn",{index:v+1})},`${y}:${v}`))]})}),o.jsx("tbody",{children:l.map((y,v)=>o.jsxs("tr",{className:"hover:bg-surface-2",children:[o.jsx("th",{className:"sticky left-0 z-10 border-b border-r border-border/15 bg-surface px-2 py-2 text-right text-[10px] font-normal text-muted-foreground",children:v+1}),i.map((S,A)=>{const T=u?.row===v&&u.column===A;return o.jsx("td",{className:`border-b border-r border-border/15 p-0 ${T?"bg-primary/15":""}`,children:o.jsx("button",{type:"button",onClick:L=>{const I=c.current?.getBoundingClientRect(),j=L.currentTarget.getBoundingClientRect();if(!I?.width||!I.height)return;const P=L.clientX||j.left+j.width/2,F=L.clientY||j.top+j.height/2;f({row:v,column:A,xPercent:(P-I.left)/I.width*100,yPercent:(F-I.top)/I.height*100})},className:"block h-full min-h-9 w-full whitespace-pre-wrap px-3 py-2 text-left text-foreground outline-none hover:bg-primary/10 focus-visible:bg-primary/10",children:y[A]||" "})},`cell:${v}:${A}`)})]},`row:${v}`))})]})}),u&&g&&o.jsx(Fg,{anchor:{xPercent:u.xPercent,yPercent:u.yPercent},title:r("rightSidebar.csvInsertAnnotation"),onClick:()=>{n?.(g,`csv:${t}:${u.row+1}:${u.column+1}`),f(null)},children:r("rightSidebar.csvInsertAnnotation")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:u&&p?r("rightSidebar.csvSelectedCell",{row:u.row+1,column:i[u.column]||u.column+1}):r("rightSidebar.csvPickHint",{rows:l.length,columns:i.length})})})]})}function Cd(e,t){let n=e;for(const r of t){if(!n||typeof n!="object")return;n=n[r]}return n}function uJ(e,t){const n=JSON.parse(e),r=Cd(n,["meta","version"]);if(t)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(r??"未知")},{label:"活动层编号",value:String(Cd(n,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Cd(n,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Cd(n,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const s=Cd(n,["net_settings","classes"]),i=Array.isArray(s)?s.find(c=>c&&typeof c=="object"&&c.name==="Default"):void 0,l=Cd(n,["board","design_settings","drc_exclusions"]);return[{label:"文件性质",value:"KiCad 工程配置"},{label:"格式版本",value:String(r??"未知")},{label:"网络类数量",value:String(Array.isArray(s)?s.length:0)},{label:"默认间距",value:i?.clearance!==void 0?`${i.clearance} mm`:"未设置"},{label:"默认线宽",value:i?.track_width!==void 0?`${i.track_width} mm`:"未设置"},{label:"默认过孔",value:i?.via_diameter!==void 0?`${i.via_diameter} / ${i.via_drill??"—"} mm(外径/钻孔)`:"未设置"},{label:"DRC 排除项",value:String(Array.isArray(l)?l.length:0)}]}function dJ(e,t){return`"KiCad项目标注: ${e} / 项: ${t.label} / 值: ${t.value}"`}function fJ({content:e,filePath:t,localState:n,onInsertAnnotation:r}){const{t:s}=qn(),i=b.useRef(null),[l,c]=b.useState(null),u=b.useMemo(()=>{try{return{items:uJ(e,n),error:null}}catch(p){return{items:[],error:p instanceof Error?p.message:String(p)}}},[e,n]),f=l===null?null:u.items[l.index];return u.error?o.jsx("pre",{className:"min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-3 font-mono text-xs text-foreground",children:e}):o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col bg-surface",children:[n&&o.jsx("div",{className:"border-b border-[color:var(--warning)]/20 bg-[color:var(--warning)]/5 px-3 py-2 text-xs text-[color:var(--warning)]",children:s("rightSidebar.kicadLocalStateNotice")}),o.jsxs("div",{ref:i,className:"relative min-h-0 flex-1",children:[o.jsxs("div",{className:"h-full overflow-auto px-3 py-2",children:[o.jsx("div",{className:"divide-y divide-border/15",children:u.items.map((p,g)=>o.jsxs("button",{type:"button",onClick:y=>{const v=i.current?.getBoundingClientRect(),S=y.currentTarget.getBoundingClientRect();if(!v?.width||!v.height)return;const A=y.clientX||S.left+S.width/2,T=y.clientY||S.top+S.height/2;c({index:g,xPercent:(A-v.left)/v.width*100,yPercent:(T-v.top)/v.height*100})},className:`grid w-full grid-cols-[minmax(7rem,0.8fr)_minmax(0,1.4fr)] gap-3 px-2 py-3 text-left transition hover:bg-surface-2 ${l?.index===g?"bg-primary/10":""}`,children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:p.label}),o.jsx("span",{className:"break-words text-xs text-foreground",children:p.value})]},p.label))}),o.jsxs("details",{className:"mt-3 border-t border-border/15 pt-3",children:[o.jsx("summary",{className:"cursor-pointer text-xs font-semibold text-muted-foreground",children:s("rightSidebar.kicadShowRawJson")}),o.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre p-2 font-mono text-[10px] leading-relaxed text-foreground",children:e})]})]}),f&&l&&o.jsx(Fg,{anchor:{xPercent:l.xPercent,yPercent:l.yPercent},title:s("rightSidebar.kicadInsertSetting"),onClick:()=>{r?.(dJ(t,f),`kicad-project:${t}:${f.label}`),c(null)},children:s("rightSidebar.kicadInsertSetting")})]}),o.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border/15 px-3 py-2",children:o.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:f?`${f.label}: ${f.value}`:s("rightSidebar.kicadProjectPickHint")})})]})}const hJ=b.forwardRef(function({src:t,title:n,exitFullscreenLabel:r,onFullscreenChange:s},i){const l=b.useRef(null),[c,u]=b.useState(!1),[f,p]=b.useState(!1),g=c||f;b.useEffect(()=>{s?.(g)},[g,s]),b.useEffect(()=>{const S=()=>{u(document.fullscreenElement===l.current)};return document.addEventListener("fullscreenchange",S),()=>document.removeEventListener("fullscreenchange",S)},[]),b.useEffect(()=>{if(!f)return;const S=A=>{A.key==="Escape"&&p(!1)};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[f]);const y=b.useCallback(async()=>{const S=l.current;if(S){if(f){p(!1);return}if(document.fullscreenElement===S){await document.exitFullscreen();return}if(S.requestFullscreen&&document.fullscreenEnabled!==!1)try{await S.requestFullscreen();return}catch{}p(!0)}},[f]);b.useImperativeHandle(i,()=>({toggleFullscreen:y}),[y]);const v=o.jsxs("div",{ref:l,"data-html-preview-frame":!0,className:g?"fixed inset-0 z-modal-panel flex min-h-0 flex-col overflow-hidden bg-surface pt-[env(safe-area-inset-top,0px)] text-foreground":"flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[g&&o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b border-border/15 bg-[var(--chrome-bg)] px-3",children:[o.jsx("span",{className:"min-w-0 truncate text-[12px] font-semibold",children:n}),o.jsx("button",{type:"button",onClick:()=>{y()},"aria-label":r,title:`${r} (Esc)`,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:o.jsx(ty,{size:15})})]}),o.jsx("iframe",{src:t,title:n,sandbox:"allow-scripts",className:"block min-h-0 w-full flex-1 border-0 bg-white"})]});return f?ia.createPortal(v,document.body):v}),bT="termdock-file-search-match",k2="termdock-file-search-current";function pJ(e){const t=e.metaKey||e.ctrlKey,n=e.key.toLocaleLowerCase();return t&&n==="f"?"open":t&&n==="g"||e.key==="F3"?e.shiftKey?"previous":"next":e.key==="Escape"?"close":null}function mJ(e){return e.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function gJ(e,t){const n=t.trim().toLocaleLowerCase();if(!n)return[];const r=[];let s="",i=null;const l=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let p=l.nextNode();p;p=l.nextNode()){if(!(p instanceof Text)||!p.data)continue;const g=mJ(p);if(!g)continue;i&&i!==g&&(s+=`
179
- `);const y=s.length;s+=p.data,r.push({node:p,start:y,end:s.length,group:g}),i=g}const c=s.toLocaleLowerCase(),u=[];let f=0;for(;f<=c.length-n.length;){const p=c.indexOf(n,f);if(p<0)break;const g=p+n.length,y=r.find(S=>S.start<=p&&S.end>p),v=r.find(S=>S.start<g&&S.end>=g);if(y&&v&&y.group===v.group){const S=document.createRange();S.setStart(y.node,p-y.start),S.setEnd(v.node,g-v.start),u.push(S)}f=p+Math.max(n.length,1)}return u}function yT(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Qp(){const e=yT();e?.delete(bT),e?.delete(k2)}function x4(e,t){const n=yT();if(!n||typeof Highlight>"u")return;n.set(bT,new Highlight(...e));const r=e[t];r?n.set(k2,new Highlight(r)):n.delete(k2)}function b4(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}const Jy="termdock:right-sidebar:file-tree-scroll:v1",ev="termdock:right-sidebar:file-preview-reading-state:v1",Tf="termdock:right-sidebar:file-tree-width:v1",vT="termdock:right-sidebar:markdown-view-mode:v1",wT="termdock:right-sidebar:diff-change-list-mode:v1",ST="termdock:right-sidebar:diff-wrap:v1",AT="termdock:diff-viewer:view-type:v1",TT="termdock:right-sidebar:file-search-mode:v1",Ux="termdock:right-sidebar:collapsed-git-repo-groups:v1",y4="termdock:right-sidebar:collapsed-diff-directories:v1",zx="termdock:right-sidebar:branch-audit-module-open:v1",CT="termdock:right-sidebar:branch-audit-module:v1",xJ=150,kT="termdock:right-sidebar:active-git-repo:v1",v4="termdock:right-sidebar:context-draft-enabled:v1",w4="termdock:right-sidebar:context-draft-collapsed:v1",S4="termdock:right-sidebar:context-draft-auto-collapse:v1",Gx="termdock:right-sidebar:context-draft-text:v1",bJ=300,yJ=20,vJ=120,wJ=250,SJ=250,AJ=120,TJ=700,Wx=600,A4=[2e3,5e3,15e3,3e4],CJ=320,kJ=500,_J=20,LJ=12e3,_2=300,T4=240,EJ=560,_T="border-r px-2 py-1.5 sm:px-3 sm:py-2",ng="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",LT=`${_T} border-b border-border/15 font-semibold last:border-r-0`,ET=`${_T} border-border/10 align-top text-muted-foreground last:border-r-0`,tv="termdock-file-preview-horizontal-scroll",C4=b.lazy(()=>l0(()=>import("./ModelPreview-D3WI8Egu.js"),__vite__mapDeps([2,3,1,4]))),IT=`${tv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function IJ(e,t,n){return e&&!t?"unified":n}const RJ=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function NJ(e){return e==="preview"||e==="source"}function MJ(e){return e==="list"||e==="tree"||e==="ai"}function k4(){return Or(vT,NJ)??"preview"}function DJ(){return Or(wT,MJ)??"tree"}function Cf(e){return typeof e=="boolean"}function jJ(e){return typeof e=="string"}function PJ(){return Or(ST,Cf)??!0}function BJ(e){return e==="unified"||e==="split"}function FJ(){return Or(AT,BJ)??"unified"}function OJ(e){return e==="name"||e==="content"||e==="regex"}function QJ(){return Or(TT,OJ)??"name"}function RT(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:bo(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function $J(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function NT(){return Or(kT,$J)??{}}function _4(e){if(!e)return;const t=NT();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Vx(e,t){e&&Gn(kT,{...NT(),[e]:t})}function HJ(e,t){if(!t)return null;const n=new Set((e.repoFilters??[]).map(r=>r.root));return n.has(t)?t:n.size>0?null:(e.repositories??[]).some(r=>r.root===t)?t:null}function L2(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function L4(e){const t=Or(e,L2);return t?new Set(t):new Set}function qx(e,t){Gn(e,[...t])}function UJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.filePath=="string"&&typeof t.hunkHeader=="string"&&typeof t.hunkIndex=="number"&&typeof t.fingerprint=="string"&&typeof t.additions=="number"&&typeof t.deletions=="number"&&typeof t.diff=="string"&&(t.oldPath===void 0||t.oldPath===null||typeof t.oldPath=="string")&&(t.newPath===void 0||t.newPath===null||typeof t.newPath=="string")&&(t.source===void 0||t.source==="committed"||t.source==="uncommitted"||t.source==="unknown")&&(t.commit===void 0||t.commit===null||typeof t.commit=="string")}function zJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.available=="boolean"&&(t.repoRoot===void 0||typeof t.repoRoot=="string")&&(t.workspaceRoot===void 0||typeof t.workspaceRoot=="string")&&(t.baseRef===void 0||typeof t.baseRef=="string")&&(t.baseBranch===void 0||typeof t.baseBranch=="string")&&(t.currentBranch===void 0||t.currentBranch===null||typeof t.currentBranch=="string")&&(t.headRef===void 0||t.headRef===null||typeof t.headRef=="string")&&(t.diffFingerprint===void 0||typeof t.diffFingerprint=="string")&&(t.stat===void 0||typeof t.stat=="string")&&(t.files===void 0||L2(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(UJ))&&(t.commits===void 0||L2(t.commits))&&(t.commitCount===void 0||typeof t.commitCount=="number")&&(t.diff===void 0||typeof t.diff=="string")&&(t.truncated===void 0||typeof t.truncated=="boolean")&&(t.error===void 0||typeof t.error=="string")}function GJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&zJ(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function WJ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return Array.isArray(n.selectedRepoRoots)&&n.selectedRepoRoots.every(r=>typeof r=="string")&&!!n.repoTargetBranches&&typeof n.repoTargetBranches=="object"&&!Array.isArray(n.repoTargetBranches)&&Object.values(n.repoTargetBranches).every(r=>typeof r=="string")&&(n.repoBaseBranches===void 0||!!n.repoBaseBranches&&typeof n.repoBaseBranches=="object"&&!Array.isArray(n.repoBaseBranches)&&Object.values(n.repoBaseBranches).every(r=>typeof r=="string"))&&(n.previewEntries===void 0||Array.isArray(n.previewEntries)&&n.previewEntries.every(GJ))&&(n.selectedPreviewKey===void 0||n.selectedPreviewKey===null||typeof n.selectedPreviewKey=="string")&&(n.selectedPreviewFileKey===void 0||n.selectedPreviewFileKey===null||typeof n.selectedPreviewFileKey=="string")&&(n.previewDetailOpen===void 0||typeof n.previewDetailOpen=="boolean")&&(n.previewScrollTops===void 0||!!n.previewScrollTops&&typeof n.previewScrollTops=="object"&&!Array.isArray(n.previewScrollTops)&&Object.values(n.previewScrollTops).every(r=>typeof r=="number"))&&(n.previewMobileSlideIndex===void 0||typeof n.previewMobileSlideIndex=="number")&&(n.includeUncommitted===void 0||typeof n.includeUncommitted=="boolean")&&typeof n.updatedAt=="number"})}function E4(){return Or(CT,WJ)??{}}function I4(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function R4(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function MT(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||R4(n)===R4(r)}function N4(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!MT(r,t))??""}function E2(e,t){const n=Math.max(T4,t-320),r=Math.min(EJ,n);return Math.min(r,Math.max(T4,e))}function VJ(e){return typeof e=="number"&&Number.isFinite(e)}function qJ(e){return E2(Or(Tf,VJ)??_2,e)}function DT(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function uf(e){return RJ.has(DT(e))}function jT(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function I2(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||jT(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function YJ(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const PT=b.createContext(null);function bm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function BT(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function FT(e){return e.replace(/\s+#+\s*$/,"").trim()}function R2(e,t){const r=BT(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",s=t.headingSlugCounts.get(r)??0;return t.headingSlugCounts.set(r,s+1),s===0?r:`${r}-${s}`}function M4(e){return BT(e)||e.trim()}function rg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=M2(t[2]);return n?{id:bm(t[1]),definition:{href:n.href,title:n.title}}:null}function KJ(e){const t=new Map;for(const n of e){const r=rg(n);r&&t.set(r.id,r.definition)}return t}function OT(e){return e.trim().toLowerCase()}function QT(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:OT(t[1]),text:t[2]}:null}function XJ(e){const t=new Map;let n=null;for(const r of e){const s=QT(r);if(s){n=s.id,t.set(s.id,{id:s.id,text:s.text,index:t.size+1});continue}if(n&&/^\s{4,}\S/.test(r)){const i=t.get(n);i&&(i.text=`${i.text} ${r.trim()}`);continue}r.trim()&&(n=null)}return t}function ZJ(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(QT(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function JJ(e){const t=[...e];let n=0;const r=e[0]?.trim();if(r==="---"||r==="+++"){for(t[0]="",n=1;n<e.length&&e[n].trim()!==r;)t[n]="",n+=1;n<e.length&&(t[n]="",n+=1)}for(;n<e.length;){const s=e[n].trim();if(s.startsWith("<!--")){if(t[n]="",!s.includes("-->")){for(n+=1;n<e.length&&!e[n].includes("-->");)t[n]="",n+=1;n<e.length&&(t[n]="")}n+=1;continue}n+=1}return t}function $T(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function Ff(e){const t=e.split(/[?#]/,1)[0],n=t.startsWith("/"),r=[];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`${n?"/":""}${r.join("/")}`||(n?"/":".")}function eee(e,t,n){const r=e.trim();if(!r||/^(?:https?:|mailto:|javascript:|data:|#)/i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))return null;const s=r.indexOf("#"),i=s>=0?r.slice(0,s):r,l=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=l?decodeURIComponent(l):null}catch{return null}const p=n?Ff(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=Ff(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=Ff(`${$T(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function tee(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!G2(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=Ff(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=Ff(`${$T(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const N2=128,nee=360,Yx=480;function nv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function ree(e,t,n,r){if(!t||!n)return null;let s,i;return nv(e)?(i=Math.min(Math.max(n,N2),nee),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Yx&&(s=s*Yx/i,i=Yx),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function see(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function HT(e){const t=see(e),n=xt(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function iee({src:e,alt:t,title:n}){const r=nv(e),s=HT(e),i=b.useRef(null),[l,c]=b.useState(!1),[u,f]=b.useState(0),[p,g]=b.useState({status:"loading"}),[y,v]=b.useState(null);b.useLayoutEffect(()=>{const T=i.current,L=T?.parentElement?.parentElement??T?.parentElement;if(!L)return;const I=()=>f(L.clientWidth);if(I(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(I);return j.observe(L),()=>j.disconnect()},[]),b.useEffect(()=>{if(l)return;const T=i.current;if(!T||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(I=>{I.some(j=>j.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(T),()=>L.disconnect()},[l]),b.useEffect(()=>{if(!l)return;const T=new AbortController;let L=null;g({status:"loading"});const I=window.setTimeout(()=>{T.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:T.signal}).then(async j=>{if(!j.ok)throw new Error(`HTTP ${j.status}`);const P=Number(j.headers.get("X-Image-Width"))||0,F=Number(j.headers.get("X-Image-Height"))||0;return{blob:await j.blob(),width:P,height:F}}).then(({blob:j,width:P,height:F})=>{T.signal.aborted||(L=URL.createObjectURL(j),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const j=T.signal.reason;T.signal.aborted&&!(j instanceof DOMException&&j.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(I)}),()=>{window.clearTimeout(I),T.abort(),L&&URL.revokeObjectURL(L)}},[l,s]);const S=ree(e,y?.width??0,y?.height??0,u),A=S??{width:N2*2,height:N2};return o.jsx("div",{ref:i,className:"block max-w-full",style:S?{width:S.width,height:S.height}:void 0,children:p.status==="ready"?o.jsx("img",{src:p.objectUrl,alt:t,title:n,decoding:"async",className:`${r?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:S?{width:S.width,height:S.height}:void 0,onLoad:T=>{if(y)return;const L=T.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):p.status==="fallback"?o.jsx("img",{src:s,alt:t,title:n,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:S?{width:S.width,height:S.height}:void 0,onLoad:T=>{if(y)return;const L=T.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):o.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Kx(e,t,n,r,s){const i=tee(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const l=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(iee,{src:i,alt:t,title:r});return s.onImageOpen?o.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:r||t||"Open image",onClick:u=>{u.stopPropagation(),s.onImageOpen?.(l)},children:c},e):o.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c},e)}function Xx(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function D4(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function M2(e){const t=e.trim(),n=t.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(n)return{href:n[1],title:n[2]??n[3]??n[4]};const r=t.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return r?{href:r[1],title:r[2]??r[3]??r[4]}:null}const UT="",oee=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function aee(e){return e.replace(oee,(t,n)=>`${UT}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function j4(e){return e.replace(new RegExp(`${UT}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function lee(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const zT={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let $p=null;function GT(){return $p||($p=l0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw $p=null,e})),$p}function WT({html:e}){const{t}=qn(),[n,r]=b.useState(null);return b.useEffect(()=>{let s=!1;return r(null),GT().then(i=>{s||r(i.sanitize(e,zT))}).catch(()=>{s||r("")}),()=>{s=!0}},[e]),n===null?o.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:t("rightSidebar.renderingHtml")}):n?o.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:n}}):null}function cee({html:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!1;return n(null),GT().then(s=>{r||n(s.sanitize(e,zT))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function VT(e){const t=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!t)return null;const n=t[1].toLowerCase();return{tag:n,selfContained:new RegExp(`</${n}>`,"i").test(e)}}let Hp=null;function uee(){return Hp||(Hp=Promise.all([l0(()=>import("./katex-DnlPpQZa.js"),[]),l0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw Hp=null,e})),Hp}function nh({tex:e,display:t=!1}){const[n,r]=b.useState(null),[s,i]=b.useState(!1);if(b.useEffect(()=>{let c=!1;return r(null),i(!1),uee().then(u=>{c||r(u.renderToString(e,{displayMode:t,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[t,e]),s)return o.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:t?`$$${e}$$`:`$${e}$`});if(!n)return o.jsx("span",{className:"text-muted-foreground/70",children:t?"Rendering formula...":e});const l=t?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return o.jsx("span",{className:l,dangerouslySetInnerHTML:{__html:n}})}function dee(e,t,n){if(/^<br\s*\/?>$/i.test(e))return o.jsx("br",{},t);const r=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!r)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?o.jsx(cee,{html:e},t):null;const s=r[1].toLowerCase(),i=wi(r[2],`${t}-${s}`,!0,n);return s==="kbd"?o.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:i},t):s==="mark"?o.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:i},t):s==="sub"?o.jsx("sub",{children:i},t):o.jsx("sup",{children:i},t)}function wi(e,t,n=!0,r){const s=aee(e),i=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,l=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&l.push(j4(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?dee(f,p,r):null;if(g)l.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))l.push(o.jsx(nh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))l.push(o.jsx(nh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;l.push(o.jsx("code",{className:`${n?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:lee(f.slice(y,-y))},p))}else if(f.startsWith("~~"))l.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:wi(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))l.push(o.jsx("strong",{className:"font-semibold text-foreground",children:wi(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))l.push(o.jsx("em",{className:"italic",children:wi(f.slice(1,-1),`${p}-em`,n,r)},p));else if(f.startsWith("![")){const y=f.match(/^!\[([^\]]*)\]\((.*)\)$/),v=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^!\[([^\]]+)\]$/);if(y){const A=M2(y[2]);l.push(A?Kx(p,y[1],A.href,A.title,r):f)}else if(v){const A=v[2]||v[1],T=r.referenceDefinitions.get(bm(A));l.push(T?Kx(p,v[1],T.href,T.title,r):f)}else if(S){const A=r.referenceDefinitions.get(bm(S[1]));l.push(A?Kx(p,S[1],A.href,A.title,r):f)}else l.push(f)}else if(f.startsWith("[^")){const y=OT(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);l.push(v?o.jsx("sup",{id:`fnref-${v.id}`,title:v.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:o.jsx("a",{href:`#fn-${v.id}`,className:"text-primary no-underline",children:v.index})},p):f)}else if(f.startsWith("<http")){const y=f.slice(1,-1);l.push(o.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(f.startsWith("<")&&f.endsWith(">")&&D4(f.slice(1,-1))){const y=f.slice(1,-1);l.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(D4(Xx(f).linkText)){const{linkText:y,suffix:v}=Xx(f);l.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&l.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=Xx(f),S=y.startsWith("www.")?`https://${y}`:y;l.push(o.jsx("a",{href:S,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&l.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),A=v?v[2]||v[1]:S?.[1]??null,T=A?r.referenceDefinitions.get(bm(A)):null,L=y?M2(y[2]):null,I=L?.href??T?.href??null,j=I?YJ(I):null,P=y?.[1]??v?.[1]??S?.[1]??"";l.push(j?o.jsx("a",{href:j,title:L?.title??T?.title,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:wi(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&l.push(j4(s.slice(c))),l.length>0?l:[e]}function qT(e){return/(?: {2,}|\\)$/.test(e)}function YT(e){return e.replace(/(?: {2,}|\\)$/,"")}function sg(e){return/^(?: {4}|\t)/.test(e)}function KT(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function XT(e,t,n){const r=[];return e.forEach((s,i)=>{const l=qT(s);r.push(...wi(YT(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(l?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function D2(e,t,n){const r=[],s=[];return e.forEach((i,l)=>{s.push(qT(i)),r.push(wi(YT(i),`${t}-${l}`,!0,n))}),{perLine:r,hardBreaks:s}}function j2(e,t,n,r,s){const i=[];return e.forEach((l,c)=>{const u=n[c]??0,f=!!(s&&u>=s.start&&u<=s.end);i.push(o.jsx("span",{"data-md-ref-start":u,"data-md-ref-end":u,"data-selected":f?"true":void 0,children:l},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function rh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,l=0;for(let c=0;c<t.length;c+=1){const u=t[c];if(s){r+=u,s=!1;continue}if(u==="\\"){s=!0;continue}if(u==="`"){const f=c;for(;c+1<t.length&&t[c+1]==="`";)c+=1;const p=c-f+1;r+="`".repeat(p),i===0?i=p:i===p&&(i=0);continue}if(i===0&&u==="["?l+=1:i===0&&u==="]"&&l>0&&(l-=1),u==="|"&&i===0&&l===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function ZT(e){return rh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function ig(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function og(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function fee(e,t){return e>96||e>44&&t>.35}function rv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function sv(e){const t=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!t)return null;const n=/^\d+[.)]$/.test(t[1]);return{ordered:n,start:n?Number.parseInt(t[1],10):void 0,content:t[2]}}function JT(e,t,n,r,s,i=new Set){const l=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(rg(f)||i.has(u))){u+=1;continue}const p=sv(f),g=rv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(A=>A.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const A of c)A.item.lineEnd=u+1;u+=1;continue}break}if(g<n||g===n&&p.ordered!==r)break;const y={content:p.content,ordered:p.ordered,start:p.start,children:[],paragraphs:[],lineStart:u+1,lineEnd:u+1};for(;c.length>0&&c[c.length-1].indent>=g;)c.pop();const v=c[c.length-1]?.item??null;v?v.children.push(y):l.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:l,nextIndex:u}}function iv(e,t,n,r=0){return e.map((s,i)=>{const l=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!l,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[l?o.jsx("input",{type:"checkbox",checked:l[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,wi(l?.[2]??s.content,`li-${t}-${i}`,!0,n),s.paragraphs.length>0&&o.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:s.paragraphs.map((c,u)=>o.jsx("p",{children:wi(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:hee(s.children,`${t}-${i}`,n,r)}})}function hee(e,t,n,r=0){const s=[];for(const i of e){const l=s[s.length-1];l&&l.ordered===i.ordered?l.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,l)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:iv(i.items,`${t}-g${l}`,n,r)}))}function ov(e,t){return e.map(n=>{const r=!!(t&&n.refStart<=t.end&&n.refEnd>=t.start);return o.jsxs("li",{className:n.taskItem?"list-none":void 0,"data-md-ref-start":n.refStart,"data-md-ref-end":n.refEnd,"data-selected":r?"true":void 0,children:[n.content,n.groups.length>0&&pee(n.groups,t)]},n.key)})}function pee(e,t){return e.map((n,r)=>{const s=n.ordered?"ol":"ul";return o.jsx(s,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:ov(n.items,t)},`nested-${r}`)})}function mee(e){const t=Array.from(e.footnoteDefinitions.values()).sort((n,r)=>n.index-r.index);return t.length===0?null:o.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[o.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),o.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:t.map(n=>o.jsxs("li",{id:`fn-${n.id}`,children:[wi(n.text,`footnote-${n.id}`,!0,e)," ",o.jsx("a",{href:`#fnref-${n.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(n.index),children:"↩"})]},n.id))})]})}function gee(e,t,n,r){const s=[];let i=0;const l=c=>r?.[c]??c+1;for(;i<e.length;){const c=e[i],u=c.trim();if(!u){i+=1;continue}if(/^<details>\s*$/i.test(u)){const L=i;let I="Details";const j=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?I=P[1].trim()||I:j.push(e[i].trimStart()),i+=1}i<e.length&&(i+=1),s.push({kind:"static",node:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:wi(I,`${t}-details-${L}-summary`,!0,n)}),j.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:XT(j,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=VT(c);if(f){const L=[c],I=i;for(i+=1;i<e.length&&!f.selfContained&&!new RegExp(`</${f.tag}>`,"i").test(e[i]);)L.push(e[i]),i+=1;i<e.length&&!f.selfContained&&(L.push(e[i]),i+=1),s.push({kind:"static",node:o.jsx(WT,{html:L.join(`
179
+ `);const y=s.length;s+=p.data,r.push({node:p,start:y,end:s.length,group:g}),i=g}const c=s.toLocaleLowerCase(),u=[];let f=0;for(;f<=c.length-n.length;){const p=c.indexOf(n,f);if(p<0)break;const g=p+n.length,y=r.find(S=>S.start<=p&&S.end>p),v=r.find(S=>S.start<g&&S.end>=g);if(y&&v&&y.group===v.group){const S=document.createRange();S.setStart(y.node,p-y.start),S.setEnd(v.node,g-v.start),u.push(S)}f=p+Math.max(n.length,1)}return u}function yT(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function Qp(){const e=yT();e?.delete(bT),e?.delete(k2)}function x4(e,t){const n=yT();if(!n||typeof Highlight>"u")return;n.set(bT,new Highlight(...e));const r=e[t];r?n.set(k2,new Highlight(r)):n.delete(k2)}function b4(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}const Jy="termdock:right-sidebar:file-tree-scroll:v1",ev="termdock:right-sidebar:file-preview-reading-state:v1",Tf="termdock:right-sidebar:file-tree-width:v1",vT="termdock:right-sidebar:markdown-view-mode:v1",wT="termdock:right-sidebar:diff-change-list-mode:v1",ST="termdock:right-sidebar:diff-wrap:v1",AT="termdock:diff-viewer:view-type:v1",TT="termdock:right-sidebar:file-search-mode:v1",Ux="termdock:right-sidebar:collapsed-git-repo-groups:v1",y4="termdock:right-sidebar:collapsed-diff-directories:v1",zx="termdock:right-sidebar:branch-audit-module-open:v1",CT="termdock:right-sidebar:branch-audit-module:v1",xJ=150,kT="termdock:right-sidebar:active-git-repo:v1",v4="termdock:right-sidebar:context-draft-enabled:v1",w4="termdock:right-sidebar:context-draft-collapsed:v1",S4="termdock:right-sidebar:context-draft-auto-collapse:v1",Gx="termdock:right-sidebar:context-draft-text:v1",bJ=300,yJ=20,vJ=120,wJ=250,SJ=250,AJ=120,TJ=700,Wx=600,A4=[2e3,5e3,15e3,3e4],CJ=320,kJ=500,_J=20,LJ=12e3,_2=300,T4=240,EJ=560,_T="border-r px-2 py-1.5 sm:px-3 sm:py-2",ng="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",LT=`${_T} border-b border-border/15 font-semibold last:border-r-0`,ET=`${_T} border-border/10 align-top text-muted-foreground last:border-r-0`,tv="termdock-file-preview-horizontal-scroll",C4=b.lazy(()=>l0(()=>import("./ModelPreview-W7h96fo0.js"),__vite__mapDeps([2,3,1,4]))),IT=`${tv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function IJ(e,t,n){return e&&!t?"unified":n}const RJ=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function NJ(e){return e==="preview"||e==="source"}function MJ(e){return e==="list"||e==="tree"||e==="ai"}function k4(){return Or(vT,NJ)??"preview"}function DJ(){return Or(wT,MJ)??"tree"}function Cf(e){return typeof e=="boolean"}function jJ(e){return typeof e=="string"}function PJ(){return Or(ST,Cf)??!0}function BJ(e){return e==="unified"||e==="split"}function FJ(){return Or(AT,BJ)??"unified"}function OJ(e){return e==="name"||e==="content"||e==="regex"}function QJ(){return Or(TT,OJ)??"name"}function RT(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:bo(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function $J(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function NT(){return Or(kT,$J)??{}}function _4(e){if(!e)return;const t=NT();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Vx(e,t){e&&Gn(kT,{...NT(),[e]:t})}function HJ(e,t){if(!t)return null;const n=new Set((e.repoFilters??[]).map(r=>r.root));return n.has(t)?t:n.size>0?null:(e.repositories??[]).some(r=>r.root===t)?t:null}function L2(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function L4(e){const t=Or(e,L2);return t?new Set(t):new Set}function qx(e,t){Gn(e,[...t])}function UJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.filePath=="string"&&typeof t.hunkHeader=="string"&&typeof t.hunkIndex=="number"&&typeof t.fingerprint=="string"&&typeof t.additions=="number"&&typeof t.deletions=="number"&&typeof t.diff=="string"&&(t.oldPath===void 0||t.oldPath===null||typeof t.oldPath=="string")&&(t.newPath===void 0||t.newPath===null||typeof t.newPath=="string")&&(t.source===void 0||t.source==="committed"||t.source==="uncommitted"||t.source==="unknown")&&(t.commit===void 0||t.commit===null||typeof t.commit=="string")}function zJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.available=="boolean"&&(t.repoRoot===void 0||typeof t.repoRoot=="string")&&(t.workspaceRoot===void 0||typeof t.workspaceRoot=="string")&&(t.baseRef===void 0||typeof t.baseRef=="string")&&(t.baseBranch===void 0||typeof t.baseBranch=="string")&&(t.currentBranch===void 0||t.currentBranch===null||typeof t.currentBranch=="string")&&(t.headRef===void 0||t.headRef===null||typeof t.headRef=="string")&&(t.diffFingerprint===void 0||typeof t.diffFingerprint=="string")&&(t.stat===void 0||typeof t.stat=="string")&&(t.files===void 0||L2(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(UJ))&&(t.commits===void 0||L2(t.commits))&&(t.commitCount===void 0||typeof t.commitCount=="number")&&(t.diff===void 0||typeof t.diff=="string")&&(t.truncated===void 0||typeof t.truncated=="boolean")&&(t.error===void 0||typeof t.error=="string")}function GJ(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&zJ(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function WJ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>{if(!t||typeof t!="object"||Array.isArray(t))return!1;const n=t;return Array.isArray(n.selectedRepoRoots)&&n.selectedRepoRoots.every(r=>typeof r=="string")&&!!n.repoTargetBranches&&typeof n.repoTargetBranches=="object"&&!Array.isArray(n.repoTargetBranches)&&Object.values(n.repoTargetBranches).every(r=>typeof r=="string")&&(n.repoBaseBranches===void 0||!!n.repoBaseBranches&&typeof n.repoBaseBranches=="object"&&!Array.isArray(n.repoBaseBranches)&&Object.values(n.repoBaseBranches).every(r=>typeof r=="string"))&&(n.previewEntries===void 0||Array.isArray(n.previewEntries)&&n.previewEntries.every(GJ))&&(n.selectedPreviewKey===void 0||n.selectedPreviewKey===null||typeof n.selectedPreviewKey=="string")&&(n.selectedPreviewFileKey===void 0||n.selectedPreviewFileKey===null||typeof n.selectedPreviewFileKey=="string")&&(n.previewDetailOpen===void 0||typeof n.previewDetailOpen=="boolean")&&(n.previewScrollTops===void 0||!!n.previewScrollTops&&typeof n.previewScrollTops=="object"&&!Array.isArray(n.previewScrollTops)&&Object.values(n.previewScrollTops).every(r=>typeof r=="number"))&&(n.previewMobileSlideIndex===void 0||typeof n.previewMobileSlideIndex=="number")&&(n.includeUncommitted===void 0||typeof n.includeUncommitted=="boolean")&&typeof n.updatedAt=="number"})}function E4(){return Or(CT,WJ)??{}}function I4(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function R4(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function MT(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||R4(n)===R4(r)}function N4(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!MT(r,t))??""}function E2(e,t){const n=Math.max(T4,t-320),r=Math.min(EJ,n);return Math.min(r,Math.max(T4,e))}function VJ(e){return typeof e=="number"&&Number.isFinite(e)}function qJ(e){return E2(Or(Tf,VJ)??_2,e)}function DT(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function uf(e){return RJ.has(DT(e))}function jT(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function I2(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||jT(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function YJ(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const PT=b.createContext(null);function bm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function BT(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function FT(e){return e.replace(/\s+#+\s*$/,"").trim()}function R2(e,t){const r=BT(e).toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").trim().replace(/\s+/g,"-")||"section",s=t.headingSlugCounts.get(r)??0;return t.headingSlugCounts.set(r,s+1),s===0?r:`${r}-${s}`}function M4(e){return BT(e)||e.trim()}function rg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=M2(t[2]);return n?{id:bm(t[1]),definition:{href:n.href,title:n.title}}:null}function KJ(e){const t=new Map;for(const n of e){const r=rg(n);r&&t.set(r.id,r.definition)}return t}function OT(e){return e.trim().toLowerCase()}function QT(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:OT(t[1]),text:t[2]}:null}function XJ(e){const t=new Map;let n=null;for(const r of e){const s=QT(r);if(s){n=s.id,t.set(s.id,{id:s.id,text:s.text,index:t.size+1});continue}if(n&&/^\s{4,}\S/.test(r)){const i=t.get(n);i&&(i.text=`${i.text} ${r.trim()}`);continue}r.trim()&&(n=null)}return t}function ZJ(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(QT(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function JJ(e){const t=[...e];let n=0;const r=e[0]?.trim();if(r==="---"||r==="+++"){for(t[0]="",n=1;n<e.length&&e[n].trim()!==r;)t[n]="",n+=1;n<e.length&&(t[n]="",n+=1)}for(;n<e.length;){const s=e[n].trim();if(s.startsWith("<!--")){if(t[n]="",!s.includes("-->")){for(n+=1;n<e.length&&!e[n].includes("-->");)t[n]="",n+=1;n<e.length&&(t[n]="")}n+=1;continue}n+=1}return t}function $T(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function Ff(e){const t=e.split(/[?#]/,1)[0],n=t.startsWith("/"),r=[];for(const i of t.split("/"))if(!(!i||i===".")){if(i===".."){r.length>0&&r.pop();continue}r.push(i)}return`${n?"/":""}${r.join("/")}`||(n?"/":".")}function eee(e,t,n){const r=e.trim();if(!r||/^(?:https?:|mailto:|javascript:|data:|#)/i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))return null;const s=r.indexOf("#"),i=s>=0?r.slice(0,s):r,l=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=l?decodeURIComponent(l):null}catch{return null}const p=n?Ff(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=Ff(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=Ff(`${$T(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function tee(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!G2(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=Ff(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=Ff(`${$T(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const N2=128,nee=360,Yx=480;function nv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function ree(e,t,n,r){if(!t||!n)return null;let s,i;return nv(e)?(i=Math.min(Math.max(n,N2),nee),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Yx&&(s=s*Yx/i,i=Yx),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function see(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function HT(e){const t=see(e),n=xt(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function iee({src:e,alt:t,title:n}){const r=nv(e),s=HT(e),i=b.useRef(null),[l,c]=b.useState(!1),[u,f]=b.useState(0),[p,g]=b.useState({status:"loading"}),[y,v]=b.useState(null);b.useLayoutEffect(()=>{const T=i.current,L=T?.parentElement?.parentElement??T?.parentElement;if(!L)return;const I=()=>f(L.clientWidth);if(I(),typeof ResizeObserver>"u")return;const j=new ResizeObserver(I);return j.observe(L),()=>j.disconnect()},[]),b.useEffect(()=>{if(l)return;const T=i.current;if(!T||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(I=>{I.some(j=>j.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(T),()=>L.disconnect()},[l]),b.useEffect(()=>{if(!l)return;const T=new AbortController;let L=null;g({status:"loading"});const I=window.setTimeout(()=>{T.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:T.signal}).then(async j=>{if(!j.ok)throw new Error(`HTTP ${j.status}`);const P=Number(j.headers.get("X-Image-Width"))||0,F=Number(j.headers.get("X-Image-Height"))||0;return{blob:await j.blob(),width:P,height:F}}).then(({blob:j,width:P,height:F})=>{T.signal.aborted||(L=URL.createObjectURL(j),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const j=T.signal.reason;T.signal.aborted&&!(j instanceof DOMException&&j.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(I)}),()=>{window.clearTimeout(I),T.abort(),L&&URL.revokeObjectURL(L)}},[l,s]);const S=ree(e,y?.width??0,y?.height??0,u),A=S??{width:N2*2,height:N2};return o.jsx("div",{ref:i,className:"block max-w-full",style:S?{width:S.width,height:S.height}:void 0,children:p.status==="ready"?o.jsx("img",{src:p.objectUrl,alt:t,title:n,decoding:"async",className:`${r?"":"termdock-fade-in "}block max-h-[480px] max-w-full object-contain`,style:S?{width:S.width,height:S.height}:void 0,onLoad:T=>{if(y)return;const L=T.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):p.status==="fallback"?o.jsx("img",{src:s,alt:t,title:n,loading:"lazy",decoding:"async",className:"block max-h-[480px] max-w-full object-contain",style:S?{width:S.width,height:S.height}:void 0,onLoad:T=>{if(y)return;const L=T.currentTarget;L.naturalWidth>0&&L.naturalHeight>0&&v({width:L.naturalWidth,height:L.naturalHeight})}}):o.jsx("div",{"aria-hidden":!0,className:"flex max-w-full animate-pulse items-center justify-center rounded bg-surface-elevated/60",style:{width:A.width,height:A.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Kx(e,t,n,r,s){const i=tee(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const l=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(iee,{src:i,alt:t,title:r});return s.onImageOpen?o.jsx("button",{type:"button",className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2 text-left transition hover:border-border-strong focus:outline-none focus:ring-2 focus:ring-ring/45",title:r||t||"Open image",onClick:u=>{u.stopPropagation(),s.onImageOpen?.(l)},children:c},e):o.jsx("span",{className:"my-2 block max-w-full overflow-hidden rounded-md border border-border/20 bg-surface-2",children:c},e)}function Xx(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function D4(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function M2(e){const t=e.trim(),n=t.match(/^<([^>]+)>(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);if(n)return{href:n[1],title:n[2]??n[3]??n[4]};const r=t.match(/^(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?$/);return r?{href:r[1],title:r[2]??r[3]??r[4]}:null}const UT="",oee=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function aee(e){return e.replace(oee,(t,n)=>`${UT}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function j4(e){return e.replace(new RegExp(`${UT}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function lee(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const zT={ALLOWED_TAGS:["a","abbr","b","blockquote","br","code","del","details","div","em","i","kbd","li","mark","ol","p","pre","s","span","strong","sub","summary","sup","table","tbody","td","th","thead","tr","u","ul"],ALLOWED_ATTR:["href","title","class","id","colspan","rowspan"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0};let $p=null;function GT(){return $p||($p=l0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw $p=null,e})),$p}function WT({html:e}){const{t}=qn(),[n,r]=b.useState(null);return b.useEffect(()=>{let s=!1;return r(null),GT().then(i=>{s||r(i.sanitize(e,zT))}).catch(()=>{s||r("")}),()=>{s=!0}},[e]),n===null?o.jsx("div",{className:"py-2 text-xs text-muted-foreground",children:t("rightSidebar.renderingHtml")}):n?o.jsx("div",{className:"text-muted-foreground",dangerouslySetInnerHTML:{__html:n}}):null}function cee({html:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!1;return n(null),GT().then(s=>{r||n(s.sanitize(e,zT))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function VT(e){const t=e.trim().match(/^<(div|section|article|aside|table|p|ul|ol|li|blockquote|pre|figure|figcaption)\b[^>]*>/i);if(!t)return null;const n=t[1].toLowerCase();return{tag:n,selfContained:new RegExp(`</${n}>`,"i").test(e)}}let Hp=null;function uee(){return Hp||(Hp=Promise.all([l0(()=>import("./katex-DnlPpQZa.js"),[]),l0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw Hp=null,e})),Hp}function nh({tex:e,display:t=!1}){const[n,r]=b.useState(null),[s,i]=b.useState(!1);if(b.useEffect(()=>{let c=!1;return r(null),i(!1),uee().then(u=>{c||r(u.renderToString(e,{displayMode:t,throwOnError:!1,trust:!1,strict:"ignore"}))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[t,e]),s)return o.jsx("code",{className:"rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground",children:t?`$$${e}$$`:`$${e}$`});if(!n)return o.jsx("span",{className:"text-muted-foreground/70",children:t?"Rendering formula...":e});const l=t?"my-2 overflow-auto rounded-md bg-surface-2 px-3 py-2 text-center":"inline-block align-middle";return o.jsx("span",{className:l,dangerouslySetInnerHTML:{__html:n}})}function dee(e,t,n){if(/^<br\s*\/?>$/i.test(e))return o.jsx("br",{},t);const r=e.match(/^<(kbd|mark|sub|sup)>(.*?)<\/\1>$/i);if(!r)return/^<(a|abbr|span|b|strong|em|i|u|s|del|code)\b[\s\S]*<\/\1>$/i.test(e)?o.jsx(cee,{html:e},t):null;const s=r[1].toLowerCase(),i=wi(r[2],`${t}-${s}`,!0,n);return s==="kbd"?o.jsx("kbd",{className:"rounded border border-border/30 bg-surface-2 px-1.5 py-0.5 font-mono text-[0.85em] text-foreground shadow-sm",children:i},t):s==="mark"?o.jsx("mark",{className:"rounded bg-warning/25 px-0.5 text-foreground",children:i},t):s==="sub"?o.jsx("sub",{children:i},t):o.jsx("sup",{children:i},t)}function wi(e,t,n=!0,r){const s=aee(e),i=/(\\\([^)]*\\\)|\$[^$\n]+\$|<br\s*\/?>|<(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)\b[\s\S]*?<\/(?:a|abbr|span|b|strong|em|i|u|s|del|code|kbd|mark|sub|sup)>|!?\[[^\]]*\]\((?:<[^>]+>|(?:[^\s()]+|\([^()\s]*\))+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\)|!?\[[^\]]+\]\[[^\]]*\]|!?\[[^\]]+\]|\[\^[^\]]+\]|(`+)([\s\S]*?)\2|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|\*[^*\s][^*]*\*|_[^_\s][^_]*_|<https?:\/\/[^>\s]+>|<[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+>|https?:\/\/[^\s<]+|www\.[^\s<]+|[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+)/gi,l=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&l.push(j4(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?dee(f,p,r):null;if(g)l.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))l.push(o.jsx(nh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))l.push(o.jsx(nh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;l.push(o.jsx("code",{className:`${n?"break-all":"whitespace-nowrap"} rounded bg-surface-2 px-1 py-0.5 font-mono text-[0.92em] text-foreground`,children:lee(f.slice(y,-y))},p))}else if(f.startsWith("~~"))l.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:wi(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))l.push(o.jsx("strong",{className:"font-semibold text-foreground",children:wi(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))l.push(o.jsx("em",{className:"italic",children:wi(f.slice(1,-1),`${p}-em`,n,r)},p));else if(f.startsWith("![")){const y=f.match(/^!\[([^\]]*)\]\((.*)\)$/),v=f.match(/^!\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^!\[([^\]]+)\]$/);if(y){const A=M2(y[2]);l.push(A?Kx(p,y[1],A.href,A.title,r):f)}else if(v){const A=v[2]||v[1],T=r.referenceDefinitions.get(bm(A));l.push(T?Kx(p,v[1],T.href,T.title,r):f)}else if(S){const A=r.referenceDefinitions.get(bm(S[1]));l.push(A?Kx(p,S[1],A.href,A.title,r):f)}else l.push(f)}else if(f.startsWith("[^")){const y=OT(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);l.push(v?o.jsx("sup",{id:`fnref-${v.id}`,title:v.text,className:"ml-0.5 rounded bg-surface-2 px-1 text-[0.72em] font-semibold text-primary",children:o.jsx("a",{href:`#fn-${v.id}`,className:"text-primary no-underline",children:v.index})},p):f)}else if(f.startsWith("<http")){const y=f.slice(1,-1);l.push(o.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(f.startsWith("<")&&f.endsWith(">")&&D4(f.slice(1,-1))){const y=f.slice(1,-1);l.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p))}else if(D4(Xx(f).linkText)){const{linkText:y,suffix:v}=Xx(f);l.push(o.jsx("a",{href:`mailto:${y}`,className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&l.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=Xx(f),S=y.startsWith("www.")?`https://${y}`:y;l.push(o.jsx("a",{href:S,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:y},p)),v&&l.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),A=v?v[2]||v[1]:S?.[1]??null,T=A?r.referenceDefinitions.get(bm(A)):null,L=y?M2(y[2]):null,I=L?.href??T?.href??null,j=I?YJ(I):null,P=y?.[1]??v?.[1]??S?.[1]??"";l.push(j?o.jsx("a",{href:j,title:L?.title??T?.title,target:"_blank",rel:"noreferrer",className:`${n?"break-all":"whitespace-nowrap"} text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,children:wi(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&l.push(j4(s.slice(c))),l.length>0?l:[e]}function qT(e){return/(?: {2,}|\\)$/.test(e)}function YT(e){return e.replace(/(?: {2,}|\\)$/,"")}function sg(e){return/^(?: {4}|\t)/.test(e)}function KT(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function XT(e,t,n){const r=[];return e.forEach((s,i)=>{const l=qT(s);r.push(...wi(YT(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(l?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function D2(e,t,n){const r=[],s=[];return e.forEach((i,l)=>{s.push(qT(i)),r.push(wi(YT(i),`${t}-${l}`,!0,n))}),{perLine:r,hardBreaks:s}}function j2(e,t,n,r,s){const i=[];return e.forEach((l,c)=>{const u=n[c]??0,f=!!(s&&u>=s.start&&u<=s.end);i.push(o.jsx("span",{"data-md-ref-start":u,"data-md-ref-end":u,"data-selected":f?"true":void 0,children:l},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function rh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,l=0;for(let c=0;c<t.length;c+=1){const u=t[c];if(s){r+=u,s=!1;continue}if(u==="\\"){s=!0;continue}if(u==="`"){const f=c;for(;c+1<t.length&&t[c+1]==="`";)c+=1;const p=c-f+1;r+="`".repeat(p),i===0?i=p:i===p&&(i=0);continue}if(i===0&&u==="["?l+=1:i===0&&u==="]"&&l>0&&(l-=1),u==="|"&&i===0&&l===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function ZT(e){return rh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function ig(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function og(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function fee(e,t){return e>96||e>44&&t>.35}function rv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function sv(e){const t=e.trim().match(/^([-+*]|\d+[.)])\s+(.+)$/);if(!t)return null;const n=/^\d+[.)]$/.test(t[1]);return{ordered:n,start:n?Number.parseInt(t[1],10):void 0,content:t[2]}}function JT(e,t,n,r,s,i=new Set){const l=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(rg(f)||i.has(u))){u+=1;continue}const p=sv(f),g=rv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(A=>A.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const A of c)A.item.lineEnd=u+1;u+=1;continue}break}if(g<n||g===n&&p.ordered!==r)break;const y={content:p.content,ordered:p.ordered,start:p.start,children:[],paragraphs:[],lineStart:u+1,lineEnd:u+1};for(;c.length>0&&c[c.length-1].indent>=g;)c.pop();const v=c[c.length-1]?.item??null;v?v.children.push(y):l.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:l,nextIndex:u}}function iv(e,t,n,r=0){return e.map((s,i)=>{const l=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!l,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[l?o.jsx("input",{type:"checkbox",checked:l[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,wi(l?.[2]??s.content,`li-${t}-${i}`,!0,n),s.paragraphs.length>0&&o.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:s.paragraphs.map((c,u)=>o.jsx("p",{children:wi(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:hee(s.children,`${t}-${i}`,n,r)}})}function hee(e,t,n,r=0){const s=[];for(const i of e){const l=s[s.length-1];l&&l.ordered===i.ordered?l.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,l)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:iv(i.items,`${t}-g${l}`,n,r)}))}function ov(e,t){return e.map(n=>{const r=!!(t&&n.refStart<=t.end&&n.refEnd>=t.start);return o.jsxs("li",{className:n.taskItem?"list-none":void 0,"data-md-ref-start":n.refStart,"data-md-ref-end":n.refEnd,"data-selected":r?"true":void 0,children:[n.content,n.groups.length>0&&pee(n.groups,t)]},n.key)})}function pee(e,t){return e.map((n,r)=>{const s=n.ordered?"ol":"ul";return o.jsx(s,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} mt-1 space-y-0.5 pl-4 marker:text-muted-foreground/60`,children:ov(n.items,t)},`nested-${r}`)})}function mee(e){const t=Array.from(e.footnoteDefinitions.values()).sort((n,r)=>n.index-r.index);return t.length===0?null:o.jsxs("section",{className:"mt-3 border-t border-border/20 pt-2 text-[12px] leading-5 text-muted-foreground",children:[o.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/80",children:e.footnotesLabel}),o.jsx("ol",{className:"list-decimal space-y-1 pl-5",children:t.map(n=>o.jsxs("li",{id:`fn-${n.id}`,children:[wi(n.text,`footnote-${n.id}`,!0,e)," ",o.jsx("a",{href:`#fnref-${n.id}`,className:"text-primary no-underline","aria-label":e.backToFootnoteLabel(n.index),children:"↩"})]},n.id))})]})}function gee(e,t,n,r){const s=[];let i=0;const l=c=>r?.[c]??c+1;for(;i<e.length;){const c=e[i],u=c.trim();if(!u){i+=1;continue}if(/^<details>\s*$/i.test(u)){const L=i;let I="Details";const j=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?I=P[1].trim()||I:j.push(e[i].trimStart()),i+=1}i<e.length&&(i+=1),s.push({kind:"static",node:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:wi(I,`${t}-details-${L}-summary`,!0,n)}),j.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:XT(j,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=VT(c);if(f){const L=[c],I=i;for(i+=1;i<e.length&&!f.selfContained&&!new RegExp(`</${f.tag}>`,"i").test(e[i]);)L.push(e[i]),i+=1;i<e.length&&!f.selfContained&&(L.push(e[i]),i+=1),s.push({kind:"static",node:o.jsx(WT,{html:L.join(`
180
180
  `)},`${t}-html-${I}`)});continue}const p=u.match(/^(```|~~~)\s*(.*)$/);if(p){const L=[],I=p[1],j=p[2]?.trim(),P=i;for(i+=1;i<e.length&&!e[i].trim().startsWith(I);)L.push(e[i]),i+=1;i<e.length&&(i+=1),j.toLowerCase()==="mermaid"?s.push({kind:"static",node:o.jsx(tC,{code:L.join(`
181
181
  `),blockKey:`${t}-code-${P}`},`${t}-code-${P}`)}):["math","latex","tex"].includes(j.toLowerCase())?s.push({kind:"static",node:o.jsx(nh,{tex:L.join(`
182
182
  `),display:!0},`${t}-code-${P}`)}):s.push({kind:"code",key:`${t}-code-${P}`,code:L.join(`
183
183
  `),lang:j,blockKey:`${t}-code-${P}`,codeStartLine:l(P)+1});continue}if(sg(c)){const L=[],I=i;for(;i<e.length&&(sg(e[i])||!e[i].trim());)L.push(e[i].trim()?KT(e[i]):""),i+=1;s.push({kind:"code",key:`${t}-indented-code-${I}`,code:L.join(`
184
- `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${I}`,codeStartLine:l(I)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const I=`h${Math.min(6,g[1].length+1)}`,j=FT(g[2]),P=R2(j,n);s.push({kind:"static",node:o.jsx(I,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:wi(j,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&og(e[i+1])){const L=rh(c),I=ZT(e[i+1]),j=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)j.push(rh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:IT,"data-markdown-table-scroll":!0,children:o.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[o.jsx("thead",{className:"bg-surface-2 text-foreground",children:o.jsx("tr",{children:L.map((F,R)=>o.jsx("th",{className:`${LT} ${ig(I[R]??null)}`,children:o.jsx("div",{className:ng,children:wi(F,`${t}-th-${P}-${R}`,!0,n)})},`h-${R}`))})}),o.jsx("tbody",{children:j.map((F,R)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((C,$)=>o.jsx("td",{className:`${ET} ${ig(I[$]??null)}`,children:o.jsx("div",{className:ng,children:wi(F[$]??"",`${t}-td-${P}-${R}-${$}`,!0,n)})},`c-${$}`))},`r-${R}`))})]})},`${t}-table-${P}`)});continue}const y=sv(c);if(y){const L=y.ordered,I=rv(c),j=y.start,P=i,F=JT(e,i,I,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?j:void 0,renders:iv(F.items,`${t}-list-${P}`,n,l(0)-1)});continue}const v=[c.trimStart()],S=[l(i)],A=i;for(i+=1;i<e.length&&e[i].trim()&&!I2(e[i])&&!(i+1<e.length&&e[i].includes("|")&&og(e[i+1]));)v.push(e[i].trimStart()),S.push(l(i)),i+=1;const T=D2(v,`${t}-p-${A}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${A}`,perLine:T.perLine,hardBreaks:T.hardBreaks,lineNums:S})}return s}function xee(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:j2(n.perLine,n.hardBreaks,n.lineNums,n.keyPrefix,t)},n.keyPrefix);case"list":{const r=n.ordered?"ol":"ul";return o.jsx(r,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:ov(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(ag,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let Up=null,P4=!1;const zp=16,eC=192;function bee(){return Up||(Up=l0(()=>import("./mermaid.core-CbGyS7XX.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw Up=null,e})),Up}function yee(e){P4||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),P4=!0)}function vee(e){const t=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!t)return e;const[,,n]=t,r=n.trim().split(/[\s,]+/).map(Number),[,,s,i]=r;if(!Number.isFinite(s)||!Number.isFinite(i)||s<=0||i<=0)return e;const l=Math.max(eC,Math.ceil(s)),c=Math.ceil(l/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${l}" height="${c}">`)}function wee(e){const t=e?.querySelector("svg");if(!t)return;let n;try{n=t.getBBox()}catch{return}if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return;const r=n.x-zp,s=n.y-zp,i=n.width+zp*2,l=n.height+zp*2,c=Math.max(eC,Math.ceil(i)),u=Math.ceil(c/i*l);t.setAttribute("viewBox",`${r} ${s} ${i} ${l}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function See(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return Yd(`code.${n}`)??n}function tC({code:e,blockKey:t}){const{t:n}=qn(),[r,s]=b.useState(null),[i,l]=b.useState(!1),c=b.useRef(null),u=b.useContext(PT);b.useEffect(()=>{let p=!1;return s(null),l(!1),bee().then(async g=>{yee(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(vee(v))}).catch(()=>{p||l(!0)}),()=>{p=!0}},[t,e]),b.useLayoutEffect(()=>{r&&wee(c.current)},[r]);const f=b.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(ag,{code:e,lang:"mermaid",blockKey:`${t}-fallback`}):o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),o.jsx("div",{className:"bg-surface p-3",children:r?o.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:n("rightSidebar.openMermaidDiagram"),onClick:p=>{p.stopPropagation(),f()},children:o.jsx("span",{ref:c,role:"img","aria-label":n("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:r}})}):o.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:n("rightSidebar.renderingDiagram")})})]})}function ag({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=See(t),[l,c]=b.useState(null);b.useEffect(()=>{if(!i||!K9(e)){c(null);return}let f=!1;return X9().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(Z9(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=l??(e||" ").split(`
184
+ `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${I}`,codeStartLine:l(I)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const I=`h${Math.min(6,g[1].length+1)}`,j=FT(g[2]),P=R2(j,n);s.push({kind:"static",node:o.jsx(I,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:wi(j,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&og(e[i+1])){const L=rh(c),I=ZT(e[i+1]),j=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)j.push(rh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:IT,"data-markdown-table-scroll":!0,children:o.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[o.jsx("thead",{className:"bg-surface-2 text-foreground",children:o.jsx("tr",{children:L.map((F,R)=>o.jsx("th",{className:`${LT} ${ig(I[R]??null)}`,children:o.jsx("div",{className:ng,children:wi(F,`${t}-th-${P}-${R}`,!0,n)})},`h-${R}`))})}),o.jsx("tbody",{children:j.map((F,R)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((C,$)=>o.jsx("td",{className:`${ET} ${ig(I[$]??null)}`,children:o.jsx("div",{className:ng,children:wi(F[$]??"",`${t}-td-${P}-${R}-${$}`,!0,n)})},`c-${$}`))},`r-${R}`))})]})},`${t}-table-${P}`)});continue}const y=sv(c);if(y){const L=y.ordered,I=rv(c),j=y.start,P=i,F=JT(e,i,I,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?j:void 0,renders:iv(F.items,`${t}-list-${P}`,n,l(0)-1)});continue}const v=[c.trimStart()],S=[l(i)],A=i;for(i+=1;i<e.length&&e[i].trim()&&!I2(e[i])&&!(i+1<e.length&&e[i].includes("|")&&og(e[i+1]));)v.push(e[i].trimStart()),S.push(l(i)),i+=1;const T=D2(v,`${t}-p-${A}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${A}`,perLine:T.perLine,hardBreaks:T.hardBreaks,lineNums:S})}return s}function xee(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:j2(n.perLine,n.hardBreaks,n.lineNums,n.keyPrefix,t)},n.keyPrefix);case"list":{const r=n.ordered?"ol":"ul";return o.jsx(r,{start:n.start,className:`${n.ordered?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:ov(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(ag,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let Up=null,P4=!1;const zp=16,eC=192;function bee(){return Up||(Up=l0(()=>import("./mermaid.core-CA8slCHp.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw Up=null,e})),Up}function yee(e){P4||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),P4=!0)}function vee(e){const t=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!t)return e;const[,,n]=t,r=n.trim().split(/[\s,]+/).map(Number),[,,s,i]=r;if(!Number.isFinite(s)||!Number.isFinite(i)||s<=0||i<=0)return e;const l=Math.max(eC,Math.ceil(s)),c=Math.ceil(l/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${l}" height="${c}">`)}function wee(e){const t=e?.querySelector("svg");if(!t)return;let n;try{n=t.getBBox()}catch{return}if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return;const r=n.x-zp,s=n.y-zp,i=n.width+zp*2,l=n.height+zp*2,c=Math.max(eC,Math.ceil(i)),u=Math.ceil(c/i*l);t.setAttribute("viewBox",`${r} ${s} ${i} ${l}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function See(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return Yd(`code.${n}`)??n}function tC({code:e,blockKey:t}){const{t:n}=qn(),[r,s]=b.useState(null),[i,l]=b.useState(!1),c=b.useRef(null),u=b.useContext(PT);b.useEffect(()=>{let p=!1;return s(null),l(!1),bee().then(async g=>{yee(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(vee(v))}).catch(()=>{p||l(!0)}),()=>{p=!0}},[t,e]),b.useLayoutEffect(()=>{r&&wee(c.current)},[r]);const f=b.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(ag,{code:e,lang:"mermaid",blockKey:`${t}-fallback`}):o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"mermaid"}),o.jsx("div",{className:"bg-surface p-3",children:r?o.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:n("rightSidebar.openMermaidDiagram"),onClick:p=>{p.stopPropagation(),f()},children:o.jsx("span",{ref:c,role:"img","aria-label":n("rightSidebar.mermaidDiagram"),className:"block max-h-[70vh] max-w-full overflow-auto rounded bg-white p-2 text-slate-900 [&_svg]:block [&_svg]:h-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:r}})}):o.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:n("rightSidebar.renderingDiagram")})})]})}function ag({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=See(t),[l,c]=b.useState(null);b.useEffect(()=>{if(!i||!K9(e)){c(null);return}let f=!1;return X9().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(Z9(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=l??(e||" ").split(`
185
185
  `).map(f=>[f||" "]);return o.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[t&&o.jsx("div",{className:"border-b border-border/15 bg-surface-2 px-3 py-1.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:t}),o.jsx("pre",{className:`${tv} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:o.jsx("code",{children:u.map((f,p)=>{const g=r!=null?r+p:null,y=!!(s&&g!=null&&g>=s.start&&g<=s.end);return o.jsxs("span",{"data-md-ref-start":g??void 0,"data-md-ref-end":g??void 0,"data-selected":y?"true":void 0,children:[f,p<u.length-1?`
186
186
  `:null]},`${n}-line-${p}`)})})})]})}function Aee(e,t,n,r,s){e=JJ(e);const i=KJ(e),l=ZJ(e),c=[],u={markdownFilePath:t,rootPath:n,referenceDefinitions:i,footnoteDefinitions:XJ(e),headingSlugCounts:new Map,images:c,onImageOpen:r,footnotesLabel:s?.footnotes??"Footnotes",backToFootnoteLabel:s?.backToFootnote??(y=>`Back to footnote ${y}`)},f=[];let p=0;for(;p<e.length;){const y=e[p],v=y.trim();if(rg(y)||l.has(p)){p+=1;continue}if(!v){p+=1;continue}if(/^<details>\s*$/i.test(v)){const R=p;let C="Details";const $=[];for(p+=1;p<e.length&&!/^<\/details>\s*$/i.test(e[p].trim());){const Q=e[p].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);Q?C=Q[1].trim()||C:$.push(e[p].trimStart()),p+=1}p<e.length&&(p+=1),f.push({key:`details-${R}`,startLine:R+1,endLine:p,content:o.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[o.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:wi(C,`details-${R}-summary`,!0,u)}),$.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:XT($,`details-${R}`,u)})]})});continue}const S=VT(y);if(S){const R=[y],C=p;for(p+=1;p<e.length&&!S.selfContained&&!new RegExp(`</${S.tag}>`,"i").test(e[p]);)R.push(e[p]),p+=1;p<e.length&&!S.selfContained&&(R.push(e[p]),p+=1),f.push({key:`html-${C}`,startLine:C+1,endLine:p,content:o.jsx(WT,{html:R.join(`
187
187
  `)})});continue}const A=v.match(/^(```|~~~)\s*(.*)$/);if(A){const R=[],C=A[1],$=A[2]?.trim(),Q=p;for(p+=1;p<e.length&&!e[p].trim().startsWith(C);)R.push(e[p]),p+=1;p<e.length&&(p+=1),f.push({key:`code-${Q}`,startLine:Q+1,endLine:p,fineGrained:$.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes($.toLowerCase()),content:$.toLowerCase()==="mermaid"?o.jsx(tC,{code:R.join(`
@@ -454,4 +454,4 @@ ${Lt}
454
454
  + }
455
455
  return context;
456
456
  }`}};function l7(){if(typeof window>"u")return"kotlin";const t=new URLSearchParams(window.location.search).get("fixture");return t&&t in F2?t:"kotlin"}function c7(){return typeof window>"u"?"unified":new URLSearchParams(window.location.search).get("view")==="split"?"split":"unified"}function u7(){if(typeof window>"u")return"words";const e=new URLSearchParams(window.location.search).get("inline");return e==="none"||e==="chars"||e==="words"?e:"words"}function d7(){return typeof window>"u"?!0:new URLSearchParams(window.location.search).get("wrap")!=="off"}function jte(){const[e,t]=b.useState(()=>l7()),[n,r]=b.useState(()=>c7()),[s,i]=b.useState(()=>u7()),[l,c]=b.useState(()=>d7()),u=F2[e],f=b.useMemo(()=>Object.entries(F2),[]);return b.useEffect(()=>{if(typeof window>"u")return;let p=window.location.search;const g=()=>{window.location.search!==p&&(p=window.location.search,t(l7()),r(c7()),i(u7()),c(d7()))};window.addEventListener("popstate",g),window.addEventListener("pageshow",g),window.addEventListener("focus",g);const y=window.setInterval(g,250);return()=>{window.removeEventListener("popstate",g),window.removeEventListener("pageshow",g),window.removeEventListener("focus",g),window.clearInterval(y)}},[]),o.jsx("div",{className:"min-h-screen bg-background-subtle text-foreground","data-diff-lab":!0,"data-diff-lab-fixture":e,"data-diff-lab-view":n,"data-diff-lab-inline":s,"data-diff-lab-wrap":l?"on":"off",children:o.jsxs("div",{className:"mx-auto flex min-h-screen max-w-[1180px] flex-col px-4 py-4",children:[o.jsxs("header",{className:"mb-3 flex flex-wrap items-center justify-between gap-3 border-b border-border/20 pb-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-semibold",children:"Diff Lab"}),o.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Fixed fixtures for iterating diff rendering without app auth, PWA state, or live Git data."})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("select",{value:e,onChange:p=>t(p.target.value),"aria-label":"Fixture",className:"h-8 rounded-md border border-border/30 bg-surface px-2 text-xs text-foreground outline-none",children:f.map(([p,g])=>o.jsx("option",{value:p,children:g.label},p))}),o.jsxs("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>r("unified"),className:`rounded-full px-3 text-xs font-semibold ${n==="unified"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Unified"}),o.jsx("button",{type:"button",onClick:()=>r("split"),className:`rounded-full px-3 text-xs font-semibold ${n==="split"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Split"})]}),o.jsx("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:["none","words","chars"].map(p=>o.jsx("button",{type:"button",onClick:()=>i(p),className:`rounded-full px-3 text-xs font-semibold ${s===p?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:p},p))}),o.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:`h-8 rounded-full px-3 text-xs font-semibold ${l?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:["Wrap ",l?"on":"off"]})]})]}),o.jsx("main",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border/20 bg-surface",children:o.jsx(dT,{filePath:u.path,repoRoot:"/tmp/termdock-diff-lab",changedFile:{path:u.path,absolutePath:`/tmp/termdock-diff-lab/${u.path}`,repoRoot:"/tmp/termdock-diff-lab",status:"modified",staged:!1,unstaged:!0,untracked:!1,tracked:!0,canStage:!1,canUnstage:!1,canStash:!1,canRestoreWorktree:!1},diffOverride:u.diff,oldSourceOverride:u.oldSource,active:!0,wrap:l,showScrollHint:!l,viewType:n,inlineMode:s})})]})})}const mC=40,O2="/tmp/termdock-diff-review-lab";function f7(e,t){const n=[`diff --git a/${e} b/${e}`,`--- a/${e}`,`+++ b/${e}`,`@@ -1,${t} +1,${t} @@`];for(let r=0;r<t;r+=1)r%5===0&&n.push(`-const removed_${r} = ${r};`),r%3===0&&n.push(`+const added_${r} = ${r} * 2;`),n.push(` context line ${r} in ${e}`);return n.join(`
457
- `)}function Pte(e,t){return Array.from({length:mC},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,l=`${O2}/${i}`,c=f7(i,s),u=f7(i,1);return{key:l,path:i,absolutePath:l,status:"modified",repoRoot:O2,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function Bte(){const e=b.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),I=L===null?0:Number.parseInt(L,10);return Number.isInteger(I)&&I>0?I:0},[]),t=e>0,[n,r]=b.useState(()=>new Set);b.useEffect(()=>{if(!t)return;const L=Array.from({length:mC},(I,j)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(j),F})},e+j*20));return()=>L.forEach(I=>window.clearTimeout(I))},[t,e]);const s=b.useMemo(()=>Pte(n,t),[n,t]),i=b.useMemo(()=>[{key:"mock-repo",root:O2,label:"diff-review-lab",files:s.map(L=>({key:L.key,path:L.path,absolutePath:L.absolutePath,displayName:L.displayName,displayDir:L.displayDir,status:L.status}))}],[s]),l=b.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const I=Number.parseInt(L,10);return Number.isInteger(I)&&I>=0&&I<s.length?I:null},[s.length]),[c,u]=b.useState(()=>l!==null?s[l].key:null),[f,p]=b.useState(()=>({key:l!==null?s[l].key:null,nonce:l!==null?1:0})),[g,y]=b.useState("list"),[v,S]=b.useState(new Set),[A,T]=b.useState(l!==null?1:0);return o.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[o.jsxs("div",{className:"shrink-0 border-b border-border/20 px-3 py-2 text-xs text-muted-foreground",children:["DiffReview Lab · ",s.length," mock files · selected: ",o.jsx("span",{"data-lab-selected":!0,children:c??"none"})," · slide ",A]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(Jm,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:c,scrollToKey:f.key,scrollToKeyNonce:f.nonce,mode:g,onModeChange:L=>{L!=="ai"&&y(L)},collapsedDirectoryKeys:v,onToggleDirectory:L=>S(I=>{const j=new Set(I);return j.has(L)?j.delete(L):j.add(L),j}),onSelectFile:L=>{u(L.key),p(I=>({key:L.key,nonce:I.nonce+1}))},onMobileSlideChange:T,renderLeading:()=>null,renderStreamBadge:L=>o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const Fte=6e4,ab="termdock:build-id:v1";let h7=!1;function p7(){h7||(h7=!0,window.setTimeout(()=>{window.location.reload()},80))}function Q2(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function Ote(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function Qte(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Q2(e)})})}function $te(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788145843770",t=window.localStorage.getItem(ab);if(t&&t!==e){Ote().finally(()=>{window.localStorage.setItem(ab,e),p7()});return}t!==e&&window.localStorage.setItem(ab,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",p7),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{Qte(r),Q2(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Q2(r)).catch(()=>{})};s(),n=window.setInterval(s,Fte),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}VF();$te();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,XA(e))}catch{}function Hte(){const{t:e}=qn(),[t,n]=b.useState(null),[r,s]=b.useState(null),i=b.useCallback(async()=>{try{const l=await NE();n(l),s(null)}catch(l){s(l instanceof Error?l.message:"Failed to query auth status")}},[]);return b.useEffect(()=>{i()},[i]),b.useEffect(()=>{const l=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(Am,l),()=>window.removeEventListener(Am,l)},[]),t===null?o.jsx("div",{className:"flex w-screen items-center justify-center bg-background text-muted-foreground",style:{height:"var(--app-vh, 100vh)"},children:r?`${e("common.error")}: ${r}`:e("common.loading")}):t.enabled&&!t.authenticated?o.jsx(Mte,{onLoginSuccess:i}):o.jsx(Rte,{})}Zk.createRoot(document.getElementById("root")).render(o.jsx(D.StrictMode,{children:o.jsx(bR,{children:o.jsx(rS,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(Dte,{}):e.get("diff-review-lab")==="1"?o.jsx(Bte,{}):e.get("diff-lab")==="1"?o.jsx(jte,{}):o.jsx(Hte,{})})()})})}));export{GN as M,si as R,PM as S,l0 as _,KN as a,ZN as b,Rt as c,o as j,qn as u,ML as v};
457
+ `)}function Pte(e,t){return Array.from({length:mC},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,l=`${O2}/${i}`,c=f7(i,s),u=f7(i,1);return{key:l,path:i,absolutePath:l,status:"modified",repoRoot:O2,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function Bte(){const e=b.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),I=L===null?0:Number.parseInt(L,10);return Number.isInteger(I)&&I>0?I:0},[]),t=e>0,[n,r]=b.useState(()=>new Set);b.useEffect(()=>{if(!t)return;const L=Array.from({length:mC},(I,j)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(j),F})},e+j*20));return()=>L.forEach(I=>window.clearTimeout(I))},[t,e]);const s=b.useMemo(()=>Pte(n,t),[n,t]),i=b.useMemo(()=>[{key:"mock-repo",root:O2,label:"diff-review-lab",files:s.map(L=>({key:L.key,path:L.path,absolutePath:L.absolutePath,displayName:L.displayName,displayDir:L.displayDir,status:L.status}))}],[s]),l=b.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const I=Number.parseInt(L,10);return Number.isInteger(I)&&I>=0&&I<s.length?I:null},[s.length]),[c,u]=b.useState(()=>l!==null?s[l].key:null),[f,p]=b.useState(()=>({key:l!==null?s[l].key:null,nonce:l!==null?1:0})),[g,y]=b.useState("list"),[v,S]=b.useState(new Set),[A,T]=b.useState(l!==null?1:0);return o.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[o.jsxs("div",{className:"shrink-0 border-b border-border/20 px-3 py-2 text-xs text-muted-foreground",children:["DiffReview Lab · ",s.length," mock files · selected: ",o.jsx("span",{"data-lab-selected":!0,children:c??"none"})," · slide ",A]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(Jm,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:c,scrollToKey:f.key,scrollToKeyNonce:f.nonce,mode:g,onModeChange:L=>{L!=="ai"&&y(L)},collapsedDirectoryKeys:v,onToggleDirectory:L=>S(I=>{const j=new Set(I);return j.has(L)?j.delete(L):j.add(L),j}),onSelectFile:L=>{u(L.key),p(I=>({key:L.key,nonce:I.nonce+1}))},onMobileSlideChange:T,renderLeading:()=>null,renderStreamBadge:L=>o.jsx("span",{className:"text-[10px] text-muted-foreground",children:L}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const Fte=6e4,ab="termdock:build-id:v1";let h7=!1;function p7(){h7||(h7=!0,window.setTimeout(()=>{window.location.reload()},80))}function Q2(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function Ote(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function Qte(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Q2(e)})})}function $te(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788146995793",t=window.localStorage.getItem(ab);if(t&&t!==e){Ote().finally(()=>{window.localStorage.setItem(ab,e),p7()});return}t!==e&&window.localStorage.setItem(ab,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",p7),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{Qte(r),Q2(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Q2(r)).catch(()=>{})};s(),n=window.setInterval(s,Fte),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}VF();$te();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,XA(e))}catch{}function Hte(){const{t:e}=qn(),[t,n]=b.useState(null),[r,s]=b.useState(null),i=b.useCallback(async()=>{try{const l=await NE();n(l),s(null)}catch(l){s(l instanceof Error?l.message:"Failed to query auth status")}},[]);return b.useEffect(()=>{i()},[i]),b.useEffect(()=>{const l=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(Am,l),()=>window.removeEventListener(Am,l)},[]),t===null?o.jsx("div",{className:"flex w-screen items-center justify-center bg-background text-muted-foreground",style:{height:"var(--app-vh, 100vh)"},children:r?`${e("common.error")}: ${r}`:e("common.loading")}):t.enabled&&!t.authenticated?o.jsx(Mte,{onLoginSuccess:i}):o.jsx(Rte,{})}Zk.createRoot(document.getElementById("root")).render(o.jsx(D.StrictMode,{children:o.jsx(bR,{children:o.jsx(rS,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(Dte,{}):e.get("diff-review-lab")==="1"?o.jsx(Bte,{}):e.get("diff-lab")==="1"?o.jsx(jte,{}):o.jsx(Hte,{})})()})})}));export{GN as M,si as R,PM as S,l0 as _,KN as a,ZN as b,Rt as c,o as j,qn as u,ML as v};