termdock 1.4.136 → 1.4.137

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 (66) hide show
  1. package/dist/client/assets/{ModelPreview-N79HO2Xj.js → ModelPreview-B_15098g.js} +1 -1
  2. package/dist/client/assets/{abnfDiagram-VRR7QNED-BDD2dTMf.js → abnfDiagram-VRR7QNED-CxT5HdLc.js} +1 -1
  3. package/dist/client/assets/{arc-DorSIVIJ.js → arc-DIBRuTBU.js} +1 -1
  4. package/dist/client/assets/{architectureDiagram-ZJ3FMSHR--CyRzZak.js → architectureDiagram-ZJ3FMSHR-Bs6_7Dj8.js} +1 -1
  5. package/dist/client/assets/{blockDiagram-677ZJIJ3-DRwAr1I5.js → blockDiagram-677ZJIJ3-3op2jx2E.js} +1 -1
  6. package/dist/client/assets/{c4Diagram-LMCZKHZV-Ckc2ONKa.js → c4Diagram-LMCZKHZV-BoIbO-RC.js} +1 -1
  7. package/dist/client/assets/channel-DPr_StHU.js +1 -0
  8. package/dist/client/assets/{chunk-2Q5K7J3B-JIf6QffJ.js → chunk-2Q5K7J3B-DbtK5AeL.js} +1 -1
  9. package/dist/client/assets/{chunk-32BRIVSS-CrTjyEwl.js → chunk-32BRIVSS-CYJKhqD8.js} +1 -1
  10. package/dist/client/assets/{chunk-5VM5RSS4-aTkk2IJY.js → chunk-5VM5RSS4-DD1_neFV.js} +1 -1
  11. package/dist/client/assets/{chunk-EX3LRPZG-B4l-wm5s.js → chunk-EX3LRPZG-C8f70vD8.js} +1 -1
  12. package/dist/client/assets/{chunk-JWPE2WC7-DMxa154b.js → chunk-JWPE2WC7-s_-xQkqn.js} +1 -1
  13. package/dist/client/assets/{chunk-MOJQB5TN-Ksw1aADz.js → chunk-MOJQB5TN-BAgaTxQ0.js} +1 -1
  14. package/dist/client/assets/{chunk-RYQCIY6F-BQbDzzp-.js → chunk-RYQCIY6F-Dd_tkLTs.js} +1 -1
  15. package/dist/client/assets/{chunk-V7JOEXUC-C69WNuJ0.js → chunk-V7JOEXUC-usI4eGK6.js} +1 -1
  16. package/dist/client/assets/{chunk-VR4S4FIN-B8fTAxMd.js → chunk-VR4S4FIN-yCAknfdP.js} +1 -1
  17. package/dist/client/assets/{chunk-XXDRQBXY-p1VblfTF.js → chunk-XXDRQBXY-uRdasUgd.js} +1 -1
  18. package/dist/client/assets/classDiagram-OUVF2IWQ-msZMVPWM.js +1 -0
  19. package/dist/client/assets/classDiagram-v2-EOCWNBFH-msZMVPWM.js +1 -0
  20. package/dist/client/assets/{cose-bilkent-JH36ORCC-d7VPt96a.js → cose-bilkent-JH36ORCC-CuOmp48Y.js} +1 -1
  21. package/dist/client/assets/{cynefin-VYW2F7L2-RndaE4Ee.js → cynefin-VYW2F7L2--uhztSd7.js} +1 -1
  22. package/dist/client/assets/{cynefinDiagram-TSTJHNR4-9Ec6dcNk.js → cynefinDiagram-TSTJHNR4-C9reurzU.js} +1 -1
  23. package/dist/client/assets/{dagre-VKFMJZFB-DZLHGL4u.js → dagre-VKFMJZFB-BTs-Xxii.js} +1 -1
  24. package/dist/client/assets/{diagram-FQU43EPY-BVUV0Rn9.js → diagram-FQU43EPY-3G7IHyQr.js} +1 -1
  25. package/dist/client/assets/{diagram-G47NLZAW-BIY5l77G.js → diagram-G47NLZAW-CP6MsBWW.js} +1 -1
  26. package/dist/client/assets/{diagram-NH7WQ7WH-TeO07f_s.js → diagram-NH7WQ7WH-DOGhBfLv.js} +1 -1
  27. package/dist/client/assets/{diagram-OA4YK3LP-CPZcFO_D.js → diagram-OA4YK3LP-CHKo49iL.js} +1 -1
  28. package/dist/client/assets/{diagram-WEI45ONY-C1TrcDj_.js → diagram-WEI45ONY-CgurpSA-.js} +1 -1
  29. package/dist/client/assets/{ebnfDiagram-CCIWWBDH-BWvo-Zeh.js → ebnfDiagram-CCIWWBDH-Y5D3g4PM.js} +1 -1
  30. package/dist/client/assets/{erDiagram-Q63AITRT-BJSy-5jU.js → erDiagram-Q63AITRT-ChCXkC8x.js} +1 -1
  31. package/dist/client/assets/{flowDiagram-23GEKE2U-Bt6fjIq2.js → flowDiagram-23GEKE2U-DSAAnqaK.js} +1 -1
  32. package/dist/client/assets/{ganttDiagram-NO4QXBWP-BbUUOUEp.js → ganttDiagram-NO4QXBWP-Bf6jlk3e.js} +1 -1
  33. package/dist/client/assets/{gitGraphDiagram-IHSO6WYX-bvyVR88D.js → gitGraphDiagram-IHSO6WYX-CjxTUSWK.js} +1 -1
  34. package/dist/client/assets/{index-COmOaQLJ.js → index-Czdzov0N.js} +5 -5
  35. package/dist/client/assets/{infoDiagram-FWYZ7A6U-BtFgHVDM.js → infoDiagram-FWYZ7A6U-BlZuR9Aa.js} +1 -1
  36. package/dist/client/assets/{ishikawaDiagram-FXEZZL3T-CKGl8mSB.js → ishikawaDiagram-FXEZZL3T-DL999nAM.js} +1 -1
  37. package/dist/client/assets/{journeyDiagram-5HDEW3XC-_L01s2Ve.js → journeyDiagram-5HDEW3XC-iQuJSwc7.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-HUTT4EX6-S93MxTVa.js → kanban-definition-HUTT4EX6-CztQ06Do.js} +1 -1
  39. package/dist/client/assets/{linear-dLKElKxI.js → linear-iGLaUX1m.js} +1 -1
  40. package/dist/client/assets/{mermaid.core-9k4zR2lI.js → mermaid.core-0rN8fFng.js} +4 -4
  41. package/dist/client/assets/{mindmap-definition-LN4V7U3C-BXhrW-0f.js → mindmap-definition-LN4V7U3C-BnhhJ0in.js} +1 -1
  42. package/dist/client/assets/{pegDiagram-2B236MQR-5SzKoVuo.js → pegDiagram-2B236MQR-CZPTANSI.js} +1 -1
  43. package/dist/client/assets/{pieDiagram-ENE6RG2P-Dwx5_pHw.js → pieDiagram-ENE6RG2P-C2uRckoK.js} +1 -1
  44. package/dist/client/assets/{quadrantDiagram-ABIIQ3AL-Du5tFuj1.js → quadrantDiagram-ABIIQ3AL-tj2Y0i1p.js} +1 -1
  45. package/dist/client/assets/{railroadDiagram-RFXS5EU6-BBkV0idf.js → railroadDiagram-RFXS5EU6-BwQMSsAg.js} +1 -1
  46. package/dist/client/assets/{requirementDiagram-TGXJPOKE-6IGFJSA4.js → requirementDiagram-TGXJPOKE-DRpke6X5.js} +1 -1
  47. package/dist/client/assets/{sankeyDiagram-HTMAVEWB-DPxS4t4Z.js → sankeyDiagram-HTMAVEWB-DXz7kiIj.js} +1 -1
  48. package/dist/client/assets/{sequenceDiagram-DBY2YBRQ-DbqpnqCF.js → sequenceDiagram-DBY2YBRQ-5WsCrpnh.js} +1 -1
  49. package/dist/client/assets/{sizeCapture-X5ZJPWSS-CbxBaNt1.js → sizeCapture-X5ZJPWSS-BmFioRCr.js} +1 -1
  50. package/dist/client/assets/{stateDiagram-2N3HPSRC-B0DKaz5K.js → stateDiagram-2N3HPSRC-CkNQJ4KX.js} +1 -1
  51. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-DyIgv5Rc.js +1 -0
  52. package/dist/client/assets/{swimlanes-5IMT3BWC-CjHnH2IO.js → swimlanes-5IMT3BWC-Bc4v9Rmf.js} +2 -2
  53. package/dist/client/assets/swimlanesDiagram-G3AALYLV-DxSx4i_x.js +8 -0
  54. package/dist/client/assets/{timeline-definition-FHXFAJF6-iKTzZKOP.js → timeline-definition-FHXFAJF6-CKBhyL-0.js} +1 -1
  55. package/dist/client/assets/{vennDiagram-L72KCM5P-ikL6G0oa.js → vennDiagram-L72KCM5P-uE41Ry1N.js} +1 -1
  56. package/dist/client/assets/{wardleyDiagram-EHGQE667-oOKYl9NH.js → wardleyDiagram-EHGQE667-BJrjOoeL.js} +1 -1
  57. package/dist/client/assets/{xychartDiagram-FW5EYKEG-Ys7S6f0K.js → xychartDiagram-FW5EYKEG-CZ495fDP.js} +1 -1
  58. package/dist/client/index.html +1 -1
  59. package/dist/client/sw.js +1 -1
  60. package/package.json +1 -1
  61. package/runtime-manifest.json +1 -1
  62. package/dist/client/assets/channel-Cm_Q58zS.js +0 -1
  63. package/dist/client/assets/classDiagram-OUVF2IWQ-Cdr3a4Sz.js +0 -1
  64. package/dist/client/assets/classDiagram-v2-EOCWNBFH-Cdr3a4Sz.js +0 -1
  65. package/dist/client/assets/stateDiagram-v2-6OUMAXLB-BfY1l2b0.js +0 -1
  66. package/dist/client/assets/swimlanesDiagram-G3AALYLV-Bla7ZtT1.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-N79HO2Xj.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-9k4zR2lI.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-B_15098g.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-0rN8fFng.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
2
2
  import{r as Bg,a as R_,g as x7}from"./react-XDCjal2T.js";import{b as x,R as M,r as ui,a as N_}from"./dnd-BCFAPC0L.js";import{L as M_,l as D_}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 a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).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 z1={exports:{}},gf={};var p5;function j_(){if(p5)return gf;p5=1;var e=Bg(),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 a(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 gf.Fragment=n,gf.jsx=a,gf.jsxs=a,gf}var m5;function P_(){return m5||(m5=1,z1.exports=j_()),z1.exports}var o=P_(),Rp={},g5;function B_(){if(g5)return Rp;g5=1;var e=R_();return Rp.createRoot=e.createRoot,Rp.hydrateRoot=e.hydrateRoot,Rp}var F_=B_();const O_=x7(F_);function x5(e){return e!==null&&typeof e=="object"&&"constructor"in e&&e.constructor===Object}function Ry(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]:x5(t[r])&&x5(e[r])&&Object.keys(t[r]).length>0&&Ry(e[r],t[r])})}const b7={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 dd(){const e=typeof document<"u"?document:{};return Ry(e,b7),e}const Q_={document:b7,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 la(){const e=typeof window<"u"?window:{};return Ry(e,Q_),e}function $_(e=""){return e.trim().split(" ").filter(t=>!!t.trim())}function H_(e){const t=e;Object.keys(t).forEach(n=>{try{t[n]=null}catch{}try{delete t[n]}catch{}})}function y7(e,t=0){return setTimeout(e,t)}function Ym(){return Date.now()}function U_(e){const t=la();let n;return t.getComputedStyle&&(n=t.getComputedStyle(e,null)),!n&&e.currentStyle&&(n=e.currentStyle),n||(n=e.style),n}function z_(e,t="x"){const n=la();let r,s,i;const a=U_(e);return n.WebKitCSSMatrix?(s=a.transform||a.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(c=>c.replace(",",".")).join(", ")),i=new n.WebKitCSSMatrix(s==="none"?"":s)):(i=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.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 Np(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"}function G_(e){return typeof window<"u"&&typeof window.HTMLElement<"u"?e instanceof HTMLElement:e&&(e.nodeType===1||e.nodeType===11)}function $a(...e){const t=Object(e[0]);for(let n=1;n<e.length;n+=1){const r=e[n];if(r!=null&&!G_(r)){const s=Object.keys(Object(r)).filter(i=>i!=="__proto__"&&i!=="constructor"&&i!=="prototype");for(let i=0,a=s.length;i<a;i+=1){const c=s[i],u=Object.getOwnPropertyDescriptor(r,c);u!==void 0&&u.enumerable&&(Np(t[c])&&Np(r[c])?r[c].__swiper__?t[c]=r[c]:$a(t[c],r[c]):!Np(t[c])&&Np(r[c])?(t[c]={},r[c].__swiper__?t[c]=r[c]:$a(t[c],r[c])):t[c]=r[c])}}}return t}function Qd(e,t,n){e.style.setProperty(t,n)}function v7({swiper:e,targetPosition:t,side:n}){const r=la(),s=-e.translate;let i=null,a;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=()=>{a=new Date().getTime(),i===null&&(i=a);const g=Math.max(Math.min((a-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 Pc(e,t=""){const n=la(),r=[...e.children];return n.HTMLSlotElement&&e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(s=>s.matches(t)):r}function W_(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 V_(e,t){const n=la();let r=t.contains(e);return!r&&n.HTMLSlotElement&&t instanceof HTMLSlotElement&&(r=[...t.assignedElements()].includes(e),r||(r=W_(e,t))),r}function Xm(e){try{console.warn(e);return}catch{}}function Gb(e,t=[]){const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:$_(t)),n}function q_(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 K_(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 cu(e,t){return la().getComputedStyle(e,null).getPropertyValue(t)}function b5(e){let t=e,n;if(t){for(n=0;(t=t.previousSibling)!==null;)t.nodeType===1&&(n+=1);return n}}function Y_(e,t){const n=[];let r=e.parentElement;for(;r;)n.push(r),r=r.parentElement;return n}function y5(e,t,n){const r=la();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 v5(e,t=""){typeof trustedTypes<"u"?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:n=>n}).createHTML(t):e.innerHTML=t}let G1;function X_(){const e=la(),t=dd();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}function w7(){return G1||(G1=X_()),G1}let W1;function Z_({userAgent:e}={}){const t=w7(),n=la(),r=n.navigator.platform,s=e||n.navigator.userAgent,i={ios:!1,android:!1},a=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(`${a}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 S7(e={}){return W1||(W1=Z_(e)),W1}let V1;function J_(){const e=la(),t=S7();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(),a=i||s&&t.ios;return{isSafari:n||i,needPerspectiveFix:n,need3dFix:a,isWebView:s}}function A7(){return V1||(V1=J_()),V1}function eL({swiper:e,on:t,emit:n}){const r=la();let s=null,i=null;const a=()=>{!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:C,contentRect:T,target:L})=>{L&&L!==e.el||(v=T?T.width:(C[0]||C).inlineSize,S=T?T.height:(C[0]||C).blockSize)}),(v!==g||S!==y)&&a()})}),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",a),r.addEventListener("orientationchange",f)}),t("destroy",()=>{u(),r.removeEventListener("resize",a),r.removeEventListener("orientationchange",f)})}function tL({swiper:e,extendParams:t,on:n,emit:r}){const s=[],i=la(),a=(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=Y_(e.hostEl);for(let p=0;p<f.length;p+=1)a(f[p])}a(e.hostEl,{childList:e.params.observeSlideChildren}),a(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 nL={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(a=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach(c=>{c.apply(s,[a,...r])}),t.eventsListeners&&t.eventsListeners[a]&&t.eventsListeners[a].forEach(c=>{c.apply(s,r)})}),t}};function rL(){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(cu(r,"padding-left")||0,10)-parseInt(cu(r,"padding-right")||0,10),n=n-parseInt(cu(r,"padding-top")||0,10)-parseInt(cu(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 sL(){const e=this;function t(K,W){return parseFloat(K.getPropertyValue(e.getDirectionLabel(W))||0)}const n=e.params,{wrapperEl:r,slidesEl:s,rtlTranslate:i,wrongRTL:a}=e,c=e.virtual&&n.virtual.enabled,u=c?e.virtual.slides.length:e.slides.length,f=Pc(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 C=n.slidesOffsetAfter;typeof C=="function"&&(C=n.slidesOffsetAfter.call(e));const T=e.snapGrid.length,L=e.slidesGrid.length,E=e.size-S-C;let D=n.spaceBetween,P=-S,F=0,j=0;if(typeof E>"u")return;typeof D=="string"&&D.indexOf("%")>=0?D=parseFloat(D.replace("%",""))/100*E:typeof D=="string"&&(D=parseFloat(D)),e.virtualSize=-D-S-C,f.forEach(K=>{i?K.style.marginLeft="":K.style.marginRight="",K.style.marginBottom="",K.style.marginTop=""}),n.centeredSlides&&n.cssMode&&(Qd(r,"--swiper-centered-offset-before",""),Qd(r,"--swiper-centered-offset-after","")),n.cssMode&&(Qd(r,"--swiper-slides-offset-before",`${S}px`),Qd(r,"--swiper-slides-offset-after",`${C}px`));const A=n.grid&&n.grid.rows>1&&e.grid;A?e.grid.initSlides(f):e.grid&&e.grid.unsetSlides();let H;const Q=n.slidesPerView==="auto"&&n.breakpoints&&Object.keys(n.breakpoints).filter(K=>typeof n.breakpoints[K].slidesPerView<"u").length>0;for(let K=0;K<p;K+=1){H=0;const W=f[K];if(!(W&&(A&&e.grid.updateSlide(K,W,f),cu(W,"display")==="none"))){if(c&&n.slidesPerView==="auto")n.virtual.slidesPerViewAutoSlideSize&&(H=n.virtual.slidesPerViewAutoSlideSize),H&&W&&(n.roundLengths&&(H=Math.floor(H)),W.style[e.getDirectionLabel("width")]=`${H}px`);else if(n.slidesPerView==="auto"){Q&&(W.style[e.getDirectionLabel("width")]="");const de=getComputedStyle(W),X=W.style.transform,pe=W.style.webkitTransform;if(X&&(W.style.transform="none"),pe&&(W.style.webkitTransform="none"),n.roundLengths)H=e.isHorizontal()?y5(W,"width"):y5(W,"height");else{const ye=t(de,"width"),Ae=t(de,"padding-left"),ie=t(de,"padding-right"),V=t(de,"margin-left"),z=t(de,"margin-right"),ce=de.getPropertyValue("box-sizing");if(ce&&ce==="border-box")H=ye+V+z;else{const{clientWidth:ge,offsetWidth:he}=W;H=ye+Ae+ie+V+z+(he-ge)}}X&&(W.style.transform=X),pe&&(W.style.webkitTransform=pe),n.roundLengths&&(H=Math.floor(H))}else H=(E-(n.slidesPerView-1)*D)/n.slidesPerView,n.roundLengths&&(H=Math.floor(H)),W&&(W.style[e.getDirectionLabel("width")]=`${H}px`);W&&(W.swiperSlideSize=H),v.push(H),n.centeredSlides?(P=P+H/2+F/2+D,F===0&&K!==0&&(P=P-E/2-D),K===0&&(P=P-E/2-D),Math.abs(P)<1/1e3&&(P=0),n.roundLengths&&(P=Math.floor(P)),j%n.slidesPerGroup===0&&g.push(P),y.push(P)):(n.roundLengths&&(P=Math.floor(P)),(j-Math.min(e.params.slidesPerGroupSkip,j))%e.params.slidesPerGroup===0&&g.push(P),y.push(P),P=P+H+D),e.virtualSize+=H+D,F=H,j+=1}}if(e.virtualSize=Math.max(e.virtualSize,E)+C,i&&a&&(n.effect==="slide"||n.effect==="coverflow")&&(r.style.width=`${e.virtualSize+D}px`),n.setWrapperSize&&(r.style[e.getDirectionLabel("width")]=`${e.virtualSize+D}px`),A&&e.grid.updateWrapperSize(H,g),!n.centeredSlides){const K=n.slidesPerView!=="auto"&&n.slidesPerView%1!==0,W=n.snapToSlideEdge&&!n.loop&&(n.slidesPerView==="auto"||K);let de=g.length;if(W){let pe;if(n.slidesPerView==="auto"){pe=1;let ye=0;for(let Ae=v.length-1;Ae>=0&&(ye+=v[Ae]+(Ae<v.length-1?D:0),ye<=E);Ae-=1)pe=v.length-Ae}else pe=Math.floor(n.slidesPerView);de=Math.max(p-pe,0)}const X=[];for(let pe=0;pe<g.length;pe+=1){let ye=g[pe];n.roundLengths&&(ye=Math.floor(ye)),W?pe<=de&&X.push(ye):g[pe]<=e.virtualSize-E&&X.push(ye)}g=X,Math.floor(e.virtualSize-E)-Math.floor(g[g.length-1])>1&&(W||g.push(e.virtualSize-E))}if(c&&n.loop){const K=v[0]+D;if(n.slidesPerGroup>1){const W=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/n.slidesPerGroup),de=K*n.slidesPerGroup;for(let X=0;X<W;X+=1)g.push(g[g.length-1]+de)}for(let W=0;W<e.virtual.slidesBefore+e.virtual.slidesAfter;W+=1)n.slidesPerGroup===1&&g.push(g[g.length-1]+K),y.push(y[y.length-1]+K),e.virtualSize+=K}if(g.length===0&&(g=[0]),D!==0){const K=e.isHorizontal()&&i?"marginLeft":e.getDirectionLabel("marginRight");f.filter((W,de)=>!n.cssMode||n.loop?!0:de!==f.length-1).forEach(W=>{W.style[K]=`${D}px`})}if(n.centeredSlides&&n.centeredSlidesBounds){let K=0;v.forEach(de=>{K+=de+(D||0)}),K-=D;const W=K>E?K-E:0;g=g.map(de=>de<=0?-S:de>W?W+C:de)}if(n.centerInsufficientSlides){let K=0;if(v.forEach(W=>{K+=W+(D||0)}),K-=D,K<E){const W=(E-K)/2;g.forEach((de,X)=>{g[X]=de-W}),y.forEach((de,X)=>{y[X]=de+W})}}if(Object.assign(e,{slides:f,snapGrid:g,slidesGrid:y,slidesSizesGrid:v}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){Qd(r,"--swiper-centered-offset-before",`${-g[0]}px`),Qd(r,"--swiper-centered-offset-after",`${e.size/2-v[v.length-1]/2}px`);const K=-e.snapGrid[0],W=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(de=>de+K),e.slidesGrid=e.slidesGrid.map(de=>de+W)}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 K=`${n.containerModifierClass}backface-hidden`,W=e.el.classList.contains(K);p<=n.maxBackfaceHiddenSlides?W||e.el.classList.add(K):W&&e.el.classList.remove(K)}}function iL(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 a=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(a(c))}else n.push(a(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 oL(){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 w5=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function aL(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 a=-e;s&&(a=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=(a+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),y=(a-i[0]+(n.centeredSlides?t.minTranslate():0)-p)/(f.swiperSlideSize+c),v=-(a-p),S=v+t.slidesSizesGrid[u],C=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)),w5(f,T,n.slideVisibleClass),w5(f,C,n.slideFullyVisibleClass),f.progress=s?-g:g,f.originalProgress=s?-y:y}}function lL(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:a,progressLoop:c}=t;const u=i,f=a;if(r===0)s=0,i=!0,a=!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,a=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],C=Math.abs(e);C>=y?c=(C-y)/S:c=(C+S-v)/S,c>1&&(c-=1)}Object.assign(t,{progress:s,progressLoop:c,isBeginning:i,isEnd:a}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),i&&!u&&t.emit("reachBeginning toEdge"),a&&!f&&t.emit("reachEnd toEdge"),(u&&!i||f&&!a)&&t.emit("fromEdge"),t.emit("progress",s)}const q1=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};function cL(){const e=this,{slides:t,params:n,slidesEl:r,activeIndex:s}=e,i=e.virtual&&n.virtual.enabled,a=e.grid&&n.grid&&n.grid.rows>1,c=g=>Pc(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 a?(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&&(a||(p=K_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!p&&(p=t[0]),f=q_(u,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!f===0&&(f=t[t.length-1]))),t.forEach(g=>{q1(g,g===u,n.slideActiveClass),q1(g,g===p,n.slideNextClass),q1(g,g===f,n.slidePrevClass)}),e.emitSlidesClasses()}const Cm=(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()}},K1=(e,t)=>{if(!e.slides[t])return;const n=e.slides[t].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},Wb=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 a=s,c=[a-t];c.push(...Array.from({length:t}).map((u,f)=>a+r+f)),e.slides.forEach((u,f)=>{c.includes(u.column)&&K1(e,f)});return}const i=s+r-1;if(e.params.rewind||e.params.loop)for(let a=s-t;a<=i+t;a+=1){const c=(a%n+n)%n;(c<s||c>i)&&K1(e,c)}else for(let a=Math.max(s-t,0);a<=Math.min(i+t,n-1);a+=1)a!==s&&(a>i||a<s)&&K1(e,a)};function uL(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 dL(e){const t=this,n=t.rtlTranslate?t.translate:-t.translate,{snapGrid:r,params:s,activeIndex:i,realIndex:a,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=uL(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(C=>C.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:a,realIndex:y,previousIndex:i,activeIndex:u}),t.initialized&&Wb(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==y&&t.emit("realIndexChange"),t.emit("slideChange"))}function fL(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,a;if(s){for(let c=0;c<n.slides.length;c+=1)if(n.slides[c]===s){i=!0,a=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=a;else{n.clickedSlide=void 0,n.clickedIndex=void 0;return}r.slideToClickedSlide&&n.clickedIndex!==void 0&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}var hL={updateSize:rL,updateSlides:sL,updateAutoHeight:iL,updateSlidesOffset:oL,updateSlidesProgress:aL,updateProgress:lL,updateSlidesClasses:cL,updateActiveIndex:dL,updateClickedSlide:fL};function pL(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 a=z_(i,e);return a+=t.cssOverflowAdjustment(),r&&(a=-a),a||0}function mL(e,t){const n=this,{rtlTranslate:r,params:s,wrapperEl:i,progress:a}=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!==a&&n.updateProgress(e),n.emit("setTranslate",n.translate,t)}function gL(){return-this.snapGrid[0]}function xL(){return-this.snapGrid[this.snapGrid.length-1]}function bL(e=0,t=this.params.speed,n=!0,r=!0,s){const i=this,{params:a,wrapperEl:c}=i;if(i.animating&&a.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),a.cssMode){const g=i.isHorizontal();if(t===0)c[g?"scrollLeft":"scrollTop"]=-p;else{if(!i.support.smoothScroll)return v7({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 yL={getTranslate:pL,setTranslate:mL,minTranslate:gL,maxTranslate:xL,translateTo:bL};function vL(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 T7({swiper:e,runCallbacks:t,direction:n,step:r}){const{activeIndex:s,previousIndex:i}=e;let a=n;a||(s>i?a="next":s<i?a="prev":a="reset"),e.emit(`transition${r}`),t&&a==="reset"?e.emit(`slideResetTransition${r}`):t&&s!==i&&(e.emit(`slideChangeTransition${r}`),a==="next"?e.emit(`slideNextTransition${r}`):e.emit(`slidePrevTransition${r}`))}function wL(e=!0,t){const n=this,{params:r}=n;r.cssMode||(r.autoHeight&&n.updateAutoHeight(),T7({swiper:n,runCallbacks:e,direction:t,step:"Start"}))}function SL(e=!0,t){const n=this,{params:r}=n;n.animating=!1,!r.cssMode&&(n.setTransition(0),T7({swiper:n,runCallbacks:e,direction:t,step:"End"}))}var AL={setTransition:vL,transitionStart:wL,transitionEnd:SL};function TL(e=0,t,n=!0,r,s){typeof e=="string"&&(e=parseInt(e,10));const i=this;let a=e;a<0&&(a=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 C=Math.min(i.params.slidesPerGroupSkip,a);let T=C+Math.floor((a-C)/i.params.slidesPerGroup);T>=u.length&&(T=u.length-1);const L=-u[T];if(c.normalizeSlideIndex)for(let A=0;A<f.length;A+=1){const H=-Math.floor(L*100),Q=Math.floor(f[A]*100),K=Math.floor(f[A+1]*100);typeof f[A+1]<"u"?H>=Q&&H<K-(K-Q)/2?a=A:H>=Q&&H<K&&(a=A+1):H>=Q&&(a=A)}if(i.initialized&&a!==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)!==a))return!1;a!==(p||0)&&n&&i.emit("beforeSlideChangeStart"),i.updateProgress(L);let E;a>g?E="next":a<g?E="prev":E="reset";const D=i.virtual&&i.params.virtual.enabled;if(!(D&&s)&&(y&&-L===i.translate||!y&&L===i.translate))return i.updateActiveIndex(a),c.autoHeight&&i.updateAutoHeight(),i.updateSlidesClasses(),c.effect!=="slide"&&i.setTranslate(L),E!=="reset"&&(i.transitionStart(n,E),i.transitionEnd(n,E)),!1;if(c.cssMode){const A=i.isHorizontal(),H=y?L:-L;if(t===0)D&&(i.wrapperEl.style.scrollSnapType="none",i._immediateVirtual=!0),D&&!i._cssModeVirtualInitialSet&&i.params.initialSlide>0?(i._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{v[A?"scrollLeft":"scrollTop"]=H})):v[A?"scrollLeft":"scrollTop"]=H,D&&requestAnimationFrame(()=>{i.wrapperEl.style.scrollSnapType="",i._immediateVirtual=!1});else{if(!i.support.smoothScroll)return v7({swiper:i,targetPosition:H,side:A?"left":"top"}),!0;v.scrollTo({[A?"left":"top"]:H,behavior:"smooth"})}return!0}const j=A7().isSafari;return D&&!s&&j&&i.isElement&&i.virtual.update(!1,!1,a),i.setTransition(t),i.setTranslate(L),i.updateActiveIndex(a),i.updateSlidesClasses(),i.emit("beforeTransitionStart",t,r),i.transitionStart(n,E),t===0?i.transitionEnd(n,E):i.animating||(i.animating=!0,i.onSlideToWrapperTransitionEnd||(i.onSlideToWrapperTransitionEnd=function(H){!i||i.destroyed||H.target===this&&(i.wrapperEl.removeEventListener("transitionend",i.onSlideToWrapperTransitionEnd),i.onSlideToWrapperTransitionEnd=null,delete i.onSlideToWrapperTransitionEnd,i.transitionEnd(n,E))}),i.wrapperEl.addEventListener("transitionend",i.onSlideToWrapperTransitionEnd)),!0}function CL(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 a=e;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)a=a+s.virtual.slidesBefore;else{let c;if(i){const C=a*s.params.grid.rows;c=s.slides.find(T=>T.getAttribute("data-swiper-slide-index")*1===C).column}else c=s.getSlideIndexByData(a);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 C=y?c<s.activeIndex?"prev":"next":c-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:C,slideTo:!0,activeSlideIndex:C==="next"?c+1:c-u+1,slideRealIndex:C==="next"?s.realIndex:void 0})}if(i){const C=a*s.params.grid.rows;a=s.slides.find(T=>T.getAttribute("data-swiper-slide-index")*1===C).column}else a=s.getSlideIndexByData(a)}return requestAnimationFrame(()=>{s.slideTo(a,t,n,r)}),s}function kL(e,t=!0,n){const r=this,{enabled:s,params:i,animating:a}=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(a&&!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 _L(e,t=!0,n){const r=this,{params:s,snapGrid:i,slidesGrid:a,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(E){return E<0?-Math.floor(Math.abs(E)):Math.floor(E)}const v=y(g),S=i.map(E=>y(E)),C=s.freeMode&&s.freeMode.enabled;let T=i[S.indexOf(v)-1];if(typeof T>"u"&&(s.cssMode||C)){let E;i.forEach((D,P)=>{v>=D&&(E=P)}),typeof E<"u"&&(T=C?i[E]:i[E>0?E-1:E])}let L=0;if(typeof T<"u"&&(L=a.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 E=r.params.virtual&&r.params.virtual.enabled&&r.virtual?r.virtual.slides.length-1:r.slides.length-1;return r.slideTo(E,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 LL(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 EL(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 a=Math.min(s.params.slidesPerGroupSkip,i),c=a+Math.floor((i-a)/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 IL(){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 a=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(Pc(n,`${a}[data-swiper-slide-index="${i}"]`)[0]),y7(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}var RL={slideTo:TL,slideToLoop:CL,slideNext:kL,slidePrev:_L,slideReset:LL,slideToClosest:EL,slideToClickedSlide:IL};function NL(e,t){const n=this,{params:r,slidesEl:s}=n;if(!r.loop||n.virtual&&n.params.virtual.enabled)return;const i=()=>{Pc(s,`.${r.slideClass}, swiper-slide`).forEach((S,C)=>{S.setAttribute("data-swiper-slide-index",C)})},a=()=>{const v=Pc(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)&&a();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 C=n.isElement?Gb("swiper-slide",[r.slideBlankClass]):Gb("div",[r.slideClass,r.slideBlankClass]);n.slidesEl.append(C)}};if(f){if(r.loopAddBlankSlides){const v=u-n.slides.length%u;g(v),n.recalcSlides(),n.updateSlides()}else Xm("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 Xm("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 ML({slideRealIndex:e,slideTo:t=!0,direction:n,setTranslate:r,activeSlideIndex:s,initial:i,byController:a,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:C,slidesOffsetAfter:T,initialSlide:L}=v,E=S||!!C||!!T;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&v.virtual.enabled){t&&(!E&&u.snapIndex===0?u.slideTo(u.virtual.slides.length,0,!1,!0):E&&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 D=v.slidesPerView;D==="auto"?D=u.slidesPerViewDynamic():(D=Math.ceil(parseFloat(v.slidesPerView,10)),E&&D%2===0&&(D=D+1));const P=v.slidesPerGroupAuto?D:v.slidesPerGroup;let F=E?Math.max(P,Math.ceil(D/2)):P;F%P!==0&&(F+=P-F%P),F+=v.loopAdditionalSlides,u.loopedSlides=F;const j=u.grid&&v.grid&&v.grid.rows>1;f.length<D+F||u.params.effect==="cards"&&f.length<D+F*2?Xm("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"):j&&v.grid.fill==="row"&&Xm("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const A=[],H=[],Q=j?Math.ceil(f.length/v.grid.rows):f.length,K=i&&Q-L<D&&!E;let W=K?L:u.activeIndex;typeof s>"u"?s=u.getSlideIndex(f.find(V=>V.classList.contains(v.slideActiveClass))):W=s;const de=n==="next"||!n,X=n==="prev"||!n;let pe=0,ye=0;const ie=(j?f[s].column:s)+(E&&typeof r>"u"?-D/2+.5:0);if(ie<F){pe=Math.max(F-ie,P);for(let V=0;V<F-ie;V+=1){const z=V-Math.floor(V/Q)*Q;if(j){const ce=Q-z-1;for(let ge=f.length-1;ge>=0;ge-=1)f[ge].column===ce&&A.push(ge)}else A.push(Q-z-1)}}else if(ie+D>Q-F){ye=Math.max(ie-(Q-F*2),P),K&&(ye=Math.max(ye,D-Q+L+1));for(let V=0;V<ye;V+=1){const z=V-Math.floor(V/Q)*Q;j?f.forEach((ce,ge)=>{ce.column===z&&H.push(ge)}):H.push(z)}}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),u.params.effect==="cards"&&f.length<D+F*2&&(H.includes(s)&&H.splice(H.indexOf(s),1),A.includes(s)&&A.splice(A.indexOf(s),1)),X&&A.forEach(V=>{f[V].swiperLoopMoveDOM=!0,y.prepend(f[V]),f[V].swiperLoopMoveDOM=!1}),de&&H.forEach(V=>{f[V].swiperLoopMoveDOM=!0,y.append(f[V]),f[V].swiperLoopMoveDOM=!1}),u.recalcSlides(),v.slidesPerView==="auto"?u.updateSlides():j&&(A.length>0&&X||H.length>0&&de)&&u.slides.forEach((V,z)=>{u.grid.updateSlide(z,V,u.slides)}),v.watchSlidesProgress&&u.updateSlidesOffset(),t){if(A.length>0&&X){if(typeof e>"u"){const V=u.slidesGrid[W],ce=u.slidesGrid[W+pe]-V;c?u.setTranslate(u.translate-ce):(u.slideTo(W+Math.ceil(pe),0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-ce,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-ce))}else if(r){const V=j?A.length/v.grid.rows:A.length;u.slideTo(u.activeIndex+V,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(H.length>0&&de)if(typeof e>"u"){const V=u.slidesGrid[W],ce=u.slidesGrid[W-ye]-V;c?u.setTranslate(u.translate-ce):(u.slideTo(W-ye,0,!1,!0),r&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-ce,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-ce))}else{const V=j?H.length/v.grid.rows:H.length;u.slideTo(u.activeIndex-V,0,!1,!0)}}if(u.allowSlidePrev=p,u.allowSlideNext=g,u.controller&&u.controller.control&&!a){const V={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({...V,slideTo:z.params.slidesPerView===v.slidesPerView?t:!1})}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix({...V,slideTo:u.controller.control.params.slidesPerView===v.slidesPerView?t:!1})}u.emit("loopFix")}function DL(){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 jL={loopCreate:NL,loopFix:ML,loopDestroy:DL};function PL(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 BL(){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 FL={setGrabCursor:PL,unsetGrabCursor:BL};function OL(e,t=this){function n(r){if(!r||r===dd()||r===la())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 S5(e,t,n){const r=la(),{params:s}=e,i=s.edgeSwipeDetection,a=s.edgeSwipeThreshold;return i&&(n<=a||n>=r.innerWidth-a)?i==="prevent"?(t.preventDefault(),!0):!1:!0}function QL(e){const t=this;if(t.destroyed)return;const n=dd();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"){S5(t,r,r.targetTouches[0].pageX);return}const{params:i,touches:a,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"&&!V_(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?OL(g,u):u.closest(g))){t.allowClick=!0;return}if(i.swipeHandler&&!u.closest(i.swipeHandler))return;a.currentX=r.pageX,a.currentY=r.pageY;const v=a.currentX,S=a.currentY;if(!S5(t,r,v))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=v,a.startY=S,s.touchStartTime=Ym(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,i.threshold>0&&(s.allowThresholdMove=!1);let C=!0;u.matches(s.focusableElements)&&(C=!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=C&&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 $L(e){const t=dd(),n=this;if(n.destroyed)return;const r=n.touchEventsData,{params:s,touches:i,rtlTranslate:a,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=Ym());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(a&&(p>i.startX&&-n.translate<=n.maxTranslate()||p<i.startX&&-n.translate>=n.minTranslate()))return;if(!a&&(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,C=n.isHorizontal()?i.currentX-i.previousX:i.currentY-i.previousY;s.oneWayMovement&&(S=Math.abs(S)*(a?1:-1),C=Math.abs(C)*(a?1:-1)),i.diff=S,S*=s.touchRatio,a&&(S=-S,C=-C);const T=n.touchesDirection;n.swipeDirection=S>0?"prev":"next",n.touchesDirection=C>0?"prev":"next";const L=n.params.loop&&!s.cssMode,E=n.touchesDirection==="next"&&n.allowSlideNext||n.touchesDirection==="prev"&&n.allowSlidePrev;if(!r.isMoved){if(L&&E&&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&&E&&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 D=!0,P=s.resistanceRatio;if(s.touchReleaseOnEdges&&(P=0),S>0?(L&&E&&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()&&(D=!1,s.resistance&&(r.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+r.startTranslate+S)**P))):S<0&&(L&&E&&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()&&(D=!1,s.resistance&&(r.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-r.startTranslate-S)**P))),D&&(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 HL(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:a,touches:c,rtlTranslate:u,slidesGrid:f,enabled:p}=t;if(!p||!a.simulateTouch&&r.pointerType==="mouse")return;if(n.allowTouchCallbacks&&t.emit("touchEnd",r),n.allowTouchCallbacks=!1,!n.isTouched){n.isMoved&&a.grabCursor&&t.setGrabCursor(!1),n.isMoved=!1,n.startMoving=!1;return}a.grabCursor&&n.isMoved&&n.isTouched&&(t.allowSlideNext===!0||t.allowSlidePrev===!0)&&t.setGrabCursor(!1);const g=Ym(),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=Ym(),y7(()=>{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(a.followFinger?v=u?t.translate:-t.translate:v=-n.currentTranslate,a.cssMode)return;if(a.freeMode&&a.freeMode.enabled){t.freeMode.onTouchEnd({currentPos:v});return}const S=v>=-t.maxTranslate()&&!t.params.loop;let C=0,T=t.slidesSizesGrid[0];for(let F=0;F<f.length;F+=F<a.slidesPerGroupSkip?1:a.slidesPerGroup){const j=F<a.slidesPerGroupSkip-1?1:a.slidesPerGroup;typeof f[F+j]<"u"?(S||v>=f[F]&&v<f[F+j])&&(C=F,T=f[F+j]-f[F]):(S||v>=f[F])&&(C=F,T=f[f.length-1]-f[f.length-2])}let L=null,E=null;a.rewind&&(t.isBeginning?E=a.virtual&&a.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(L=0));const D=(v-f[C])/T,P=C<a.slidesPerGroupSkip-1?1:a.slidesPerGroup;if(y>a.longSwipesMs){if(!a.longSwipes){t.slideTo(t.activeIndex);return}t.swipeDirection==="next"&&(D>=a.longSwipesRatio?t.slideTo(a.rewind&&t.isEnd?L:C+P):t.slideTo(C)),t.swipeDirection==="prev"&&(D>1-a.longSwipesRatio?t.slideTo(C+P):E!==null&&D<0&&Math.abs(D)>a.longSwipesRatio?t.slideTo(E):t.slideTo(C))}else{if(!a.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(C+P):t.slideTo(C):(t.swipeDirection==="next"&&t.slideTo(L!==null?L:C+P),t.swipeDirection==="prev"&&t.slideTo(E!==null?E:C))}}function A5(){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,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const c=a&&t.loop;if((t.slidesPerView==="auto"||t.slidesPerView>1)&&e.isEnd&&!e.isBeginning&&!e.params.centeredSlides&&!c){const u=a?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}else e.params.loop&&!a?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 UL(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 zL(){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 GL(e){const t=this;t.destroyed||(Cm(t,e.target),!(t.params.cssMode||t.params.slidesPerView!=="auto"&&!t.params.autoHeight)&&t.update())}function WL(){const e=this;e.destroyed||e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const C7=(e,t)=>{const n=dd(),{params:r,el:s,wrapperEl:i,device:a}=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](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",A5,!0):e[f]("observerUpdate",A5,!0),s[u]("load",e.onLoad,{capture:!0}))};function VL(){const e=this,{params:t}=e;e.onTouchStart=QL.bind(e),e.onTouchMove=$L.bind(e),e.onTouchEnd=HL.bind(e),e.onDocumentTouchStart=WL.bind(e),t.cssMode&&(e.onScroll=zL.bind(e)),e.onClick=UL.bind(e),e.onLoad=GL.bind(e),C7(e,"on")}function qL(){C7(this,"off")}var KL={attachEvents:VL,detachEvents:qL};const T5=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;function YL(){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 a=dd(),c=r.breakpointsBase==="window"||!r.breakpointsBase?r.breakpointsBase:"container",u=["window","container"].includes(r.breakpointsBase)||!r.breakpointsBase?e.el:a.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=T5(e,r),v=T5(e,g),S=e.params.grabCursor,C=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&&!C?e.unsetGrabCursor():!S&&C&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(j=>{if(typeof g[j]>"u")return;const A=r[j]&&r[j].enabled,H=g[j]&&g[j].enabled;A&&!H&&e[j].disable(),!A&&H&&e[j].enable()});const L=g.direction&&g.direction!==r.direction,E=r.loop&&(g.slidesPerView!==r.slidesPerView||L),D=r.loop;L&&n&&e.changeDirection(),$a(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&&(E?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!D&&F?(e.loopCreate(t),e.updateSlides()):D&&!F&&e.loopDestroy()),e.emit("breakpoint",g)}function XL(e,t="window",n){if(!e||t==="container"&&!n)return;let r=!1;const s=la(),i=t==="window"?s.innerHeight:n.clientHeight,a=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}});a.sort((c,u)=>parseInt(c.value,10)-parseInt(u.value,10));for(let c=0;c<a.length;c+=1){const{point:u,value:f}=a[c];t==="window"?s.matchMedia(`(min-width: ${f}px)`).matches&&(r=u):f<=n.clientWidth&&(r=u)}return r||"max"}var ZL={setBreakpoint:YL,getBreakpoint:XL};function JL(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 eE(){const e=this,{classNames:t,params:n,rtl:r,el:s,device:i}=e,a=JL(["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(...a),s.classList.add(...t),e.emitContainerClasses()}function tE(){const e=this,{el:t,classNames:n}=e;!t||typeof t=="string"||(t.classList.remove(...n),e.emitContainerClasses())}var nE={addClasses:eE,removeClasses:tE};function rE(){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 sE={checkOverflow:rE},Vb={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 iE(e,t){return function(r={}){const s=Object.keys(r)[0],i=r[s];if(typeof i!="object"||i===null){$a(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)){$a(t,r);return}typeof e[s]=="object"&&!("enabled"in e[s])&&(e[s].enabled=!0),e[s]||(e[s]={enabled:!1}),$a(t,r)}}const Y1={eventsEmitter:nL,update:hL,translate:yL,transition:AL,slide:RL,loop:jL,grabCursor:FL,events:KL,breakpoints:ZL,checkOverflow:sE,classes:nE},X1={};let Ny=class Mc{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=$a({},r),n&&!r.el&&(r.el=n);const s=dd();if(r.el&&typeof r.el=="string"&&s.querySelectorAll(r.el).length>1){const u=[];return s.querySelectorAll(r.el).forEach(f=>{const p=$a({},r,{el:f});u.push(new Mc(p))}),u}const i=this;i.__swiper__=!0,i.support=w7(),i.device=S7({userAgent:r.userAgent}),i.browser=A7(),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 a={};i.modules.forEach(u=>{u({params:r,swiper:i,extendParams:iE(r,a),on:i.on.bind(i),once:i.once.bind(i),off:i.off.bind(i),emit:i.emit.bind(i)})});const c=$a({},Vb,a);return i.params=$a({},c,X1,r),i.originalParams=$a({},i.params),i.passedParams=$a({},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=Pc(n,`.${r.slideClass}, swiper-slide`),i=b5(s[0]);return b5(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=Pc(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(),a=(r.maxTranslate()-s)*t+s;r.translateTo(a,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:a,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?a[g]+c[g]-a[f]<u:a[g]-a[f]<u)&&(p+=1);else for(let g=f-1;g>=0;g-=1)a[f]-a[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(a=>{a.complete&&Cm(t,a)}),t.updateSize(),t.updateSlides(),t.updateProgress(),t.updateSlidesClasses();function s(){const a=t.rtlTranslate?t.translate*-1:t.translate,c=Math.min(Math.max(a,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 a=t.virtual&&r.virtual.enabled?t.virtual.slides:t.slides;i=t.slideTo(a.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 a=r&&r.shadowRoot&&r.shadowRoot.querySelector?r.shadowRoot.querySelector(s()):Pc(r,s())[0];return!a&&n.params.createElements&&(a=Gb("div",n.params.wrapperClass),r.append(a),Pc(r,`.${n.params.slideClass}`).forEach(c=>{a.append(c)})),Object.assign(n,{el:r,wrapperEl:a,slidesEl:n.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:a,hostEl:n.isElement?r.parentNode.host:r,mounted:!0,rtl:r.dir.toLowerCase()==="rtl"||cu(r,"direction")==="rtl",rtlTranslate:n.params.direction==="horizontal"&&(r.dir.toLowerCase()==="rtl"||cu(r,"direction")==="rtl"),wrongRTL:cu(a,"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?Cm(n,i):i.addEventListener("load",a=>{Cm(n,a.target)})}),Wb(n),n.initialized=!0,Wb(n),n.emit("init"),n.emit("afterInit"),n}destroy(t=!0,n=!0){const r=this,{params:s,el:i,wrapperEl:a,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"),a&&a.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),H_(r)),r.destroyed=!0),null}static extendDefaults(t){$a(X1,t)}static get extendedDefaults(){return X1}static get defaults(){return Vb}static installModule(t){Mc.prototype.__modules__||(Mc.prototype.__modules__=[]);const n=Mc.prototype.__modules__;typeof t=="function"&&n.indexOf(t)<0&&n.push(t)}static use(t){return Array.isArray(t)?(t.forEach(n=>Mc.installModule(n)),Mc):(Mc.installModule(t),Mc)}};Object.keys(Y1).forEach(e=>{Object.keys(Y1[e]).forEach(t=>{Ny.prototype[t]=Y1[e][t]})});Ny.use([eL,tL]);const k7=["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 id(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"&&!e.__swiper__}function g0(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]:id(t[r])&&id(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:g0(e[r],t[r]):e[r]=t[r]})}function _7(e={}){return e.navigation&&typeof e.navigation.nextEl>"u"&&typeof e.navigation.prevEl>"u"}function L7(e={}){return e.pagination&&typeof e.pagination.el>"u"}function E7(e={}){return e.scrollbar&&typeof e.scrollbar.el>"u"}function I7(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 oE(e=""){return e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function aE({swiper:e,slides:t,passedParams:n,changedParams:r,nextEl:s,prevEl:i,scrollbarEl:a,paginationEl:c}){const u=r.filter(H=>H!=="children"&&H!=="direction"&&H!=="wrapperClass"),{params:f,pagination:p,navigation:g,scrollbar:y,virtual:v,thumbs:S}=e;let C,T,L,E,D,P,F,j;r.includes("thumbs")&&n.thumbs&&n.thumbs.swiper&&!n.thumbs.swiper.destroyed&&f.thumbs&&(!f.thumbs.swiper||f.thumbs.swiper.destroyed)&&(C=!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||a)&&(f.scrollbar||f.scrollbar===!1)&&y&&!y.el&&(E=!0),r.includes("navigation")&&n.navigation&&(n.navigation.prevEl||i)&&(n.navigation.nextEl||s)&&(f.navigation||f.navigation===!1)&&g&&!g.prevEl&&!g.nextEl&&(D=!0);const A=H=>{e[H]&&(e[H].destroy(),H==="navigation"?(e.isElement&&(e[H].prevEl.remove(),e[H].nextEl.remove()),f[H].prevEl=void 0,f[H].nextEl=void 0,e[H].prevEl=void 0,e[H].nextEl=void 0):(e.isElement&&e[H].el.remove(),f[H].el=void 0,e[H].el=void 0))};r.includes("loop")&&e.isElement&&(f.loop&&!n.loop?P=!0:!f.loop&&n.loop?F=!0:j=!0),u.forEach(H=>{if(id(f[H])&&id(n[H]))Object.assign(f[H],n[H]),(H==="navigation"||H==="pagination"||H==="scrollbar")&&"enabled"in n[H]&&!n[H].enabled&&A(H);else{const Q=n[H];(Q===!0||Q===!1)&&(H==="navigation"||H==="pagination"||H==="scrollbar")?Q===!1&&A(H):f[H]=n[H]}}),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&&(j=!0),C&&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()),E&&(e.isElement&&(!a||typeof a=="string")&&(a=document.createElement("div"),a.classList.add("swiper-scrollbar"),a.part.add("scrollbar"),e.el.appendChild(a)),a&&(f.scrollbar.el=a),y.init(),y.updateSize(),y.setTranslate()),D&&(e.isElement&&((!s||typeof s=="string")&&(s=document.createElement("div"),s.classList.add("swiper-button-next"),v5(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"),v5(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||j)&&e.loopDestroy(),(F||j)&&e.loopCreate(),e.update()}function lE(e={},t=!0){const n={on:{}},r={},s={};g0(n,Vb),n._emitClasses=!0,n.init=!1;const i={},a=k7.map(u=>u.replace(/_/,"")),c=Object.assign({},e);return Object.keys(c).forEach(u=>{typeof e[u]>"u"||(a.indexOf(u)>=0?id(e[u])?(n[u]={},s[u]={},g0(n[u],e[u]),g0(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 cE({el:e,nextEl:t,prevEl:n,paginationEl:r,scrollbarEl:s,swiper:i},a){_7(a)&&t&&n&&(i.params.navigation.nextEl=t,i.originalParams.navigation.nextEl=t,i.params.navigation.prevEl=n,i.originalParams.navigation.prevEl=n),L7(a)&&r&&(i.params.pagination.el=r,i.originalParams.pagination.el=r),E7(a)&&s&&(i.params.scrollbar.el=s,i.originalParams.scrollbar.el=s),i.init(e)}function uE(e,t,n,r,s){const i=[];if(!t)return i;const a=u=>{i.indexOf(u)<0&&i.push(u)};if(n&&r){const u=r.map(s),f=n.map(s);u.join("")!==f.join("")&&a("children"),r.length!==n.length&&a("children")}return k7.filter(u=>u[0]==="_").map(u=>u.replace(/_/,"")).forEach(u=>{if(u in e&&u in t)if(id(e[u])&&id(t[u])){const f=Object.keys(e[u]),p=Object.keys(t[u]);f.length!==p.length?a(u):(f.forEach(g=>{e[u][g]!==t[u][g]&&a(u)}),p.forEach(g=>{e[u][g]!==t[u][g]&&a(u)}))}else e[u]!==t[u]&&a(u)}),i}const dE=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 Zm(){return Zm=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},Zm.apply(this,arguments)}function R7(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function N7(e){const t=[];return M.Children.toArray(e).forEach(n=>{R7(n)?t.push(n):n.props&&n.props.children&&N7(n.props.children).forEach(r=>t.push(r))}),t}function fE(e){const t=[],n={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return M.Children.toArray(e).forEach(r=>{if(R7(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=N7(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 hE(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:a}=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<=a&&f.push(t[r(p)]);return f.map((p,g)=>M.cloneElement(p,{swiper:e,style:s,key:p.props.virtualIndex||p.key||`slide-${g}`}))}function oh(e,t){return typeof window>"u"?x.useEffect(e,t):x.useLayoutEffect(e,t)}const C5=x.createContext(null),pE=x.createContext(null),$h=x.forwardRef(({className:e,tag:t="div",wrapperTag:n="div",children:r,onSwiper:s,...i}={},a)=>{let c=!1;const[u,f]=x.useState("swiper"),[p,g]=x.useState(null),[y,v]=x.useState(!1),S=x.useRef(!1),C=x.useRef(null),T=x.useRef(null),L=x.useRef(null),E=x.useRef(null),D=x.useRef(null),P=x.useRef(null),F=x.useRef(null),j=x.useRef(null),{params:A,passedParams:H,rest:Q,events:K}=lE(i),{slides:W,slots:de}=fE(r),X=()=>{v(!y)};Object.assign(A.on,{_containerClasses(V,z){f(z)}});const pe=()=>{Object.assign(A.on,K),c=!0;const V={...A};if(delete V.wrapperClass,T.current=new Ny(V),T.current.virtual&&T.current.params.virtual.enabled){T.current.virtual.slides=W;const z={cache:!1,slides:W,renderExternal:g,renderExternalUpdate:!1};g0(T.current.params.virtual,z),g0(T.current.originalParams.virtual,z)}};C.current||pe(),T.current&&T.current.on("_beforeBreakpoint",X);const ye=()=>{c||!K||!T.current||Object.keys(K).forEach(V=>{T.current.on(V,K[V])})},Ae=()=>{!K||!T.current||Object.keys(K).forEach(V=>{T.current.off(V,K[V])})};x.useEffect(()=>()=>{T.current&&T.current.off("_beforeBreakpoint",X)}),x.useEffect(()=>{!S.current&&T.current&&(T.current.emitSlidesClasses(),S.current=!0)}),oh(()=>{if(a&&(a.current=C.current),!!C.current)return T.current.destroyed&&pe(),cE({el:C.current,nextEl:D.current,prevEl:P.current,paginationEl:F.current,scrollbarEl:j.current,swiper:T.current},A),s&&!T.current.destroyed&&s(T.current),()=>{T.current&&!T.current.destroyed&&T.current.destroy(!0,!1)}},[]),oh(()=>{ye();const V=uE(H,L.current,W,E.current,z=>z.key);return L.current=H,E.current=W,V.length&&T.current&&!T.current.destroyed&&aE({swiper:T.current,slides:W,passedParams:H,changedParams:V,nextEl:D.current,prevEl:P.current,scrollbarEl:j.current,paginationEl:F.current}),()=>{Ae()}}),oh(()=>{dE(T.current)},[p]);function ie(){return A.virtual?hE(T.current,W,p):W.map((V,z)=>M.cloneElement(V,{swiper:T.current,swiperSlideIndex:z}))}return M.createElement(t,Zm({ref:C,className:I7(`${u}${e?` ${e}`:""}`)},Q),M.createElement(pE.Provider,{value:T.current},de["container-start"],M.createElement(n,{className:oE(A.wrapperClass)},de["wrapper-start"],ie(),de["wrapper-end"]),_7(A)&&M.createElement(M.Fragment,null,M.createElement("div",{ref:P,className:"swiper-button-prev"}),M.createElement("div",{ref:D,className:"swiper-button-next"})),E7(A)&&M.createElement("div",{ref:j,className:"swiper-scrollbar"}),L7(A)&&M.createElement("div",{ref:F,className:"swiper-pagination"}),de["container-end"]))});$h.displayName="Swiper";const od=x.forwardRef(({tag:e="div",children:t,className:n="",swiper:r,zoom:s,lazy:i,virtualIndex:a,swiperSlideIndex:c,...u}={},f)=>{const p=x.useRef(null),[g,y]=x.useState("swiper-slide"),[v,S]=x.useState(!1);function C(D,P,F){P===p.current&&y(F)}oh(()=>{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",C),()=>{r&&r.off("_slideClass",C)}}}),oh(()=>{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,E=()=>{S(!0)};return M.createElement(e,Zm({ref:p,className:I7(`${g}${n?` ${n}`:""}`),"data-swiper-slide-index":a,onLoad:E},u),s&&M.createElement(C5.Provider,{value:T},M.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":typeof s=="number"?s:void 0},L(),i&&!v&&M.createElement("div",{className:"swiper-lazy-preloader",ref:D=>{D&&(D.lazyPreloaderManaged=!0)}}))),!s&&M.createElement(C5.Provider,{value:T},L(),i&&!v&&M.createElement("div",{className:"swiper-lazy-preloader",ref:D=>{D&&(D.lazyPreloaderManaged=!0)}})))});od.displayName="SwiperSlide";const go=[];for(let e=0;e<256;++e)go.push((e+256).toString(16).slice(1));function mE(e,t=0){return(go[e[t+0]]+go[e[t+1]]+go[e[t+2]]+go[e[t+3]]+"-"+go[e[t+4]]+go[e[t+5]]+"-"+go[e[t+6]]+go[e[t+7]]+"-"+go[e[t+8]]+go[e[t+9]]+"-"+go[e[t+10]]+go[e[t+11]]+go[e[t+12]]+go[e[t+13]]+go[e[t+14]]+go[e[t+15]]).toLowerCase()}let Z1;const gE=new Uint8Array(16);function xE(){if(!Z1){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Z1=crypto.getRandomValues.bind(crypto)}return Z1(gE)}const bE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),k5={randomUUID:bE};function yE(e,t,n){e=e||{};const r=e.random??e.rng?.()??xE();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,mE(r)}function vE(e,t,n){return k5.randomUUID&&!e?k5.randomUUID():yE(e)}const wE={},_5=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:()=>{(wE?"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},SE=e=>e?_5(e):_5;var J1={exports:{}},ex={},tx={exports:{}},nx={};var L5;function AE(){if(L5)return nx;L5=1;var e=Bg();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,a=e.useDebugValue;function c(g,y){var v=y(),S=r({inst:{value:v,getSnapshot:y}}),C=S[0].inst,T=S[1];return i(function(){C.value=v,C.getSnapshot=y,u(C)&&T({inst:C})},[g,v,y]),s(function(){return u(C)&&T({inst:C}),g(function(){u(C)&&T({inst:C})})},[g]),a(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 nx.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,nx}var E5;function TE(){return E5||(E5=1,tx.exports=AE()),tx.exports}var I5;function CE(){if(I5)return ex;I5=1;var e=Bg(),t=TE();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,a=e.useEffect,c=e.useMemo,u=e.useDebugValue;return ex.useSyncExternalStoreWithSelector=function(f,p,g,y,v){var S=i(null);if(S.current===null){var C={hasValue:!1,value:null};S.current=C}else C=S.current;S=c(function(){function L(j){if(!E){if(E=!0,D=j,j=y(j),v!==void 0&&C.hasValue){var A=C.value;if(v(A,j))return P=A}return P=j}if(A=P,r(D,j))return A;var H=y(j);return v!==void 0&&v(A,H)?(D=j,A):(D=j,P=H)}var E=!1,D,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 a(function(){C.hasValue=!0,C.value=T},[T]),u(T),T},ex}var R5;function kE(){return R5||(R5=1,J1.exports=CE()),J1.exports}var _E=kE();const LE=x7(_E),M7={},{useDebugValue:EE}=M,{useSyncExternalStoreWithSelector:IE}=LE;let N5=!1;const RE=e=>e;function NE(e,t=RE,n){(M7?"production":void 0)!=="production"&&n&&!N5&&(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"),N5=!0);const r=IE(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return EE(r),r}const M5=e=>{(M7?"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"?SE(e):e,n=(r,s)=>NE(t,r,s);return Object.assign(n,t),n},D7=e=>e?M5(e):M5,yh="auth:unauthorized";let Ku=null;class qa extends Error{constructor(t,n,r){super(t),this.status=n,this.code=r,this.name="TerminalApiError"}status;code}async function ME(){const e=await fetch("/api/terminal/update");if(!e.ok)throw new qa("Failed to load update state",e.status);return e.json()}async function DE(){const e=await ur(),t=await fetch("/api/terminal/update/check",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new qa("Failed to check for updates",t.status);return t.json()}async function jE(){const e=await ur(),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 qa(n.error||"Failed to restart Termdock",t.status)}return t.json()}async function PE(){const e=await fetch("/api/terminal/quota");if(!e.ok)throw new qa("Failed to fetch quota",e.status);return e.json()}async function BE(){const e=await ur(),t=await fetch("/api/terminal/quota/refresh",{method:"POST",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new qa("Failed to refresh quota",t.status);return t.json()}const wu=8e3,FE=32e3,pc=1e4,x0=45e3,OE=8e3,QE=8e3,$E=15e3,HE=1e4,C0=5e3;let UE=0;const km=[];let rx=!1;function eu(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:++UE,ts:Date.now(),...t}});km.push(n),zE()}async function zE(){if(!rx){rx=!0;try{for(;km.length>0;){const e=km[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),km.shift()}catch{break}}}finally{rx=!1}}}function GE(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 Cs(e,t,n,r){const{signal:s,cleanup:i}=GE(t?.signal??void 0,n,r);try{return await fetch(e,{...t,signal:s})}catch(a){throw a instanceof DOMException&&a.name==="TimeoutError"?new Error(r):a}finally{i()}}async function j7(e,t,n){let r=null;const s=new Promise((i,a)=>{r=setTimeout(()=>a(new Error(n)),t)});try{return await Promise.race([e.text(),s])}finally{r&&clearTimeout(r)}}async function k0(e,t,n){const r=await j7(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){Ku=null;try{window.dispatchEvent(new CustomEvent(yh))}catch{}}return n}}async function ur(){if(Ku)return Ku;const e=await Cs("/api/csrf-token",void 0,OE,"CSRF token request timed out");if(!e.ok)throw new Error("Failed to get CSRF token");const t=await k0(e,C0,"CSRF token response timed out");if(!t.csrfToken)throw new Error("Invalid CSRF token response");return Ku=t.csrfToken,Ku}function P7(){Ku=null}const WE=2e4,D5=8e3,VE=1500,To=new Map,qE=24,KE=40,YE=40;function XE(e){return e.retryState.retryCount>=2||e.pendingInputs.length>=YE?"congested":e.retryState.retryCount>=1||e.pendingInputs.length>=8?"degraded":"good"}function j5(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 B7(e){if(e.ws.readyState!==WebSocket.OPEN)return;const t=XE(e);if(t==="good"){j5(e);return}if(e.inputFlushTimer)return;const n=t==="congested"?KE:qE;e.inputFlushTimer=setTimeout(()=>{e.inputFlushTimer=null,j5(e)},n)}const ah=new Map;function ZE(e,t,n,r){const s=ah.get(e);s&&(ah.delete(e),t?s.resolve({success:!0,layout:n}):s.reject(new Error(r||"Tmux action failed")))}function JE(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 P5=new Map;async function eI(e){const t=await ur(),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 tI(e,t,n,r={}){const{maxRetries:s=10,initialRetryDelay:i=1e3,maxRetryDelay:a=2e4,connectionTimeout:c=15e3}=r,u={maxRetries:s,initialDelayMs:i,maxDelayMs:a,connectionTimeoutMs:c,retryCount:0,retryTimeout:null,connectionTimeoutId:null,isClosed:!1,isSuspended:!1};let f=null,p=P5.get(e)??0;P5.delete(e);const g=[];let y=!1,v=null;const S=new WeakSet,C=()=>{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>=D5)try{F.ws.close()}catch{}},D5)}},WE)},E=()=>{if(u.isClosed=!0,C(),f){T(f),To.delete(e);try{f.ws.close()}catch{}f=null}},D=()=>{if(u.isClosed)return;if(f){S.add(f.ws),T(f);try{f.ws.close()}catch{}}const F=JE(e,p),j=new WebSocket(F);y=!1,u.connectionTimeoutId=setTimeout(()=>{j.readyState!==WebSocket.OPEN&&(y=!0,j.close(),P(new Error("WebSocket connection timeout"),!1))},c);const A={ws:j,onEvent:t,onError:n,reconnectNow:()=>{if(!u.isClosed&&(u.isSuspended=!1,!v)){if(C(),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,D()},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};j.onopen=()=>{C(),u.retryCount=0,A.lastInboundAt=Date.now(),A.inboundSequence+=1,L(A),B7(A)},j.onmessage=H=>{A.lastInboundAt=Date.now(),A.inboundSequence+=1;try{const Q=JSON.parse(H.data);if(Q.type==="pong"){A.pongTimer&&(clearTimeout(A.pongTimer),A.pongTimer=null);return}if(Q.type==="tmux-result"&&Q.reqId){ZE(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(W=>typeof W=="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 K=Q;if(K.type==="connected"){typeof K.replayLastSeq=="number"&&K.replayLastSeq>0&&(p=K.replayLastSeq,A.lastSeq=p),t(K);return}if(K.type==="exit"){E(),t(K);return}t(K),K.type==="data"&&typeof K.seq=="number"&&Number.isFinite(K.seq)&&K.seq>p&&(p=K.seq,A.lastSeq=p)}catch(Q){n?.(Q,!1)}},j.onerror=()=>{S.has(j)||(C(),T(A),y||(y=!0,P(new Error("WebSocket connection error"),!1)))},j.onclose=H=>{if(!S.has(j)&&(C(),T(A),!u.isClosed&&!y)){if(y=!0,H.code===4001){console.warn("[Terminal] WS 4001: Session not found on server",{code:H.code,reason:H.reason,stack:new Error().stack}),P(new Error("Session not found on server"),!0);return}if(H.code===4003||H.code===4401){try{window.dispatchEvent(new CustomEvent(yh))}catch{}P(new Error("Authentication required"),!0);return}P(new Error("WebSocket connection closed"),!1)}},f=A,To.set(e,f)},P=(F,j)=>{if(!u.isClosed)if(j)n?.(F,!0),E();else{u.retryCount=Math.min(u.retryCount+1,Math.max(1,s));const A=Math.min(i*Math.pow(2,u.retryCount-1),a);if(t({type:"reconnecting",attempt:u.retryCount,maxAttempts:s}),u.isSuspended)return;u.retryTimeout=setTimeout(()=>{u.isClosed||D()},A)}};return D(),E}async function F7(e,t){const n=To.get(e);if(n){if(n.ws.readyState===WebSocket.OPEN){n.pendingInputs.push(t),B7(n);return}if(n.ws.readyState===WebSocket.CONNECTING){n.pendingInputs.push(t);return}}const r=await ur(),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 nI(e,t){const n=To.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(()=>{To.get(e)!==n||n.retryState.isClosed||(n.inboundSequence<=r?n.reconnectNow():t?.())},VE),!0}function rI(e){const t=To.get(e);return t?(t.reconnectNow(),!0):!1}function B5(){for(const e of To.values())e.suspendReconnect()}function F5(e,t,n){const r=To.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"focus",focused:t,reason:n}))}catch{}}function O5(e,t,n){const r=To.get(e);if(!(!r||r.ws.readyState!==WebSocket.OPEN))try{r.ws.send(JSON.stringify({type:"viewing",viewing:t,reason:n}))}catch{}}function Q5(e){const t=To.get(e);if(!(!t||t.ws.readyState!==WebSocket.OPEN))try{t.ws.send(JSON.stringify({type:"agent-review-ack"}))}catch{}}function $5(e,t,n){const r=To.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 sI(e,t,n,r){const s=To.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 ur(),a=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(!a.ok){const u=await a.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(u.error||"Failed to resize terminal")}const c=await a.json().catch(()=>({success:!0}));if(c?.success===!1||c?.ok===!1)throw new Error(c?.error||"Failed to resize terminal")}async function iI(e,t){const n=To.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,a)=>{const c=Math.random().toString(36).substring(7);ah.set(c,{resolve:i,reject:a}),n.ws.send(JSON.stringify({type:"tmux",reqId:c,...t})),setTimeout(()=>{ah.has(c)&&(ah.delete(c),a(new Error("Tmux action timed out")))},3e4)});const r=await ur(),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 O7(e){const t=To.get(e);if(t){t.retryState.isClosed=!0;try{t.ws.close()}catch{}To.delete(e)}const n=await ur(),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 oI(e,t){const n=To.get(e);if(n){n.retryState.isClosed=!0;try{n.ws.close()}catch{}To.delete(e)}const r=await ur(),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 aI(e){const t=await Cs(`/api/terminal/${e}/health`,{method:"GET"},QE,"Terminal health check timed out");if(!t.ok){if(t.status===404)return{healthy:!1,sessionId:e};const n=await k0(t,C0,"Terminal health error response timed out").catch(()=>({error:"Failed to check terminal health"}));throw new Error(n.error||"Failed to check terminal health")}return k0(t,C0,"Terminal health response timed out")}async function lI(e){const t=await ur(),n=await Cs("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)},HE,"Terminal force-kill request timed out");if(!n.ok){const r=await k0(n,C0,"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 qb(){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 Kb(){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 Q7(e){const t=e.trim();if(!t)throw new Error("tmux session name is required");const n=await ur(),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 cI(){const e=await ur(),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 qa(n.error||"Failed to restore tmux Agent sessions",t.status);return n}async function uI(){const e=await ur(),t=await fetch("/api/terminal/tmux/recovery",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok)throw new qa("Failed to dismiss tmux recovery",t.status)}const Mp=new Map;function dI(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 fI(){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 $7(e){const t=dI(e),n=Mp.get(t);if(n)return n;const r=await ur(),s=Cs("/api/terminal/session-inventory/open",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(e)},$E,"Terminal session open request timed out").then(async i=>{if(!i.ok){const a=await k0(i,C0,"Terminal session open error response timed out").catch(()=>({error:"Failed to open session"}));throw new qa(a.error||"Failed to open session",i.status,typeof a.code=="string"?a.code:void 0)}return k0(i,C0,"Terminal session open response timed out")}).finally(()=>{Mp.get(t)===s&&Mp.delete(t)});return Mp.set(t,s),s}async function _m(e,t){const n=await ur(),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 hI(e){const t=await ur(),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 pI(e){const t=await ur(),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 mI(){const e=await ur(),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 H5(){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 gI(e){const t=await ur(),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 _0(){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 wo(e){const t=await ur(),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 xf(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 xI(){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 bI(e,t){const n=await ur(),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 yI(){const e=await fetch("/api/auth/status");if(!e.ok)throw new Error("Failed to query auth status");return e.json()}async function vI(e){const t=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok)return P7(),{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 wI(){const e=await ur();await fetch("/api/auth/logout",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),P7()}async function H7(){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 SI(){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 AI(e){const t=await ur(),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 TI(e){const t=await ur(),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 My extends Error{constructor(t,n,r){super(t),this.code=n,this.migration=r,this.name="AgentPluginManifestError"}code;migration}async function CI(){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 kI(e){const t=await ur(),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 My(r.error||"Failed to create agent plugin",r.code,r.migration);return r}async function _I(e){const t=await ur(),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 My(r.error||"Failed to install agent plugin",r.code,r.migration);return r}async function LI(e){const t=await ur(),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 EI(e){const t=await ur(),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 II(e){const t=await ur(),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 RI(e){const t=await ur(),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 NI(e){const t=await ur(),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 qa(r.error||"Failed to resume agent session",n.status,typeof r.code=="string"?r.code:void 0);return{command:r.command??""}}async function U5(){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 U7(e){const t=await ur(),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 qa(r.error||"Failed to prepare Agent session resume",n.status,typeof r.code=="string"?r.code:void 0);return r}async function MI(e){const t=await ur(),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 $d(e){const t=await ur(),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 DI(){const e=await ur(),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 jI(){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 z5(e){const t=await ur(),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 PI(){const e=await ur(),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 BI={".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 Dy(e){const t=e.lastIndexOf(".");return t<0?null:BI[e.slice(t).toLowerCase()]??null}function jy(e){return Dy(e)!==null}function z7(e){const t=Dy(e);return t==="image/heic"||t==="image/heif"}const FI={".mp4":"video/mp4",".m4v":"video/x-m4v",".webm":"video/webm",".mov":"video/quicktime",".ogv":"video/ogg",".mpeg":"video/mpeg",".mpg":"video/mpeg"};function G7(e){const t=e.lastIndexOf(".");return t<0?null:FI[e.slice(t).toLowerCase()]??null}function W7(e){return G7(e)!==null}function OI(e){return`/api/terminal/fs/video?path=${encodeURIComponent(e)}&action=view_file`}const QI=[".stl",".glb",".gltf"];function V7(e){const t=e.lastIndexOf(".");if(t<0)return null;const n=e.slice(t).toLowerCase();return QI.includes(n)?n:null}function q7(e){return V7(e)!==null}function K7(e){const t=e.toLowerCase();return t.endsWith(".kicad_sch")?".kicad_sch":t.endsWith(".kicad_pcb")?".kicad_pcb":null}function $I(e){return K7(e)!==null}function HI(e){return K7(e)===".kicad_pcb"?"pcb-front":"schematic"}const UI=[".html",".htm"];function bf(e){const t=e.lastIndexOf(".");if(t<0)return!1;const n=e.slice(t).toLowerCase();return UI.includes(n)}function zI(e){return`/api/terminal/fs/preview/${e.split(/[\\/]+/).filter(Boolean).map(n=>encodeURIComponent(n)).join("/")}`}const GI={".stl":"model/stl",".glb":"model/gltf-binary",".gltf":"model/gltf+json"};async function Py(e,t,n,r="list_directory",s,i="name"){const a=new URLSearchParams({path:e});n&&a.set("showHidden","true"),i!=="name"&&a.set("sort",i),a.set("action",r),s&&a.set("requestSlotId",s);const c=await Cs(`/api/terminal/fs/list?${a}`,{signal:t},wu,"Directory listing took too long. The folder may be on slow storage or blocked by another process.");if(!c.ok){const u=await c.json().catch(()=>({error:"Failed to list directory"}));throw new Error(u.error||"Failed to list directory")}return c.json()}async function WI(e,t,n,r,s,i="name",a,c={}){const u=new URLSearchParams({path:e,query:t,stream:"true"});s&&u.set("showHidden","true"),i==="content"&&u.set("mode","content"),a&&u.set("requestSlotId",a);for(const S of c.excludePatterns??[])u.append("exclude",S);c.caseSensitive&&u.set("caseSensitive","true"),c.wholeWord&&u.set("wholeWord","true"),c.regex&&u.set("regex","true");const f=await fetch(`/api/terminal/fs/search?${u}`,{signal:r});if(!f.ok||!f.body){const S=await f.json().catch(()=>({error:"Failed to search files"}));throw new Error(S.error||"Failed to search files")}const p=f.body.getReader(),g=new TextDecoder;let y="";const v=S=>{if(!S.trim())return;const C=JSON.parse(S);if(C.type==="meta")n({path:C.path,query:C.query,engine:C.engine,mode:C.mode,limited:C.limited});else if(C.type==="batch")n({entries:C.entries??[]});else if(C.type==="content-batch")n({contentEntries:C.contentEntries??[]});else{if(C.type==="error")throw new Error(C.message||"Search failed");C.type==="done"&&n({total:C.total,truncated:C.truncated,limited:C.limited,engine:C.engine,mode:C.mode,done:!0})}};for(;;){const{value:S,done:C}=await p.read();if(C)break;y+=g.decode(S,{stream:!0});let T=y.indexOf(`
3
3
  `);for(;T>=0;)v(y.slice(0,T)),y=y.slice(T+1),T=y.indexOf(`
4
4
  `)}y+=g.decode(),v(y)}async function VI(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 p=await s.json().catch(()=>({error:"Failed to watch files"}));throw new Error(p.error||"Failed to watch files")}const i=s.body.getReader(),a=new TextDecoder;let c="",u=null;const f=p=>{if(!p.trim())return;const g=JSON.parse(p);if(g.type==="events"&&g.events?.length){t(g.events);const y=g.events.find(v=>v.type==="rescan-required"&&v.reason!=="event-storm"&&v.reason!=="reconnected");y?.reason&&(u=y.reason)}};for(;;){const{value:p,done:g}=await i.read();if(g)break;c+=a.decode(p,{stream:!0});let y=c.indexOf(`
@@ -75,7 +75,7 @@ ${t.trim()}`:""].filter(Boolean).join(`
75
75
  `)}async function LO(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{t.remove()}}function EO({error:e,componentStack:t}){const{t:n}=Vn(),[r,s]=M.useState("idle"),i=async()=>{const a=_O(e,t,{url:window.location.href,userAgent:navigator.userAgent,capturedAt:new Date().toISOString()});s(await LO(a)?"copied":"failed")};return o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:o.jsx("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("h3",{className:"font-medium text-foreground",children:n("errorBoundary.title")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e?.message||n("errorBoundary.unexpected")})]}),o.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>{i()},className:"rounded-full bg-surface-2 px-5 py-2.5 text-sm font-medium text-foreground ring-1 ring-border/15 transition hover:bg-surface-elevated active:scale-[0.97]",children:n(r==="copied"?"errorBoundary.copied":r==="failed"?"errorBoundary.copyFailed":"errorBoundary.copyDetails")}),o.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"rounded-full bg-primary px-5 py-2.5 text-sm font-medium text-primary-foreground shadow-sm transition-all hover:bg-primary/90 active:scale-[0.97]",children:n("errorBoundary.retry")})]})]})})}let sA=class extends M.Component{state={hasError:!1,error:null,componentStack:""};static getDerivedStateFromError(t){return{hasError:!0,error:t,componentStack:""}}componentDidCatch(t,n){console.error("Terminal error caught by boundary:",t,n),this.setState({componentStack:n.componentStack??""})}render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsx(EO,{error:this.state.error,componentStack:this.state.componentStack}):this.props.children}};function y2(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const Jf=15;function IO(){return iA.map(e=>e.id)}const iA=[{id:"default",label:"Base",programs:[],includeAlt:!0,rowLayout:[3,3,3],actions:[],showOnDesktop:!1},{id:"opencode",label:"Code",programs:["opencode"],includeAlt:!1,rowLayout:[6],actions:[{id:"opencode-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo||\r"},{id:"opencode-new",label:"/new",sequence:"/new",doubleTapSequence:"/new||\r"},{id:"opencode-models",label:"/models",sequence:"/models",doubleTapSequence:"/models||\r"},{id:"opencode-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact||\r"}],showOnDesktop:!0},{id:"claude",label:"Claude",programs:["claude","claude-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"claude-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"claude-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"claude-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"}],showOnDesktop:!0},{id:"kimi",label:"Kimi",programs:["kimi","kimi-code"],includeAlt:!1,rowLayout:[6],actions:[{id:"kimi-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"kimi-new",label:"/new",sequence:"/new",doubleTapSequence:"/new\r"},{id:"kimi-sessions",label:"/sessions",sequence:"/sessions",doubleTapSequence:"/sessions\r"},{id:"kimi-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"kimi-goal",label:"/goal",sequence:"/goal",doubleTapSequence:"/goal\r"}],showOnDesktop:!0},{id:"codex",label:"Codex",programs:["codex"],includeAlt:!1,rowLayout:[6],actions:[{id:"codex-undo",label:"/undo",sequence:"/undo",doubleTapSequence:"/undo\r"},{id:"codex-clear",label:"/clear",sequence:"/clear",doubleTapSequence:"/clear\r"},{id:"codex-model",label:"/model",sequence:"/model",doubleTapSequence:"/model\r"},{id:"codex-compact",label:"/compact",sequence:"/compact",doubleTapSequence:"/compact\r"},{id:"codex-resume",label:"/resume",sequence:"/resume",doubleTapSequence:"/resume\r"}],showOnDesktop:!0},{id:"coco",label:"Coco",programs:["coco"],includeAlt:!1,rowLayout:[6],actions:[{id:"coco-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"coco-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"coco-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"coco-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0},{id:"traex",label:"TraeX",programs:["traex","traecli"],includeAlt:!1,rowLayout:[6],actions:[{id:"traex-undo",label:"/undo",sequence:"/||undo ",doubleTapSequence:"/||undo ||\r"},{id:"traex-clear",label:"/clear",sequence:"/||clear ",doubleTapSequence:"/||clear ||\r"},{id:"traex-compact",label:"/compact",sequence:"/||compact ",doubleTapSequence:"/||compact ||\r"},{id:"traex-model",label:"/model",sequence:"/||model ",doubleTapSequence:"/||model ||\r"},{id:"traex-resume",label:"/resume",sequence:"/||resume ",doubleTapSequence:"/||resume ||\r"}],showOnDesktop:!0}];function Sh(){return iA.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function tv(e){const t=Array.isArray(e)?e.map(n=>Math.min(20,Math.max(2,Math.floor(n)))).filter(n=>Number.isFinite(n)):[];return t.length>0?t:[3,3]}function oA(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const nv=/^\/(.+)\/([gimsuy]*)$/;function S3(e){return nv.test(e.trim())}function og(e){const t=e.trim().match(nv);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function aA(e){if(typeof e!="string")return null;const t=e.trim();return t?nv.test(t)?og(t)?t:null:t.toLowerCase():null}function A3(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\r/g,"\r").replace(/\\n/g,`
76
76
  `).replace(/\\t/g," ")}const T3="||",RO=120;function NO(e){return e.includes(T3)?e.split(T3).filter(t=>t.length>0):[e]}function p0(e){const t=new Set,n=e.map((s,i)=>{const a=typeof s.id=="string"&&s.id.trim().length>0?s.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):`preset-${i+1}`,c=t.has(a)?`${a}-${i+1}`:a;return t.add(c),{id:c,label:typeof s.label=="string"&&s.label.trim().length>0?s.label.trim():"Preset",programs:Array.isArray(s.programs)?s.programs.map(u=>aA(u)).filter(u=>!!u):[],includeAlt:typeof s.includeAlt=="boolean"?!!s.includeAlt:!1,rowLayout:tv(s.rowLayout),showOnDesktop:typeof s.showOnDesktop=="boolean"?!!s.showOnDesktop:!1,actions:Array.isArray(s.actions)?s.actions.map((u,f)=>{const p={id:typeof u.id=="string"&&u.id.trim().length>0?u.id:`${c}-action-${f+1}`,label:typeof u.label=="string"?u.label:`Key ${f+1}`,sequence:typeof u.sequence=="string"?u.sequence:""};return typeof u.doubleTapSequence=="string"&&(p.doubleTapSequence=u.doubleTapSequence),p}):[]}}).filter(s=>s.id!=="auto"),r=Sh()[0];return r&&!n.some(s=>s.id==="default")&&n.unshift(r),n}function MO(e,t){const n=oA(e);if(!n)return"default";for(const r of t)if(r.id!=="default")for(const s of r.programs){const i=og(s);if(i){if(i.test(n))return r.id}else if(n.includes(s))return r.id}return"default"}function C3(e,t){return e.find(n=>n.id===t)??e.find(n=>n.id==="default")??Sh()[0]}function DO(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function jO(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function lA(e,t){const n=tv(t),r=[];let s=0,i=0;for(;s<e.length;){const a=n[Math.min(i,n.length-1)]??3;r.push({columns:a,items:e.slice(s,s+a)}),s+=a,i+=1}return r}const cA=28,uA=({mode:e,presetLabel:t,title:n,ariaLabel:r,disabled:s,onPointerDown:i,buttonRef:a})=>o.jsx("button",{ref:a,type:"button",onPointerDown:i,tabIndex:-1,disabled:s,className:"h-7 w-7 rounded-full bg-surface-2 shadow-sm text-[11px] font-medium active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",title:n,"aria-label":r??n,children:e==="auto"?o.jsx($D,{size:14}):(t.charAt(0)||"?").toUpperCase()}),PO={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Kp=8;function BO(e,t){return PO[e]??null}const FO=({visible:e,interactive:t=!0,presentation:n="mobile",activeModifier:r,lockedModifier:s,disabled:i,defaultShowExtended:a=!1,presetLabel:c,presetModeLabel:u,presetMode:f,presetOptions:p,includeAlt:g,presetRowLayout:y,extraActions:v,onKeyPress:S,onTextPress:C,onPastePress:T,onFilePress:L,fileUploadState:E="idle",fileUploadProgress:D=0,longPressMode:P="arrows",copyFeedback:F="idle",onLongPressModeToggle:j,onModifierToggle:A,onPresetSelect:H,onExpandedChange:Q})=>{const{t:K}=Vn(),[W,de]=M.useState(a),[X,pe]=M.useState(!1),ye=M.useRef(null),Ae=n==="desktop-actions",ie=Ae||W,[V,z]=M.useState(!1),[ce,ge]=M.useState(null),he=i||!e||!t,Ce=i||!e,xe=M.useRef(null),ae=M.useRef(null),Le=M.useRef(null),Z=M.useRef(null),Ze=M.useRef(null),at=M.useRef(F),He=M.useRef(null),be=M.useRef(0),Be=M.useCallback(ht=>{if(he)return;const $t=ht.target;if(!($t instanceof HTMLElement))return;const ct=$t.closest("button"),We=ct?.hasAttribute("data-mobile-native-action")===!0;ct&&!We?(ht.preventDefault(),Bl(Kp)):ct&&Bl(Kp)},[he]),fe=M.useCallback(ht=>{ht.preventDefault()},[]),Ke=M.useCallback(ht=>{const $t=ht.target;he||$t instanceof HTMLElement&&$t.closest("button")&&$t.blur()},[he]);M.useEffect(()=>{de(a)},[a]),M.useEffect(()=>{Ae||Q?.(W)},[Ae,Q,W]),M.useEffect(()=>{he&&(He.current!==null&&(window.clearTimeout(He.current.timer),He.current=null),z(!1),ge(null))},[he]),M.useEffect(()=>{e||(z(!1),ge(null))},[e]),M.useEffect(()=>{if(!V)return;const ht=()=>{const $t=xe.current?.getBoundingClientRect();$t&&ge({left:Math.max(8,$t.left),top:Math.max(8,$t.top-8)})};return ht(),window.addEventListener("resize",ht),window.addEventListener("scroll",ht,!0),()=>{window.removeEventListener("resize",ht),window.removeEventListener("scroll",ht,!0)}},[V]),M.useEffect(()=>{const ht=at.current;if(at.current=F,F==="idle"||F===ht)return;if(Ze.current!==null&&window.clearTimeout(Ze.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(F==="copied"){ae.current?.animate?.([{transform:"scale(1)"},{transform:"scale(1.16)",offset:.28},{transform:"scale(0.96)",offset:.62},{transform:"scale(1)"}],{duration:720,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});const ct=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];Le.current?.animate?.(ct,{duration:760,easing:"ease-out"}),Z.current?.animate?.(ct,{duration:760,delay:130,easing:"ease-out"})}else ae.current?.animate?.([{transform:"translateX(0)"},{transform:"translateX(-2px)"},{transform:"translateX(2px)"},{transform:"translateX(0)"}],{duration:280,easing:"ease-out"});Bl(Kp),F==="copied"&&(Ze.current=window.setTimeout(()=>{Bl(Kp),Ze.current=null},90),P==="copy"&&j?.())},[F,P,j]),M.useEffect(()=>()=>{Ze.current!==null&&window.clearTimeout(Ze.current)},[]);const Ye=M.useCallback((ht,$t)=>{he||(ht.preventDefault(),S($t))},[S,he]),et=M.useCallback((ht,$t)=>{he||(ht.preventDefault(),A($t))},[A,he]),q=M.useCallback(ht=>{he||(ht.preventDefault(),de($t=>{const ct=!$t;return ct&&(pe(!0),ye.current!==null&&window.clearTimeout(ye.current),ye.current=window.setTimeout(()=>{pe(!1),ye.current=null},350)),ct}))},[he]),ue=M.useCallback(()=>{const ht=typeof performance<"u"?performance.now():Date.now();ht-be.current<350||(be.current=ht,T?.())},[T]),Xe=M.useCallback(ht=>{he||(ht.stopPropagation(),ht.pointerType!=="touch"&&(ht.preventDefault(),ue()))},[he,ue]),Ne=M.useCallback(ht=>{he||(ht.preventDefault(),ht.stopPropagation(),ue())},[he,ue]),Ge=M.useCallback(ht=>{he||E==="uploading"||!L||(ht.preventDefault(),ht.stopPropagation(),L())},[E,L,he]),Fe=M.useCallback(ht=>{he||ht.stopPropagation()},[he]),ft=250,it=M.useCallback(()=>{He.current!==null&&(window.clearTimeout(He.current.timer),He.current=null)},[]);M.useEffect(()=>()=>{it(),ye.current!==null&&(window.clearTimeout(ye.current),ye.current=null)},[it]);const Mt=M.useCallback((ht,$t)=>{if(he)return;if(ht.preventDefault(),!$t.doubleTapSequence){C($t.sequence);return}const ct=He.current;if(ct!==null&&ct.actionId===$t.id){window.clearTimeout(ct.timer),He.current=null,C($t.doubleTapSequence);return}it();const We=window.setTimeout(()=>{He.current=null,C($t.sequence)},ft);He.current={actionId:$t.id,timer:We}},[it,C,he]),vt=M.useCallback(ht=>{he||(ht.preventDefault(),ht.stopPropagation(),j?.())},[j,he]),Gt=M.useCallback(ht=>{he||ht.stopPropagation()},[he]),Zt=M.useCallback(ht=>{if(he)return;ht.preventDefault();const $t=ht.currentTarget.getBoundingClientRect();ge({left:Math.max(8,$t.left),top:Math.max(8,$t.top-8)}),z(ct=>!ct)},[he]),an=M.useCallback((ht,$t)=>{he||(ht.preventDefault(),z(!1),ge(null),H($t))},[H,he]),$n=v.length>0,we=M.useMemo(()=>{const ht=[{id:"preset",kind:"preset"}];if(!Ae&&g&&ht.push({id:"alt",kind:"alt"}),$n){const $t=v.map(ct=>({id:ct.id,kind:"text",action:ct}));return ht.concat($t)}return Ae?ht:ht.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,$n,g,Ae]),dt=M.useMemo(()=>lA(we,y),[we,y]),gt=`${Ae?"space-y-1":"mt-1 space-y-1"}${X?" pointer-events-none":""}`,Wt=V&&ce?ui.createPortal(o.jsx("div",{className:"fixed z-popover min-w-28 -translate-y-full rounded-2xl bg-surface-elevated p-1.5 shadow-xl border border-border/15",style:{left:ce.left,top:ce.top},children:o.jsx("div",{className:"grid gap-1",children:p.map(ht=>o.jsx("button",{type:"button",onPointerDown:$t=>an($t,ht.id),tabIndex:-1,disabled:Ce,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${ht.id===f?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:ht.label},ht.id))})}),document.body):null;return o.jsxs(o.Fragment,{children:[Wt,o.jsx("div",{"data-mobile-keyboard":"true",className:`z-chrome select-none overflow-hidden app-chrome-bg transition-all duration-150 ease-out px-1 py-0 ${e?Ae?"max-h-24":"max-h-40":"max-h-0"} ${e?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"} ${t?"":"[&_button]:pointer-events-none"}`,onMouseDownCapture:Be,onPointerDownCapture:Be,onContextMenuCapture:fe,onFocusCapture:Ke,children:o.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!Ae&&o.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[o.jsx("button",{type:"button",onPointerDown:ht=>Ye(ht,"esc"),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"Esc"}),o.jsx("button",{type:"button",onPointerDown:ht=>et(ht,"ctrl"),tabIndex:-1,disabled:Ce,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${r==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${s==="ctrl"?"ring-2 ring-accent":""}`,children:o.jsx("span",{className:"font-medium",children:s==="ctrl"?"Ctrl*":"Ctrl"})}),o.jsx("button",{type:"button",onPointerDown:ht=>Ye(ht,"ctrl-c"),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-C"}),o.jsx("button",{type:"button",onPointerDown:ht=>Ye(ht,"ctrl-u"),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-U"}),o.jsxs("button",{type:"button","data-mobile-native-action":"true",onPointerDown:Fe,onTouchStart:Fe,onClick:Ge,tabIndex:-1,disabled:Ce||!L||E==="uploading",title:E==="uploading"?`${K("rightSidebar.uploading")} ${Math.round(D)}%`:K(E==="inserted"?"rightSidebar.inserted":E==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":K("rightSidebar.insertLocalFile"),className:`relative h-7 w-full overflow-hidden rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${E==="inserted"?"bg-primary/15 text-primary":E==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[E==="uploading"&&o.jsx("span",{"aria-hidden":"true","data-file-upload-progress":"true",className:"absolute inset-y-0 left-0 bg-primary/25 transition-[width] duration-150 ease-out",style:{width:`${Math.max(0,Math.min(100,D))}%`}}),o.jsx("span",{className:"relative z-10 flex items-center justify-center",children:E==="uploading"?o.jsx(zn,{size:15,className:"animate-spin"}):E==="inserted"?o.jsx(va,{size:15}):E==="failed"?o.jsx(es,{size:15}):o.jsx(cM,{size:15})}),E!=="idle"&&o.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:E==="uploading"?`${K("rightSidebar.uploading")} ${Math.round(D)}%`:K(E==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),o.jsx("button",{type:"button",onPointerDown:()=>C("/"),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"/"}),o.jsx("button",{type:"button",onPointerDown:ht=>Ye(ht,"enter"),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:o.jsx(d8,{size:16})}),o.jsxs("button",{ref:ae,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Gt,onTouchStart:Gt,onClick:vt,tabIndex:-1,disabled:Ce,title:K(F==="copied"?"terminal.copied":F==="failed"?"terminal.copyFailed":P==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":K(P==="copy"?"terminal.switchLongPressToArrows":"terminal.switchLongPressToCopy"),className:`relative isolate h-7 w-full overflow-visible rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-colors keyboard-button-active disabled:opacity-50 flex items-center justify-center ${F==="copied"?"bg-primary/15 text-primary":F==="failed"?"bg-destructive/15 text-destructive":P==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[o.jsx("span",{ref:Le,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),o.jsx("span",{ref:Z,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/40 opacity-0"}),o.jsxs("span",{className:"relative z-10 h-4 w-4","aria-hidden":"true",children:[o.jsx(va,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${F==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),o.jsx(es,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${F==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),o.jsx(u8,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${F==="idle"&&P==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),o.jsx(KM,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${F==="idle"&&P==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),F!=="idle"&&o.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:F==="copied"?`${K("terminal.copied")} · ${K("terminal.longPressSendsArrows")}`:`${K("terminal.copyFailed")} · ${K("terminal.longPressSelectsText")}`})]}),o.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Xe,onPointerUp:Fe,onTouchStart:Fe,onTouchEnd:Fe,onClick:Ne,tabIndex:-1,disabled:Ce,title:K("terminal.paste"),"aria-label":K("terminal.paste"),className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:o.jsx(HN,{size:15})}),o.jsx("button",{type:"button",onPointerDown:q,tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:W?o.jsx(c8,{size:16}):o.jsx(wa,{size:16})})]}),ie&&o.jsx("div",{className:gt,children:dt.map((ht,$t)=>{const ct=ht.items[0]?.kind==="preset",We=Math.max(2,ht.columns),Zn=ct?`${cA}px repeat(${Math.max(1,We-1)}, minmax(0, 1fr))`:`repeat(${We}, minmax(0, 1fr))`;return o.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:Zn},children:ht.items.map(An=>An.kind==="preset"?o.jsx(uA,{buttonRef:An.id==="preset"?xe:void 0,mode:f,presetLabel:c,title:u,disabled:Ce,onPointerDown:Zt},An.id):An.kind==="alt"?o.jsx("button",{type:"button",onPointerDown:Ve=>et(Ve,"alt"),tabIndex:-1,disabled:Ce,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${r==="alt"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${s==="alt"?"ring-2 ring-accent":""}`,children:o.jsx("span",{className:"font-medium",children:s==="alt"?"Alt*":"Alt"})},An.id):An.kind==="text"?o.jsxs("button",{type:"button",onPointerDown:Ve=>Mt(Ve,An.action),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm px-1 text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 relative",children:[An.action.label,An.action.doubleTapSequence&&o.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},An.id):o.jsx("button",{type:"button",onPointerDown:Ve=>Ye(Ve,An.keyName),tabIndex:-1,disabled:Ce,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:An.keyName==="ctrl-d"?"Ctrl-D":An.keyName==="home"?"Home":"End"},An.id))},`row-${$t}`)})})]})})]})},OO=({isMobile:e,isInputFocused:t,isIOS:n,isConnecting:r,connectionError:s,terminalSessionId:i})=>{if(typeof window>"u")return null;const a=window.visualViewport?Math.max(0,Math.round(window.innerHeight-window.visualViewport.height-window.visualViewport.offsetTop)):0;return o.jsxs("div",{className:"px-3 py-2 bg-surface text-foreground text-xs border-b border-border/15",children:[o.jsx("div",{className:"font-bold mb-2",children:"Debug Info"}),o.jsxs("div",{className:"grid grid-cols-2 gap-1 font-mono",children:[o.jsxs("div",{children:["isMobile: ",o.jsx("span",{className:e?"text-accent":"text-destructive",children:String(e)})]}),o.jsxs("div",{children:["touchPoints: ",navigator.maxTouchPoints]}),o.jsxs("div",{children:["innerWidth: ",window.innerWidth]}),o.jsxs("div",{children:["innerHeight: ",window.innerHeight]}),o.jsxs("div",{children:["viewportH:"," ",window.visualViewport?Math.round(window.visualViewport.height):"N/A"]}),o.jsxs("div",{children:["inputFocused: ",String(t)]}),o.jsxs("div",{children:["keyboard~: ",a,"px"]}),o.jsxs("div",{children:["connecting:"," ",o.jsx("span",{className:r?"text-muted-foreground":"text-accent",children:String(r)})]}),o.jsxs("div",{children:["sessionId:"," ",o.jsx("span",{className:i?"text-accent":"text-destructive",children:i?"✓":"✗"})]}),o.jsxs("div",{children:["error:"," ",o.jsx("span",{className:s?"text-destructive":"text-accent",children:s?"Yes":"No"})]}),o.jsxs("div",{children:["isIOS:"," ",o.jsx("span",{className:n?"text-muted-foreground":"text-accent",children:String(n)})]})]}),o.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:o.jsx("div",{children:"Tip: Tap the status bar 3 times to toggle debug panel"})})]})},QO=/^Reconnecting/i,$O=({connectionError:e,isFatalError:t,isRestarting:n,isConnecting:r,onHardRestart:s})=>{const{t:i}=Vn(),a=!!e&&QO.test(e);return r&&!e||a?o.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:o.jsx("span",{className:"text-[11px] text-muted-foreground/60 animate-pulse tracking-wide",children:e||i("connection.reconnecting")})}):e?o.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2",children:o.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-destructive/70",children:[o.jsx("span",{children:e}),t&&o.jsx("button",{type:"button",onClick:s,disabled:n,className:"text-[11px] text-destructive/90 hover:text-destructive underline underline-offset-2 transition-colors disabled:opacity-40",children:i("common.retry")})]})}):null};let eh=[],Mx=!1;function Qa(e,t,n={}){typeof window>"u"||(eh.push(JSON.stringify({level:e,message:t,data:{ts:Date.now(),...n}})),HO())}async function HO(){if(!Mx){Mx=!0;try{for(;eh.length>0;){const e=eh[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),eh.shift()}catch{eh=[];break}}}finally{Mx=!1}}}const v2=80,UO=60,zO="termdock:viewport-keyboard-change",w2="termdock:viewport-layout-change",Qc=240,k3=640,_3=360,GO=[50,150,300,500,800,1200],WO=28,VO=72,dA=500;function qO({measuredHeight:e,documentVisible:t,editableFocused:n}){return t&&n&&e>=v2}function S2(){if(typeof document>"u")return!1;const e=document.activeElement;return e instanceof HTMLElement&&e.matches('input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])')}function KO({measuredHeight:e,referenceHeight:t,keyboardOpenAgeMs:n,isIOS:r,isTerminalInputFocused:s}){const i=t-e,a=i>=WO&&i<=VO;return r&&s&&n>=dA&&a?t:e}const ag=e=>{const t=typeof e=="number"?e:Number.parseFloat(typeof e=="string"?e:"0");return Number.isFinite(t)&&t>0?Math.round(t):0},fA=(e,t)=>{const n=e.map(ag).filter(r=>r>0);return n.find(r=>r>=Qc)??n[0]??t},uh=()=>typeof window>"u"?k3:fA([window.innerHeight,document.documentElement?.clientHeight,document.body?.clientHeight,window.visualViewport?.height,window.screen?.availHeight,window.screen?.height],k3),hA=()=>typeof window>"u"?_3:fA([window.innerWidth,document.documentElement?.clientWidth,document.body?.clientWidth,window.visualViewport?.width,window.screen?.availWidth,window.screen?.width],_3),Yp=e=>{const t=Number.parseFloat(e||"0");return Number.isFinite(t)?Math.max(0,Math.round(t)):0},A2=()=>typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,YO=()=>typeof window>"u"?!1:navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)").matches===!0,pA=()=>{if(typeof window>"u"||!A2()||!YO())return{top:0,right:0,bottom:0,left:0};if(!(uh()>=hA()))return{top:0,right:0,bottom:0,left:0};const t=window.screen?.width||window.innerWidth,n=window.screen?.height||window.innerHeight,r=Math.min(t,n),s=Math.max(t,n);return r>=700?{top:20,right:0,bottom:20,left:0}:s<780?{top:20,right:0,bottom:0,left:0}:{top:s>=852?59:s>=844?47:44,right:0,bottom:34,left:0}};function XO(e="--app-vh"){if(typeof window>"u"||typeof document>"u")return;const t=ag(window.visualViewport?.height),n=Math.max(0,Math.round(window.visualViewport?.offsetTop??0)),r=uh(),i=t>=Qc?Math.min(r,t+n):r,a=Math.max(r,i),c=document.documentElement.style;c.setProperty(e,`${Math.max(i,Qc)}px`),c.setProperty("--app-base-vh",`${Math.max(a,Qc)}px`),c.setProperty("--app-visible-vh",`${Math.max(i,Qc)}px`),c.setProperty("--app-vv-offset-top",`${n}px`),c.setProperty("--kb-translate-y","0px"),c.setProperty("--kb-margin-top","0px"),c.setProperty("--kb-height","0px");const u=pA();u.top>0&&c.setProperty("--safe-top-inset",`${u.top}px`),u.right>0&&c.setProperty("--safe-right-inset",`${u.right}px`),u.bottom>0&&c.setProperty("--safe-bottom-inset",`${u.bottom}px`),u.left>0&&c.setProperty("--safe-left-inset",`${u.left}px`)}function ZO(e={}){const{cssVarName:t="--app-vh"}=e,n=M.useMemo(()=>cd("viewport"),[]),r=M.useCallback(()=>{if(typeof window>"u")return 0;const v=window.visualViewport,S=uh();if(!v)return S;const C=ag(v.height);if(C<Qc&&S>=Qc)return S;const T=v.offsetTop,E=C<S-1&&T>0&&T<=96?C+T:C,D=Math.max(0,Math.min(S,E));return D>0?Math.round(D):S},[]),[s,i]=M.useState(r),a=M.useRef([]),c=M.useRef(0),u=M.useRef(0),f=M.useRef(0),p=M.useRef(!1),g=M.useRef(null),y=M.useRef(new Map);return M.useEffect(()=>{if(typeof window>"u")return;let v=null,S=null;const C=new Set,T=(V,z,ce)=>[V,z,ce].sort((ge,he)=>ge-he)[1],L=()=>{if(S?.isConnected)return S;try{return S=document.createElement("div"),S.setAttribute("aria-hidden","true"),S.style.cssText=["position:fixed","top:0","left:0","width:0","height:0","visibility:hidden","pointer-events:none","padding-top:constant(safe-area-inset-top)","padding-top:env(safe-area-inset-top,0px)","padding-right:constant(safe-area-inset-right)","padding-right:env(safe-area-inset-right,0px)","padding-bottom:constant(safe-area-inset-bottom)","padding-bottom:env(safe-area-inset-bottom,0px)","padding-left:constant(safe-area-inset-left)","padding-left:env(safe-area-inset-left,0px)"].join(";"),(document.body||document.documentElement).appendChild(S),S}catch{}return null},E=()=>{let V={top:0,right:0,bottom:0,left:0};try{const ge=L();if(ge){const he=getComputedStyle(ge);V={top:Yp(he.paddingTop),right:Yp(he.paddingRight),bottom:Yp(he.paddingBottom),left:Yp(he.paddingLeft)}}}catch{}const z=pA(),ce={top:Math.max(V.top,z.top),right:Math.max(V.right,z.right),bottom:Math.max(V.bottom,z.bottom),left:Math.max(V.left,z.left)};return document.documentElement.style.setProperty("--safe-top-inset",`${ce.top}px`),document.documentElement.style.setProperty("--safe-right-inset",`${ce.right}px`),document.documentElement.style.setProperty("--safe-bottom-inset",`${ce.bottom}px`),document.documentElement.style.setProperty("--safe-left-inset",`${ce.left}px`),ce},D=(V,z,ce,ge)=>{const he=Math.max(z,ce);if(c.current===0){c.current=he,u.current=V,document.documentElement.style.setProperty("--app-base-vh",`${he}px`);return}const Ce=Math.abs(V-u.current),xe=ge<=v2;(Ce>UO||xe)&&(c.current=he,u.current=V,document.documentElement.style.setProperty("--app-base-vh",`${he}px`))},P=(V="event")=>{v=null;const z=r(),ce=Math.round(window.visualViewport?.offsetTop??0),ge=ag(window.visualViewport?.height),he=ge>=Qc?ge:z,Ce=uh(),xe=hA(),ae=Math.max(0,he+ce),Le=E(),Z=Le.bottom,Ze=Math.max(0,c.current-ae-Z);D(xe,Ce,ae,Ze);const at=a.current;at.push(z),at.length>3&&at.shift();let He=z;at.length===3&&z<=at[0]&&(He=T(at[0],at[1],at[2])),i(gt=>gt===z?gt:z);const be=Number.parseInt(document.documentElement.style.getPropertyValue(t)||"0",10);document.documentElement.style.setProperty(t,`${He}px`),document.documentElement.style.setProperty("--app-vv-offset-top",`${ce}px`);const Be=c.current,fe=Math.min(He,he),Ke=Math.max(0,Math.min(Be,ae)),Ye=Math.max(0,Math.round(Be-Ke-Z)),et=S2(),q=qO({measuredHeight:Ye,documentVisible:document.visibilityState==="visible",editableFocused:et}),ue=q,Xe=performance.now();ue&&g.current===null?g.current=Xe:ue||(g.current=null);const Ne=g.current===null?0:Math.max(0,Xe-g.current),Ge=xe>Be?"landscape":"portrait",Fe=Math.round(xe/20)*20,ft=`${Ge}:${Fe}`,it=y.current.get(ft)??0,Mt=document.activeElement?.matches('[data-terminal-input-anchor="true"]')===!0,vt=q?KO({measuredHeight:Ye,referenceHeight:it,keyboardOpenAgeMs:Ne,isIOS:A2(),isTerminalInputFocused:Mt}):0,Gt=vt>=v2;A2()&&Mt&&ue&&Ne>=dA&&Ye>it&&y.current.set(ft,Ye);const Zt=-vt,an=vt;document.documentElement.style.setProperty("--kb-translate-y",`${Zt}px`),document.documentElement.style.setProperty("--kb-margin-top",`${an}px`),document.documentElement.style.setProperty("--kb-height",`${vt}px`),document.documentElement.style.setProperty("--app-visible-vh",`${Ke}px`);const $n=Math.abs(vt-f.current)>1,we=Gt!==p.current;($n||we)&&(f.current=vt,p.current=Gt,document.dispatchEvent(new CustomEvent(zO,{detail:{baseHeight:Be,visibleHeight:Ke,visualViewportHeight:he,offsetTop:ce,keyboardHeight:vt,isOpen:Gt,source:V}}))),(be!==He||ce>0||$n||we)&&n("sync",{cssVarName:t,innerHeight:Ce,baseHeight:Be,rawViewportHeight:he,offsetTop:ce,visibleHeight:Ke,rawHeight:z,appliedHeight:He,keyboardViewportHeight:fe,measuredKeyboardHeight:Ye,editableFocused:et,applyKeyboardInset:q,referenceKeyboardHeight:it,keyboardOpenAgeMs:Math.round(Ne),correctedKeyboardToolbar:vt!==Ye,keyboardHeight:vt,isKeyboardOpen:Gt,safeAreaInsets:Le,filtered:He!==z,source:V}),document.dispatchEvent(new CustomEvent(w2,{detail:{height:He,baseHeight:Be,visibleHeight:Ke,offsetTop:ce,source:V}}))},F=(V="event")=>{(V.includes("visibilitychange")||V.includes("pageshow"))&&n("schedule",{source:V}),v===null&&(v=window.requestAnimationFrame(()=>P(V)))},j=V=>{F(`${V}:now`);for(const z of GO){const ce=window.setTimeout(()=>{C.delete(ce),F(`${V}:${z}ms`)},z);C.add(ce)}};j("mount");const A=()=>F("resize"),H=()=>F("orientationchange"),Q=()=>F("visualViewport.resize"),K=()=>F("visualViewport.scroll"),W=()=>j("focusin"),de=()=>j("focusout"),X=V=>{const z=document.activeElement;z instanceof HTMLElement&&S2()&&z.blur(),g.current=null,f.current=0,p.current=!1,a.current=[];const ce=Math.max(c.current,uh(),Qc),ge=document.documentElement.style;ge.setProperty(t,`${ce}px`),ge.setProperty("--app-visible-vh",`${ce}px`),ge.setProperty("--app-vv-offset-top","0px"),ge.setProperty("--kb-translate-y","0px"),ge.setProperty("--kb-margin-top","0px"),ge.setProperty("--kb-height","0px"),i(he=>he===ce?he:ce),n("keyboard session reset",{source:V,baseHeight:ce})};window.addEventListener("resize",A),window.addEventListener("orientationchange",H),window.visualViewport?.addEventListener("resize",Q),window.visualViewport?.addEventListener("scroll",K),document.addEventListener("focusin",W),document.addEventListener("focusout",de);const pe=V=>{n("resume",{source:V,innerHeight:Math.round(window.innerHeight),visualViewport:window.visualViewport?{width:Math.round(window.visualViewport.width),height:Math.round(window.visualViewport.height),offsetTop:Math.round(window.visualViewport.offsetTop)}:null,hidden:document.hidden}),j(V)},ye=()=>{document.hidden?X("visibilitychange:hidden"):pe("visibilitychange")},Ae=()=>pe("pageshow"),ie=()=>X("pagehide");return document.addEventListener("visibilitychange",ye),window.addEventListener("pageshow",Ae),window.addEventListener("pagehide",ie),()=>{window.removeEventListener("resize",A),window.removeEventListener("orientationchange",H),window.visualViewport?.removeEventListener("resize",Q),window.visualViewport?.removeEventListener("scroll",K),document.removeEventListener("focusin",W),document.removeEventListener("focusout",de),document.removeEventListener("visibilitychange",ye),window.removeEventListener("pageshow",Ae),window.removeEventListener("pagehide",ie),v!==null&&window.cancelAnimationFrame(v),C.forEach(V=>window.clearTimeout(V)),C.clear(),S?.remove()}},[t,n,r]),s}const JO=120,eQ=80,tQ=400;function L3(){if(typeof window>"u"||document.visibilityState!=="visible"||!S2())return 0;const e=Number.parseFloat(document.documentElement.style.getPropertyValue("--kb-height")||"0");if(Number.isFinite(e)&&e>0)return Math.round(e);const t=window.visualViewport;if(!t)return 0;const n=Number.parseFloat(document.documentElement.style.getPropertyValue("--app-base-vh")||"0")||window.innerHeight,r=Number.parseFloat(document.documentElement.style.getPropertyValue("--safe-bottom-inset")||"0")||0,s=t.height+t.offsetTop;return Math.max(0,Math.round(n-s-r))}function mA(e){const{enabled:t,openThresholdPx:n=JO,closeThresholdPx:r=eQ,settleDelayMs:s=tQ}=e,i=M.useMemo(()=>cd("keyboard"),[]),a=M.useRef(!1),c=M.useRef(null),u=M.useRef(0),[f,p]=M.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return M.useEffect(()=>{if(typeof window>"u"||!t){a.current=!1,c.current!==null&&(clearTimeout(c.current),c.current=null),p(j=>!j.isOpen&&!j.isSettled&&j.keyboardHeight===0?j:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let g=null;const y=()=>{g=null;const j=L3();let A=a.current;if(j>=n?A=!0:j<=r&&(A=!1),a.current=A,A){const H=Math.abs(j-u.current);u.current=j,H>10&&(c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,p(Q=>Q.isSettled?Q:{...Q,isSettled:!0})},s))}else c.current!==null&&(clearTimeout(c.current),c.current=null);p(H=>{const Q=A?H.isSettled:!1;return H.isOpen===A&&H.keyboardHeight===j&&H.isSettled===Q?H:(i("sync",{keyboardHeight:j,isOpen:A,isSettled:Q,visualViewport:window.visualViewport?{width:Math.round(window.visualViewport.width),height:Math.round(window.visualViewport.height),offsetTop:Math.round(window.visualViewport.offsetTop)}:null}),{isOpen:A,isSettled:Q,keyboardHeight:j})})},v=(j="event")=>{(j.includes("visibilitychange")||j.includes("pageshow"))&&i("schedule",{source:j}),g===null&&(g=window.requestAnimationFrame(y))};v("mount");const S=()=>v("resize"),C=()=>v("orientationchange"),T=()=>v("visualViewport.resize"),L=()=>v("visualViewport.scroll"),E=()=>v("viewport-keyboard-change");window.addEventListener("resize",S),window.addEventListener("orientationchange",C),window.visualViewport?.addEventListener("resize",T),window.visualViewport?.addEventListener("scroll",L),document.addEventListener("termdock:viewport-keyboard-change",E);const D=j=>{i("resume",{source:j,keyboardHeight:L3(),hidden:document.hidden}),v(`${j}:now`),window.setTimeout(()=>v(`${j}:50ms`),50),window.setTimeout(()=>v(`${j}:200ms`),200)},P=()=>{document.hidden||D("visibilitychange")},F=()=>D("pageshow");return document.addEventListener("visibilitychange",P),window.addEventListener("pageshow",F),()=>{window.removeEventListener("resize",S),window.removeEventListener("orientationchange",C),window.visualViewport?.removeEventListener("resize",T),window.visualViewport?.removeEventListener("scroll",L),document.removeEventListener("termdock:viewport-keyboard-change",E),document.removeEventListener("visibilitychange",P),window.removeEventListener("pageshow",F),g!==null&&window.cancelAnimationFrame(g),c.current!==null&&(clearTimeout(c.current),c.current=null)}},[i,t,n,r,s]),f}const Bm=300,nQ=120,rQ=250,sQ=6e4;function Dx(e,t){return t?e.find(n=>n.id===t||n.backendSessionId===t)?.id??null:null}function Xp(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function iQ(e){return e.foregroundSessionId===null||e.sessionId===e.foregroundSessionId||e.foregroundReady}function oQ(e){return e.isMobileLayout?e.visibleSessionIds.has(e.sessionId):e.sessionId===e.foregroundSessionId||e.deferredViewportSessionIds.has(e.sessionId)}function aQ(e){return e.requestToken===0||e.foregroundSessionId===null||e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function lQ(e,t){return e===null||t-e>=rQ}function cQ(e){return e.wasPageHidden||e.reason==="bfcache"||e.reason==="online"}function uQ(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,sQ-(e.now-e.reconnectStartedAt))}function dQ(e,t){const n=new Map;let r=0;for(const s of e)if(!n.has(s)){if(t.has(s)){n.set(s,0);continue}n.set(s,Bm+r*nQ),r+=1}return n}const fQ="Session not found on server",jx="Terminal session not found",hQ="STALE_SESSION_RESTORE_REJECTED";function pQ(e){return e?.message===fQ}function E3(e){return e?.code===hQ}function th(e,t){if(!e||e.startsWith("/"))return e;const n=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${n}`:n}function Xg(e,t){return th(e,t).replace(/ /g,"\\ ")}function gA(e,t){return`${Xg(e,t)} `}function T2(e,t){return Xg(e,t)}function mQ(e,t,n){if(!n)return T2(e,t);const r=n.start===n.end?`${n.start}`:`${n.start}-${n.end}`;return`${T2(e,t)}:${r}`}const gQ="/tmp";async function xA(e,t,n){const s=(await t(gQ,[e])).files[0];if(!s?.path)throw new Error("Upload did not return a file path");return n(s.path),s}const xQ=xA;function Hr(e,t){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(e);if(n===null||n==="")return null;const r=JSON.parse(n);return t(r)?r:null}catch{return null}}function On(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Px(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}const dh=new Map,fh=new Map,Fm=new Map;function w0(e,t,n){if(typeof window>"u")return;const r=Date.now(),s=Fm.get(e)??0,i=r-s;if(i>=n){Fm.set(e,r),On(e,t);return}if(fh.set(e,t),dh.has(e))return;const a=n-i,c=setTimeout(()=>{dh.delete(e);const u=fh.get(e);fh.delete(e),Fm.set(e,Date.now()),u!==void 0&&On(e,u)},a);dh.set(e,c)}function o0(e){const t=dh.get(e);t&&(clearTimeout(t),dh.delete(e));const n=fh.get(e);n!==void 0&&(fh.delete(e),Fm.set(e,Date.now()),On(e,n))}function bQ(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}const yQ=600,Ah=320,vQ=280,wQ=5;function Bx(e,t,n=0){const r=Math.max(Ah,t-Math.max(0,n)-wQ*(n>0?2:1)-vQ);return Math.min(r,Math.max(Ah,e))}const bA="termdock:right-sidebar:tabs-by-session:v2",yA="termdock:right-sidebar:explorer-roots-by-session:v2",rv="termdock:right-sidebar:pinned-explorer-roots:v1",vA="termdock:right-sidebar:selected-files-by-session:v2",wA="termdock:right-sidebar:show-hidden-files:v1",C2="termdock:right-sidebar:file-sort-modes:v1",I3="termdock-sidebar-group-by-folder",SA="termdock-sidebar-collapsed-folder-groups",AA="termdock-left-sidebar-pinned",TA="termdock-left-sidebar-width",CA="termdock-right-sidebar-pinned",kA="termdock-right-sidebar-width",sv="termdock:right-sidebar:widths-by-session:v1",_A="termdock:right-sidebar:split-state-initialized:v1",LA="termdock-right-sidebar-layout-preference";function SQ(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(AA);return e===null?!0:e==="1"}catch{return!0}}function R3(e){if(!(typeof window>"u"))try{window.localStorage.setItem(AA,e?"1":"0")}catch{}}function AQ(){if(typeof window>"u")return 300;try{const e=window.localStorage.getItem(TA);if(!e)return 300;const t=parseInt(e,10);return Number.isFinite(t)&&t>=200&&t<=500?t:300}catch{return 300}}function TQ(e){if(!(typeof window>"u"))try{window.localStorage.setItem(TA,String(e))}catch{}}function CQ(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(CA)==="1"}catch{return!1}}function N3(e){if(!(typeof window>"u"))try{window.localStorage.setItem(CA,e?"1":"0")}catch{}}function Fx(){if(typeof window>"u")return 760;try{const e=window.localStorage.getItem(kA);if(!e)return 760;const t=parseInt(e,10);return Number.isFinite(t)&&t>=Ah?t:760}catch{return 760}}function kQ(e){if(!(typeof window>"u"))try{window.localStorage.setItem(kA,String(e))}catch{}}function _Q(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>typeof t=="number"&&Number.isFinite(t)&&t>=Ah)}function k2(){return Hr(sv,_Q)??{}}function M3(e,t){if(!e){kQ(t);return}On(sv,{...k2(),[e]:t})}function LQ(){if(typeof window>"u")return"auto";try{const e=window.localStorage.getItem(LA);return e==="narrow"||e==="wide"?e:"auto"}catch{return"auto"}}function EQ(e){if(!(typeof window>"u"))try{window.localStorage.setItem(LA,e)}catch{}}function IQ(e,t,n){return!t||n==="auto"?e<yQ:n==="narrow"}function RQ(){return!0}function D3(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(I3,"1"):window.localStorage.setItem(I3,"0")}catch{}}function NQ(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(SA);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function MQ(e){if(!(typeof window>"u"))try{window.localStorage.setItem(SA,JSON.stringify([...e]))}catch{}}function DQ(e){return e==="git"||e==="files"||e==="diff"}function jQ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(DQ)}function _2(){return Hr(bA,jQ)??{}}function Ox(e,t){e&&On(bA,{..._2(),[e]:t})}function PQ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>typeof t=="string")}function j3(){return Hr(yA,PQ)??{}}function Zp(e){On(yA,e)}function BQ(e){return e!==null&&typeof e=="object"&&typeof e.path=="string"&&(e.kind==="file"||e.kind==="directory")}function FQ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>Array.isArray(t)&&t.every(n=>typeof n=="string"||BQ(n)))}function EA(e){const t=new Set,n=[];for(const r of e){const s=typeof r=="string"?{path:r,kind:"directory"}:r;!s.path||t.has(s.path)||(t.add(s.path),n.push(s))}return n}function OQ(){const e=Hr(rv,FQ)??{},t={};for(const[n,r]of Object.entries(e))t[n]=EA(r);return t}function P3(e){On(rv,e)}function QQ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>typeof t=="string")}function L2(){return Hr(vA,QQ)??{}}function Jp(e,t){if(!e)return;const n={...L2()};t?n[e]=t:delete n[e],On(vA,n)}function E2(e,t){return t?e?`${e}\0${t}`:t:null}function B3(e,t,n){return n?`split-workspace\0${n}`:E2(e,t)}function IA(){const e=Hr(_A,t=>Array.isArray(t)&&t.every(n=>typeof n=="string"));return new Set(e??[])}function $Q(e){const t=IA();t.has(e)||(t.add(e),On(_A,[...t]))}function HQ(e){return typeof e=="boolean"}function UQ(){return Hr(wA,HQ)??!1}function zQ(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>t==="modified")}function GQ(){return Hr(C2,zQ)??{}}let jf=null;const Qx=new Map;let Pf=null;const $x=globalThis.crypto?.randomUUID?.()??`pins-${Math.random().toString(36).slice(2)}`;function WQ(e){const t=e.replace(/\/+$/,"")||"/";return t==="/"?"/":t.slice(0,t.lastIndexOf("/"))||"/"}function Bf(e,t){const n=e.replace(/\/+$/,"")||"/";return t===n||t.startsWith(`${n}/`)}function VQ(e,t="name"){return[...e].sort((n,r)=>{if(n.type==="directory"&&r.type!=="directory")return-1;if(n.type!=="directory"&&r.type==="directory")return 1;if(t==="modified"){const s=Date.parse(r.modified??"")-Date.parse(n.modified??"");if(Number.isFinite(s)&&s!==0)return s}return n.name.localeCompare(r.name)})}function qQ(e){return e.entry?{name:e.entry.name,path:e.entry.path,type:e.entry.type,isSymlink:e.entry.isSymlink,modified:e.entry.modified,expanded:!1,loaded:!1,children:e.entry.type==="directory"?[]:void 0}:null}const ut=D7(e=>({leftOpen:!1,rightOpen:!1,leftPinned:SQ(),leftSidebarWidth:AQ(),rightPinned:CQ(),rightSidebarWidth:Fx(),rightSidebarLayoutPreference:LQ(),rightTab:"files",rightSearchOpen:!1,rootPath:null,contextKey:null,rightSidebarWidthContextKey:null,explorerRoot:null,explorerRootCache:j3(),pinnedExplorerRootsCache:OQ(),pinnedExplorerRootsHydrated:!1,expandedPaths:new Set,selectedFilePath:null,directoryCache:new Map,fileSortModes:GQ(),fileSortModesHydrated:!1,showHiddenFiles:UQ(),groupByFolder:RQ(),collapsedGroups:NQ(),changedFiles:new Map,fileChangeVersions:new Map,fileWatchEpoch:0,gitBundleLoading:!1,gitBundleSlow:!1,gitBundleLoadingOwner:null,gitBundleError:null,gitBundleLastLoadedAt:null,gitBundleCacheInfo:null,projectStateCache:new Map,openLeft:()=>e({leftOpen:!0}),closeLeft:()=>e({leftOpen:!1}),toggleLeft:()=>e(t=>({leftOpen:!t.leftOpen,rightOpen:t.leftOpen?t.rightOpen:!1})),toggleLeftPinned:()=>e(t=>{const n=!t.leftPinned;return R3(n),{leftPinned:n,leftOpen:!0}}),setLeftPinned:t=>e(()=>(R3(t),{leftPinned:t})),setLeftSidebarWidth:t=>e(n=>{const r=Math.min(Math.max(t,200),500);return n.leftSidebarWidth===r?n:(TQ(r),{leftSidebarWidth:r})}),toggleRightPinned:()=>e(t=>{const n=!t.rightPinned;return N3(n),{rightPinned:n,rightOpen:!0}}),setRightPinned:t=>e(()=>(N3(t),{rightPinned:t})),setRightSidebarWidth:t=>e(n=>{const r=Math.max(t,Ah);return n.rightSidebarWidth===r?n:(M3(n.rightSidebarWidthContextKey,r),{rightSidebarWidth:r})}),setRightSidebarLayoutPreference:t=>e(n=>n.rightSidebarLayoutPreference===t?n:(EQ(t),{rightSidebarLayoutPreference:t})),openRight:()=>e({rightOpen:!0}),closeRight:()=>e({rightOpen:!1,rightSearchOpen:!1}),toggleRight:()=>e(t=>({rightOpen:!t.rightOpen,rightSearchOpen:t.rightOpen?!1:t.rightSearchOpen,leftOpen:t.rightOpen?t.leftOpen:!1})),closeAll:()=>e({leftOpen:!1,rightOpen:!1,rightSearchOpen:!1}),setRightTab:t=>e(n=>(Ox(n.contextKey,t),{rightTab:t})),openRightSearch:()=>e({rightSearchOpen:!0}),closeRightSearch:()=>e({rightSearchOpen:!1}),setRightSearchOpen:t=>e({rightSearchOpen:t}),setRootPath:(t,n=null,r=null)=>e(s=>{const i=E2(n,t),a=B3(n,t,r),c=r?a:i;if(s.contextKey===c&&s.rightSidebarWidthContextKey===a)return t===s.rootPath?s:{rootPath:t};const u=new Map(s.projectStateCache);s.contextKey&&u.set(s.contextKey,{rightTab:s.rightTab,explorerRoot:s.explorerRoot,expandedPaths:new Set(s.expandedPaths),selectedFilePath:s.selectedFilePath,directoryCache:new Map(s.directoryCache),changedFiles:new Map(s.changedFiles),gitBundleError:s.gitBundleError,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,gitBundleCacheInfo:s.gitBundleCacheInfo});const f=r?IA().has(r):!1;let p={...j3(),...s.explorerRootCache};const g=!!r&&!f,y=g&&i?s.contextKey===i?{rightTab:s.rightTab,explorerRoot:s.explorerRoot,expandedPaths:new Set(s.expandedPaths),selectedFilePath:s.selectedFilePath,directoryCache:new Map(s.directoryCache),changedFiles:new Map(s.changedFiles),gitBundleError:s.gitBundleError,gitBundleLastLoadedAt:s.gitBundleLastLoadedAt,gitBundleCacheInfo:s.gitBundleCacheInfo}:u.get(i):void 0;if(g&&r){const D=y?.rightTab??(i?_2()[i]:void 0)??"files",P=y?.explorerRoot??(i?s.explorerRootCache[i]:void 0)??t,F=y?.selectedFilePath??(i?L2()[i]:void 0)??null,j={rightTab:D,explorerRoot:P,expandedPaths:new Set(y?.expandedPaths??[]),selectedFilePath:F,directoryCache:new Map(y?.directoryCache??[]),changedFiles:new Map(y?.changedFiles??[]),gitBundleError:y?.gitBundleError??null,gitBundleLastLoadedAt:y?.gitBundleLastLoadedAt??null,gitBundleCacheInfo:y?.gitBundleCacheInfo??null};c&&(u.set(c,j),Ox(c,D),Jp(c,F),P&&(p={...p,[c]:P},Zp(p))),$Q(r)}const v=c?u.get(c):void 0,S=c?_2()[c]:void 0,C=k2();let T=a?C[a]:void 0;r&&a&&T===void 0&&(T=(i?C[i]:void 0)??Fx(),M3(a,T));const L=c?p[c]:void 0,E=c?L2()[c]:void 0;return{rootPath:t,contextKey:c,rightSidebarWidthContextKey:a,rightSidebarWidth:T??Fx(),rightTab:v?.rightTab??S??"files",explorerRoot:v?.explorerRoot??L??t,expandedPaths:v?new Set(v.expandedPaths):new Set,selectedFilePath:v?.selectedFilePath??E??null,explorerRootCache:p,directoryCache:v?new Map(v.directoryCache):new Map,changedFiles:v?new Map(v.changedFiles):new Map,gitBundleLoading:!1,gitBundleSlow:!1,gitBundleLoadingOwner:null,gitBundleError:v?.gitBundleError??null,gitBundleLastLoadedAt:v?.gitBundleLastLoadedAt??null,gitBundleCacheInfo:v?.gitBundleCacheInfo??null,projectStateCache:u}}),inheritRightSidebarStateFromSplitWorkspace:(t,n)=>e(r=>{if(!t||n.length===0)return r;const s=k2(),i=B3(null,null,t);if(!i)return r;const a=s[i]??(r.rightSidebarWidthContextKey===i?r.rightSidebarWidth:void 0),c=r.contextKey===i?{rightTab:r.rightTab,explorerRoot:r.explorerRoot,expandedPaths:new Set(r.expandedPaths),selectedFilePath:r.selectedFilePath,directoryCache:new Map(r.directoryCache),changedFiles:new Map(r.changedFiles),gitBundleError:r.gitBundleError,gitBundleLastLoadedAt:r.gitBundleLastLoadedAt,gitBundleCacheInfo:r.gitBundleCacheInfo}:r.projectStateCache.get(i);if(a===void 0&&!c)return r;const u={...s},f=new Map(r.projectStateCache),p={...r.explorerRootCache};for(const g of n){const y=E2(g.sessionId,g.rootPath);y&&(a!==void 0&&(u[y]=a),c&&(f.set(y,{...c,expandedPaths:new Set(c.expandedPaths),directoryCache:new Map(c.directoryCache),changedFiles:new Map(c.changedFiles)}),Ox(y,c.rightTab),Jp(y,c.selectedFilePath),c.explorerRoot?p[y]=c.explorerRoot:delete p[y]))}return a!==void 0&&On(sv,u),c&&Zp(p),{projectStateCache:f,explorerRootCache:p}}),setExplorerRoot:t=>e(n=>{if(n.explorerRoot===t)return n;const r={...n.explorerRootCache};return n.contextKey&&t&&(r[n.contextKey]=t,Zp(r)),{explorerRoot:t,explorerRootCache:r}}),resetExplorerToProject:()=>e(t=>{if(t.explorerRoot===t.rootPath)return t;const n={...t.explorerRootCache};return t.contextKey&&t.rootPath&&(n[t.contextKey]=t.rootPath,Zp(n)),{explorerRoot:t.rootPath,explorerRootCache:n}}),pinExplorerRoot:(t,n="directory")=>e(r=>{if(!r.rootPath||!t)return r;const s=r.rootPath,i=r.pinnedExplorerRootsCache[r.rootPath]??[];if(i.some(c=>c.path===t))return r;const a={...r.pinnedExplorerRootsCache,[r.rootPath]:[{path:t,kind:n},...i].slice(0,12)};return P3(a),(async()=>{try{await ut.getState().hydratePinnedExplorerRoots();const c=await wo({pinnedExplorerRoot:{rootPath:s,path:t,kind:n,pinned:!0},pinnedExplorerRootsOrigin:$x});ut.getState().syncPinnedExplorerRoots(c.pinnedExplorerRoots??{})}catch{}})(),{pinnedExplorerRootsCache:a}}),unpinExplorerRoot:t=>e(n=>{if(!n.rootPath||!t)return n;const r=n.rootPath,s=n.pinnedExplorerRootsCache[n.rootPath]??[],i=s.find(u=>u.path===t);if(!s.some(u=>u.path===t))return n;const a=s.filter(u=>u.path!==t),c={...n.pinnedExplorerRootsCache};return a.length>0?c[n.rootPath]=a:delete c[n.rootPath],P3(c),(async()=>{try{await ut.getState().hydratePinnedExplorerRoots();const u=await wo({pinnedExplorerRoot:{rootPath:r,path:t,kind:i?.kind??"directory",pinned:!1},pinnedExplorerRootsOrigin:$x});ut.getState().syncPinnedExplorerRoots(u.pinnedExplorerRoots??{})}catch{}})(),{pinnedExplorerRootsCache:c}}),hydratePinnedExplorerRoots:async()=>{if(!ut.getState().pinnedExplorerRootsHydrated)return Pf||(Pf=(async()=>{const t=ut.getState().pinnedExplorerRootsCache;let r=(await _0()).pinnedExplorerRoots??{};Object.keys(r).length===0&&Object.keys(t).length>0&&(r=(await wo({pinnedExplorerRoots:t,pinnedExplorerRootsOrigin:$x})).pinnedExplorerRoots??t),ut.getState().syncPinnedExplorerRoots(r)})().finally(()=>{Pf=null}),Pf)},syncPinnedExplorerRoots:t=>e(()=>{const n={};for(const[r,s]of Object.entries(t)){const i=EA(s);i.length>0&&(n[r]=i.slice(0,12))}return Px(rv),{pinnedExplorerRootsCache:n,pinnedExplorerRootsHydrated:!0}}),toggleExpanded:t=>e(n=>{const r=new Set(n.expandedPaths);return r.has(t)?r.delete(t):r.add(t),{expandedPaths:r}}),selectFile:t=>e(n=>(Jp(n.contextKey,t),{selectedFilePath:t})),toggleShowHiddenFiles:()=>e(t=>{const n=!t.showHiddenFiles;On(wA,n);const r=new Map(t.projectStateCache);for(const[s,i]of r)r.set(s,{...i,directoryCache:new Map});return{showHiddenFiles:n,directoryCache:new Map,projectStateCache:r}}),toggleGroupByFolder:()=>e(t=>{const n=!t.groupByFolder;return D3(n),{groupByFolder:n}}),setGroupByFolder:t=>e(n=>n.groupByFolder===t?n:(D3(t),{groupByFolder:t})),toggleGroupCollapsed:t=>e(n=>{const r=new Set(n.collapsedGroups);return r.has(t)?r.delete(t):r.add(t),MQ(r),{collapsedGroups:r}}),setDirectoryCache:(t,n)=>e(r=>{const s=new Map(r.directoryCache);return s.set(t,n),{directoryCache:s}}),hydrateFileSortModes:async()=>{if(!ut.getState().fileSortModesHydrated)return jf||(jf=(async()=>{const t=ut.getState().fileSortModes;let r=(await _0()).fileSortModes??{};Object.keys(r).length===0&&Object.keys(t).length>0&&(r=(await wo({fileSortModes:t})).fileSortModes??t),Px(C2),e({fileSortModes:r,fileSortModesHydrated:!0,directoryCache:new Map})})().finally(()=>{jf=null}),jf)},setDirectorySortMode:async(t,n)=>{try{await ut.getState().hydrateFileSortModes()}catch{}const r=ut.getState().fileSortModes[t]??"name",s=(Qx.get(t)??0)+1;Qx.set(t,s),e(i=>{const a={...i.fileSortModes};n==="modified"?a[t]=n:delete a[t];const c=new Map(i.directoryCache);return c.delete(t),{fileSortModes:a,fileSortModesHydrated:!0,directoryCache:c}});try{await wo({fileSortMode:{path:t,mode:n}}),Px(C2)}catch{if(Qx.get(t)!==s)return;e(i=>{const a={...i.fileSortModes};r==="modified"?a[t]=r:delete a[t];const c=new Map(i.directoryCache);return c.delete(t),{fileSortModes:a,directoryCache:c}})}},invalidateDirectoryCache:(t,n=!1)=>e(r=>{const s=new Map(r.directoryCache);for(const i of s.keys())(i===t||n&&Bf(t,i))&&s.delete(i);return{directoryCache:s}}),applyFileWatchEvents:t=>e(n=>{if(t.length===0)return n;const r=new Map(n.directoryCache),s=new Map(n.fileChangeVersions);let i=n.selectedFilePath,a=!1,c=!1,u=!1;const f=p=>{s.set(p,(s.get(p)??0)+1),c=!0};for(const p of t){if(p.type==="rescan-required"){for(const T of r.keys())Bf(p.path,T)&&(r.delete(T),a=!0);u=!0,i&&Bf(p.path,i)&&f(i);continue}const g=WQ(p.path),y=r.get(g);if(p.type==="deleted"){if(f(p.path),i&&Bf(p.path,i)&&(i=null,Jp(n.rootPath,null)),y){const T=y.filter(L=>L.path!==p.path);T.length!==y.length&&(r.set(g,T),a=!0)}for(const T of r.keys())Bf(p.path,T)&&(r.delete(T),a=!0);continue}f(p.path);const v=qQ(p);if(!v||!y)continue;const S=y.find(T=>T.path===v.path),C=VQ(S?y.map(T=>T.path===v.path?{...T,...v,children:T.children}:T):[...y,v],n.fileSortModes[g]??"name");r.set(g,C),a=!0}return!a&&!c&&!u?n:{directoryCache:a?r:n.directoryCache,selectedFilePath:i,fileChangeVersions:c?s:n.fileChangeVersions,fileWatchEpoch:u?n.fileWatchEpoch+1:n.fileWatchEpoch}}),bumpFileWatchEpoch:()=>e(t=>({fileWatchEpoch:t.fileWatchEpoch+1})),setChangedFiles:t=>e({changedFiles:t}),beginGitBundleLoading:t=>e({gitBundleLoading:!0,gitBundleSlow:!1,gitBundleLoadingOwner:t}),setGitBundleSlowFor:(t,n)=>e(r=>r.gitBundleLoadingOwner===t?{gitBundleSlow:n}:r),finishGitBundleLoading:t=>e(n=>n.gitBundleLoadingOwner===t?{gitBundleLoading:!1,gitBundleSlow:!1,gitBundleLoadingOwner:null}:n),resetGitBundleLoading:()=>e({gitBundleLoading:!1,gitBundleSlow:!1,gitBundleLoadingOwner:null}),setGitBundleError:t=>e({gitBundleError:t}),markGitBundleLoaded:(t=null)=>e({gitBundleLastLoadedAt:Date.now(),gitBundleCacheInfo:t})})),KQ=320,F3="termdock:mobile-keyboard-expanded",O3="termdock:mobile-keyboard-preset-mode",Q3="termdock:mobile-long-press-mode";function Hx(){return typeof window>"u"?!1:(navigator.maxTouchPoints>0||"ontouchstart"in window)&&window.innerWidth<768}const YQ={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},XQ=({sessionId:e,mode:t,tmuxSessionName:n=null,terminalSettings:r=Jy(),colorTheme:s="dark",toolbarPresets:i=[],isActive:a=!0,focusRequestToken:c=0,resumeRequestToken:u=0,resumeRequestReason:f="visibility",resumeRequestDelayMs:p=0,forceResumeReconnect:g=!1,initialConnectDelayMs:y=0,initialConnectEnabled:v=!0,resumeRequestEnabled:S=!0,onStreamReadyChange:C,onStreamConnected:T,onViewportReadyChange:L,onKeyboardVisibilityChange:E,suppressKeyboard:D=!1,keyboardPortalTarget:P=null,sharedMobileKeyboardLayout:F=!1,suppressPageFlipRefresh:j=!1,showDebug:A,onStatusChange:H})=>{const{t:Q}=Vn(),[K,W]=M.useState(r.fontSize),de=M.useMemo(()=>vO(),[]),X=M.useMemo(()=>cd("session"),[]),pe=M.useMemo(()=>cd("keyboard"),[]),ye=M.useRef(p);ye.current=p;const Ae=M.useRef(null);M.useEffect(()=>{W(r.fontSize)},[r.fontSize]);const ie=M.useMemo(()=>({...r,fontSize:K}),[r,K]),[V]=M.useState(e||vE()),[z,ce]=M.useState(Hx),[ge,he]=M.useState(!1),[Ce,xe]=M.useState(!1),[ae,Le]=M.useState(!1),[Z,Ze]=M.useState(()=>typeof document>"u"?!0:!document.hidden),[at,He]=M.useState(()=>typeof document>"u"?!0:document.hasFocus()),[be,Be]=M.useState(!1),{isOpen:fe,keyboardHeight:Ke}=mA({enabled:z&&a}),[Ye,et]=M.useState(null),[q,ue]=M.useState(null),[Xe,Ne]=M.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(F3)==="true"),[Ge,Fe]=M.useState(()=>{if(typeof window>"u")return"auto";const De=window.localStorage.getItem(O3);return De&&De.length>0?De:"auto"}),[ft,it]=M.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(Q3)==="copy"?"copy":"arrows"),[Mt,vt]=M.useState("idle"),[Gt,Zt]=M.useState("idle"),[an,$n]=M.useState(0),we=rs(De=>De.sessions.get(V)),{setTerminalSession:dt,setConnecting:gt,appendToBuffer:Wt,replaceBuffer:ht,clearTerminalSession:$t,removeTerminalSession:ct,clearBuffer:We,setSessionActiveProgram:Zn,setSessionCwd:An,setSessionCopyMode:Ve,setSessionAgentStatus:En,setSessionShellTitle:jt,setSessionPromptState:yr,clearAgentNeedsReview:Fn}=rs.getState(),Tn=M.useMemo(()=>`wt-${V.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[V]),Rr=we?.terminalSessionId??null,gr=we?.mode??"shell",Br=we?.activeProgram??null,Nr=M.useMemo(()=>p0(i),[i]),Se=gr==="tmux",te=we?.bufferChunks??[],Nt=we?.isConnecting??!1,Ie=Rr,rn=M.useCallback(async De=>{const xt=DF(De,we?.cwd||we?.directory);if(!xt)return;let At=xt,nt="directory";try{At=(await Py(xt)).path}catch(Tt){if(!(Tt instanceof Error)||Tt.message!=="Path is not a directory")return;nt="file"}try{const Tt=ut.getState();Tt.setRightTab("files"),Tt.openRight(),window.dispatchEvent(new CustomEvent(b2,{detail:{path:At,kind:nt}}))}catch{}},[we?.cwd,we?.directory]),Qt=t??we?.mode??"shell",Et=Qt==="tmux"?n??we?.tmuxSessionName??null:null,[Jt,un]=M.useState(null),nr=M.useRef(!1),[Oe,mt]=M.useState(!1),[ln,en]=M.useState(!1),[kn,Cn]=M.useState(null),[Rt,Ln]=M.useState(0),[qn,cn]=M.useState(null),rr=A!==void 0?A:!1,Xt=M.useRef(null),kr=M.useRef(null),wn=M.useRef(null),Kr=M.useRef(null),rt=M.useRef(null),Bt=M.useRef(!1),$e=M.useRef(null),st=M.useRef([]),Vt=M.useRef(0),Ht=M.useRef(!1),bn=M.useRef(null),Re=M.useRef(null),Je=M.useRef(-1),St=M.useRef(null),tn=M.useRef(0),Xn=M.useRef(null),dn=M.useRef(null),pn=M.useRef(0),qt=M.useRef(a);qt.current=a;const Kn=M.useRef(z),or=M.useRef(null),_n=M.useRef(null),Ar=M.useRef(null),ts=M.useRef(null),Jn=M.useRef(null),dr=M.useRef(null),jr=M.useRef(null),re=M.useCallback(()=>{ts.current=null;const De=Ar.current;Ar.current=null,De&&jt(De.sessionId,De.title)},[jt]),Ee=M.useCallback((De,xt)=>{if(Ar.current={sessionId:De,title:xt},ts.current===null){if(typeof window>"u"){re();return}ts.current=window.requestAnimationFrame(re)}},[re]),Qe=M.useCallback(()=>{ts.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(ts.current),ts.current=null,Ar.current=null},[]),je=M.useCallback(async()=>{const De=Qt;return(await $7({preferredFrontendSessionId:V,mode:De,tmuxSessionName:De==="tmux"?Et||Tn:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[Qt,Et,Tn,V]),bt=M.useRef(!1);M.useEffect(()=>{if(!a){rt.current?.blur(),bt.current=!1;return}if(bt.current||(bt.current=!0,!JB(z,j)))return;const De=rt.current?.getDimensions()??null;let xt=0,At=0;xt=requestAnimationFrame(()=>{At=requestAnimationFrame(()=>{rt.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})})});const nt=window.setTimeout(()=>{const Tt=rt.current,Hn=Tt?.getDimensions()??null;Tt?.requestRefresh("page-flip",{forceRedraw:J8(De,Hn),reconcileServerSize:!0})},360);return()=>{cancelAnimationFrame(xt),cancelAnimationFrame(At),window.clearTimeout(nt)}},[a,z,j,Ie]),M.useEffect(()=>{Kn.current=z},[z]);const yt=M.useCallback(()=>{qt.current&&rt.current?.focus()},[]),Ut=M.useCallback(De=>{typeof window>"u"||typeof document>"u"||!qt.current||Kn.current||document.hidden||(or.current!==null&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{if(or.current=null,!qt.current||Kn.current||document.hidden)return;const xt=document.activeElement,At=xt?.getAttribute("data-terminal-input-anchor")==="true";if((xt instanceof HTMLInputElement||xt instanceof HTMLTextAreaElement||xt instanceof HTMLSelectElement||xt?.isContentEditable===!0)&&!At){pe("desktop resume focus skipped: editable active",{reason:De});return}pe("desktop resume focus",{reason:De}),rt.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),rt.current?.focus()},50))},[pe]);M.useEffect(()=>()=>{or.current!==null&&typeof window<"u"&&window.clearTimeout(or.current),or.current=null,_n.current!==null&&typeof window<"u"&&window.clearTimeout(_n.current),_n.current=null,Jn.current!==null&&typeof window<"u"&&window.clearTimeout(Jn.current),Jn.current=null,dr.current!==null&&typeof window<"u"&&window.clearTimeout(dr.current),dr.current=null},[]),M.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const De=()=>{_n.current!==null&&window.clearTimeout(_n.current),_n.current=window.setTimeout(()=>{_n.current=null;const xt=document.activeElement,nt=!(xt?.getAttribute("data-terminal-input-anchor")==="true")&&!!(xt&&(xt instanceof HTMLInputElement||xt instanceof HTMLTextAreaElement||xt instanceof HTMLSelectElement||xt.isContentEditable));xO({isActive:qt.current,isMobile:Kn.current,documentVisible:!document.hidden,activeElementIsEditable:nt})&&yt()},0)};return document.addEventListener("pointerup",De),()=>{document.removeEventListener("pointerup",De),_n.current!==null&&(window.clearTimeout(_n.current),_n.current=null)}},[yt]);const Kt=M.useCallback(()=>{vr.current=!1,Ln(De=>De+1)},[]),nn=M.useCallback((De,xt)=>{const At=wn.current,nt=Date.now();if(At&&xt&&rI(At)){Ae.current={startedAt:nt,strategy:"reconnect",reason:De},Qa("info","PWA_RESUME terminal-start",{frontendSessionId:V,backendSessionId:At,strategy:"reconnect",reason:De,active:qt.current});return}if(At&&nI(At,()=>{const Tt=Ae.current;Qa("info","PWA_RESUME terminal-responsive",{frontendSessionId:V,backendSessionId:At,durationMs:Tt?Date.now()-Tt.startedAt:null,strategy:Tt?.strategy??"probe",reason:Tt?.reason??De}),Ae.current=null,T?.(V)})){Ae.current={startedAt:nt,strategy:"probe",reason:De},Qa("info","PWA_RESUME terminal-start",{frontendSessionId:V,backendSessionId:At,strategy:"probe",reason:De,active:qt.current}),X("[Terminal] resume probe sent",{reason:De,backendSessionId:At,active:qt.current});return}X("[Terminal] resume probe missing connection, restarting ensureSession",{reason:De,backendSessionId:At,active:qt.current}),Kt()},[X,T,Kt,V]),hn=M.useCallback((De,xt)=>{const At=wn.current;At&&$e.current!==De&&($e.current=De,$5(At,De,xt),X("[Terminal] flow-control state sent",{backendSessionId:At,paused:De,reason:xt}))},[X]),Mn=M.useCallback((De,xt)=>{const At=wn.current;At&&Xn.current!==De&&(Xn.current=De,F5(At,De,xt),X("[Terminal] focus state sent",{backendSessionId:At,focused:De,reason:xt}))},[X]),Wn=M.useCallback((De,xt)=>{const At=wn.current;At&&dn.current!==De&&(dn.current=De,O5(At,De,xt),X("[Terminal] viewing state sent",{backendSessionId:At,viewing:De,reason:xt}))},[X]),fr=mO({isActive:a,viewportFocused:ae,documentVisible:Z,windowFocused:at,streamReady:be}),xn=gO({isActive:a,documentVisible:Z,windowFocused:at,streamReady:be,isDesktop:Li()!==null}),Fr=M.useRef(fr),_r=M.useRef(xn);M.useEffect(()=>{Fr.current=fr,Mn(fr,"logical-focus-change")},[fr,Mn,Ie]),M.useEffect(()=>{_r.current=xn,Wn(xn,"logical-viewing-change")},[xn,Wn,Ie]),M.useEffect(()=>{const De=xt=>{const nt=xt.detail;typeof nt=="number"&&nt>=8&&nt<=32&&W(nt)};return document.addEventListener("termfontchange",De),()=>document.removeEventListener("termfontchange",De)},[]),M.useEffect(()=>{const De=()=>{const Tt=!document.hidden;Ze(Tt),Tt&&a&&Ut("visibility")},xt=Tt=>{a&&Ut(Tt.persisted?"bfcache":"pageshow")},At=()=>{He(!0),Ut("window-focus")},nt=()=>He(!1);return document.addEventListener("visibilitychange",De),window.addEventListener("pageshow",xt),window.addEventListener("focus",At),window.addEventListener("blur",nt),()=>{document.removeEventListener("visibilitychange",De),window.removeEventListener("pageshow",xt),window.removeEventListener("focus",At),window.removeEventListener("blur",nt)}},[a,Ut]),M.useEffect(()=>{if(!u||!S||!ar.current)return;const De=ye.current,xt=()=>{rt.current?.requestRefresh(f),nn(De>0?"global-resume-background":"global-resume-visible",De<=0&&g)};if(De<=0){xt();return}const At=window.setTimeout(xt,De);return()=>window.clearTimeout(At)},[u,f,S,g,nn]);const fn=M.useRef(0);M.useEffect(()=>{if(be){fn.current=0;return}if(!Oe||Jt==="Authentication required"||Jt===jx)return;const De=fn.current,xt=Math.min(2e3*Math.pow(2,Math.min(De,4)),3e4),At=setTimeout(()=>{fn.current+=1,X("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:fn.current,backendSessionId:wn.current}),un("Reconnecting..."),mt(!1),Kt()},xt);return()=>clearTimeout(At)},[Jt,Oe,be,Rt,X,Kt]),M.useEffect(()=>{if(typeof window>"u"){he(!1);return}const De=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;he(De)},[]),M.useEffect(()=>{(!a||!z)&&xe(!1),a||Le(!1)},[a,z]),M.useEffect(()=>{wn.current=Ie,Je.current=-1,Xn.current=null,dn.current=null,$e.current=null},[Ie]),M.useEffect(()=>{C?.(V,be)},[be,C,V]),M.useEffect(()=>{Se||(Ht.current=!1,bn.current=null,Re.current&&(clearTimeout(Re.current),Re.current=null))},[Se]),M.useEffect(()=>{Ie&&rt.current?.requestRefresh("session-key-change",{force:!0})},[Ie]),M.useEffect(()=>{const De=a&&z&&fe;pe("visibility signal",{sessionId:V,isActive:a,isMobile:z,isInputFocused:Ce,isViewportKeyboardOpen:fe,viewportKeyboardHeight:Ke,visible:De}),E?.(V,De)},[E,V,a,z,fe,Ke,pe]),M.useEffect(()=>{a&&c&&c!==tn.current&&(tn.current=c,yt())},[c,yt,a]),M.useEffect(()=>{Kr.current=V},[V]),M.useEffect(()=>{!z&&(Ye!==null||q!==null)&&(et(null),ue(null),St.current=null)},[z,Ye,q]),M.useEffect(()=>{!Ie&&(Ye!==null||q!==null)&&(et(null),ue(null),St.current=null)},[Ie,Ye,q]),M.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(F3,Xe?"true":"false")},[Xe]),M.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(O3,Ge)},[Ge]),M.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Q3,ft)},[ft]),M.useEffect(()=>{ce(Hx());const De=()=>{ce(Hx())};return window.addEventListener("resize",De),()=>window.removeEventListener("resize",De)},[]);const Ft=M.useCallback(()=>{pn.current+=1,re(),Qe();const De=Xt.current;Xt.current=null,kr.current=null,Be(!1),rt.current?.setSessionReady(!1);const xt=wn.current;xt&&$5(xt,!1,"stream-disconnect"),Bt.current=!1,$e.current=null,st.current=[],De?.()},[Qe,re]),xr=M.useCallback(De=>{if(kr.current===De){X(`[startStream] Skipping - already connected to ${De}`);return}X(`[startStream] Starting stream for frontendSessionId=${V} backendSessionId=${De}`),Cn(null),Ft();const xt=pn.current+1;pn.current=xt;const At=de.connect(De,{onEvent:nt=>{if(pn.current!==xt)return;const Tt=V;if(Tt)switch(nt.type){case"connected":{const Hn=Ae.current;Hn&&(Qa("info","PWA_RESUME terminal-connected",{frontendSessionId:Tt,backendSessionId:wn.current,durationMs:Date.now()-Hn.startedAt,strategy:Hn.strategy,reason:Hn.reason}),Ae.current=null),T?.(Tt),(nt.runtime||nt.ptyBackend)&&X(`[Terminal] connected frontendSessionId=${Tt} backendSessionId=${wn.current} runtime=${nt.runtime??"unknown"} pty=${nt.ptyBackend??"unknown"} cwd=${nt.cwd??"unknown"}`),gt(Tt,!1),un(null),mt(!1),Cn(null),Be(!0),wn.current&&(F5(wn.current,Fr.current,"stream-connected"),O5(wn.current,_r.current,"stream-connected")),rt.current?.setSessionReady(!0),$e.current=null,hn(Bt.current,"stream-connected"),nt.tuiProgress!==void 0&&rs.getState().setSessionTuiProgress(Tt,nt.tuiProgress??null),nt.shellTitle!==void 0&&rs.getState().setSessionShellTitle(Tt,nt.shellTitle??null),nt.promptState!==void 0&&nt.promptState!==null&&rs.getState().setSessionPromptState(Tt,nt.promptState);const cr=rs.getState().getTerminalSession(Tt);if(cr?.terminalSessionId&&nt.mode&&rs.getState().setTerminalSession(Tt,{sessionId:cr.terminalSessionId,cols:80,rows:24,mode:nt.mode,tmuxSessionName:nt.tmuxSessionName??null,cwd:nt.cwd??null}),nt.activeProgram!==void 0&&Zn(Tt,nt.activeProgram??null,nt.activeProgramSource??null,nt.activeProgramRaw??null),requestAnimationFrame(()=>{requestAnimationFrame(()=>{rt.current?.requestRefresh("connected",{force:!0,forceRedraw:!0,reconcileServerSize:qt.current})})}),typeof window<"u"&&qt.current&&Kn.current&&(window.setTimeout(()=>{rt.current?.requestRefresh("connected",{force:!0,forceRedraw:!0,reconcileServerSize:qt.current})},120),window.setTimeout(()=>{rt.current?.requestRefresh("connected",{force:!0,forceRedraw:!0,reconcileServerSize:qt.current})},360)),nt.mode!=="tmux"&&(cn(null),Ve(Tt,!1)),X("[Terminal] Connected event received:",{frontendSessionId:Tt,backendSessionId:wn.current,storeHasState:!!cr,storeTerminalId:cr?.terminalSessionId,hasHistoryInStore:!!cr?.history?.length,historyLength:cr?.history?.length??0}),cr?.history&&cr.history.length>0){X(`[Terminal] Restoring ${cr.history.length} history chunks to frontend session ${Tt}`);const ms=cr.history.reduce((Jr,It)=>Jr+It.length,0),mr=Math.max(300,Math.min(2e3,Math.ceil(ms/200)));Vt.current=Date.now()+mr,cr.history.forEach(Jr=>{Wt(Tt,Jr,{markActivity:!1})}),rs.getState().setSessionHistory(Tt,[]),X(`[Terminal] History restoration complete for ${Tt}`)}else X(`[Terminal] No history to restore for ${Tt}`);const Pr=nt.replayChunks;if(Pr&&Pr.length>0){nt.replayOutOfWindow?(X(`[Terminal] Replay out-of-window, clearing buffer before replay (${Pr.length} chunks)`),We(Tt),rt.current?.clear()):X(`[Terminal] Replay incremental: ${Pr.length} chunks`);const ms=Pr.reduce((Jr,It)=>Jr+It.length,0),mr=Math.max(200,Math.min(1500,Math.ceil(ms/200)));Vt.current=Math.max(Vt.current,Date.now()+mr);for(const Jr of Pr)Wt(Tt,Jr)}break}case"reconnecting":{Cn(Hn=>Hn??Date.now()),un("Reconnecting..."),mt(!1);break}case"data":{nt.data&&(Bt.current?st.current.push(nt.data):Wt(Tt,nt.data));break}case"tmux-layout":{cn(nt.layout??null),nt.layout&&Ve(Tt,nt.layout.inCopyMode);break}case"tmux-screen-sync":{const Hn=nt.generation??0;if(Hn<Je.current)break;Je.current=Hn,st.current=[],rt.current?.clear(),ht(Tt,nt.chunks??[]),typeof nt.cols=="number"&&typeof nt.rows=="number"&&rt.current?.notifyServerSize(nt.cols,nt.rows,"tmux-screen-sync");break}case"active-program":{Zn(Tt,nt.activeProgram??null,nt.activeProgramSource??null,nt.activeProgramRaw??null);break}case"cwd":{An(Tt,nt.cwd??null);break}case"agent-status":{En(Tt,{agentStatus:nt.agentStatus??null,agentIndicator:nt.agentIndicator??null,agentStatusDetail:nt.agentStatusDetail??null,agent:nt.agent??null,agentMessage:nt.agentMessage??null,agentNativeSessionId:nt.agentNativeSessionId??null,agentResumeRecovered:nt.agentResumeRecovered===!0,agentRich:nt.agentRich===!0,agentActivity:nt.agentActivity??0,agentCwd:nt.agentCwd??null,reviewed:nt.reviewed??null});break}case"git-status":{rs.getState().setSessionGitStatus(Tt,nt.gitStatus??null);break}case"focus-mode":{X("[Terminal] focus tracking mode",{backendSessionId:wn.current,requested:nt.focusTrackingRequested===!0});break}case"pty-size":{typeof nt.cols=="number"&&typeof nt.rows=="number"&&rt.current?.notifyServerSize(nt.cols,nt.rows,nt.source);break}case"shell-title":{Ee(Tt,nt.title??null);break}case"prompt-state":{yr(Tt,nt.state??"idle",nt.exitCode??null);break}case"tui-progress":{rs.getState().setSessionTuiProgress(Tt,nt.tuiProgress??null);break}case"exit":{const Hn=typeof nt.exitCode=="number"?nt.exitCode:null,cr=typeof nt.signal=="number"?nt.signal:null;Wt(Tt,`\r
77
77
  [Process exited${Hn!==null?` with code ${Hn}`:""}${cr!==null?` (signal ${cr})`:""}]\r
78
- `),$t(Tt),gt(Tt,!1),un("Terminal session ended"),Be(!1),mt(!1),Cn(null),cn(null),Ve(Tt,!1),Ft();break}}},onError:(nt,Tt)=>{if(pn.current!==xt)return;const Hn=V;if(!Hn)return;const cr=Tt&&nt.message==="Authentication required",Pr=pQ(nt),ms=cr?nt.message:Pr||Tt?"Reconnecting...":nt.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${Tt}):`,ms),Pr&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:wn.current,frontendSessionId:Hn,isActive:a,isMobile:z,fatal:Tt,stack:new Error().stack}),un(ms),mt(!!Tt),Tt&&(Cn(null),gt(Hn,!1),Ft(),Pr&&(X("[onError] Session lost, auto-recreating"),un("Reconnecting..."),mt(!1),$t(Hn),We(Hn),wn.current=null,vr.current=!1,Kt()))}},YQ);Xt.current=()=>{At.close(),pn.current===xt&&(kr.current=null)},kr.current=De},[Wt,We,$t,X,Ft,T,hn,Kt,Ee,gt,Zn,En,Ve,An,yr,de,V]);M.useEffect(()=>{const De=uQ({isActive:a,isStreamReady:be,reconnectStartedAt:kn,now:Date.now()});if(De===null)return;const xt=window.setTimeout(()=>{X("[Terminal] visible reconnect watchdog expired",{backendSessionId:wn.current,reconnectStartedAt:kn}),Ft(),gt(V,!1),un("Reconnecting..."),mt(!1),Cn(Date.now()),Kt()},De);return()=>window.clearTimeout(xt)},[X,Ft,a,be,kn,Kt,V,gt]);const vr=M.useRef(!1),ar=M.useRef(!1),Wr=M.useRef(0);M.useEffect(()=>()=>{Wr.current+=1,vr.current=!1,Ft()},[Ft]);const Pn=M.useRef(Qt),hr=M.useRef(Et);M.useEffect(()=>{const De=Pn.current,xt=hr.current;Pn.current=Qt,hr.current=Et,Kr.current===V&&(De===Qt&&xt===Et||(vr.current=!1,Ft(),Ln(At=>At+1)))},[Qt,Et,Ft,V]),M.useEffect(()=>{if(Kr.current!==V&&(X(`[useEffect] sessionId changed from ${Kr.current} to ${V}, allowing reinitialization`),vr.current=!1,ar.current=!1),vr.current&&Kr.current===V){X(`[useEffect] Already initialized for sessionId=${V}, skipping`);return}const De=async Hn=>{if(X(`[ensureSession] Starting for sessionId=${V}, runId=${Hn}`),!Kr.current||Kr.current!==V){X(`[ensureSession] SessionId mismatch or stale run (current=${Kr.current}, target=${V}), skipping`);return}if(Hn!==Wr.current){X(`[ensureSession] Stale run detected (runId=${Hn}, currentRunId=${Wr.current}), skipping`);return}const cr=rs.getState(),Pr=cr.getTerminalSession(V),ms=Pr?.mode??Qt;X("[ensureSession] Current state from store:",{terminalSessionId:Pr?.terminalSessionId,mode:Pr?.mode,tmuxSessionName:Pr?.tmuxSessionName,isConnecting:Pr?.isConnecting});let mr=Pr?.terminalSessionId??null,Jr=!mr;if(mr&&ms!==Qt?(X(`[ensureSession] Store mode mismatch for ${mr}: current=${ms} desired=${Qt}, will create new session`),Jr=!0,cr.clearTerminalSession(V),mr=null):mr&&Qt==="tmux"&&Et&&Pr?.tmuxSessionName!==Et&&(X(`[ensureSession] Store tmux name mismatch for ${mr}: current=${Pr?.tmuxSessionName} desired=${Et}, will create new session`),Jr=!0,cr.clearTerminalSession(V),mr=null),mr&&de.checkHealth&&!qt.current){X(`[ensureSession] Checking health of existing session ${mr}`);try{const It=await de.checkHealth(mr);if(X("[ensureSession] Health check result:",It),!It.healthy)X(`[ensureSession] Session ${mr} is NOT healthy (healthy=${It.healthy}), will create new session`),X("[ensureSession] Health check details:",It),Jr=!0,It.mode&&Pr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Pr.terminalSessionId,cols:80,rows:24,mode:It.mode,tmuxSessionName:It.tmuxSessionName??null}),cr.clearTerminalSession(V),X("[ensureSession] Cleared unhealthy session from store");else{X(`[ensureSession] Session ${mr} is healthy, reusing it, cwd=${It.cwd}, clients=${It.clients}, lastActivity=${Date.now()-(It.lastActivity||0)}ms ago`),It.mode&&Pr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Pr.terminalSessionId,cols:80,rows:24,mode:It.mode,tmuxSessionName:It.tmuxSessionName??null}),X(`[ensureSession] Setting terminalIdRef to ${mr} and starting stream`),wn.current=mr,xr(mr),X(`[ensureSession] Successfully reused healthy session ${mr}, returning early`);return}}catch(It){X(`[ensureSession] Failed to check health of session ${mr}:`,It),X("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(X(`[ensureSession] Decision: shouldCreateNewSession=${Jr}, terminalId=${mr}`),Jr){X(`[ensureSession] Creating new session, shouldCreateNewSession=${Jr}, runId=${Hn}`),un(null),mt(!1),cr.setConnecting(V,!0);const Lo=rs.getState().getTerminalSession(V),Ya=(Lo?.mode??Qt)===Qt&&(Qt!=="tmux"||!Et||Lo?.tmuxSessionName===Et);if(Lo?.terminalSessionId&&Ya)X(`[ensureSession] Race condition avoided: another instance already created session ${Lo.terminalSessionId}`),cr.setConnecting(V,!1),mr=Lo.terminalSessionId,Jr=!1;else try{const qs=await je();if(X(`[ensureSession] Opened managed backend session ${qs.sessionId}`),Hn!==Wr.current){X(`[ensureSession] Stale run after session creation (runId=${Hn}, currentRunId=${Wr.current}), leaving ${qs.sessionId} for sibling`);return}cr.setTerminalSession(V,qs),X(`[ensureSession] Updated store with new session ${qs.sessionId}`),mr=qs.sessionId}catch(qs){if(Hn!==Wr.current){X("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(qs instanceof qa&&E3(qs)){X("[ensureSession] Confirmed missing persisted session:",{sessionId:V,error:qs.message}),cr.clearTerminalSession(V),un(jx),mt(!0),cr.setConnecting(V,!1);return}un("Reconnecting..."),mt(!0),cr.setConnecting(V,!1);return}}if(Hn!==Wr.current){X(`[ensureSession] Stale run before starting stream (runId=${Hn}, currentRunId=${Wr.current}), skipping`);return}if(!mr){X(`[ensureSession] No terminalId, terminalId=${mr}`);return}X(`[ensureSession] Starting stream for session ${mr}`),wn.current=mr,xr(mr),X(`[ensureSession] ensureSession completed for sessionId=${V}, terminalId=${mr}`)};let xt=null,At=null;const nt=()=>{At=null,!(vr.current&&Kr.current===V)&&(X(`[useEffect] Running ensureSession for sessionId=${V}, hasInitialized=${vr.current}`),vr.current=!0,ar.current=!0,xt=++Wr.current,De(xt))};if(!v&&!ar.current){X(`[useEffect] Holding background connection until the selected session is ready: ${V}`);return}const Tt=ar.current?0:Math.max(0,y);return Tt>0?(X(`[useEffect] Delaying initial connection for sessionId=${V} by ${Tt}ms`),At=window.setTimeout(nt,Tt)):nt(),()=>{At!==null&&window.clearTimeout(At),X(`[useEffect] Cleanup for sessionId=${V}, runId=${xt??"pending"}`)}},[V,Rt,xr,Ft,de,X,Qt,Et,Tn,y,v]);const lr=M.useCallback(async()=>{if(V&&!ln){en(!0),un(null),mt(!1),Cn(null),Ft();try{de.forceKill&&await de.forceKill({sessionId:V})}catch{}ct(V),We(V),rt.current?.clear(),await new Promise(De=>setTimeout(De,100));try{gt(V,!0);const De=await je();dt(V,De),wn.current=De.sessionId,xr(De.sessionId)}catch(De){un(De instanceof qa&&E3(De)?jx:"Reconnecting..."),mt(!0),gt(V,!1)}finally{en(!1)}}},[V,ln,Ft,de,ct,We,gt,dt,xr,je]),Fs=M.useCallback((De,xt)=>{if(!qt.current||!De)return;const At=CO(De),nt=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(De);if(Se&&nt&&(Ht.current=!0),Date.now()<Vt.current)return;let Tt=De,Hn=xt?.consumeModifier??!1;if(!xt?.skipModifierTransform&&Ye&&De.length>0){const ms=De[0];if(ms.length===1&&/[a-zA-Z]/.test(ms)){const mr=ms.toUpperCase();Ye==="ctrl"?(Tt=String.fromCharCode(mr.charCodeAt(0)&31),Hn=!0):Ye==="alt"&&(Tt=`\x1B${De}`,Hn=!0)}Hn||(Ye==="alt"&&(Tt=`\x1B${De}`),Hn=!0)}const cr=wn.current;if(!cr)return;(async()=>{try{if(Se&&!At&&Ht.current&&de.tmuxAction){Ht.current=!1;try{await de.tmuxAction(cr,{action:"copy-mode",enabled:!1})}catch{}if(kO(Tt))return}await de.sendInput(cr,Tt),Fn(V)}catch(ms){un(ms instanceof Error?ms.message:"Failed to send input")}})(),Hn&&(q||et(null),yt())},[Ye,Fn,yt,Se,q,de]);M.useEffect(()=>{const De=xt=>{if(!qt.current)return;const At=xt,nt=At.detail?.text;if(!nt)return;const Tt=At.detail?.nonce;if(nr.current){Tt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Tt,ok:!1}}));return}rt.current?.sendSequence(nt,{paste:At.detail?.paste}),Tt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Tt,ok:!0}})),bO(Kn.current,At.detail?.focus!==!1)&&yt()};return window.addEventListener("termdock-insert-reference",De),()=>window.removeEventListener("termdock-insert-reference",De)},[yt]);const Mr=M.useCallback((De,xt)=>{const At=wn.current;if(!At){pe("xterm resize push skipped: no terminalId",{cols:De,rows:xt});return}pe("xterm resize push",{cols:De,rows:xt}),de.resize({sessionId:At,cols:De,rows:xt}).catch(nt=>{nt&&/session not found/i.test(String(nt.message||nt))&&console.warn("[Terminal] resize 404 session not found",{sessionId:At,cols:De,rows:xt,stack:new Error().stack})})},[de,pe]),is=M.useCallback(async De=>{const xt=wn.current;if(!(!xt||!de.tmuxAction))try{const At=await de.tmuxAction(xt,De);At.layout&&(cn(At.layout),De.action==="switch-session"&&(dt(V,{sessionId:xt,cols:80,rows:24,mode:"tmux",tmuxSessionName:At.layout.sessionName}),_m(V,{tmuxSessionName:At.layout.sessionName}).catch(nt=>{console.warn("[Terminal] failed to update inventory after tmux switch",nt)})))}catch(At){un(At instanceof Error?At.message:"Failed to execute tmux action")}},[V,dt,de]);M.useEffect(()=>{if(!qn||!Ie)return;const xt=qn.windows.find(At=>At.id===qn.activeWindowId)?.panes.find(At=>At.id===qn.activePaneId);xt&&rt.current?.requestRefresh("tmux-layout",{candidateSize:{cols:xt.width,rows:xt.height},skipScrollToBottom:!0,dedupeKey:`${Ie}:${qn.sessionId}:${xt.id}:${xt.width}x${xt.height}`})},[qn,Ie]);const wi=M.useCallback((De,xt=5)=>{const At=Math.max(1,Math.min(Math.floor(xt)||1,40));Ht.current=!0;const nt=bn.current;if(nt&&nt.direction===De){nt.lines+=At;return}nt&&is({action:"scroll",direction:nt.direction,lines:nt.lines}).finally(()=>{yt()}),bn.current={direction:De,lines:At},Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>{const Tt=bn.current;Tt&&(bn.current=null,is({action:"scroll",direction:Tt.direction,lines:Tt.lines}).finally(()=>{yt()}))},0)},[yt,is]),Ho=M.useCallback(De=>{const xt=Date.now(),At=St.current,nt=At!==null&&At.modifier===De&&xt-At.timestamp<=KQ;if(St.current={modifier:De,timestamp:xt},q===De){ue(null),et(null);return}if(nt){ue(De),et(De);return}q!==null&&q!==De&&ue(null),et(Tt=>Tt===De?null:De)},[q]),Lr=M.useCallback(De=>{if(Le(De&&qt.current),pe("input focus changed",{focused:De,isActive:qt.current,isMobile:Kn.current}),!Kn.current||!qt.current){xe(!1);return}xe(xt=>xt===De?xt:De)},[pe]),ks=M.useCallback(De=>{if(Bt.current=De,hn(De,"viewport-watermark"),!De&&st.current.length>0){const xt=V;if(xt){const At=st.current;st.current=[];for(const nt of At)Wt(xt,nt)}}},[Wt,hn,V]),Xi=M.useCallback(De=>{qt.current&&rt.current?.ensureSizeMatches(De)},[]),Ii=M.useRef(null);M.useEffect(()=>{if(!a)return;const De=Ii.current;if(!De)return;const xt=()=>Xi("pointerdown"),At=()=>Xi("keydown"),nt=()=>Xi("touchstart"),Tt=()=>Xi("wheel");return De.addEventListener("pointerdown",xt),De.addEventListener("keydown",At),De.addEventListener("touchstart",nt,{passive:!0}),De.addEventListener("wheel",Tt,{passive:!0}),()=>{De.removeEventListener("pointerdown",xt),De.removeEventListener("keydown",At),De.removeEventListener("touchstart",nt),De.removeEventListener("wheel",Tt)}},[a,Xi]);const Ka=M.useCallback(De=>{rt.current=De},[]),di=M.useCallback(De=>{L?.(V,De)},[L,V]),Os=M.useCallback(De=>{const xt=BO(De);if(!xt)return;const At=Ye!==null;rt.current?.sendSequence(xt,{consumeModifier:At})},[Ye]),Ms=M.useCallback(De=>{const xt=NO(De);if(xt.length===0)return;const At=Ye!==null;rt.current?.sendSequence(A3(xt[0]),{consumeModifier:At});for(let nt=1;nt<xt.length;nt+=1){const Tt=xt[nt];window.setTimeout(()=>{rt.current?.sendSequence(A3(Tt))},RO*nt)}},[Ye]),Zi=M.useCallback(()=>{rt.current?.pasteClipboardText()},[]),Qs=M.useCallback(De=>{dr.current!==null&&(window.clearTimeout(dr.current),dr.current=null),Zt(De),(De==="inserted"||De==="failed")&&(dr.current=window.setTimeout(()=>{dr.current=null,Zt("idle")},1400))},[]),Vr=M.useCallback(()=>{Qs("idle"),$n(0),jr.current?.click()},[Qs]),pr=M.useCallback(De=>{const xt=De.currentTarget.files?.[0];De.currentTarget.value="",xt&&($n(0),Qs("uploading"),xA(xt,(At,nt)=>Yb(At,nt,void 0,$n),At=>{if(!qt.current||nr.current)throw new Error("Terminal unavailable");window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:gA(At,null),focus:!0}}))}).then(()=>Qs("inserted"),()=>Qs("failed")))},[Qs]),fi=Nt||Jt!==null;nr.current=fi;const _s=M.useRef(Br);fi||(_s.current=Br);const hi=fi?_s.current:Br,wr=M.useMemo(()=>MO(hi,Nr),[hi,Nr]),Ji=M.useMemo(()=>C3(Nr,Ge),[Ge,Nr]),Er=!z&&Ge!=="auto"&&Ji.showOnDesktop!==!0?"auto":Ge,Gs=Er==="auto"?wr:Er,Ur=M.useMemo(()=>C3(Nr,Gs),[Gs,Nr]),eo=M.useMemo(()=>Ur.actions.filter(De=>De.sequence.trim().length>0).map((De,xt)=>({...De,label:y2(De,xt)})),[Ur.actions]),to=M.useMemo(()=>oA(Br),[Br]),Ls=Ur.label,$s=M.useMemo(()=>Er!=="auto"?`Manual preset: ${Ur.label}`:to?`Auto preset · ${Ur.label} (${to})`:"Auto preset",[to,Er,Ur.label]),Sa=M.useCallback(De=>{Fe(De)},[]),Aa=M.useCallback(()=>{it(De=>De==="copy"?"arrows":"copy"),vt("idle")},[]),Ta=M.useCallback(()=>{typeof window>"u"||(Jn.current!==null&&window.clearTimeout(Jn.current),Jn.current=window.setTimeout(()=>{Jn.current=null,vt("idle")},1200))},[]),Tl=M.useCallback(De=>{Jn.current!==null&&typeof window<"u"&&(window.clearTimeout(Jn.current),Jn.current=null),vt(De?"copied":"failed"),Ta()},[Ta]),ds=M.useCallback(De=>{Ne(De)},[]),Ws=M.useMemo(()=>z?DO(Nr):jO(Nr),[z,Nr]),Ri=M.useMemo(()=>hO(s),[s]),Co=M.useMemo(()=>`terminal::${V}`,[V]);M.useEffect(()=>{H?.({isConnecting:Nt,isRestarting:ln,hasError:!!Jt,sessionId:Ie})},[Nt,ln,Jt,Ie,H]);const no=!Ie||Nt||ln,Ca=M.useCallback((De,xt)=>{if(no)return;const At=Math.max(1,Math.min(Math.floor(xt)||1,40));wi(De,At)},[wi,no]);M.useEffect(()=>{if(!a||!z)return;rt.current?.requestRefresh("resize",{skipScrollToBottom:!fe,force:!0})},[a,z,fe,Ke,V]),M.useEffect(()=>{if(!a||!z)return;const De=xt=>{const At=xt.detail;rt.current?.requestRefresh("resize",{skipScrollToBottom:At?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",De),()=>{document.removeEventListener("termdock:viewport-keyboard-change",De)}},[a,z,V]);const ro=!D&&(z||Ur.showOnDesktop===!0),ko=a,Vs=z&&!F?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Hs=z&&!F?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,ni=o.jsx(FO,{visible:ro,interactive:ko,presentation:z?"mobile":"desktop-actions",activeModifier:Ye,lockedModifier:q,disabled:no,defaultShowExtended:Xe,presetLabel:Ls,presetModeLabel:$s,presetMode:Er,presetOptions:Ws,includeAlt:Ur.includeAlt,presetRowLayout:Ur.rowLayout,extraActions:eo,onKeyPress:Os,onTextPress:Ms,onPastePress:z?Zi:void 0,onFilePress:z?Vr:void 0,fileUploadState:Gt,fileUploadProgress:an,longPressMode:ft,copyFeedback:Mt,onLongPressModeToggle:Aa,onModifierToggle:Ho,onPresetSelect:Sa,onExpandedChange:ds}),_o=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return o.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:Vs,children:[o.jsx("input",{ref:jr,type:"file",className:"hidden",onChange:pr}),rr&&o.jsx(OO,{isMobile:z,isInputFocused:Ce,isIOS:ge,isConnecting:Nt,connectionError:Jt,terminalSessionId:Ie}),o.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Ri.background,...Hs},children:[o.jsx("div",{ref:Ii,className:"h-full w-full box-border",children:o.jsx(sA,{fallback:o.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:o.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Q("terminal.componentFailed")})]})}),children:o.jsx(uO,{ref:Ka,sessionKey:Co,chunks:te,onInput:Fs,onResize:Mr,onFlowControl:ks,onTmuxScroll:Se?Ca:void 0,tmuxScrollSensitivity:.38,onDoubleTap:z?()=>{rt.current?.sendSequence(" ")}:void 0,onInputFocusChange:Lr,onMobileLongPressCopyResult:Tl,onReadyChange:di,onDirectoryLinkActivate:rn,terminalSettings:ie,theme:Ri,enableTouchScroll:z,mobileLongPressMode:ft,autoFocus:!z&&!_o},Co)})}),o.jsx($O,{connectionError:Jt,isFatalError:Oe,isRestarting:ln,isConnecting:Nt,onHardRestart:lr})]}),P?D?null:ui.createPortal(ni,P):ni]})},ZQ=1e3,JQ=2e4,e$=9e4,t$=5e3,qr={ws:null,listeners:new Set,reconnectAttempt:0,reconnectTimer:null,idleCloseTimer:null,closing:!1};let em=0,S0=null;function n$(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/control/ws`}function RA(){qr.idleCloseTimer&&(clearTimeout(qr.idleCloseTimer),qr.idleCloseTimer=null)}function r$(){RA(),!(qr.ws&&qr.ws.readyState===WebSocket.OPEN)&&(qr.idleCloseTimer=setTimeout(()=>{qr.idleCloseTimer=null,qr.listeners.size===0&&s$()},t$))}function s$(){if(qr.ws){try{qr.ws.close()}catch{}qr.ws=null}S0&&(clearInterval(S0),S0=null)}function $3(){if(qr.reconnectTimer)return;const e=Math.min(ZQ*Math.pow(2,qr.reconnectAttempt),JQ);qr.reconnectAttempt+=1,qr.reconnectTimer=setTimeout(()=>{qr.reconnectTimer=null,NA()},e)}function NA(){const e=n$();if(!e||qr.ws&&qr.ws.readyState===WebSocket.OPEN)return;let t;try{t=new WebSocket(e)}catch{$3();return}qr.ws=t,t.onopen=()=>{qr.reconnectAttempt=0,em=Date.now(),S0||(S0=setInterval(()=>{if(!(!qr.ws||qr.ws.readyState!==WebSocket.OPEN)&&em>0&&Date.now()-em>e$)try{qr.ws.close()}catch{}},3e4),S0.unref?.())},t.onmessage=n=>{em=Date.now();let r=null;try{r=JSON.parse(n.data)}catch{return}if(!r)return;if(r.type==="update-state"){const a=r.state;if(!a||typeof a.status!="string"||typeof a.currentVersion!="string")return;const c={type:"update-state",state:a};for(const u of qr.listeners)try{u(c)}catch(f){console.error("[clientStateSync] listener threw:",f)}return}if(r.type==="context-draft"){if(typeof r.text!="string")return;const a={type:"context-draft",text:r.text,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:Date.now(),origin:typeof r.origin=="string"?r.origin:null};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type==="pinned-explorer-roots"){if(!r.pinnedExplorerRoots||typeof r.pinnedExplorerRoots!="object"||Array.isArray(r.pinnedExplorerRoots))return;const a={type:"pinned-explorer-roots",pinnedExplorerRoots:r.pinnedExplorerRoots,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:Date.now(),origin:typeof r.origin=="string"?r.origin:null};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type==="config-updated"){if(r.key!=="toolbar-presets"&&r.key!=="agent-rules"&&r.key!=="program-detection")return;const a={type:"config-updated",key:r.key,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type!=="client-state"||!r.state)return;const s=r.state,i={type:"client-state",clientState:{sessions:Array.isArray(s.sessions)?s.sessions:[],updatedAt:typeof s.updatedAt=="number"?s.updatedAt:Date.now()},inventory:r.inventory,seq:typeof r.seq=="number"?r.seq:void 0};for(const a of qr.listeners)try{a(i)}catch(c){console.error("[clientStateSync] listener threw:",c)}},t.onclose=()=>{qr.ws===t&&(qr.ws=null),qr.listeners.size>0&&$3()},t.onerror=()=>{}}function Th(e){return qr.listeners.add(e),RA(),qr.ws||NA(),()=>{qr.listeners.delete(e),qr.listeners.size===0&&r$()}}function MA(e,t,n){const r=e.findIndex(s=>n(s)===t);return r<0?null:e[r+1]?n(e[r+1]):r>0?n(e[r-1]):null}const Ux="termdock-sessions",I2="termdock-active-session",iv="termdock-sessions-cache";function R2(){try{const e=localStorage.getItem(I2);return e&&e.trim().length>0?e:null}catch{return null}}function Yd(e){try{e?localStorage.setItem(I2,e):localStorage.removeItem(I2)}catch{}}function DA(){if(typeof window>"u")return null;try{const e=localStorage.getItem(iv);if(!e)return null;const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null&&typeof n.sessionId=="string"&&typeof n.name=="string"):null}catch{return null}}function Qu(e){if(!(typeof window>"u"))try{localStorage.setItem(iv,JSON.stringify(e))}catch{}}function H3(){if(!(typeof window>"u"))try{localStorage.removeItem(iv)}catch{}}function jA(e){return e.map(t=>({...t,mode:t.mode==="tmux"?"tmux":"shell",tmuxSessionName:t.tmuxSessionName??null,customName:t.customName===!0}))}function U3(e){return jA(e.map(t=>({sessionId:t.sessionId,name:t.name,customName:t.customName===!0,backendSessionId:t.backendSessionId,mode:t.mode,tmuxSessionName:t.tmuxSessionName,createdAt:t.createdAt,lastActivity:t.lastActivity}))).map((t,n)=>({...t,activeProgram:e[n]?.activeProgram??null,cwd:e[n]?.cwd??null}))}function z3(e){return e.map(t=>`${t.sessionId}:${t.name}:${t.customName}:${t.backendSessionId}:${t.mode}:${t.tmuxSessionName}:${t.lastActivity}:${t.activeProgram??""}:${t.cwd??""}`).join("|")}function N2(e,t){return e.length===0?null:t&&e.some(n=>n.sessionId===t)?t:e[0]?.sessionId??null}function i$(){const e=DA()??[];return{sessions:e,activeSessionId:N2(e,R2())}}function o$(){const e=x.useRef(DA()).current,t=x.useRef(R2()).current,[n,r]=x.useState(e??[]),[s,i]=x.useState(null),[a,c]=x.useState(e&&e.length>0?N2(e,t):t),[u,f]=x.useState(e===null),p=x.useRef(!1),g=x.useRef(null),y=x.useRef(e===null),v=x.useRef(0),S=x.useRef(new Set),C=x.useRef(0);x.useEffect(()=>{y.current=u},[u]),x.useEffect(()=>{g.current=a},[a]);const T=x.useCallback(pe=>{const ye=N2(pe,g.current??R2());return c(Ae=>Ae===ye?Ae:ye),Yd(ye),g.current=ye,ye},[]),L=x.useCallback((pe,ye)=>{const Ae=pe.filter(ie=>!S.current.has(ie.sessionId));r(ie=>z3(ie)===z3(Ae)?ie:Ae),Qu(Ae),ye?.reconcileActive&&T(Ae)},[T]),E=x.useCallback((pe,ye)=>{const Ae=S.current.size===0?pe:{...pe,clientSessions:pe.clientSessions.filter(ie=>!S.current.has(ie.sessionId))};i(Ae),L(U3(Ae.clientSessions),ye)},[L]),D=x.useCallback(()=>typeof window>"u"?[]:localStorage.getItem(Ux)?(localStorage.removeItem(Ux),H3(),Yd(null),r([]),c(null),console.info("[session-persist] discarded legacy local session cache"),[]):[],[]),P=x.useCallback(async()=>{if(typeof window>"u")return[];const pe=C.current;try{const ye=await fI(),Ae=U3(ye.clientSessions);return pe!==C.current?(console.info("[session-inventory] ignored restore snapshot superseded by a local mutation"),Ae.filter(ie=>!S.current.has(ie.sessionId))):(E(ye,{reconcileActive:!0}),Ae.length>0?Ae:D())}catch(ye){console.error("Failed to restore sessions from server:",ye);try{return D()}catch(Ae){console.error("Failed to discard legacy local sessions:",Ae)}}finally{f(!1)}return[]},[E,D]),F=x.useCallback(async pe=>{const ye=++C.current,Ae=await $7(pe);return ye===C.current&&(E(Ae.inventory),c(Ae.session.sessionId),Yd(Ae.session.sessionId)),Ae},[E]),j=x.useCallback(async(pe,ye)=>{++C.current,S.current.add(pe),r(Ae=>{const ie=Ae.filter(ce=>ce.sessionId!==pe),V=ye!=null&&ie.some(ce=>ce.sessionId===ye),z=g.current===pe?V?ye:MA(Ae,pe,ce=>ce.sessionId):g.current;return c(z),Yd(z),Qu(ie),ie});try{await pI(pe)}catch(Ae){console.error("Failed to remove session from inventory:",Ae)}},[]),A=x.useCallback(pe=>{const ye=Date.now();r(Ae=>{const ie=Ae.map(V=>V.sessionId===pe?{...V,lastActivity:ye}:V);return Qu(ie),ie})},[]),H=x.useCallback(pe=>{c(pe),Yd(pe)},[]),Q=x.useCallback(async(pe,ye)=>{const Ae=ye.trim();if(!Ae)return;const ie=++C.current;r(V=>{const z=V.map(ce=>ce.sessionId===pe?{...ce,name:Ae,customName:!0}:ce);return Qu(z),z});try{const V=await _m(pe,{name:Ae,customName:!0});ie===C.current&&E(V)}catch(V){console.error("Failed to rename session in inventory:",V)}},[E]),K=x.useCallback(async pe=>{const ye=++C.current;r(Ae=>{const ie=Ae.map(V=>V.sessionId===pe?{...V,customName:!1}:V);return Qu(ie),ie});try{const Ae=await _m(pe,{customName:!1});ye===C.current&&E(Ae)}catch(Ae){console.error("Failed to reset session name in inventory:",Ae)}},[E]),W=x.useCallback(async pe=>{const ye=++C.current;r(Ae=>{const ie=new Map(Ae.map(he=>[he.sessionId,he])),V=pe.map(he=>ie.get(he)).filter(he=>he!==void 0),z=new Set(pe),ce=Ae.filter(he=>!z.has(he.sessionId)),ge=[...V,...ce];return Qu(ge),ge});try{const Ae=await hI(pe);ye===C.current&&E(Ae)}catch(Ae){console.error("Failed to reorder sessions in inventory:",Ae)}},[E]),de=x.useCallback(async()=>{++C.current;for(const pe of n)S.current.add(pe.sessionId);r([]),i(null),c(null),Yd(null),H3(),typeof window<"u"&&localStorage.removeItem(Ux);try{await mI()}catch(pe){console.error("Failed to clear session inventory:",pe)}},[n]),X=x.useCallback(async(pe,ye)=>{const Ae=++C.current;r(ie=>{const V=ie.map(z=>z.sessionId===pe?{...z,backendSessionId:ye}:z);return Qu(V),V});try{const ie=await _m(pe,{backendSessionId:ye});Ae===C.current&&E(ie)}catch(ie){console.error("Failed to update session backend in inventory:",ie)}},[E]);return x.useEffect(()=>{p.current||(p.current=!0,P())},[P]),x.useEffect(()=>Th(ye=>{if(ye.type!=="client-state"||y.current)return;const Ae=typeof ye.seq=="number"?ye.seq:null;if(Ae!==null){if(Ae<v.current){console.warn("[session-inventory] ignored stale control snapshot",{seq:Ae,latestSeq:v.current});return}v.current=Ae}if(ye.inventory){E(ye.inventory,{reconcileActive:!0});return}const ie=jA(ye.clientState.sessions||[]);L(ie,{reconcileActive:!0})}),[E,L]),{sessions:n,inventory:s,activeSessionId:a,isLoading:u,openSession:F,removeSession:j,updateSessionActivity:A,setActiveSession:H,updateSessionBackendId:X,renameSession:Q,resetSessionCustomName:K,reorderSessions:W,clearAllSessions:de,restoreSessions:P}}const PA=5*6e4,a$=4,l$=3e4;function c$(e){const t=new Set([...e.currentVisibleSessionIds].filter(a=>e.validSessionIds.has(a))),n=e.idleMs??PA,s=Math.max(t.size*2,e.maxSessions??a$)-t.size;return s===0||[...e.lastVisitedAtBySessionId].filter(([a,c])=>e.validSessionIds.has(a)&&!t.has(a)&&Number.isFinite(c)&&e.now-c<n).sort((a,c)=>c[1]-a[1]).slice(0,s).map(([a])=>a).forEach(a=>t.add(a)),t}const u$="termdock:startup:";function hh(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${u$}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function d$(e,t){e||ui.flushSync(t)}const M2="horizontal";function $c(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function BA(e,t){if(!Array.isArray(e)||e.length!==t)return $c(t);const n=e.map(Number);if(n.some(s=>!Number.isFinite(s)||s<=0))return $c(t);const r=n.reduce((s,i)=>s+i,0);return r<=0?$c(t):n.map(s=>s/r)}function f$(e){return e==="horizontal"||e==="vertical"||e==="grid"}function h$(e){if(!Array.isArray(e))return[];const t=new Set,n=new Set,r=[];for(const s of e){if(!s||typeof s!="object")continue;const i=s;if(typeof i.id!="string"||!i.id||n.has(i.id))continue;const a=Array.isArray(i.sessionIds)?i.sessionIds.filter(u=>typeof u=="string"&&!!u&&!t.has(u)):[],c=[...new Set(a)];c.length<2||(c.forEach(u=>t.add(u)),n.add(i.id),r.push({id:i.id,...typeof i.name=="string"&&i.name.trim()?{name:i.name.trim().slice(0,80)}:{},sessionIds:c,layout:f$(i.layout)?i.layout:M2,ratios:BA(i.ratios,c.length)}))}return r}function p$(e,t){const n=new Set(t);return e.flatMap(r=>{const s=r.sessionIds.filter(i=>n.has(i));return s.length<2?[]:[{...r,sessionIds:s,ratios:s.length===r.sessionIds.length?BA(r.ratios,s.length):$c(s.length)}]})}function Ch(e,t){if(t)return e.find(n=>n.sessionIds.includes(t))}function zx(e,t,n){if(!t||!n||t===n)return e;const r=Ch(e,t),s=Ch(e,n);if(r&&r.id===s?.id)return e;const i=[...r?.sessionIds??[t],...s?.sessionIds??[n]],a=[...new Set(i)],c={id:r?.id??`split:${t}`,...r?.name?{name:r.name}:{},sessionIds:a,layout:a.length>2&&(!r||r.layout===M2)?"grid":r?.layout??M2,ratios:$c(a.length)},u=new Set([r?.id,s?.id].filter(Boolean)),f=e.filter(g=>!u.has(g.id)),p=r?Math.max(0,e.findIndex(g=>g.id===r.id)):f.length;return f.splice(Math.min(p,f.length),0,c),f}function m$(e,t){const n=Ch(e,t);if(!n||!t)return e;if(n.sessionIds.length<=2)return e.filter(s=>s.id!==n.id);const r=n.sessionIds.filter(s=>s!==t);return e.map(s=>s.id===n.id?{...s,sessionIds:r,ratios:$c(r.length)}:s)}function g$(e,t){const n=Ch(e,t);return n?e.filter(r=>r.id!==n.id):e}function x$(e,t,n){return e.map(r=>{if(r.id!==t)return r;const s=[...new Set(n)],i=new Set(r.sessionIds);return s.length===r.sessionIds.length&&s.every(c=>i.has(c))?{...r,sessionIds:s}:r})}function b$(e,t,n){const r=n.trim().slice(0,80);return e.map(s=>s.id===t?{...s,...r?{name:r}:{name:void 0}}:s)}const D2=320,FA=1,y$=D2+120,v$=48,w$=72,j2="termdock:split-workspaces:v2",OA="termdock:split-workspace:v1",S$=.1,A$=.9,T$=.28,C$=300,k$=8,_$=280,L$=160;function Gx(){if(typeof window>"u")return{mobile:!1,landscape:!1};const t=(navigator.maxTouchPoints>0||"ontouchstart"in window)&&Math.min(window.innerWidth,window.innerHeight)<768;return{mobile:t,landscape:t&&window.innerWidth>window.innerHeight}}function E$(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(j2);if(e)return h$(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(OA)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const n=Math.min(A$,Math.max(S$,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[n,1-n]}]}}catch{}return[]}function I$(e,t){const n=new Map(e.map(a=>[a.id,a])),r=new Map;t.forEach(a=>a.sessionIds.forEach(c=>r.set(c,a)));const s=new Set,i=[];for(const a of e){const c=r.get(a.id);if(!c){i.push({key:a.id,sessions:[a]});continue}if(s.has(c.id))continue;s.add(c.id);const u=c.sessionIds.flatMap(f=>{const p=n.get(f);return p?[p]:[]});u.length>=2&&i.push({key:c.id,sessions:u,workspace:c})}return i}function G3(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(n=>n.cancel())}catch{}}function tm(e,t){const n=lg(e,t);if(n===null)return;const r=e.wrapperEl;G3(e),r&&(r.style.transitionDuration="0ms");try{const s=e;s.setTransition?.(0),s.setTranslate?.(n),G3(e),r&&(r.style.transitionDuration="0ms",r.style.transform=`translate3d(${n}px, 0px, 0px)`)}catch{r&&(r.style.transitionDuration="0ms",r.style.transform=`translate3d(${n}px, 0px, 0px)`)}}function P2(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function lg(e,t){const n=e.snapGrid,r=Array.isArray(n)?n[t]:void 0;return typeof r!="number"||!Number.isFinite(r)?null:-r}function R$(e,t){const n=P2(e),r=lg(e,t);return n!==null&&r!==null&&Math.abs(n-r)<=FA}function N$(e){const t=[],n=new Map,r=new Map,s=new Map;for(const i of e){const a=n.get(i.id)??[];if(a.push(i.id),n.set(i.id,a),i.sessionId){const c=r.get(i.sessionId)??[];c.push(i.id),r.set(i.sessionId,c)}if(i.mode==="tmux"&&i.tmuxSessionName){const c=s.get(i.tmuxSessionName)??[];c.push(i.id),s.set(i.tmuxSessionName,c)}}for(const[i,a]of n)a.length>1&&t.push({kind:"frontend",key:i,sessionIds:a});for(const[i,a]of r)a.length>1&&t.push({kind:"backend",key:i,sessionIds:a});for(const[i,a]of s)a.length>1&&t.push({kind:"tmux",key:i,sessionIds:a});return t}function QA(e){const t=new Map;for(const n of e)t.set(n.id,n);return Array.from(t.values())}function $A(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function M$(e,t){const n=QA(e),r=n.findIndex(s=>s.id===t.id);if(r>=0){const s=[...n];return s[r]=t,s}return[...n,t]}function W3(e,t){const n=new Map(e.map(r=>[r.id,r]));return t.map(r=>{const s=n.get(r.sessionId);return{...$A(r),history:s?.history}})}function V3(e,t){return e.length===0?null:t&&e.some(n=>n.sessionId===t)?t:e[0]?.sessionId??null}function q3(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function K3(e){const t=new Map;for(const[n,r]of e)t.set(n,r.cwd??null);return t}function D$(e,t){if(e.size!==t.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0}function j$(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const n=Date.now().toString(36),r=Math.random().toString(36).slice(2,8);return`wt-${n}${r}`}const P$=({terminalSettings:e=Jy(),colorTheme:t="dark",toolbarPresets:n=[],showDebug:r,terminalFocusAvailable:s=!0,defaultSessionMode:i="shell",defaultTmuxSessionName:a="",connectionPrioritySessionId:c=null,connectionPriorityReady:u=!0,onStatusChange:f,onSessionDataUpdate:p})=>{const{t:g}=Vn(),y=x.useMemo(()=>cd("session"),[]),v=x.useMemo(()=>cd("terminal"),[]),[S,C]=x.useState([]),[T,L]=x.useState(null),[E,D]=x.useState(!0),[P,F]=x.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[j,A]=x.useState(()=>new Set),[H,Q]=x.useState(0),[K,W]=x.useState(()=>new Set),[de,X]=x.useState(()=>new Set),[pe,ye]=x.useState(()=>new Map),Ae=x.useRef(!1),ie=x.useRef(null),V=x.useRef({}),[z,ce]=x.useState(null),[ge,he]=x.useState(()=>E$()),[Ce,xe]=x.useState(!1),[ae,Le]=x.useState(null),[Z,Ze]=x.useState(null),[at,He]=x.useState(null),[be,Be]=x.useState(!1),[fe,Ke]=x.useState(()=>Gx().mobile),[Ye,et]=x.useState(()=>Gx().landscape),[q,ue]=x.useState(null),[Xe,Ne]=x.useState(null),Ge=x.useRef(s),Fe=x.useRef(!1),ft=x.useRef(null),it=x.useRef(null),Mt=x.useRef(fe),vt=x.useRef(null),Gt=x.useRef(0),Zt=x.useRef([]),an=x.useRef(0),$n=x.useRef(null),we=x.useRef(!1),dt=x.useRef(!0),gt=x.useRef(null),Wt=x.useRef(""),ht=x.useRef(null),$t=x.useRef(0);x.useEffect(()=>{if(typeof window>"u")return;const re=()=>{const Ee=Gx();Mt.current=Ee.mobile,Ke(Ee.mobile),et(Ee.landscape)};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]);const{sessions:ct,inventory:We,activeSessionId:Zn,isLoading:An,openSession:Ve,setActiveSession:En,removeSession:jt,renameSession:yr,resetSessionCustomName:Fn,reorderSessions:Tn,restoreSessions:Rr}=o$(),gr=We?.tmuxRecovery??null;x.useEffect(()=>{He(null),Ze(null)},[gr?.id]);const Br=x.useCallback(async()=>{Ze("restore"),He(null);try{const re=await cI();await Rr(),re.failed>0&&He(g("tab.tmuxRecoveryPartial",{restored:re.restored,failed:re.failed}))}catch{He(g("tab.tmuxRecoveryFailed"))}finally{Ze(null)}},[Rr,g]),Nr=x.useCallback(async()=>{Ze("dismiss"),He(null);try{await uI(),await Rr()}catch{He(g("tab.tmuxRecoveryDismissFailed"))}finally{Ze(null)}},[Rr,g]),Se=ut(re=>re.groupByFolder),te=ut(re=>re.leftOpen||re.rightOpen),[Nt,Ie]=x.useState(()=>K3(rs.getState().sessions));x.useEffect(()=>rs.subscribe(re=>{const Ee=K3(re.sessions);Ie(Qe=>D$(Qe,Ee)?Qe:Ee)}),[]);const{arranged:rn}=x.useMemo(()=>rA(S,re=>Nt.get(re.id)??null,Se,""),[S,Nt,Se]),Qt=x.useRef(rn);Qt.current=rn;const Et=x.useMemo(()=>I$(rn,ge),[rn,ge]),Jt=x.useRef(Et);Jt.current=Et;const un=x.useMemo(()=>Ch(ge,T),[T,ge]),nr=x.useMemo(()=>{const re=Et.find(Ee=>Ee.sessions.some(Qe=>Qe.id===T));return new Set(re?.sessions.map(Ee=>Ee.id)??[])},[T,Et]);x.useEffect(()=>{if(!fe)return;const re=()=>{const Qe=Date.now(),je=new Set(Zt.current.map(bt=>bt.id));ye(bt=>{const yt=new Map;for(const[Ut,Kt]of bt)je.has(Ut)&&(nr.has(Ut)||Qe-Kt<PA)&&yt.set(Ut,Kt);return nr.forEach(Ut=>yt.set(Ut,Qe)),yt})};re();const Ee=window.setInterval(re,l$);return()=>window.clearInterval(Ee)},[nr,fe]);const Oe=x.useMemo(()=>fe?c$({currentVisibleSessionIds:nr,lastVisitedAtBySessionId:pe,validSessionIds:new Set(S.map(re=>re.id)),now:Date.now()}):nr,[nr,fe,pe,S]),mt=x.useMemo(()=>Dx(S.map(re=>({id:re.id,backendSessionId:re.sessionId})),c),[c,S]),ln=x.useMemo(()=>V3(ct,Zn),[Zn,ct]),en=Xp({prioritySessionId:mt,activeSessionId:T,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null}),kn=x.useMemo(()=>dQ(Et.flatMap(re=>re.sessions.map(Ee=>Ee.id)),nr),[nr,Et]),Cn=en!==null&&j.has(en),Rt=x.useCallback((re,Ee)=>{A(Qe=>{if(Qe.has(re)===Ee)return Qe;const bt=new Set(Qe);return Ee?bt.add(re):bt.delete(re),bt})},[]),Ln=x.useCallback(re=>{const Ee=mt??vt.current;re===Ee&&(hh("foreground-stream-connected"),Q(Gt.current))},[mt]),qn=x.useCallback((re,Ee)=>{W(Qe=>{if(Qe.has(re)===Ee)return Qe;const je=new Set(Qe);return Ee?je.add(re):je.delete(re),je})},[]),cn=en!==null&&K.has(en);x.useEffect(()=>{cn&&hh("foreground-viewport-ready")},[cn]),x.useEffect(()=>{if(!cn||fe)return;const Ee=Et.flatMap(Qe=>Qe.sessions.map(je=>je.id)).filter(Qe=>Qe!==en).map((Qe,je)=>window.setTimeout(()=>{X(bt=>{if(bt.has(Qe))return bt;const yt=new Set(bt);return yt.add(Qe),je===0&&hh("background-viewports-started"),yt})},v$+je*w$));return()=>Ee.forEach(Qe=>window.clearTimeout(Qe))},[en,cn,fe,Et]),x.useEffect(()=>{typeof window>"u"||(ge.length>0?(window.localStorage.setItem(j2,JSON.stringify(ge)),window.localStorage.removeItem(OA)):window.localStorage.removeItem(j2))},[ge]),x.useEffect(()=>{An||E||ge.length===0||he(re=>p$(re,S.map(Ee=>Ee.id)))},[An,E,S,ge.length]),x.useEffect(()=>{if(!ae)return;const re=window.setTimeout(()=>Le(null),3200);return()=>window.clearTimeout(re)},[ae]),x.useEffect(()=>()=>ht.current?.(),[]),vt.current=T,Gt.current=P.token,Zt.current=S,$n.current=Zn,we.current=An,dt.current=E,Ge.current=s;const rr=x.useCallback((re=ie.current)=>{const Ee=an.current,Qe=typeof window<"u"?window.visualViewport:null,je=re?P2(re):null,bt=re?lg(re,Ee):null;return{sessionsLength:Zt.current.length,workspaceSlidesLength:Jt.current.length,sessionIds:Zt.current.map(yt=>yt.id),activeSessionId:vt.current,activeSessionIndex:Ee,persistedActiveId:$n.current,isLoading:we.current,isRestoring:dt.current,activeIndex:re?.activeIndex??null,previousIndex:re?.previousIndex??null,animating:re?.animating??null,allowTouchMove:re?.allowTouchMove??null,width:re?.width??null,translate:je,targetTranslate:bt,translateDelta:je!==null&&bt!==null?je-bt:null,snapGridLength:re?.snapGrid?.length??null,targetSnap:re?.snapGrid?.[Ee]??null,visualViewport:Qe?{width:Math.round(Qe.width),height:Math.round(Qe.height),offsetTop:Math.round(Qe.offsetTop)}:null}},[]),Xt=x.useCallback((re,Ee)=>{y(re,{...rr(),...Ee})},[y,rr]);x.useEffect(()=>{An||E||T!==Zn&&En(T)},[T,An,E,Zn,En]);const kr=x.useMemo(()=>{if(rn.length===0||!T)return 0;const re=Et.findIndex(Ee=>Ee.sessions.some(Qe=>Qe.id===T));return re>=0?re:0},[Et,T]);an.current=kr;const wn=x.useCallback(()=>{ft.current&&(clearTimeout(ft.current),ft.current=null)},[]),Kr=x.useCallback(re=>{wn(),ft.current=setTimeout(()=>{ft.current=null,Fe.current=!1,Xt("[swiper:touch-guard-clear]",{reason:re})},y$)},[wn,Xt]),rt=x.useCallback((re,Ee={})=>{const Qe=ie.current,je=an.current,bt=Jt.current;if(!Qe||bt.length===0||je<0||je>=bt.length)return;if(Fe.current){Xt("[swiper:sync-skip-touch]",{reason:re});return}if(Qe.animating){Xt("[swiper:sync-skip-animating]",{reason:re});return}const yt=P2(Qe),Ut=lg(Qe,je),Kt=yt!==null&&Ut!==null&&Math.abs(yt-Ut)<=FA,nn=Qe.activeIndex===je;if(Xt("[swiper:sync-check]",{reason:re,activeIndexAligned:nn,translateAligned:Kt,immediate:Ee.immediate===!0}),!(nn&&Kt)){if(nn){tm(Qe,je),Xt("[swiper:sync-forced-active]",{reason:re,translateAligned:Kt,immediate:Ee.immediate===!0});return}Ee.immediate?(tm(Qe,je),Qe.slideTo(je,0,!1),tm(Qe,je)):Qe.slideTo(je,D2,!1),Xt("[swiper:sync-applied]",{reason:re,activeIndexAligned:nn,translateAligned:Kt,immediate:Ee.immediate===!0})}},[Xt]);x.useEffect(()=>{const re=Ee=>{const Qe=Ee;ie.current&&(ie.current.allowTouchMove=!Qe.detail.locked),Xt("[swiper:gesture-lock]",{locked:Qe.detail.locked})};return document.addEventListener("termdock:gesture-lock",re),()=>document.removeEventListener("termdock:gesture-lock",re)},[Xt]),x.useEffect(()=>{if(S.length===0){T!==null&&L(null);return}if(!T){if(!u)return;L(Xp({prioritySessionId:mt,activeSessionId:null,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null}));return}S.some(Ee=>Ee.id===T)||L(S[0].id)},[S,T,u,mt,ln]);const Bt=x.useCallback((re,Ee)=>{if(Ee&&Date.now()<$t.current){V.current[re]=!1;return}V.current[re]=Ee,Ne(Qe=>Ee?re:Qe===re?null:Qe)},[]),$e=x.useCallback(re=>{if(!Fe.current&&re.activeIndex!==an.current){Xt("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:re.activeIndex,expectedActiveIndex:an.current}),requestAnimationFrame(()=>rt("ignored-layout-slide-change",{immediate:!0}));return}const Ee=Jt.current[re.activeIndex],Qe=Ee?.sessions.some(yt=>yt.id===T)?T:Ee?.sessions[0]?.id;if(Xt("[swiper:slide-change]",{nextSessionId:Qe??null,instanceActiveIndex:re.activeIndex}),!Qe||Qe===T)return;const je=!!T&&V.current[T]===!0,bt=Ge.current&&(!Mt.current||je);if(it.current=Qe,L(Qe),bt){ce({sessionId:Qe,token:Date.now()});return}ce(null)},[S,T,Xt,rt]);x.useEffect(()=>{if(it.current===T){Xt("[swiper:sync-skip-swiper-driven]",{activeSessionId:T}),it.current=null;return}rt("active-session-index",{immediate:!0})},[T,kr,S.length,rt,Xt]),x.useEffect(()=>{const re=ie.current;if(!re)return;const Ee=Et.length>1&&!te&&!Ce;re.allowTouchMove!==Ee&&(re.allowTouchMove=Ee,Xt("[swiper:allow-touch-sync]",{nextAllow:Ee,sidebarOverlayOpen:te}))},[Et.length,Xt,te,Ce]);const st=x.useCallback(re=>{const Ee=ie.current;if(!Ee)return;const Qe=Ee.el;if(Xt("[swiper:layout-before]",{reason:re,scrollLeft:Qe?.scrollLeft??null}),Qe&&(Qe.scrollLeft=0),Ee.updateSize(),Ee.updateSlides(),Ee.updateProgress(),Ee.updateSlidesClasses(),Qe&&(Qe.scrollLeft=0),Xt("[swiper:layout-after]",{reason:re,scrollLeft:Qe?.scrollLeft??null}),Fe.current||Ee.animating){Xt("[swiper:layout-skip-sync-motion]",{reason:re});return}rt(`layout:${re}`,{immediate:!0}),requestAnimationFrame(()=>{const je=ie.current;je&&(Fe.current||je.animating||tm(je,an.current))})},[Xt,rt]);x.useEffect(()=>()=>wn(),[wn]);const Vt=Et.map(re=>re.key).join("\0");x.useEffect(()=>{requestAnimationFrame(()=>st("group-change"))},[Se,Vt,st]),x.useEffect(()=>{let re=null,Ee="mount";const Qe=Kt=>{Ee=Kt,re===null&&(re=requestAnimationFrame(()=>{re=null,st(`viewport-change:${Ee}`)}))},je=()=>Qe("window-resize"),bt=()=>Qe("visual-viewport-resize"),yt=()=>Qe("visual-viewport-scroll"),Ut=Kt=>{Qe(`measured:${Kt.detail?.source??"unknown"}`)};return window.addEventListener("resize",je),window.visualViewport?.addEventListener("resize",bt),window.visualViewport?.addEventListener("scroll",yt),document.addEventListener(w2,Ut),Qe("mount"),()=>{window.removeEventListener("resize",je),window.visualViewport?.removeEventListener("resize",bt),window.visualViewport?.removeEventListener("scroll",yt),document.removeEventListener(w2,Ut),re!==null&&cancelAnimationFrame(re)}},[st]),x.useEffect(()=>{if(typeof document>"u")return;let re=null,Ee=null,Qe=document.hidden;const je=hn=>{if(hn!=="online"&&document.hidden)return;const Mn=performance.now();if(!lQ(Ee,Mn))return;Ee=Mn;const Wn=hn==="bfcache"||hn==="online"?hn:"visibility",fr=cQ({wasPageHidden:Qe,reason:hn});Qe=!1,Qa("info","PWA_RESUME scheduled",{source:hn,forceForegroundReconnect:fr,activeSessionId:vt.current}),F(xn=>({token:xn.token+1,reason:Wn,forceForegroundReconnect:fr})),requestAnimationFrame(()=>st(`resume:${hn}:raf`)),re&&clearTimeout(re),re=setTimeout(()=>{re=null,st(`resume:${hn}:settled`)},320)},bt=()=>{if(document.hidden){Qe=!0,B5();return}je("visibility")},yt=()=>{Qe=!0,B5()},Ut=hn=>{je(hn.persisted?"bfcache":"pageshow")},Kt=()=>je("online"),nn=()=>je("focus");return document.addEventListener("visibilitychange",bt),window.addEventListener("pagehide",yt),window.addEventListener("pageshow",Ut),window.addEventListener("online",Kt),window.addEventListener("focus",nn),()=>{document.removeEventListener("visibilitychange",bt),window.removeEventListener("pagehide",yt),window.removeEventListener("pageshow",Ut),window.removeEventListener("online",Kt),window.removeEventListener("focus",nn),re&&clearTimeout(re)}},[st]),x.useEffect(()=>{const re=N$(S),Ee=JSON.stringify(re);re.length>0&&Ee!==Wt.current?(Wt.current=Ee,console.warn("[session-invariant] duplicate mapping detected",re)):re.length===0&&Wt.current&&(Wt.current=""),p?.({sessions:S.map(Qe=>({id:Qe.id,name:Qe.name,customName:Qe.customName,mode:Qe.mode,tmuxSessionName:Qe.tmuxSessionName})),activeSessionId:T,splitWorkspaces:ge.map(({id:Qe,name:je,sessionIds:bt,layout:yt})=>({id:Qe,...je?{name:je}:{},sessionIds:bt,layout:yt}))})},[S,T,ge,p]),x.useEffect(()=>{if(An||Ae.current)return;Ae.current=!0;const re=Dx(ct.map(yt=>({id:yt.sessionId,backendSessionId:yt.backendSessionId??null})),c),Ee=V3(ct,Zn),Qe=Xp({prioritySessionId:u?re:null,activeSessionId:null,persistedActiveSessionId:Ee,firstSessionId:ct[0]?.sessionId??null}),je=QA(ct.map($A));if(y("[Session] Restoring",je.length,"persisted sessions (one-shot)"),Xt("[swiper:restore-start]",{persistedSessionIds:ct.map(yt=>yt.sessionId),nextActiveSessionId:Qe}),je.length>0){const yt=rs.getState();je.forEach(Kt=>{Kt.sessionId&&yt.setTerminalSession(Kt.id,{sessionId:Kt.sessionId,cols:80,rows:24,mode:Kt.mode,tmuxSessionName:Kt.tmuxSessionName,history:Kt.history})}),ct.forEach(Kt=>{Kt.activeProgram!=null&&yt.setSessionActiveProgram(Kt.sessionId,Kt.activeProgram),Kt.cwd!=null&&yt.setSessionCwd(Kt.sessionId,Kt.cwd)}),C(je);const Ut=Qe||je[0]?.id||null;L(Ut),Xt("[swiper:restore-complete]",{restoredSessionIds:je.map(Kt=>Kt.id),nextActiveSessionId:Ut})}(async()=>(je.length===0&&await gt.current?.({createIfEmpty:!0}),D(!1),requestAnimationFrame(()=>rt("restore-finished",{immediate:!0}))))()},[An,ct,Zn,y,Xt,rt,u,c]),x.useEffect(()=>{if(!u||E||S.length===0)return;const re=Dx(S.map(Qe=>({id:Qe.id,backendSessionId:Qe.sessionId})),c),Ee=Xp({prioritySessionId:re,activeSessionId:vt.current,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null});Ee&&Ee!==vt.current&&L(Ee)},[u,c,E,ln,S]);const Ht=x.useRef([]),bn=x.useRef(!1);vt.current=T,x.useEffect(()=>{if(E)return;const re=Ht.current,Ee=ct;if(!bn.current){C(nn=>W3(nn,Ee)),Ht.current=Ee,bn.current=!0;return}const Qe=new Set(re.map(nn=>nn.sessionId)),je=new Set(Ee.map(nn=>nn.sessionId)),bt=new Map(re.map(nn=>[nn.sessionId,nn.name]));Ht.current=Ee,C(nn=>{const hn=W3(nn,Ee);return(!vt.current||!hn.some(Mn=>Mn.id===vt.current))&&L(hn[0]?.id??null),hn});const yt=Ee.filter(nn=>!Qe.has(nn.sessionId)),Ut=[...Qe].filter(nn=>!je.has(nn)),Kt=Ee.filter(nn=>Qe.has(nn.sessionId)&&bt.get(nn.sessionId)!==nn.name);(yt.length>0||Ut.length>0||Kt.length>0)&&y("[Session] Synced persisted sessions:",{newSessionIds:yt.map(nn=>nn.sessionId),removedSessionIds:Ut,renamedSessionIds:Kt.map(nn=>nn.sessionId),currentSessionIds:Ee.map(nn=>nn.sessionId)});for(const nn of Ee){if(!nn.backendSessionId)continue;rs.getState().setTerminalSession(nn.sessionId,{sessionId:nn.backendSessionId,cols:80,rows:24,mode:nn.mode,tmuxSessionName:nn.tmuxSessionName})}},[ct,E,y]);const Re=x.useCallback(async re=>{try{const Ee=re?.mode==="tmux"||re?.mode==="shell"?re.mode:i,Qe=(re?.tmuxSessionName||"").trim(),je=a.trim(),bt=Ee==="tmux"?Qe||je||j$():null,yt=typeof re?.cwd=="string"?re.cwd:null,Ut=T?rs.getState().sessions.get(T)?.cwd??null:null,Kt=typeof yt=="string"&&yt.trim().length>0?yt:typeof Ut=="string"&&Ut.trim().length>0?Ut:void 0,nn=await Ve({mode:Ee,tmuxSessionName:bt,cwd:Kt,termType:"xterm-256color",createIfEmpty:re?.createIfEmpty===!0}),hn=nn.session,Mn=nn.terminalSession,Wn={id:hn.sessionId,name:hn.name,customName:hn.customName===!0,sessionId:Mn.sessionId,mode:Mn.mode??hn.mode,tmuxSessionName:Mn.tmuxSessionName??hn.tmuxSessionName};C(Fr=>M$(Fr,Wn)),L(Wn.id),rs.getState().setTerminalSession(Wn.id,{sessionId:Mn.sessionId,cols:80,rows:24,mode:Wn.mode,tmuxSessionName:Wn.tmuxSessionName,activeProgram:Mn.activeProgram,activeProgramRaw:Mn.activeProgramRaw,activeProgramSource:Mn.activeProgramSource,cwd:Mn.cwd}),y("[Session] Inventory opened session:",{frontendSessionId:Wn.id,backendSessionId:Mn.sessionId,reused:nn.reused,mode:Wn.mode,tmuxSessionName:Wn.tmuxSessionName});const xn=re?.command?.trim();return xn&&await F7(Mn.sessionId,`${xn}\r`),Wn.id}catch(Ee){return console.error("[Session] Failed to create new session:",Ee),null}},[i,a,T,Ve,y]);gt.current=Re;const Je=x.useCallback((re,Ee={})=>{const Qe=vt.current,je=!!Qe&&V.current[Qe]===!0;if(L(re),Mt.current&&Ee.preserveMobileKeyboard===!1){$t.current=Date.now()+600,Qe&&(V.current[Qe]=!1),Ne(null),ce(null);const bt=document.activeElement;bt instanceof HTMLTextAreaElement&&bt.closest(".terminal-viewport-container")&&bt.blur();return}je&&Mt.current&&Ne(re),Ge.current&&(!Mt.current||je)&&ce({sessionId:re,token:Date.now()})},[]),St=x.useCallback(re=>{L(re),xe(!0),Le(null)},[]),tn=x.useCallback(re=>{const Ee=vt.current;!Ee||Ee===re||(he(Qe=>zx(Qe,Ee,re)),xe(!1),Je(Ee,{preserveMobileKeyboard:!1}))},[Je]),Xn=x.useCallback(async()=>{const re=vt.current;if(!re||be)return;Be(!0);const Ee=rs.getState().sessions.get(re)?.cwd??void 0,Qe=await Re({cwd:Ee||void 0,mode:i});if(Be(!1),!Qe){Le(g("common.error"));return}he(je=>zx(je,re,Qe)),xe(!1),Je(re,{preserveMobileKeyboard:!1})},[Je,i,Re,be,g]),dn=x.useCallback(re=>{he(Ee=>g$(Ee,re)),re&&Je(re,{preserveMobileKeyboard:!1})},[Je]),pn=x.useCallback(re=>{he(Ee=>m$(Ee,re)),Je(re,{preserveMobileKeyboard:!1})},[Je]),qt=x.useCallback((re,Ee,Qe,je,bt)=>{re.preventDefault(),re.stopPropagation();const yt=re.currentTarget,Ut=re.pointerId,Kt={x:re.clientX,y:re.clientY};yt.setPointerCapture?.(Ut);const nn=Ee.getBoundingClientRect();let hn=!fe,Mn=null;const Wn=xn=>{if(xn.pointerId!==Ut)return;if(!hn){Math.hypot(xn.clientX-Kt.x,xn.clientY-Kt.y)>k$&&Mn!==null&&(window.clearTimeout(Mn),Mn=null);return}xn.preventDefault();const Fr=Qe?(xn.clientY-nn.top)/nn.height:(xn.clientX-nn.left)/nn.width,_r=Qe?nn.height:nn.width,fn=fe?0:Qe?L$:_$;he(Ft=>Ft.map(xr=>{if(xr.id!==je)return xr;const vr=xr.ratios.length===xr.sessionIds.length?[...xr.ratios]:$c(xr.sessionIds.length),ar=vr.slice(0,bt).reduce((lr,Fs)=>lr+Fs,0),Wr=vr[bt]+vr[bt+1],Pn=fn>0?Math.min(Wr/2,fn/Math.max(1,_r)):Math.min(Wr/2,T$),hr=Math.min(Wr-Pn,Math.max(Pn,Fr-ar));return vr[bt]=hr,vr[bt+1]=Wr-hr,{...xr,ratios:vr}}))},fr=()=>{Mn!==null&&(window.clearTimeout(Mn),Mn=null),window.removeEventListener("pointermove",Wn),window.removeEventListener("pointerup",fr),window.removeEventListener("pointercancel",fr),yt.classList.remove("bg-primary"),fe&&document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ht.current=null};ht.current?.(),ht.current=fr,window.addEventListener("pointermove",Wn),window.addEventListener("pointerup",fr),window.addEventListener("pointercancel",fr),fe&&(document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),Mn=window.setTimeout(()=>{Mn=null,hn=!0,yt.classList.add("bg-primary"),navigator.vibrate?.(8)},C$))},[fe]),Kn=x.useCallback(re=>{S.find(Qe=>Qe.id===re)&&(L(re),Ge.current&&!Mt.current&&ce({sessionId:re,token:Date.now()}),y("[Session] Switched to session:",re))},[S,y]),or=x.useCallback((re,Ee)=>{Ee.trim()&&(C(Qe=>Qe.map(je=>je.id===re?{...je,name:Ee.trim(),customName:!0}:je)),yr(re,Ee.trim()))},[yr]),_n=x.useCallback(re=>{C(Ee=>Ee.map(Qe=>Qe.id===re?{...Qe,customName:!1}:Qe)),Fn(re)},[Fn]),Ar=x.useCallback(re=>{C(Ee=>{const Qe=new Map(Ee.map(Ut=>[Ut.id,Ut])),je=re.map(Ut=>Qe.get(Ut)).filter(Ut=>Ut!==void 0),bt=new Set(re),yt=Ee.filter(Ut=>!bt.has(Ut.id));return[...je,...yt]}),Tn(re),y("[Session] Reordered sessions:",re),requestAnimationFrame(()=>{ie.current?.update()})},[Tn,y]),ts=x.useCallback(async re=>{const Ee=typeof re=="string"?re:re.sessionId,Qe=typeof re=="string"?"auto":re.closeMode??"auto",je=S.find(yt=>yt.id===Ee);if(!je)return;const bt=MA(rn,Ee,yt=>yt.id);try{Qe==="destroy"&&je.mode==="tmux"&&je.tmuxSessionName?(await Q7(je.tmuxSessionName),y("[Session] Destroyed tmux session:",{frontendSessionId:je.id,tmuxSessionName:je.tmuxSessionName})):je.sessionId&&(await O7(je.sessionId),y("[Session] Closed backend terminal:",je.sessionId))}catch(yt){console.error("[Session] Failed to close backend terminal:",yt);return}C(yt=>{const Ut=yt.filter(Kt=>Kt.id!==Ee);return L(bt),Ut}),jt(Ee,bt),delete V.current[Ee],y("[Session] Closed session:",{sessionId:Ee,closeMode:Qe})},[S,rn,jt,y]),Jn=x.useCallback(re=>{if(!re)return;const Ee=S.filter(Qe=>Qe.sessionId===re);if(Ee.length!==0){Ee.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:re,frontendSessionIds:Ee.map(Qe=>Qe.id)}),C(Qe=>{const je=Qe.filter(bt=>bt.sessionId!==re);return je.length!==Qe.length&&!je.some(yt=>yt.id===T)&&L(je.length>0?je[0].id:null),je});for(const Qe of Ee)jt(Qe.id),delete V.current[Qe.id];y("[Session] Backend gone, dropped local session(s):",Ee.map(Qe=>Qe.id))}},[S,T,jt,y]);x.useEffect(()=>{const re=fn=>{Re(fn.detail)},Ee=fn=>{Kn(fn.detail)},Qe=()=>{const fn=vt.current;!fn||Mt.current||ce({sessionId:fn,token:Date.now()})},je=fn=>{const Ft=fn;Ft.detail&&St(Ft.detail)},bt=fn=>{const Ft=fn.detail;dn(Ft??vt.current??void 0)},yt=fn=>{const Ft=fn.detail;Ft&&pn(Ft)},Ut=fn=>{const Ft=fn.detail,xr=typeof Ft=="string"?Ft:Ft?.layout,vr=typeof Ft=="string"?vt.current:Ft?.sessionId;xr!=="horizontal"&&xr!=="vertical"&&xr!=="grid"||he(ar=>ar.map(Wr=>Wr.sessionIds.includes(vr??"")?{...Wr,layout:xr}:Wr))},Kt=fn=>{const xr=fn.detail?.direction;if(xr!=="prev"&&xr!=="next")return;const vr=Qt.current;if(vr.length<=1)return;const ar=vt.current,Wr=ar?vr.findIndex(Mr=>Mr.id===ar):-1,lr=((Wr>=0?Wr:0)+(xr==="next"?1:-1)+vr.length)%vr.length,Fs=vr[lr]?.id;Fs&&Fs!==ar&&Kn(Fs)},nn=fn=>{ts(fn.detail)},hn=fn=>{Jn(fn.detail)},Mn=fn=>{const Ft=fn;!Ft.detail?.sessionId||!Ft.detail?.name||or(Ft.detail.sessionId,Ft.detail.name)},Wn=fn=>{const Ft=fn;Ft.detail?.sessionId&&_n(Ft.detail.sessionId)},fr=fn=>{const Ft=fn;Ft.detail?.sessionIds&&Ar(Ft.detail.sessionIds)},xn=fn=>{const Ft=fn.detail;!Ft?.workspaceId||!Array.isArray(Ft.sessionIds)||he(xr=>x$(xr,Ft.workspaceId,Ft.sessionIds))},Fr=fn=>{const Ft=fn.detail;!Ft?.workspaceId||typeof Ft.name!="string"||he(xr=>b$(xr,Ft.workspaceId,Ft.name))},_r=fn=>{const Ft=fn.detail;!Ft?.primaryId||!Ft.secondaryId||Ft.primaryId===Ft.secondaryId||(he(xr=>zx(xr,Ft.primaryId,Ft.secondaryId)),Je(Ft.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",re),window.addEventListener("switch-terminal-session",Ee),window.addEventListener("focus-active-terminal-session",Qe),window.addEventListener("open-terminal-split-chooser",je),window.addEventListener("close-terminal-split",bt),window.addEventListener("remove-terminal-split-pane",yt),window.addEventListener("set-terminal-split-direction",Ut),window.addEventListener("cycle-terminal-session",Kt),window.addEventListener("close-terminal-session",nn),window.addEventListener("close-terminal-session-by-backend",hn),window.addEventListener("rename-terminal-session",Mn),window.addEventListener("reset-terminal-session-name",Wn),window.addEventListener("reorder-terminal-session",fr),window.addEventListener("reorder-terminal-split-workspace",xn),window.addEventListener("rename-terminal-split-workspace",Fr),window.addEventListener("combine-terminal-split-sessions",_r),()=>{window.removeEventListener("new-terminal-session",re),window.removeEventListener("switch-terminal-session",Ee),window.removeEventListener("focus-active-terminal-session",Qe),window.removeEventListener("open-terminal-split-chooser",je),window.removeEventListener("close-terminal-split",bt),window.removeEventListener("remove-terminal-split-pane",yt),window.removeEventListener("set-terminal-split-direction",Ut),window.removeEventListener("cycle-terminal-session",Kt),window.removeEventListener("close-terminal-session",nn),window.removeEventListener("close-terminal-session-by-backend",hn),window.removeEventListener("rename-terminal-session",Mn),window.removeEventListener("reset-terminal-session-name",Wn),window.removeEventListener("reorder-terminal-session",fr),window.removeEventListener("reorder-terminal-split-workspace",xn),window.removeEventListener("rename-terminal-split-workspace",Fr),window.removeEventListener("combine-terminal-split-sessions",_r)}},[Je,Re,Kn,St,dn,pn,ts,Jn,or,_n,Ar]),x.useEffect(()=>{if(!un||fe)return;const re=Ee=>{if(!(Ee.ctrlKey||Ee.metaKey)||!Ee.shiftKey)return;if(un.layout==="horizontal"?Ee.key==="ArrowLeft"||Ee.key==="ArrowRight":un.layout==="vertical"?Ee.key==="ArrowUp"||Ee.key==="ArrowDown":Ee.key.startsWith("Arrow")){Ee.preventDefault(),Ee.stopPropagation();const je=un.sessionIds.indexOf(vt.current??""),bt=Ee.key==="ArrowLeft"||Ee.key==="ArrowUp"?-1:1,yt=(Math.max(0,je)+bt+un.sessionIds.length)%un.sessionIds.length,Ut=un.sessionIds[yt];if(!Ut)return;Je(Ut);return}Ee.key==="Backspace"&&(Ee.preventDefault(),Ee.stopPropagation(),dn(vt.current??void 0))};return window.addEventListener("keydown",re,!0),()=>window.removeEventListener("keydown",re,!0)},[Je,un,dn,fe]);const dr=re=>{const Ee=rs.getState().sessions.get(re.id);return Dc(re,Ee?.activeProgram??null,Ee?.cwd??null,void 0,Ee?.shellTitle??null,Ee?.promptState??null)},jr=(re,Ee={})=>{const Qe=re.id===T,je=u&&oQ({sessionId:re.id,foregroundSessionId:en,visibleSessionIds:Oe,deferredViewportSessionIds:de,isMobileLayout:fe}),bt=iQ({sessionId:re.id,foregroundSessionId:en,foregroundReady:Cn})&&u,yt=aQ({sessionId:re.id,foregroundSessionId:en,requestToken:P.token,foregroundCompletedToken:H})&&u,Ut=re.id===en?0:kn.get(re.id)??Bm;return o.jsx("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${Ee.hidden?"invisible pointer-events-none":""}`,style:Ee.containerStyle,"aria-hidden":Ee.hidden||void 0,onPointerDown:()=>{Qe||Je(re.id)},onWheelCapture:()=>{d$(Qe,()=>Je(re.id))},children:o.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:je&&o.jsx(XQ,{sessionId:re.id,mode:re.mode,tmuxSessionName:re.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:n,isActive:Qe,initialConnectEnabled:bt,resumeRequestEnabled:yt,suppressKeyboard:Ee.suppressKeyboard,keyboardPortalTarget:Ee.keyboardPortalTarget,sharedMobileKeyboardLayout:Ee.sharedMobileKeyboardLayout,suppressPageFlipRefresh:Ee.suppressPageFlipRefresh,focusRequestToken:z?.sessionId===re.id?z.token:0,resumeRequestToken:P.token,resumeRequestReason:P.reason,forceResumeReconnect:P.forceForegroundReconnect&&re.id===en,resumeRequestDelayMs:re.id===en?0:Ee.hidden?Bm:kn.get(re.id)??Bm,initialConnectDelayMs:Ut,onStreamReadyChange:Rt,onStreamConnected:Ln,onViewportReadyChange:qn,onKeyboardVisibilityChange:Bt,showDebug:r,onStatusChange:Qe?f:void 0})})},re.id)};return o.jsxs("div",{className:"relative h-full flex flex-col",children:[gr&&o.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:o.jsx(Vg,{size:18})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:g("tab.tmuxRecoveryTitle",{count:gr.sessions.length})}),o.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:g("tab.tmuxRecoveryHint")}),o.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:gr.sessions.map(re=>re.name).join(" · ")}),at&&o.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:at}),o.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[o.jsxs("button",{type:"button",disabled:Z!==null,onClick:()=>{Br()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[o.jsx(m8,{size:13,className:Z==="restore"?"animate-spin":""}),g(Z==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),o.jsx("button",{type:"button",disabled:Z!==null,onClick:()=>{Nr()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:g("tab.tmuxRecoveryDismiss")})]})]})]})}),o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsx($h,{onSwiper:re=>{ie.current=re,re.allowTouchMove=Et.length>1&&!te&&!Ce,Xt("[swiper:on-swiper]",{allowTouchMove:re.allowTouchMove}),requestAnimationFrame(()=>st("on-swiper"))},onSlideChange:$e,onTouchStart:(re,Ee)=>{const Qe=q3(Ee),je=Qe==="touch"||Qe==="pen"||Qe==="unknown";v("[swipe:touch-start]",{pointerType:Qe,allowed:je}),Xt("[swiper:touch-start]",{pointerType:Qe,allowed:je}),je&&(wn(),Fe.current=!0)},onTouchEnd:(re,Ee)=>{const Qe=q3(Ee),je=Qe==="touch"||Qe==="pen"||Qe==="unknown";v("[swipe:touch-end]",{pointerType:Qe,allowed:je}),Xt("[swiper:touch-end]",{pointerType:Qe,allowed:je}),je&&Kr("touch-end")},onTransitionEnd:()=>{const re=ie.current;if(Fe.current&&re&&!R$(re,an.current)){Xt("[swiper:transition-end-deferred]");return}wn(),Fe.current=!1,Xt("[swiper:transition-end]")},initialSlide:Math.max(0,kr),speed:D2,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"h-full",children:Et.map(re=>{const Ee=re.workspace,Qe=!!Ee&&re.sessions.length>=2,je=fe?Ye?"horizontal":"vertical":Ee?.layout??"horizontal",bt=je==="vertical",yt=Ee?.ratios.length===re.sessions.length?Ee.ratios:$c(re.sessions.length),Ut=Xe?re.sessions.findIndex(xn=>xn.id===Xe):-1,Kt=fe&&Xe?re.sessions.some(xn=>xn.id===Xe):!1,nn=re.sessions.some(xn=>xn.id===T)?T:re.sessions[0]?.id,hn=yt.flatMap((xn,Fr)=>[Kt&&Fr!==Ut?"0px":`minmax(0, ${xn}fr)`,...Fr<yt.length-1?[Kt?"0px":"1px"]:[]]).join(" "),Mn=Math.ceil(Math.sqrt(re.sessions.length)),Wn=re.sessions.length%Mn,fr={...je==="grid"?{gridTemplateColumns:`repeat(${Mn}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${Math.ceil(re.sessions.length/Mn)}, minmax(0, 1fr))`,gap:"1px"}:bt?{gridTemplateRows:hn}:{gridTemplateColumns:hn},...fe?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:{}};return o.jsx(od,{className:"h-full",children:Qe?o.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:fe?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[o.jsx("div",{"data-split-container":"true",className:"grid min-h-0 min-w-0 flex-1 overflow-hidden",style:fr,children:re.sessions.map((xn,Fr)=>o.jsxs(M.Fragment,{children:[jr(xn,{suppressKeyboard:fe&&xn.id!==nn,keyboardPortalTarget:fe?q:null,sharedMobileKeyboardLayout:fe,suppressPageFlipRefresh:!0,hidden:Kt&&Ut!==Fr,containerStyle:je==="grid"&&Wn>0&&Fr===re.sessions.length-1?{gridColumn:`span ${Mn-Wn+1}`}:void 0}),je!=="grid"&&Fr<re.sessions.length-1&&Ee&&o.jsx("button",{type:"button",className:`swiper-no-swiping relative z-20 touch-none select-none bg-[var(--border-strong)] transition-colors hover:bg-primary active:bg-primary ${bt?"cursor-row-resize":"cursor-col-resize"} ${Kt?"invisible pointer-events-none":""}`,onPointerDownCapture:_r=>{const fn=_r.currentTarget.closest('[data-split-container="true"]');fn instanceof HTMLDivElement&&qt(_r,fn,bt,Ee.id,Fr)},onDoubleClick:_r=>{fe||(_r.preventDefault(),_r.stopPropagation(),he(fn=>fn.map(Ft=>Ft.id===Ee.id?{...Ft,ratios:$c(Ft.sessionIds.length)}:Ft)))},onContextMenu:_r=>{fe&&_r.preventDefault()},"aria-label":g("tab.split"),children:o.jsx("span",{"aria-hidden":"true","data-split-divider-hitarea":"true",className:`absolute ${bt?"inset-x-0":"inset-y-0"}`,style:bt?{top:-12,bottom:-12}:{left:-12,right:-12}})})]},xn.id))}),fe&&o.jsx("div",{ref:ue,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):jr(re.sessions[0])},re.key)})})}),Ce&&T&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>xe(!1),"aria-label":g("common.close")}),o.jsxs("section",{className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":g("tab.splitTitle"),children:[o.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[o.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:o.jsx(b0,{size:17})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:g("tab.splitTitle")}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:g("tab.splitExistingHint")})]}),o.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>xe(!1),"aria-label":g("common.close"),children:o.jsx(es,{size:16})})]}),o.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[o.jsxs("button",{type:"button",disabled:be,onClick:()=>{Xn()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[o.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:o.jsx($o,{size:17})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:g("tab.splitNew")}),o.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:g("tab.splitNewHint")})]})]}),ge.filter(re=>re.id!==un?.id).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:g("tab.splitExistingGroups")}),ge.filter(re=>re.id!==un?.id).map((re,Ee)=>{const Qe=re.sessionIds.flatMap(yt=>{const Ut=S.find(Kt=>Kt.id===yt);return Ut?[Ut]:[]});if(Qe.length<2)return null;const je=re.name||`${g("tab.splitWorkspace")} ${Ee+1}`,bt=Qe.map(yt=>dr(yt).primary).join(" · ");return o.jsxs("button",{type:"button",onClick:()=>tn(Qe[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(b0,{size:15})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:je}),o.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:g("tab.splitOccupied")})]}),o.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[g("tab.sessionCount",{count:Qe.length})," · ",bt]})]}),o.jsx(va,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},re.id)})]}),o.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:g("tab.splitAvailableSessions")}),S.filter(re=>!ge.some(Ee=>Ee.sessionIds.includes(re.id))&&re.id!==T).length===0&&ge.filter(re=>re.id!==un?.id).length===0?o.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:g("tab.splitNoOtherSessions")}):S.filter(re=>!ge.some(Ee=>Ee.sessionIds.includes(re.id))&&re.id!==T).map(re=>{const Ee=Nt.get(re.id)??null,Qe=dr(re);return o.jsxs("button",{type:"button",onClick:()=>tn(re.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:Ee?o.jsx(bu,{size:15}):o.jsx(b0,{size:15})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:Qe.primary}),o.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:Ee?hc(Ee)??Ee:re.name})]}),o.jsx(va,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},re.id)})]})]})]}),ae&&o.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:ae})]})},B$={sm:"h-4 w-7",md:"h-6 w-10"},F$={sm:"h-3 w-3",md:"h-5 w-5"},O$={sm:"translate-x-3",md:"translate-x-4"};function jc({checked:e,disabled:t=!1,size:n="md",className:r=""}){return o.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${B$[n]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${r}`,children:o.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${F$[n]} ${e?O$[n]:""}`})})}function ia(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Q$=typeof Symbol=="function"&&Symbol.observable||"@@observable",Y3=Q$,X3=()=>Math.random().toString(36).substring(7).split("").join("."),$$={INIT:`@@redux/INIT${X3()}`,REPLACE:`@@redux/REPLACE${X3()}`},Z3=$$;function H$(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function HA(e,t,n){if(typeof e!="function")throw new Error(ia(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ia(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ia(1));return n(HA)(e,t)}let r=e,s=t,i=new Map,a=i,c=0,u=!1;function f(){a===i&&(a=new Map,i.forEach((T,L)=>{a.set(L,T)}))}function p(){if(u)throw new Error(ia(3));return s}function g(T){if(typeof T!="function")throw new Error(ia(4));if(u)throw new Error(ia(5));let L=!0;f();const E=c++;return a.set(E,T),function(){if(L){if(u)throw new Error(ia(6));L=!1,f(),a.delete(E),i=null}}}function y(T){if(!H$(T))throw new Error(ia(7));if(typeof T.type>"u")throw new Error(ia(8));if(typeof T.type!="string")throw new Error(ia(17));if(u)throw new Error(ia(9));try{u=!0,s=r(s,T)}finally{u=!1}return(i=a).forEach(E=>{E()}),T}function v(T){if(typeof T!="function")throw new Error(ia(10));r=T,y({type:Z3.REPLACE})}function S(){const T=g;return{subscribe(L){if(typeof L!="object"||L===null)throw new Error(ia(11));function E(){const P=L;P.next&&P.next(p())}return E(),{unsubscribe:T(E)}},[Y3](){return this}}}return y({type:Z3.INIT}),{dispatch:y,subscribe:g,getState:p,replaceReducer:v,[Y3]:S}}function J3(e,t){return function(...n){return t(e.apply(this,n))}}function e6(e,t){if(typeof e=="function")return J3(e,t);if(typeof e!="object"||e===null)throw new Error(ia(16));const n={};for(const r in e){const s=e[r];typeof s=="function"&&(n[r]=J3(s,t))}return n}function UA(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function U$(...e){return t=>(n,r)=>{const s=t(n,r);let i=()=>{throw new Error(ia(15))};const a={getState:s.getState,dispatch:(u,...f)=>i(u,...f)},c=e.map(u=>u(a));return i=UA(...c)(s.dispatch),{...s,dispatch:i}}}var Wx={exports:{}},Vx={};var t6;function z$(){if(t6)return Vx;t6=1;var e=Bg();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Vx.useSyncExternalStoreWithSelector=function(u,f,p,g,y){var v=s(null);if(v.current===null){var S={hasValue:!1,value:null};v.current=S}else S=v.current;v=a(function(){function T(F){if(!L){if(L=!0,E=F,F=g(F),y!==void 0&&S.hasValue){var j=S.value;if(y(j,F))return D=j}return D=F}if(j=D,n(E,F))return j;var A=g(F);return y!==void 0&&y(j,A)?(E=F,j):(E=F,D=A)}var L=!1,E,D,P=p===void 0?null:p;return[function(){return T(f())},P===null?void 0:function(){return T(P())}]},[f,p,g,y]);var C=r(u,v[0],v[1]);return i(function(){S.hasValue=!0,S.value=C},[C]),c(C),C},Vx}var n6;function G$(){return n6||(n6=1,Wx.exports=z$()),Wx.exports}G$();var W$=x.version.startsWith("19"),V$=Symbol.for(W$?"react.transitional.element":"react.element"),q$=Symbol.for("react.portal"),K$=Symbol.for("react.fragment"),Y$=Symbol.for("react.strict_mode"),X$=Symbol.for("react.profiler"),Z$=Symbol.for("react.consumer"),J$=Symbol.for("react.context"),zA=Symbol.for("react.forward_ref"),eH=Symbol.for("react.suspense"),tH=Symbol.for("react.suspense_list"),ov=Symbol.for("react.memo"),nH=Symbol.for("react.lazy"),rH=zA,sH=ov;function iH(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case V$:switch(e=e.type,e){case K$:case X$:case Y$:case eH:case tH:return e;default:switch(e=e&&e.$$typeof,e){case J$:case zA:case nH:case ov:return e;case Z$:return e;default:return t}}case q$:return t}}}function oH(e){return iH(e)===ov}function aH(e,t,n,r,{areStatesEqual:s,areOwnPropsEqual:i,areStatePropsEqual:a}){let c=!1,u,f,p,g,y;function v(E,D){return u=E,f=D,p=e(u,f),g=t(r,f),y=n(p,g,f),c=!0,y}function S(){return p=e(u,f),t.dependsOnOwnProps&&(g=t(r,f)),y=n(p,g,f),y}function C(){return e.dependsOnOwnProps&&(p=e(u,f)),t.dependsOnOwnProps&&(g=t(r,f)),y=n(p,g,f),y}function T(){const E=e(u,f),D=!a(E,p);return p=E,D&&(y=n(p,g,f)),y}function L(E,D){const P=!i(D,f),F=!s(E,u,D,f);return u=E,f=D,P&&F?S():P?C():F?T():y}return function(D,P){return c?L(D,P):v(D,P)}}function lH(e,{initMapStateToProps:t,initMapDispatchToProps:n,initMergeProps:r,...s}){const i=t(e,s),a=n(e,s),c=r(e,s);return aH(i,a,c,e,s)}function cH(e,t){const n={};for(const r in e){const s=e[r];typeof s=="function"&&(n[r]=(...i)=>t(s(...i)))}return n}function B2(e){return function(n){const r=e(n);function s(){return r}return s.dependsOnOwnProps=!1,s}}function r6(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function GA(e,t){return function(r,{displayName:s}){const i=function(c,u){return i.dependsOnOwnProps?i.mapToProps(c,u):i.mapToProps(c,void 0)};return i.dependsOnOwnProps=!0,i.mapToProps=function(c,u){i.mapToProps=e,i.dependsOnOwnProps=r6(e);let f=i(c,u);return typeof f=="function"&&(i.mapToProps=f,i.dependsOnOwnProps=r6(f),f=i(c,u)),f},i}}function av(e,t){return(n,r)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${r.wrappedComponentName}.`)}}function uH(e){return e&&typeof e=="object"?B2(t=>cH(e,t)):e?typeof e=="function"?GA(e):av(e,"mapDispatchToProps"):B2(t=>({dispatch:t}))}function dH(e){return e?typeof e=="function"?GA(e):av(e,"mapStateToProps"):B2(()=>({}))}function fH(e,t,n){return{...n,...e,...t}}function hH(e){return function(n,{displayName:r,areMergedPropsEqual:s}){let i=!1,a;return function(u,f,p){const g=e(u,f,p);return i?s(g,a)||(a=g):(i=!0,a=g),a}}}function pH(e){return e?typeof e=="function"?hH(e):av(e,"mergeProps"):()=>fH}function mH(e){e()}function gH(){let e=null,t=null;return{clear(){e=null,t=null},notify(){mH(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const s=t={callback:n,next:null,prev:t};return s.prev?s.prev.next=s:e=s,function(){!r||e===null||(r=!1,s.next?s.next.prev=s.prev:t=s.prev,s.prev?s.prev.next=s.next:e=s.next)}}}}var s6={notify(){},get:()=>[]};function WA(e,t){let n,r=s6,s=0,i=!1;function a(C){p();const T=r.subscribe(C);let L=!1;return()=>{L||(L=!0,T(),g())}}function c(){r.notify()}function u(){S.onStateChange&&S.onStateChange()}function f(){return i}function p(){s++,n||(n=t?t.addNestedSub(u):e.subscribe(u),r=gH())}function g(){s--,n&&s===0&&(n(),n=void 0,r.clear(),r=s6)}function y(){i||(i=!0,p())}function v(){i&&(i=!1,g())}const S={addNestedSub:a,notifyNestedSubs:c,handleChangeWrapper:u,isSubscribed:f,trySubscribe:y,tryUnsubscribe:v,getListeners:()=>r};return S}var xH=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bH=xH(),yH=()=>typeof navigator<"u"&&navigator.product==="ReactNative",vH=yH(),wH=()=>bH||vH?x.useLayoutEffect:x.useEffect,cg=wH();function i6(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function qx(e,t){if(i6(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(!Object.prototype.hasOwnProperty.call(t,n[s])||!i6(e[n[s]],t[n[s]]))return!1;return!0}var SH={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},AH={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},TH={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},VA={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},CH={[rH]:TH,[sH]:VA};function o6(e){return oH(e)?VA:CH[e.$$typeof]||SH}var kH=Object.defineProperty,_H=Object.getOwnPropertyNames,a6=Object.getOwnPropertySymbols,LH=Object.getOwnPropertyDescriptor,EH=Object.getPrototypeOf,l6=Object.prototype;function F2(e,t){if(typeof t!="string"){if(l6){const i=EH(t);i&&i!==l6&&F2(e,i)}let n=_H(t);a6&&(n=n.concat(a6(t)));const r=o6(e),s=o6(t);for(let i=0;i<n.length;++i){const a=n[i];if(!AH[a]&&!(s&&s[a])&&!(r&&r[a])){const c=LH(t,a);try{kH(e,a,c)}catch{}}}}return e}var IH=Symbol.for("react-redux-context"),RH=typeof globalThis<"u"?globalThis:{};function NH(){if(!x.createContext)return{};const e=RH[IH]??=new Map;let t=e.get(x.createContext);return t||(t=x.createContext(null),e.set(x.createContext,t)),t}var qA=NH(),MH=[null,null];function DH(e,t,n){cg(()=>e(...t),n)}function jH(e,t,n,r,s,i){e.current=r,n.current=!1,s.current&&(s.current=null,i())}function PH(e,t,n,r,s,i,a,c,u,f,p){if(!e)return()=>{};let g=!1,y=null;const v=()=>{if(g||!c.current)return;const C=t.getState();let T,L;try{T=r(C,s.current)}catch(E){L=E,y=E}L||(y=null),T===i.current?a.current||f():(i.current=T,u.current=T,a.current=!0,p())};return n.onStateChange=v,n.trySubscribe(),v(),()=>{if(g=!0,n.tryUnsubscribe(),n.onStateChange=null,y)throw y}}function BH(e,t){return e===t}function FH(e,t,n,{pure:r,areStatesEqual:s=BH,areOwnPropsEqual:i=qx,areStatePropsEqual:a=qx,areMergedPropsEqual:c=qx,forwardRef:u=!1,context:f=qA}={}){const p=f,g=dH(e),y=uH(t),v=pH(n),S=!!e;return T=>{const L=T.displayName||T.name||"Component",E=`Connect(${L})`,D={shouldHandleStateChanges:S,displayName:E,wrappedComponentName:L,WrappedComponent:T,initMapStateToProps:g,initMapDispatchToProps:y,initMergeProps:v,areStatesEqual:s,areStatePropsEqual:a,areOwnPropsEqual:i,areMergedPropsEqual:c};function P(A){const[H,Q,K]=x.useMemo(()=>{const{reactReduxForwardedRef:Be,...fe}=A;return[A.context,Be,fe]},[A]),W=x.useMemo(()=>{let Be=p;return H?.Consumer,Be},[H,p]),de=x.useContext(W),X=!!A.store&&!!A.store.getState&&!!A.store.dispatch,pe=!!de&&!!de.store,ye=X?A.store:de.store,Ae=pe?de.getServerState:ye.getState,ie=x.useMemo(()=>lH(ye.dispatch,D),[ye]),[V,z]=x.useMemo(()=>{if(!S)return MH;const Be=WA(ye,X?void 0:de.subscription),fe=Be.notifyNestedSubs.bind(Be);return[Be,fe]},[ye,X,de]),ce=x.useMemo(()=>X?de:{...de,subscription:V},[X,de,V]),ge=x.useRef(void 0),he=x.useRef(K),Ce=x.useRef(void 0),xe=x.useRef(!1),ae=x.useRef(!1),Le=x.useRef(void 0);cg(()=>(ae.current=!0,()=>{ae.current=!1}),[]);const Z=x.useMemo(()=>()=>Ce.current&&K===he.current?Ce.current:ie(ye.getState(),K),[ye,K]),Ze=x.useMemo(()=>fe=>V?PH(S,ye,V,ie,he,ge,xe,ae,Ce,z,fe):()=>{},[V]);DH(jH,[he,ge,xe,K,Ce,z]);let at;try{at=x.useSyncExternalStore(Ze,Z,Ae?()=>ie(Ae(),K):Z)}catch(Be){throw Le.current&&(Be.message+=`
78
+ `),$t(Tt),gt(Tt,!1),un("Terminal session ended"),Be(!1),mt(!1),Cn(null),cn(null),Ve(Tt,!1),Ft();break}}},onError:(nt,Tt)=>{if(pn.current!==xt)return;const Hn=V;if(!Hn)return;const cr=Tt&&nt.message==="Authentication required",Pr=pQ(nt),ms=cr?nt.message:Pr||Tt?"Reconnecting...":nt.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${Tt}):`,ms),Pr&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:wn.current,frontendSessionId:Hn,isActive:a,isMobile:z,fatal:Tt,stack:new Error().stack}),un(ms),mt(!!Tt),Tt&&(Cn(null),gt(Hn,!1),Ft(),Pr&&(X("[onError] Session lost, auto-recreating"),un("Reconnecting..."),mt(!1),$t(Hn),We(Hn),wn.current=null,vr.current=!1,Kt()))}},YQ);Xt.current=()=>{At.close(),pn.current===xt&&(kr.current=null)},kr.current=De},[Wt,We,$t,X,Ft,T,hn,Kt,Ee,gt,Zn,En,Ve,An,yr,de,V]);M.useEffect(()=>{const De=uQ({isActive:a,isStreamReady:be,reconnectStartedAt:kn,now:Date.now()});if(De===null)return;const xt=window.setTimeout(()=>{X("[Terminal] visible reconnect watchdog expired",{backendSessionId:wn.current,reconnectStartedAt:kn}),Ft(),gt(V,!1),un("Reconnecting..."),mt(!1),Cn(Date.now()),Kt()},De);return()=>window.clearTimeout(xt)},[X,Ft,a,be,kn,Kt,V,gt]);const vr=M.useRef(!1),ar=M.useRef(!1),Wr=M.useRef(0);M.useEffect(()=>()=>{Wr.current+=1,vr.current=!1,Ft()},[Ft]);const Pn=M.useRef(Qt),hr=M.useRef(Et);M.useEffect(()=>{const De=Pn.current,xt=hr.current;Pn.current=Qt,hr.current=Et,Kr.current===V&&(De===Qt&&xt===Et||(vr.current=!1,Ft(),Ln(At=>At+1)))},[Qt,Et,Ft,V]),M.useEffect(()=>{if(Kr.current!==V&&(X(`[useEffect] sessionId changed from ${Kr.current} to ${V}, allowing reinitialization`),vr.current=!1,ar.current=!1),vr.current&&Kr.current===V){X(`[useEffect] Already initialized for sessionId=${V}, skipping`);return}const De=async Hn=>{if(X(`[ensureSession] Starting for sessionId=${V}, runId=${Hn}`),!Kr.current||Kr.current!==V){X(`[ensureSession] SessionId mismatch or stale run (current=${Kr.current}, target=${V}), skipping`);return}if(Hn!==Wr.current){X(`[ensureSession] Stale run detected (runId=${Hn}, currentRunId=${Wr.current}), skipping`);return}const cr=rs.getState(),Pr=cr.getTerminalSession(V),ms=Pr?.mode??Qt;X("[ensureSession] Current state from store:",{terminalSessionId:Pr?.terminalSessionId,mode:Pr?.mode,tmuxSessionName:Pr?.tmuxSessionName,isConnecting:Pr?.isConnecting});let mr=Pr?.terminalSessionId??null,Jr=!mr;if(mr&&ms!==Qt?(X(`[ensureSession] Store mode mismatch for ${mr}: current=${ms} desired=${Qt}, will create new session`),Jr=!0,cr.clearTerminalSession(V),mr=null):mr&&Qt==="tmux"&&Et&&Pr?.tmuxSessionName!==Et&&(X(`[ensureSession] Store tmux name mismatch for ${mr}: current=${Pr?.tmuxSessionName} desired=${Et}, will create new session`),Jr=!0,cr.clearTerminalSession(V),mr=null),mr&&de.checkHealth&&!qt.current){X(`[ensureSession] Checking health of existing session ${mr}`);try{const It=await de.checkHealth(mr);if(X("[ensureSession] Health check result:",It),!It.healthy)X(`[ensureSession] Session ${mr} is NOT healthy (healthy=${It.healthy}), will create new session`),X("[ensureSession] Health check details:",It),Jr=!0,It.mode&&Pr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Pr.terminalSessionId,cols:80,rows:24,mode:It.mode,tmuxSessionName:It.tmuxSessionName??null}),cr.clearTerminalSession(V),X("[ensureSession] Cleared unhealthy session from store");else{X(`[ensureSession] Session ${mr} is healthy, reusing it, cwd=${It.cwd}, clients=${It.clients}, lastActivity=${Date.now()-(It.lastActivity||0)}ms ago`),It.mode&&Pr?.terminalSessionId&&cr.setTerminalSession(V,{sessionId:Pr.terminalSessionId,cols:80,rows:24,mode:It.mode,tmuxSessionName:It.tmuxSessionName??null}),X(`[ensureSession] Setting terminalIdRef to ${mr} and starting stream`),wn.current=mr,xr(mr),X(`[ensureSession] Successfully reused healthy session ${mr}, returning early`);return}}catch(It){X(`[ensureSession] Failed to check health of session ${mr}:`,It),X("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(X(`[ensureSession] Decision: shouldCreateNewSession=${Jr}, terminalId=${mr}`),Jr){X(`[ensureSession] Creating new session, shouldCreateNewSession=${Jr}, runId=${Hn}`),un(null),mt(!1),cr.setConnecting(V,!0);const Lo=rs.getState().getTerminalSession(V),Ya=(Lo?.mode??Qt)===Qt&&(Qt!=="tmux"||!Et||Lo?.tmuxSessionName===Et);if(Lo?.terminalSessionId&&Ya)X(`[ensureSession] Race condition avoided: another instance already created session ${Lo.terminalSessionId}`),cr.setConnecting(V,!1),mr=Lo.terminalSessionId,Jr=!1;else try{const qs=await je();if(X(`[ensureSession] Opened managed backend session ${qs.sessionId}`),Hn!==Wr.current){X(`[ensureSession] Stale run after session creation (runId=${Hn}, currentRunId=${Wr.current}), leaving ${qs.sessionId} for sibling`);return}cr.setTerminalSession(V,qs),X(`[ensureSession] Updated store with new session ${qs.sessionId}`),mr=qs.sessionId}catch(qs){if(Hn!==Wr.current){X("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(qs instanceof qa&&E3(qs)){X("[ensureSession] Confirmed missing persisted session:",{sessionId:V,error:qs.message}),cr.clearTerminalSession(V),un(jx),mt(!0),cr.setConnecting(V,!1);return}un("Reconnecting..."),mt(!0),cr.setConnecting(V,!1);return}}if(Hn!==Wr.current){X(`[ensureSession] Stale run before starting stream (runId=${Hn}, currentRunId=${Wr.current}), skipping`);return}if(!mr){X(`[ensureSession] No terminalId, terminalId=${mr}`);return}X(`[ensureSession] Starting stream for session ${mr}`),wn.current=mr,xr(mr),X(`[ensureSession] ensureSession completed for sessionId=${V}, terminalId=${mr}`)};let xt=null,At=null;const nt=()=>{At=null,!(vr.current&&Kr.current===V)&&(X(`[useEffect] Running ensureSession for sessionId=${V}, hasInitialized=${vr.current}`),vr.current=!0,ar.current=!0,xt=++Wr.current,De(xt))};if(!v&&!ar.current){X(`[useEffect] Holding background connection until the selected session is ready: ${V}`);return}const Tt=ar.current?0:Math.max(0,y);return Tt>0?(X(`[useEffect] Delaying initial connection for sessionId=${V} by ${Tt}ms`),At=window.setTimeout(nt,Tt)):nt(),()=>{At!==null&&window.clearTimeout(At),X(`[useEffect] Cleanup for sessionId=${V}, runId=${xt??"pending"}`)}},[V,Rt,xr,Ft,de,X,Qt,Et,Tn,y,v]);const lr=M.useCallback(async()=>{if(V&&!ln){en(!0),un(null),mt(!1),Cn(null),Ft();try{de.forceKill&&await de.forceKill({sessionId:V})}catch{}ct(V),We(V),rt.current?.clear(),await new Promise(De=>setTimeout(De,100));try{gt(V,!0);const De=await je();dt(V,De),wn.current=De.sessionId,xr(De.sessionId)}catch(De){un(De instanceof qa&&E3(De)?jx:"Reconnecting..."),mt(!0),gt(V,!1)}finally{en(!1)}}},[V,ln,Ft,de,ct,We,gt,dt,xr,je]),Fs=M.useCallback((De,xt)=>{if(!qt.current||!De)return;const At=CO(De),nt=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(De);if(Se&&nt&&(Ht.current=!0),Date.now()<Vt.current)return;let Tt=De,Hn=xt?.consumeModifier??!1;if(!xt?.skipModifierTransform&&Ye&&De.length>0){const ms=De[0];if(ms.length===1&&/[a-zA-Z]/.test(ms)){const mr=ms.toUpperCase();Ye==="ctrl"?(Tt=String.fromCharCode(mr.charCodeAt(0)&31),Hn=!0):Ye==="alt"&&(Tt=`\x1B${De}`,Hn=!0)}Hn||(Ye==="alt"&&(Tt=`\x1B${De}`),Hn=!0)}const cr=wn.current;if(!cr)return;(async()=>{try{if(Se&&!At&&Ht.current&&de.tmuxAction){Ht.current=!1;try{await de.tmuxAction(cr,{action:"copy-mode",enabled:!1})}catch{}if(kO(Tt))return}await de.sendInput(cr,Tt),Fn(V)}catch(ms){un(ms instanceof Error?ms.message:"Failed to send input")}})(),Hn&&(q||et(null),yt())},[Ye,Fn,yt,Se,q,de]);M.useEffect(()=>{const De=xt=>{if(!qt.current)return;const At=xt,nt=At.detail?.text;if(!nt)return;const Tt=At.detail?.nonce;if(nr.current){Tt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Tt,ok:!1}}));return}rt.current?.sendSequence(nt,{paste:At.detail?.paste}),Tt&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:Tt,ok:!0}})),bO(Kn.current,At.detail?.focus!==!1)&&yt()};return window.addEventListener("termdock-insert-reference",De),()=>window.removeEventListener("termdock-insert-reference",De)},[yt]);const Mr=M.useCallback((De,xt)=>{const At=wn.current;if(!At){pe("xterm resize push skipped: no terminalId",{cols:De,rows:xt});return}pe("xterm resize push",{cols:De,rows:xt}),de.resize({sessionId:At,cols:De,rows:xt}).catch(nt=>{nt&&/session not found/i.test(String(nt.message||nt))&&console.warn("[Terminal] resize 404 session not found",{sessionId:At,cols:De,rows:xt,stack:new Error().stack})})},[de,pe]),is=M.useCallback(async De=>{const xt=wn.current;if(!(!xt||!de.tmuxAction))try{const At=await de.tmuxAction(xt,De);At.layout&&(cn(At.layout),De.action==="switch-session"&&(dt(V,{sessionId:xt,cols:80,rows:24,mode:"tmux",tmuxSessionName:At.layout.sessionName}),_m(V,{tmuxSessionName:At.layout.sessionName}).catch(nt=>{console.warn("[Terminal] failed to update inventory after tmux switch",nt)})))}catch(At){un(At instanceof Error?At.message:"Failed to execute tmux action")}},[V,dt,de]);M.useEffect(()=>{if(!qn||!Ie)return;const xt=qn.windows.find(At=>At.id===qn.activeWindowId)?.panes.find(At=>At.id===qn.activePaneId);xt&&rt.current?.requestRefresh("tmux-layout",{candidateSize:{cols:xt.width,rows:xt.height},skipScrollToBottom:!0,dedupeKey:`${Ie}:${qn.sessionId}:${xt.id}:${xt.width}x${xt.height}`})},[qn,Ie]);const wi=M.useCallback((De,xt=5)=>{const At=Math.max(1,Math.min(Math.floor(xt)||1,40));Ht.current=!0;const nt=bn.current;if(nt&&nt.direction===De){nt.lines+=At;return}nt&&is({action:"scroll",direction:nt.direction,lines:nt.lines}).finally(()=>{yt()}),bn.current={direction:De,lines:At},Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>{const Tt=bn.current;Tt&&(bn.current=null,is({action:"scroll",direction:Tt.direction,lines:Tt.lines}).finally(()=>{yt()}))},0)},[yt,is]),Ho=M.useCallback(De=>{const xt=Date.now(),At=St.current,nt=At!==null&&At.modifier===De&&xt-At.timestamp<=KQ;if(St.current={modifier:De,timestamp:xt},q===De){ue(null),et(null);return}if(nt){ue(De),et(De);return}q!==null&&q!==De&&ue(null),et(Tt=>Tt===De?null:De)},[q]),Lr=M.useCallback(De=>{if(Le(De&&qt.current),pe("input focus changed",{focused:De,isActive:qt.current,isMobile:Kn.current}),!Kn.current||!qt.current){xe(!1);return}xe(xt=>xt===De?xt:De)},[pe]),ks=M.useCallback(De=>{if(Bt.current=De,hn(De,"viewport-watermark"),!De&&st.current.length>0){const xt=V;if(xt){const At=st.current;st.current=[];for(const nt of At)Wt(xt,nt)}}},[Wt,hn,V]),Xi=M.useCallback(De=>{qt.current&&rt.current?.ensureSizeMatches(De)},[]),Ii=M.useRef(null);M.useEffect(()=>{if(!a)return;const De=Ii.current;if(!De)return;const xt=()=>Xi("pointerdown"),At=()=>Xi("keydown"),nt=()=>Xi("touchstart"),Tt=()=>Xi("wheel");return De.addEventListener("pointerdown",xt),De.addEventListener("keydown",At),De.addEventListener("touchstart",nt,{passive:!0}),De.addEventListener("wheel",Tt,{passive:!0}),()=>{De.removeEventListener("pointerdown",xt),De.removeEventListener("keydown",At),De.removeEventListener("touchstart",nt),De.removeEventListener("wheel",Tt)}},[a,Xi]);const Ka=M.useCallback(De=>{rt.current=De},[]),di=M.useCallback(De=>{L?.(V,De)},[L,V]),Os=M.useCallback(De=>{const xt=BO(De);if(!xt)return;const At=Ye!==null;rt.current?.sendSequence(xt,{consumeModifier:At})},[Ye]),Ms=M.useCallback(De=>{const xt=NO(De);if(xt.length===0)return;const At=Ye!==null;rt.current?.sendSequence(A3(xt[0]),{consumeModifier:At});for(let nt=1;nt<xt.length;nt+=1){const Tt=xt[nt];window.setTimeout(()=>{rt.current?.sendSequence(A3(Tt))},RO*nt)}},[Ye]),Zi=M.useCallback(()=>{rt.current?.pasteClipboardText()},[]),Qs=M.useCallback(De=>{dr.current!==null&&(window.clearTimeout(dr.current),dr.current=null),Zt(De),(De==="inserted"||De==="failed")&&(dr.current=window.setTimeout(()=>{dr.current=null,Zt("idle")},1400))},[]),Vr=M.useCallback(()=>{Qs("idle"),$n(0),jr.current?.click()},[Qs]),pr=M.useCallback(De=>{const xt=De.currentTarget.files?.[0];De.currentTarget.value="",xt&&($n(0),Qs("uploading"),xA(xt,(At,nt)=>Yb(At,nt,void 0,$n),At=>{if(!qt.current||nr.current)throw new Error("Terminal unavailable");window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:gA(At,null),focus:!0}}))}).then(()=>Qs("inserted"),()=>Qs("failed")))},[Qs]),fi=Nt||Jt!==null;nr.current=fi;const _s=M.useRef(Br);fi||(_s.current=Br);const hi=fi?_s.current:Br,wr=M.useMemo(()=>MO(hi,Nr),[hi,Nr]),Ji=M.useMemo(()=>C3(Nr,Ge),[Ge,Nr]),Er=!z&&Ge!=="auto"&&Ji.showOnDesktop!==!0?"auto":Ge,Gs=Er==="auto"?wr:Er,Ur=M.useMemo(()=>C3(Nr,Gs),[Gs,Nr]),eo=M.useMemo(()=>Ur.actions.filter(De=>De.sequence.trim().length>0).map((De,xt)=>({...De,label:y2(De,xt)})),[Ur.actions]),to=M.useMemo(()=>oA(Br),[Br]),Ls=Ur.label,$s=M.useMemo(()=>Er!=="auto"?`Manual preset: ${Ur.label}`:to?`Auto preset · ${Ur.label} (${to})`:"Auto preset",[to,Er,Ur.label]),Sa=M.useCallback(De=>{Fe(De)},[]),Aa=M.useCallback(()=>{it(De=>De==="copy"?"arrows":"copy"),vt("idle")},[]),Ta=M.useCallback(()=>{typeof window>"u"||(Jn.current!==null&&window.clearTimeout(Jn.current),Jn.current=window.setTimeout(()=>{Jn.current=null,vt("idle")},1200))},[]),Tl=M.useCallback(De=>{Jn.current!==null&&typeof window<"u"&&(window.clearTimeout(Jn.current),Jn.current=null),vt(De?"copied":"failed"),Ta()},[Ta]),ds=M.useCallback(De=>{Ne(De)},[]),Ws=M.useMemo(()=>z?DO(Nr):jO(Nr),[z,Nr]),Ri=M.useMemo(()=>hO(s),[s]),Co=M.useMemo(()=>`terminal::${V}`,[V]);M.useEffect(()=>{H?.({isConnecting:Nt,isRestarting:ln,hasError:!!Jt,sessionId:Ie})},[Nt,ln,Jt,Ie,H]);const no=!Ie||Nt||ln,Ca=M.useCallback((De,xt)=>{if(no)return;const At=Math.max(1,Math.min(Math.floor(xt)||1,40));wi(De,At)},[wi,no]);M.useEffect(()=>{if(!a||!z)return;rt.current?.requestRefresh("resize",{skipScrollToBottom:!fe,force:!0})},[a,z,fe,Ke,V]),M.useEffect(()=>{if(!a||!z)return;const De=xt=>{const At=xt.detail;rt.current?.requestRefresh("resize",{skipScrollToBottom:At?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",De),()=>{document.removeEventListener("termdock:viewport-keyboard-change",De)}},[a,z,V]);const ro=!D&&(z||Ur.showOnDesktop===!0),ko=a,Vs=z&&!F?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Hs=z&&!F?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,ni=o.jsx(FO,{visible:ro,interactive:ko,presentation:z?"mobile":"desktop-actions",activeModifier:Ye,lockedModifier:q,disabled:no,defaultShowExtended:Xe,presetLabel:Ls,presetModeLabel:$s,presetMode:Er,presetOptions:Ws,includeAlt:Ur.includeAlt,presetRowLayout:Ur.rowLayout,extraActions:eo,onKeyPress:Os,onTextPress:Ms,onPastePress:z?Zi:void 0,onFilePress:z?Vr:void 0,fileUploadState:Gt,fileUploadProgress:an,longPressMode:ft,copyFeedback:Mt,onLongPressModeToggle:Aa,onModifierToggle:Ho,onPresetSelect:Sa,onExpandedChange:ds}),_o=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return o.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:Vs,children:[o.jsx("input",{ref:jr,type:"file",className:"hidden",onChange:pr}),rr&&o.jsx(OO,{isMobile:z,isInputFocused:Ce,isIOS:ge,isConnecting:Nt,connectionError:Jt,terminalSessionId:Ie}),o.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Ri.background,...Hs},children:[o.jsx("div",{ref:Ii,className:"h-full w-full box-border",children:o.jsx(sA,{fallback:o.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:o.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Q("terminal.componentFailed")})]})}),children:o.jsx(uO,{ref:Ka,sessionKey:Co,chunks:te,onInput:Fs,onResize:Mr,onFlowControl:ks,onTmuxScroll:Se?Ca:void 0,tmuxScrollSensitivity:.38,onDoubleTap:z?()=>{rt.current?.sendSequence(" ")}:void 0,onInputFocusChange:Lr,onMobileLongPressCopyResult:Tl,onReadyChange:di,onDirectoryLinkActivate:rn,terminalSettings:ie,theme:Ri,enableTouchScroll:z,mobileLongPressMode:ft,autoFocus:!z&&!_o},Co)})}),o.jsx($O,{connectionError:Jt,isFatalError:Oe,isRestarting:ln,isConnecting:Nt,onHardRestart:lr})]}),P?D?null:ui.createPortal(ni,P):ni]})},ZQ=1e3,JQ=2e4,e$=9e4,t$=5e3,qr={ws:null,listeners:new Set,reconnectAttempt:0,reconnectTimer:null,idleCloseTimer:null,closing:!1};let em=0,S0=null;function n$(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/control/ws`}function RA(){qr.idleCloseTimer&&(clearTimeout(qr.idleCloseTimer),qr.idleCloseTimer=null)}function r$(){RA(),!(qr.ws&&qr.ws.readyState===WebSocket.OPEN)&&(qr.idleCloseTimer=setTimeout(()=>{qr.idleCloseTimer=null,qr.listeners.size===0&&s$()},t$))}function s$(){if(qr.ws){try{qr.ws.close()}catch{}qr.ws=null}S0&&(clearInterval(S0),S0=null)}function $3(){if(qr.reconnectTimer)return;const e=Math.min(ZQ*Math.pow(2,qr.reconnectAttempt),JQ);qr.reconnectAttempt+=1,qr.reconnectTimer=setTimeout(()=>{qr.reconnectTimer=null,NA()},e)}function NA(){const e=n$();if(!e||qr.ws&&qr.ws.readyState===WebSocket.OPEN)return;let t;try{t=new WebSocket(e)}catch{$3();return}qr.ws=t,t.onopen=()=>{qr.reconnectAttempt=0,em=Date.now(),S0||(S0=setInterval(()=>{if(!(!qr.ws||qr.ws.readyState!==WebSocket.OPEN)&&em>0&&Date.now()-em>e$)try{qr.ws.close()}catch{}},3e4),S0.unref?.())},t.onmessage=n=>{em=Date.now();let r=null;try{r=JSON.parse(n.data)}catch{return}if(!r)return;if(r.type==="update-state"){const a=r.state;if(!a||typeof a.status!="string"||typeof a.currentVersion!="string")return;const c={type:"update-state",state:a};for(const u of qr.listeners)try{u(c)}catch(f){console.error("[clientStateSync] listener threw:",f)}return}if(r.type==="context-draft"){if(typeof r.text!="string")return;const a={type:"context-draft",text:r.text,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:Date.now(),origin:typeof r.origin=="string"?r.origin:null};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type==="pinned-explorer-roots"){if(!r.pinnedExplorerRoots||typeof r.pinnedExplorerRoots!="object"||Array.isArray(r.pinnedExplorerRoots))return;const a={type:"pinned-explorer-roots",pinnedExplorerRoots:r.pinnedExplorerRoots,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:Date.now(),origin:typeof r.origin=="string"?r.origin:null};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type==="config-updated"){if(r.key!=="toolbar-presets"&&r.key!=="agent-rules"&&r.key!=="program-detection")return;const a={type:"config-updated",key:r.key,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0};for(const c of qr.listeners)try{c(a)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(r.type!=="client-state"||!r.state)return;const s=r.state,i={type:"client-state",clientState:{sessions:Array.isArray(s.sessions)?s.sessions:[],updatedAt:typeof s.updatedAt=="number"?s.updatedAt:Date.now()},inventory:r.inventory,seq:typeof r.seq=="number"?r.seq:void 0};for(const a of qr.listeners)try{a(i)}catch(c){console.error("[clientStateSync] listener threw:",c)}},t.onclose=()=>{qr.ws===t&&(qr.ws=null),qr.listeners.size>0&&$3()},t.onerror=()=>{}}function Th(e){return qr.listeners.add(e),RA(),qr.ws||NA(),()=>{qr.listeners.delete(e),qr.listeners.size===0&&r$()}}function MA(e,t,n){const r=e.findIndex(s=>n(s)===t);return r<0?null:e[r+1]?n(e[r+1]):r>0?n(e[r-1]):null}const Ux="termdock-sessions",I2="termdock-active-session",iv="termdock-sessions-cache";function R2(){try{const e=localStorage.getItem(I2);return e&&e.trim().length>0?e:null}catch{return null}}function Yd(e){try{e?localStorage.setItem(I2,e):localStorage.removeItem(I2)}catch{}}function DA(){if(typeof window>"u")return null;try{const e=localStorage.getItem(iv);if(!e)return null;const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null&&typeof n.sessionId=="string"&&typeof n.name=="string"):null}catch{return null}}function Qu(e){if(!(typeof window>"u"))try{localStorage.setItem(iv,JSON.stringify(e))}catch{}}function H3(){if(!(typeof window>"u"))try{localStorage.removeItem(iv)}catch{}}function jA(e){return e.map(t=>({...t,mode:t.mode==="tmux"?"tmux":"shell",tmuxSessionName:t.tmuxSessionName??null,customName:t.customName===!0}))}function U3(e){return jA(e.map(t=>({sessionId:t.sessionId,name:t.name,customName:t.customName===!0,backendSessionId:t.backendSessionId,mode:t.mode,tmuxSessionName:t.tmuxSessionName,createdAt:t.createdAt,lastActivity:t.lastActivity}))).map((t,n)=>({...t,activeProgram:e[n]?.activeProgram??null,cwd:e[n]?.cwd??null}))}function z3(e){return e.map(t=>`${t.sessionId}:${t.name}:${t.customName}:${t.backendSessionId}:${t.mode}:${t.tmuxSessionName}:${t.lastActivity}:${t.activeProgram??""}:${t.cwd??""}`).join("|")}function N2(e,t){return e.length===0?null:t&&e.some(n=>n.sessionId===t)?t:e[0]?.sessionId??null}function i$(){const e=DA()??[];return{sessions:e,activeSessionId:N2(e,R2())}}function o$(){const e=x.useRef(DA()).current,t=x.useRef(R2()).current,[n,r]=x.useState(e??[]),[s,i]=x.useState(null),[a,c]=x.useState(e&&e.length>0?N2(e,t):t),[u,f]=x.useState(e===null),p=x.useRef(!1),g=x.useRef(null),y=x.useRef(e===null),v=x.useRef(0),S=x.useRef(new Set),C=x.useRef(0);x.useEffect(()=>{y.current=u},[u]),x.useEffect(()=>{g.current=a},[a]);const T=x.useCallback(pe=>{const ye=N2(pe,g.current??R2());return c(Ae=>Ae===ye?Ae:ye),Yd(ye),g.current=ye,ye},[]),L=x.useCallback((pe,ye)=>{const Ae=pe.filter(ie=>!S.current.has(ie.sessionId));r(ie=>z3(ie)===z3(Ae)?ie:Ae),Qu(Ae),ye?.reconcileActive&&T(Ae)},[T]),E=x.useCallback((pe,ye)=>{const Ae=S.current.size===0?pe:{...pe,clientSessions:pe.clientSessions.filter(ie=>!S.current.has(ie.sessionId))};i(Ae),L(U3(Ae.clientSessions),ye)},[L]),D=x.useCallback(()=>typeof window>"u"?[]:localStorage.getItem(Ux)?(localStorage.removeItem(Ux),H3(),Yd(null),r([]),c(null),console.info("[session-persist] discarded legacy local session cache"),[]):[],[]),P=x.useCallback(async()=>{if(typeof window>"u")return[];const pe=C.current;try{const ye=await fI(),Ae=U3(ye.clientSessions);return pe!==C.current?(console.info("[session-inventory] ignored restore snapshot superseded by a local mutation"),Ae.filter(ie=>!S.current.has(ie.sessionId))):(E(ye,{reconcileActive:!0}),Ae.length>0?Ae:D())}catch(ye){console.error("Failed to restore sessions from server:",ye);try{return D()}catch(Ae){console.error("Failed to discard legacy local sessions:",Ae)}}finally{f(!1)}return[]},[E,D]),F=x.useCallback(async pe=>{const ye=++C.current,Ae=await $7(pe);return ye===C.current&&(E(Ae.inventory),c(Ae.session.sessionId),Yd(Ae.session.sessionId)),Ae},[E]),j=x.useCallback(async(pe,ye)=>{++C.current,S.current.add(pe),r(Ae=>{const ie=Ae.filter(ce=>ce.sessionId!==pe),V=ye!=null&&ie.some(ce=>ce.sessionId===ye),z=g.current===pe?V?ye:MA(Ae,pe,ce=>ce.sessionId):g.current;return c(z),Yd(z),Qu(ie),ie});try{await pI(pe)}catch(Ae){console.error("Failed to remove session from inventory:",Ae)}},[]),A=x.useCallback(pe=>{const ye=Date.now();r(Ae=>{const ie=Ae.map(V=>V.sessionId===pe?{...V,lastActivity:ye}:V);return Qu(ie),ie})},[]),H=x.useCallback(pe=>{c(pe),Yd(pe)},[]),Q=x.useCallback(async(pe,ye)=>{const Ae=ye.trim();if(!Ae)return;const ie=++C.current;r(V=>{const z=V.map(ce=>ce.sessionId===pe?{...ce,name:Ae,customName:!0}:ce);return Qu(z),z});try{const V=await _m(pe,{name:Ae,customName:!0});ie===C.current&&E(V)}catch(V){console.error("Failed to rename session in inventory:",V)}},[E]),K=x.useCallback(async pe=>{const ye=++C.current;r(Ae=>{const ie=Ae.map(V=>V.sessionId===pe?{...V,customName:!1}:V);return Qu(ie),ie});try{const Ae=await _m(pe,{customName:!1});ye===C.current&&E(Ae)}catch(Ae){console.error("Failed to reset session name in inventory:",Ae)}},[E]),W=x.useCallback(async pe=>{const ye=++C.current;r(Ae=>{const ie=new Map(Ae.map(he=>[he.sessionId,he])),V=pe.map(he=>ie.get(he)).filter(he=>he!==void 0),z=new Set(pe),ce=Ae.filter(he=>!z.has(he.sessionId)),ge=[...V,...ce];return Qu(ge),ge});try{const Ae=await hI(pe);ye===C.current&&E(Ae)}catch(Ae){console.error("Failed to reorder sessions in inventory:",Ae)}},[E]),de=x.useCallback(async()=>{++C.current;for(const pe of n)S.current.add(pe.sessionId);r([]),i(null),c(null),Yd(null),H3(),typeof window<"u"&&localStorage.removeItem(Ux);try{await mI()}catch(pe){console.error("Failed to clear session inventory:",pe)}},[n]),X=x.useCallback(async(pe,ye)=>{const Ae=++C.current;r(ie=>{const V=ie.map(z=>z.sessionId===pe?{...z,backendSessionId:ye}:z);return Qu(V),V});try{const ie=await _m(pe,{backendSessionId:ye});Ae===C.current&&E(ie)}catch(ie){console.error("Failed to update session backend in inventory:",ie)}},[E]);return x.useEffect(()=>{p.current||(p.current=!0,P())},[P]),x.useEffect(()=>Th(ye=>{if(ye.type!=="client-state"||y.current)return;const Ae=typeof ye.seq=="number"?ye.seq:null;if(Ae!==null){if(Ae<v.current){console.warn("[session-inventory] ignored stale control snapshot",{seq:Ae,latestSeq:v.current});return}v.current=Ae}if(ye.inventory){E(ye.inventory,{reconcileActive:!0});return}const ie=jA(ye.clientState.sessions||[]);L(ie,{reconcileActive:!0})}),[E,L]),{sessions:n,inventory:s,activeSessionId:a,isLoading:u,openSession:F,removeSession:j,updateSessionActivity:A,setActiveSession:H,updateSessionBackendId:X,renameSession:Q,resetSessionCustomName:K,reorderSessions:W,clearAllSessions:de,restoreSessions:P}}const PA=5*6e4,a$=12,l$=3e4;function c$(e){const t=new Set([...e.currentVisibleSessionIds].filter(a=>e.validSessionIds.has(a))),n=e.idleMs??PA,s=Math.max(t.size*2,e.maxSessions??a$)-t.size;return s===0||[...e.lastVisitedAtBySessionId].filter(([a,c])=>e.validSessionIds.has(a)&&!t.has(a)&&Number.isFinite(c)&&e.now-c<n).sort((a,c)=>c[1]-a[1]).slice(0,s).map(([a])=>a).forEach(a=>t.add(a)),t}const u$="termdock:startup:";function hh(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${u$}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function d$(e,t){e||ui.flushSync(t)}const M2="horizontal";function $c(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function BA(e,t){if(!Array.isArray(e)||e.length!==t)return $c(t);const n=e.map(Number);if(n.some(s=>!Number.isFinite(s)||s<=0))return $c(t);const r=n.reduce((s,i)=>s+i,0);return r<=0?$c(t):n.map(s=>s/r)}function f$(e){return e==="horizontal"||e==="vertical"||e==="grid"}function h$(e){if(!Array.isArray(e))return[];const t=new Set,n=new Set,r=[];for(const s of e){if(!s||typeof s!="object")continue;const i=s;if(typeof i.id!="string"||!i.id||n.has(i.id))continue;const a=Array.isArray(i.sessionIds)?i.sessionIds.filter(u=>typeof u=="string"&&!!u&&!t.has(u)):[],c=[...new Set(a)];c.length<2||(c.forEach(u=>t.add(u)),n.add(i.id),r.push({id:i.id,...typeof i.name=="string"&&i.name.trim()?{name:i.name.trim().slice(0,80)}:{},sessionIds:c,layout:f$(i.layout)?i.layout:M2,ratios:BA(i.ratios,c.length)}))}return r}function p$(e,t){const n=new Set(t);return e.flatMap(r=>{const s=r.sessionIds.filter(i=>n.has(i));return s.length<2?[]:[{...r,sessionIds:s,ratios:s.length===r.sessionIds.length?BA(r.ratios,s.length):$c(s.length)}]})}function Ch(e,t){if(t)return e.find(n=>n.sessionIds.includes(t))}function zx(e,t,n){if(!t||!n||t===n)return e;const r=Ch(e,t),s=Ch(e,n);if(r&&r.id===s?.id)return e;const i=[...r?.sessionIds??[t],...s?.sessionIds??[n]],a=[...new Set(i)],c={id:r?.id??`split:${t}`,...r?.name?{name:r.name}:{},sessionIds:a,layout:a.length>2&&(!r||r.layout===M2)?"grid":r?.layout??M2,ratios:$c(a.length)},u=new Set([r?.id,s?.id].filter(Boolean)),f=e.filter(g=>!u.has(g.id)),p=r?Math.max(0,e.findIndex(g=>g.id===r.id)):f.length;return f.splice(Math.min(p,f.length),0,c),f}function m$(e,t){const n=Ch(e,t);if(!n||!t)return e;if(n.sessionIds.length<=2)return e.filter(s=>s.id!==n.id);const r=n.sessionIds.filter(s=>s!==t);return e.map(s=>s.id===n.id?{...s,sessionIds:r,ratios:$c(r.length)}:s)}function g$(e,t){const n=Ch(e,t);return n?e.filter(r=>r.id!==n.id):e}function x$(e,t,n){return e.map(r=>{if(r.id!==t)return r;const s=[...new Set(n)],i=new Set(r.sessionIds);return s.length===r.sessionIds.length&&s.every(c=>i.has(c))?{...r,sessionIds:s}:r})}function b$(e,t,n){const r=n.trim().slice(0,80);return e.map(s=>s.id===t?{...s,...r?{name:r}:{name:void 0}}:s)}const D2=320,FA=1,y$=D2+120,v$=48,w$=72,j2="termdock:split-workspaces:v2",OA="termdock:split-workspace:v1",S$=.1,A$=.9,T$=.28,C$=300,k$=8,_$=280,L$=160;function Gx(){if(typeof window>"u")return{mobile:!1,landscape:!1};const t=(navigator.maxTouchPoints>0||"ontouchstart"in window)&&Math.min(window.innerWidth,window.innerHeight)<768;return{mobile:t,landscape:t&&window.innerWidth>window.innerHeight}}function E$(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(j2);if(e)return h$(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(OA)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const n=Math.min(A$,Math.max(S$,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[n,1-n]}]}}catch{}return[]}function I$(e,t){const n=new Map(e.map(a=>[a.id,a])),r=new Map;t.forEach(a=>a.sessionIds.forEach(c=>r.set(c,a)));const s=new Set,i=[];for(const a of e){const c=r.get(a.id);if(!c){i.push({key:a.id,sessions:[a]});continue}if(s.has(c.id))continue;s.add(c.id);const u=c.sessionIds.flatMap(f=>{const p=n.get(f);return p?[p]:[]});u.length>=2&&i.push({key:c.id,sessions:u,workspace:c})}return i}function G3(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(n=>n.cancel())}catch{}}function tm(e,t){const n=lg(e,t);if(n===null)return;const r=e.wrapperEl;G3(e),r&&(r.style.transitionDuration="0ms");try{const s=e;s.setTransition?.(0),s.setTranslate?.(n),G3(e),r&&(r.style.transitionDuration="0ms",r.style.transform=`translate3d(${n}px, 0px, 0px)`)}catch{r&&(r.style.transitionDuration="0ms",r.style.transform=`translate3d(${n}px, 0px, 0px)`)}}function P2(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function lg(e,t){const n=e.snapGrid,r=Array.isArray(n)?n[t]:void 0;return typeof r!="number"||!Number.isFinite(r)?null:-r}function R$(e,t){const n=P2(e),r=lg(e,t);return n!==null&&r!==null&&Math.abs(n-r)<=FA}function N$(e){const t=[],n=new Map,r=new Map,s=new Map;for(const i of e){const a=n.get(i.id)??[];if(a.push(i.id),n.set(i.id,a),i.sessionId){const c=r.get(i.sessionId)??[];c.push(i.id),r.set(i.sessionId,c)}if(i.mode==="tmux"&&i.tmuxSessionName){const c=s.get(i.tmuxSessionName)??[];c.push(i.id),s.set(i.tmuxSessionName,c)}}for(const[i,a]of n)a.length>1&&t.push({kind:"frontend",key:i,sessionIds:a});for(const[i,a]of r)a.length>1&&t.push({kind:"backend",key:i,sessionIds:a});for(const[i,a]of s)a.length>1&&t.push({kind:"tmux",key:i,sessionIds:a});return t}function QA(e){const t=new Map;for(const n of e)t.set(n.id,n);return Array.from(t.values())}function $A(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function M$(e,t){const n=QA(e),r=n.findIndex(s=>s.id===t.id);if(r>=0){const s=[...n];return s[r]=t,s}return[...n,t]}function W3(e,t){const n=new Map(e.map(r=>[r.id,r]));return t.map(r=>{const s=n.get(r.sessionId);return{...$A(r),history:s?.history}})}function V3(e,t){return e.length===0?null:t&&e.some(n=>n.sessionId===t)?t:e[0]?.sessionId??null}function q3(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function K3(e){const t=new Map;for(const[n,r]of e)t.set(n,r.cwd??null);return t}function D$(e,t){if(e.size!==t.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0}function j$(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const n=Date.now().toString(36),r=Math.random().toString(36).slice(2,8);return`wt-${n}${r}`}const P$=({terminalSettings:e=Jy(),colorTheme:t="dark",toolbarPresets:n=[],showDebug:r,terminalFocusAvailable:s=!0,defaultSessionMode:i="shell",defaultTmuxSessionName:a="",connectionPrioritySessionId:c=null,connectionPriorityReady:u=!0,onStatusChange:f,onSessionDataUpdate:p})=>{const{t:g}=Vn(),y=x.useMemo(()=>cd("session"),[]),v=x.useMemo(()=>cd("terminal"),[]),[S,C]=x.useState([]),[T,L]=x.useState(null),[E,D]=x.useState(!0),[P,F]=x.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[j,A]=x.useState(()=>new Set),[H,Q]=x.useState(0),[K,W]=x.useState(()=>new Set),[de,X]=x.useState(()=>new Set),[pe,ye]=x.useState(()=>new Map),Ae=x.useRef(!1),ie=x.useRef(null),V=x.useRef({}),[z,ce]=x.useState(null),[ge,he]=x.useState(()=>E$()),[Ce,xe]=x.useState(!1),[ae,Le]=x.useState(null),[Z,Ze]=x.useState(null),[at,He]=x.useState(null),[be,Be]=x.useState(!1),[fe,Ke]=x.useState(()=>Gx().mobile),[Ye,et]=x.useState(()=>Gx().landscape),[q,ue]=x.useState(null),[Xe,Ne]=x.useState(null),Ge=x.useRef(s),Fe=x.useRef(!1),ft=x.useRef(null),it=x.useRef(null),Mt=x.useRef(fe),vt=x.useRef(null),Gt=x.useRef(0),Zt=x.useRef([]),an=x.useRef(0),$n=x.useRef(null),we=x.useRef(!1),dt=x.useRef(!0),gt=x.useRef(null),Wt=x.useRef(""),ht=x.useRef(null),$t=x.useRef(0);x.useEffect(()=>{if(typeof window>"u")return;const re=()=>{const Ee=Gx();Mt.current=Ee.mobile,Ke(Ee.mobile),et(Ee.landscape)};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]);const{sessions:ct,inventory:We,activeSessionId:Zn,isLoading:An,openSession:Ve,setActiveSession:En,removeSession:jt,renameSession:yr,resetSessionCustomName:Fn,reorderSessions:Tn,restoreSessions:Rr}=o$(),gr=We?.tmuxRecovery??null;x.useEffect(()=>{He(null),Ze(null)},[gr?.id]);const Br=x.useCallback(async()=>{Ze("restore"),He(null);try{const re=await cI();await Rr(),re.failed>0&&He(g("tab.tmuxRecoveryPartial",{restored:re.restored,failed:re.failed}))}catch{He(g("tab.tmuxRecoveryFailed"))}finally{Ze(null)}},[Rr,g]),Nr=x.useCallback(async()=>{Ze("dismiss"),He(null);try{await uI(),await Rr()}catch{He(g("tab.tmuxRecoveryDismissFailed"))}finally{Ze(null)}},[Rr,g]),Se=ut(re=>re.groupByFolder),te=ut(re=>re.leftOpen||re.rightOpen),[Nt,Ie]=x.useState(()=>K3(rs.getState().sessions));x.useEffect(()=>rs.subscribe(re=>{const Ee=K3(re.sessions);Ie(Qe=>D$(Qe,Ee)?Qe:Ee)}),[]);const{arranged:rn}=x.useMemo(()=>rA(S,re=>Nt.get(re.id)??null,Se,""),[S,Nt,Se]),Qt=x.useRef(rn);Qt.current=rn;const Et=x.useMemo(()=>I$(rn,ge),[rn,ge]),Jt=x.useRef(Et);Jt.current=Et;const un=x.useMemo(()=>Ch(ge,T),[T,ge]),nr=x.useMemo(()=>{const re=Et.find(Ee=>Ee.sessions.some(Qe=>Qe.id===T));return new Set(re?.sessions.map(Ee=>Ee.id)??[])},[T,Et]);x.useEffect(()=>{if(!fe)return;const re=()=>{const Qe=Date.now(),je=new Set(Zt.current.map(bt=>bt.id));ye(bt=>{const yt=new Map;for(const[Ut,Kt]of bt)je.has(Ut)&&(nr.has(Ut)||Qe-Kt<PA)&&yt.set(Ut,Kt);return nr.forEach(Ut=>yt.set(Ut,Qe)),yt})};re();const Ee=window.setInterval(re,l$);return()=>window.clearInterval(Ee)},[nr,fe]);const Oe=x.useMemo(()=>fe?c$({currentVisibleSessionIds:nr,lastVisitedAtBySessionId:pe,validSessionIds:new Set(S.map(re=>re.id)),now:Date.now()}):nr,[nr,fe,pe,S]),mt=x.useMemo(()=>Dx(S.map(re=>({id:re.id,backendSessionId:re.sessionId})),c),[c,S]),ln=x.useMemo(()=>V3(ct,Zn),[Zn,ct]),en=Xp({prioritySessionId:mt,activeSessionId:T,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null}),kn=x.useMemo(()=>dQ(Et.flatMap(re=>re.sessions.map(Ee=>Ee.id)),nr),[nr,Et]),Cn=en!==null&&j.has(en),Rt=x.useCallback((re,Ee)=>{A(Qe=>{if(Qe.has(re)===Ee)return Qe;const bt=new Set(Qe);return Ee?bt.add(re):bt.delete(re),bt})},[]),Ln=x.useCallback(re=>{const Ee=mt??vt.current;re===Ee&&(hh("foreground-stream-connected"),Q(Gt.current))},[mt]),qn=x.useCallback((re,Ee)=>{W(Qe=>{if(Qe.has(re)===Ee)return Qe;const je=new Set(Qe);return Ee?je.add(re):je.delete(re),je})},[]),cn=en!==null&&K.has(en);x.useEffect(()=>{cn&&hh("foreground-viewport-ready")},[cn]),x.useEffect(()=>{if(!cn||fe)return;const Ee=Et.flatMap(Qe=>Qe.sessions.map(je=>je.id)).filter(Qe=>Qe!==en).map((Qe,je)=>window.setTimeout(()=>{X(bt=>{if(bt.has(Qe))return bt;const yt=new Set(bt);return yt.add(Qe),je===0&&hh("background-viewports-started"),yt})},v$+je*w$));return()=>Ee.forEach(Qe=>window.clearTimeout(Qe))},[en,cn,fe,Et]),x.useEffect(()=>{typeof window>"u"||(ge.length>0?(window.localStorage.setItem(j2,JSON.stringify(ge)),window.localStorage.removeItem(OA)):window.localStorage.removeItem(j2))},[ge]),x.useEffect(()=>{An||E||ge.length===0||he(re=>p$(re,S.map(Ee=>Ee.id)))},[An,E,S,ge.length]),x.useEffect(()=>{if(!ae)return;const re=window.setTimeout(()=>Le(null),3200);return()=>window.clearTimeout(re)},[ae]),x.useEffect(()=>()=>ht.current?.(),[]),vt.current=T,Gt.current=P.token,Zt.current=S,$n.current=Zn,we.current=An,dt.current=E,Ge.current=s;const rr=x.useCallback((re=ie.current)=>{const Ee=an.current,Qe=typeof window<"u"?window.visualViewport:null,je=re?P2(re):null,bt=re?lg(re,Ee):null;return{sessionsLength:Zt.current.length,workspaceSlidesLength:Jt.current.length,sessionIds:Zt.current.map(yt=>yt.id),activeSessionId:vt.current,activeSessionIndex:Ee,persistedActiveId:$n.current,isLoading:we.current,isRestoring:dt.current,activeIndex:re?.activeIndex??null,previousIndex:re?.previousIndex??null,animating:re?.animating??null,allowTouchMove:re?.allowTouchMove??null,width:re?.width??null,translate:je,targetTranslate:bt,translateDelta:je!==null&&bt!==null?je-bt:null,snapGridLength:re?.snapGrid?.length??null,targetSnap:re?.snapGrid?.[Ee]??null,visualViewport:Qe?{width:Math.round(Qe.width),height:Math.round(Qe.height),offsetTop:Math.round(Qe.offsetTop)}:null}},[]),Xt=x.useCallback((re,Ee)=>{y(re,{...rr(),...Ee})},[y,rr]);x.useEffect(()=>{An||E||T!==Zn&&En(T)},[T,An,E,Zn,En]);const kr=x.useMemo(()=>{if(rn.length===0||!T)return 0;const re=Et.findIndex(Ee=>Ee.sessions.some(Qe=>Qe.id===T));return re>=0?re:0},[Et,T]);an.current=kr;const wn=x.useCallback(()=>{ft.current&&(clearTimeout(ft.current),ft.current=null)},[]),Kr=x.useCallback(re=>{wn(),ft.current=setTimeout(()=>{ft.current=null,Fe.current=!1,Xt("[swiper:touch-guard-clear]",{reason:re})},y$)},[wn,Xt]),rt=x.useCallback((re,Ee={})=>{const Qe=ie.current,je=an.current,bt=Jt.current;if(!Qe||bt.length===0||je<0||je>=bt.length)return;if(Fe.current){Xt("[swiper:sync-skip-touch]",{reason:re});return}if(Qe.animating){Xt("[swiper:sync-skip-animating]",{reason:re});return}const yt=P2(Qe),Ut=lg(Qe,je),Kt=yt!==null&&Ut!==null&&Math.abs(yt-Ut)<=FA,nn=Qe.activeIndex===je;if(Xt("[swiper:sync-check]",{reason:re,activeIndexAligned:nn,translateAligned:Kt,immediate:Ee.immediate===!0}),!(nn&&Kt)){if(nn){tm(Qe,je),Xt("[swiper:sync-forced-active]",{reason:re,translateAligned:Kt,immediate:Ee.immediate===!0});return}Ee.immediate?(tm(Qe,je),Qe.slideTo(je,0,!1),tm(Qe,je)):Qe.slideTo(je,D2,!1),Xt("[swiper:sync-applied]",{reason:re,activeIndexAligned:nn,translateAligned:Kt,immediate:Ee.immediate===!0})}},[Xt]);x.useEffect(()=>{const re=Ee=>{const Qe=Ee;ie.current&&(ie.current.allowTouchMove=!Qe.detail.locked),Xt("[swiper:gesture-lock]",{locked:Qe.detail.locked})};return document.addEventListener("termdock:gesture-lock",re),()=>document.removeEventListener("termdock:gesture-lock",re)},[Xt]),x.useEffect(()=>{if(S.length===0){T!==null&&L(null);return}if(!T){if(!u)return;L(Xp({prioritySessionId:mt,activeSessionId:null,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null}));return}S.some(Ee=>Ee.id===T)||L(S[0].id)},[S,T,u,mt,ln]);const Bt=x.useCallback((re,Ee)=>{if(Ee&&Date.now()<$t.current){V.current[re]=!1;return}V.current[re]=Ee,Ne(Qe=>Ee?re:Qe===re?null:Qe)},[]),$e=x.useCallback(re=>{if(!Fe.current&&re.activeIndex!==an.current){Xt("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:re.activeIndex,expectedActiveIndex:an.current}),requestAnimationFrame(()=>rt("ignored-layout-slide-change",{immediate:!0}));return}const Ee=Jt.current[re.activeIndex],Qe=Ee?.sessions.some(yt=>yt.id===T)?T:Ee?.sessions[0]?.id;if(Xt("[swiper:slide-change]",{nextSessionId:Qe??null,instanceActiveIndex:re.activeIndex}),!Qe||Qe===T)return;const je=!!T&&V.current[T]===!0,bt=Ge.current&&(!Mt.current||je);if(it.current=Qe,L(Qe),bt){ce({sessionId:Qe,token:Date.now()});return}ce(null)},[S,T,Xt,rt]);x.useEffect(()=>{if(it.current===T){Xt("[swiper:sync-skip-swiper-driven]",{activeSessionId:T}),it.current=null;return}rt("active-session-index",{immediate:!0})},[T,kr,S.length,rt,Xt]),x.useEffect(()=>{const re=ie.current;if(!re)return;const Ee=Et.length>1&&!te&&!Ce;re.allowTouchMove!==Ee&&(re.allowTouchMove=Ee,Xt("[swiper:allow-touch-sync]",{nextAllow:Ee,sidebarOverlayOpen:te}))},[Et.length,Xt,te,Ce]);const st=x.useCallback(re=>{const Ee=ie.current;if(!Ee)return;const Qe=Ee.el;if(Xt("[swiper:layout-before]",{reason:re,scrollLeft:Qe?.scrollLeft??null}),Qe&&(Qe.scrollLeft=0),Ee.updateSize(),Ee.updateSlides(),Ee.updateProgress(),Ee.updateSlidesClasses(),Qe&&(Qe.scrollLeft=0),Xt("[swiper:layout-after]",{reason:re,scrollLeft:Qe?.scrollLeft??null}),Fe.current||Ee.animating){Xt("[swiper:layout-skip-sync-motion]",{reason:re});return}rt(`layout:${re}`,{immediate:!0}),requestAnimationFrame(()=>{const je=ie.current;je&&(Fe.current||je.animating||tm(je,an.current))})},[Xt,rt]);x.useEffect(()=>()=>wn(),[wn]);const Vt=Et.map(re=>re.key).join("\0");x.useEffect(()=>{requestAnimationFrame(()=>st("group-change"))},[Se,Vt,st]),x.useEffect(()=>{let re=null,Ee="mount";const Qe=Kt=>{Ee=Kt,re===null&&(re=requestAnimationFrame(()=>{re=null,st(`viewport-change:${Ee}`)}))},je=()=>Qe("window-resize"),bt=()=>Qe("visual-viewport-resize"),yt=()=>Qe("visual-viewport-scroll"),Ut=Kt=>{Qe(`measured:${Kt.detail?.source??"unknown"}`)};return window.addEventListener("resize",je),window.visualViewport?.addEventListener("resize",bt),window.visualViewport?.addEventListener("scroll",yt),document.addEventListener(w2,Ut),Qe("mount"),()=>{window.removeEventListener("resize",je),window.visualViewport?.removeEventListener("resize",bt),window.visualViewport?.removeEventListener("scroll",yt),document.removeEventListener(w2,Ut),re!==null&&cancelAnimationFrame(re)}},[st]),x.useEffect(()=>{if(typeof document>"u")return;let re=null,Ee=null,Qe=document.hidden;const je=hn=>{if(hn!=="online"&&document.hidden)return;const Mn=performance.now();if(!lQ(Ee,Mn))return;Ee=Mn;const Wn=hn==="bfcache"||hn==="online"?hn:"visibility",fr=cQ({wasPageHidden:Qe,reason:hn});Qe=!1,Qa("info","PWA_RESUME scheduled",{source:hn,forceForegroundReconnect:fr,activeSessionId:vt.current}),F(xn=>({token:xn.token+1,reason:Wn,forceForegroundReconnect:fr})),requestAnimationFrame(()=>st(`resume:${hn}:raf`)),re&&clearTimeout(re),re=setTimeout(()=>{re=null,st(`resume:${hn}:settled`)},320)},bt=()=>{if(document.hidden){Qe=!0,B5();return}je("visibility")},yt=()=>{Qe=!0,B5()},Ut=hn=>{je(hn.persisted?"bfcache":"pageshow")},Kt=()=>je("online"),nn=()=>je("focus");return document.addEventListener("visibilitychange",bt),window.addEventListener("pagehide",yt),window.addEventListener("pageshow",Ut),window.addEventListener("online",Kt),window.addEventListener("focus",nn),()=>{document.removeEventListener("visibilitychange",bt),window.removeEventListener("pagehide",yt),window.removeEventListener("pageshow",Ut),window.removeEventListener("online",Kt),window.removeEventListener("focus",nn),re&&clearTimeout(re)}},[st]),x.useEffect(()=>{const re=N$(S),Ee=JSON.stringify(re);re.length>0&&Ee!==Wt.current?(Wt.current=Ee,console.warn("[session-invariant] duplicate mapping detected",re)):re.length===0&&Wt.current&&(Wt.current=""),p?.({sessions:S.map(Qe=>({id:Qe.id,name:Qe.name,customName:Qe.customName,mode:Qe.mode,tmuxSessionName:Qe.tmuxSessionName})),activeSessionId:T,splitWorkspaces:ge.map(({id:Qe,name:je,sessionIds:bt,layout:yt})=>({id:Qe,...je?{name:je}:{},sessionIds:bt,layout:yt}))})},[S,T,ge,p]),x.useEffect(()=>{if(An||Ae.current)return;Ae.current=!0;const re=Dx(ct.map(yt=>({id:yt.sessionId,backendSessionId:yt.backendSessionId??null})),c),Ee=V3(ct,Zn),Qe=Xp({prioritySessionId:u?re:null,activeSessionId:null,persistedActiveSessionId:Ee,firstSessionId:ct[0]?.sessionId??null}),je=QA(ct.map($A));if(y("[Session] Restoring",je.length,"persisted sessions (one-shot)"),Xt("[swiper:restore-start]",{persistedSessionIds:ct.map(yt=>yt.sessionId),nextActiveSessionId:Qe}),je.length>0){const yt=rs.getState();je.forEach(Kt=>{Kt.sessionId&&yt.setTerminalSession(Kt.id,{sessionId:Kt.sessionId,cols:80,rows:24,mode:Kt.mode,tmuxSessionName:Kt.tmuxSessionName,history:Kt.history})}),ct.forEach(Kt=>{Kt.activeProgram!=null&&yt.setSessionActiveProgram(Kt.sessionId,Kt.activeProgram),Kt.cwd!=null&&yt.setSessionCwd(Kt.sessionId,Kt.cwd)}),C(je);const Ut=Qe||je[0]?.id||null;L(Ut),Xt("[swiper:restore-complete]",{restoredSessionIds:je.map(Kt=>Kt.id),nextActiveSessionId:Ut})}(async()=>(je.length===0&&await gt.current?.({createIfEmpty:!0}),D(!1),requestAnimationFrame(()=>rt("restore-finished",{immediate:!0}))))()},[An,ct,Zn,y,Xt,rt,u,c]),x.useEffect(()=>{if(!u||E||S.length===0)return;const re=Dx(S.map(Qe=>({id:Qe.id,backendSessionId:Qe.sessionId})),c),Ee=Xp({prioritySessionId:re,activeSessionId:vt.current,persistedActiveSessionId:ln,firstSessionId:S[0]?.id??null});Ee&&Ee!==vt.current&&L(Ee)},[u,c,E,ln,S]);const Ht=x.useRef([]),bn=x.useRef(!1);vt.current=T,x.useEffect(()=>{if(E)return;const re=Ht.current,Ee=ct;if(!bn.current){C(nn=>W3(nn,Ee)),Ht.current=Ee,bn.current=!0;return}const Qe=new Set(re.map(nn=>nn.sessionId)),je=new Set(Ee.map(nn=>nn.sessionId)),bt=new Map(re.map(nn=>[nn.sessionId,nn.name]));Ht.current=Ee,C(nn=>{const hn=W3(nn,Ee);return(!vt.current||!hn.some(Mn=>Mn.id===vt.current))&&L(hn[0]?.id??null),hn});const yt=Ee.filter(nn=>!Qe.has(nn.sessionId)),Ut=[...Qe].filter(nn=>!je.has(nn)),Kt=Ee.filter(nn=>Qe.has(nn.sessionId)&&bt.get(nn.sessionId)!==nn.name);(yt.length>0||Ut.length>0||Kt.length>0)&&y("[Session] Synced persisted sessions:",{newSessionIds:yt.map(nn=>nn.sessionId),removedSessionIds:Ut,renamedSessionIds:Kt.map(nn=>nn.sessionId),currentSessionIds:Ee.map(nn=>nn.sessionId)});for(const nn of Ee){if(!nn.backendSessionId)continue;rs.getState().setTerminalSession(nn.sessionId,{sessionId:nn.backendSessionId,cols:80,rows:24,mode:nn.mode,tmuxSessionName:nn.tmuxSessionName})}},[ct,E,y]);const Re=x.useCallback(async re=>{try{const Ee=re?.mode==="tmux"||re?.mode==="shell"?re.mode:i,Qe=(re?.tmuxSessionName||"").trim(),je=a.trim(),bt=Ee==="tmux"?Qe||je||j$():null,yt=typeof re?.cwd=="string"?re.cwd:null,Ut=T?rs.getState().sessions.get(T)?.cwd??null:null,Kt=typeof yt=="string"&&yt.trim().length>0?yt:typeof Ut=="string"&&Ut.trim().length>0?Ut:void 0,nn=await Ve({mode:Ee,tmuxSessionName:bt,cwd:Kt,termType:"xterm-256color",createIfEmpty:re?.createIfEmpty===!0}),hn=nn.session,Mn=nn.terminalSession,Wn={id:hn.sessionId,name:hn.name,customName:hn.customName===!0,sessionId:Mn.sessionId,mode:Mn.mode??hn.mode,tmuxSessionName:Mn.tmuxSessionName??hn.tmuxSessionName};C(Fr=>M$(Fr,Wn)),L(Wn.id),rs.getState().setTerminalSession(Wn.id,{sessionId:Mn.sessionId,cols:80,rows:24,mode:Wn.mode,tmuxSessionName:Wn.tmuxSessionName,activeProgram:Mn.activeProgram,activeProgramRaw:Mn.activeProgramRaw,activeProgramSource:Mn.activeProgramSource,cwd:Mn.cwd}),y("[Session] Inventory opened session:",{frontendSessionId:Wn.id,backendSessionId:Mn.sessionId,reused:nn.reused,mode:Wn.mode,tmuxSessionName:Wn.tmuxSessionName});const xn=re?.command?.trim();return xn&&await F7(Mn.sessionId,`${xn}\r`),Wn.id}catch(Ee){return console.error("[Session] Failed to create new session:",Ee),null}},[i,a,T,Ve,y]);gt.current=Re;const Je=x.useCallback((re,Ee={})=>{const Qe=vt.current,je=!!Qe&&V.current[Qe]===!0;if(L(re),Mt.current&&Ee.preserveMobileKeyboard===!1){$t.current=Date.now()+600,Qe&&(V.current[Qe]=!1),Ne(null),ce(null);const bt=document.activeElement;bt instanceof HTMLTextAreaElement&&bt.closest(".terminal-viewport-container")&&bt.blur();return}je&&Mt.current&&Ne(re),Ge.current&&(!Mt.current||je)&&ce({sessionId:re,token:Date.now()})},[]),St=x.useCallback(re=>{L(re),xe(!0),Le(null)},[]),tn=x.useCallback(re=>{const Ee=vt.current;!Ee||Ee===re||(he(Qe=>zx(Qe,Ee,re)),xe(!1),Je(Ee,{preserveMobileKeyboard:!1}))},[Je]),Xn=x.useCallback(async()=>{const re=vt.current;if(!re||be)return;Be(!0);const Ee=rs.getState().sessions.get(re)?.cwd??void 0,Qe=await Re({cwd:Ee||void 0,mode:i});if(Be(!1),!Qe){Le(g("common.error"));return}he(je=>zx(je,re,Qe)),xe(!1),Je(re,{preserveMobileKeyboard:!1})},[Je,i,Re,be,g]),dn=x.useCallback(re=>{he(Ee=>g$(Ee,re)),re&&Je(re,{preserveMobileKeyboard:!1})},[Je]),pn=x.useCallback(re=>{he(Ee=>m$(Ee,re)),Je(re,{preserveMobileKeyboard:!1})},[Je]),qt=x.useCallback((re,Ee,Qe,je,bt)=>{re.preventDefault(),re.stopPropagation();const yt=re.currentTarget,Ut=re.pointerId,Kt={x:re.clientX,y:re.clientY};yt.setPointerCapture?.(Ut);const nn=Ee.getBoundingClientRect();let hn=!fe,Mn=null;const Wn=xn=>{if(xn.pointerId!==Ut)return;if(!hn){Math.hypot(xn.clientX-Kt.x,xn.clientY-Kt.y)>k$&&Mn!==null&&(window.clearTimeout(Mn),Mn=null);return}xn.preventDefault();const Fr=Qe?(xn.clientY-nn.top)/nn.height:(xn.clientX-nn.left)/nn.width,_r=Qe?nn.height:nn.width,fn=fe?0:Qe?L$:_$;he(Ft=>Ft.map(xr=>{if(xr.id!==je)return xr;const vr=xr.ratios.length===xr.sessionIds.length?[...xr.ratios]:$c(xr.sessionIds.length),ar=vr.slice(0,bt).reduce((lr,Fs)=>lr+Fs,0),Wr=vr[bt]+vr[bt+1],Pn=fn>0?Math.min(Wr/2,fn/Math.max(1,_r)):Math.min(Wr/2,T$),hr=Math.min(Wr-Pn,Math.max(Pn,Fr-ar));return vr[bt]=hr,vr[bt+1]=Wr-hr,{...xr,ratios:vr}}))},fr=()=>{Mn!==null&&(window.clearTimeout(Mn),Mn=null),window.removeEventListener("pointermove",Wn),window.removeEventListener("pointerup",fr),window.removeEventListener("pointercancel",fr),yt.classList.remove("bg-primary"),fe&&document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ht.current=null};ht.current?.(),ht.current=fr,window.addEventListener("pointermove",Wn),window.addEventListener("pointerup",fr),window.addEventListener("pointercancel",fr),fe&&(document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),Mn=window.setTimeout(()=>{Mn=null,hn=!0,yt.classList.add("bg-primary"),navigator.vibrate?.(8)},C$))},[fe]),Kn=x.useCallback(re=>{S.find(Qe=>Qe.id===re)&&(L(re),Ge.current&&!Mt.current&&ce({sessionId:re,token:Date.now()}),y("[Session] Switched to session:",re))},[S,y]),or=x.useCallback((re,Ee)=>{Ee.trim()&&(C(Qe=>Qe.map(je=>je.id===re?{...je,name:Ee.trim(),customName:!0}:je)),yr(re,Ee.trim()))},[yr]),_n=x.useCallback(re=>{C(Ee=>Ee.map(Qe=>Qe.id===re?{...Qe,customName:!1}:Qe)),Fn(re)},[Fn]),Ar=x.useCallback(re=>{C(Ee=>{const Qe=new Map(Ee.map(Ut=>[Ut.id,Ut])),je=re.map(Ut=>Qe.get(Ut)).filter(Ut=>Ut!==void 0),bt=new Set(re),yt=Ee.filter(Ut=>!bt.has(Ut.id));return[...je,...yt]}),Tn(re),y("[Session] Reordered sessions:",re),requestAnimationFrame(()=>{ie.current?.update()})},[Tn,y]),ts=x.useCallback(async re=>{const Ee=typeof re=="string"?re:re.sessionId,Qe=typeof re=="string"?"auto":re.closeMode??"auto",je=S.find(yt=>yt.id===Ee);if(!je)return;const bt=MA(rn,Ee,yt=>yt.id);try{Qe==="destroy"&&je.mode==="tmux"&&je.tmuxSessionName?(await Q7(je.tmuxSessionName),y("[Session] Destroyed tmux session:",{frontendSessionId:je.id,tmuxSessionName:je.tmuxSessionName})):je.sessionId&&(await O7(je.sessionId),y("[Session] Closed backend terminal:",je.sessionId))}catch(yt){console.error("[Session] Failed to close backend terminal:",yt);return}C(yt=>{const Ut=yt.filter(Kt=>Kt.id!==Ee);return L(bt),Ut}),jt(Ee,bt),delete V.current[Ee],y("[Session] Closed session:",{sessionId:Ee,closeMode:Qe})},[S,rn,jt,y]),Jn=x.useCallback(re=>{if(!re)return;const Ee=S.filter(Qe=>Qe.sessionId===re);if(Ee.length!==0){Ee.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:re,frontendSessionIds:Ee.map(Qe=>Qe.id)}),C(Qe=>{const je=Qe.filter(bt=>bt.sessionId!==re);return je.length!==Qe.length&&!je.some(yt=>yt.id===T)&&L(je.length>0?je[0].id:null),je});for(const Qe of Ee)jt(Qe.id),delete V.current[Qe.id];y("[Session] Backend gone, dropped local session(s):",Ee.map(Qe=>Qe.id))}},[S,T,jt,y]);x.useEffect(()=>{const re=fn=>{Re(fn.detail)},Ee=fn=>{Kn(fn.detail)},Qe=()=>{const fn=vt.current;!fn||Mt.current||ce({sessionId:fn,token:Date.now()})},je=fn=>{const Ft=fn;Ft.detail&&St(Ft.detail)},bt=fn=>{const Ft=fn.detail;dn(Ft??vt.current??void 0)},yt=fn=>{const Ft=fn.detail;Ft&&pn(Ft)},Ut=fn=>{const Ft=fn.detail,xr=typeof Ft=="string"?Ft:Ft?.layout,vr=typeof Ft=="string"?vt.current:Ft?.sessionId;xr!=="horizontal"&&xr!=="vertical"&&xr!=="grid"||he(ar=>ar.map(Wr=>Wr.sessionIds.includes(vr??"")?{...Wr,layout:xr}:Wr))},Kt=fn=>{const xr=fn.detail?.direction;if(xr!=="prev"&&xr!=="next")return;const vr=Qt.current;if(vr.length<=1)return;const ar=vt.current,Wr=ar?vr.findIndex(Mr=>Mr.id===ar):-1,lr=((Wr>=0?Wr:0)+(xr==="next"?1:-1)+vr.length)%vr.length,Fs=vr[lr]?.id;Fs&&Fs!==ar&&Kn(Fs)},nn=fn=>{ts(fn.detail)},hn=fn=>{Jn(fn.detail)},Mn=fn=>{const Ft=fn;!Ft.detail?.sessionId||!Ft.detail?.name||or(Ft.detail.sessionId,Ft.detail.name)},Wn=fn=>{const Ft=fn;Ft.detail?.sessionId&&_n(Ft.detail.sessionId)},fr=fn=>{const Ft=fn;Ft.detail?.sessionIds&&Ar(Ft.detail.sessionIds)},xn=fn=>{const Ft=fn.detail;!Ft?.workspaceId||!Array.isArray(Ft.sessionIds)||he(xr=>x$(xr,Ft.workspaceId,Ft.sessionIds))},Fr=fn=>{const Ft=fn.detail;!Ft?.workspaceId||typeof Ft.name!="string"||he(xr=>b$(xr,Ft.workspaceId,Ft.name))},_r=fn=>{const Ft=fn.detail;!Ft?.primaryId||!Ft.secondaryId||Ft.primaryId===Ft.secondaryId||(he(xr=>zx(xr,Ft.primaryId,Ft.secondaryId)),Je(Ft.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",re),window.addEventListener("switch-terminal-session",Ee),window.addEventListener("focus-active-terminal-session",Qe),window.addEventListener("open-terminal-split-chooser",je),window.addEventListener("close-terminal-split",bt),window.addEventListener("remove-terminal-split-pane",yt),window.addEventListener("set-terminal-split-direction",Ut),window.addEventListener("cycle-terminal-session",Kt),window.addEventListener("close-terminal-session",nn),window.addEventListener("close-terminal-session-by-backend",hn),window.addEventListener("rename-terminal-session",Mn),window.addEventListener("reset-terminal-session-name",Wn),window.addEventListener("reorder-terminal-session",fr),window.addEventListener("reorder-terminal-split-workspace",xn),window.addEventListener("rename-terminal-split-workspace",Fr),window.addEventListener("combine-terminal-split-sessions",_r),()=>{window.removeEventListener("new-terminal-session",re),window.removeEventListener("switch-terminal-session",Ee),window.removeEventListener("focus-active-terminal-session",Qe),window.removeEventListener("open-terminal-split-chooser",je),window.removeEventListener("close-terminal-split",bt),window.removeEventListener("remove-terminal-split-pane",yt),window.removeEventListener("set-terminal-split-direction",Ut),window.removeEventListener("cycle-terminal-session",Kt),window.removeEventListener("close-terminal-session",nn),window.removeEventListener("close-terminal-session-by-backend",hn),window.removeEventListener("rename-terminal-session",Mn),window.removeEventListener("reset-terminal-session-name",Wn),window.removeEventListener("reorder-terminal-session",fr),window.removeEventListener("reorder-terminal-split-workspace",xn),window.removeEventListener("rename-terminal-split-workspace",Fr),window.removeEventListener("combine-terminal-split-sessions",_r)}},[Je,Re,Kn,St,dn,pn,ts,Jn,or,_n,Ar]),x.useEffect(()=>{if(!un||fe)return;const re=Ee=>{if(!(Ee.ctrlKey||Ee.metaKey)||!Ee.shiftKey)return;if(un.layout==="horizontal"?Ee.key==="ArrowLeft"||Ee.key==="ArrowRight":un.layout==="vertical"?Ee.key==="ArrowUp"||Ee.key==="ArrowDown":Ee.key.startsWith("Arrow")){Ee.preventDefault(),Ee.stopPropagation();const je=un.sessionIds.indexOf(vt.current??""),bt=Ee.key==="ArrowLeft"||Ee.key==="ArrowUp"?-1:1,yt=(Math.max(0,je)+bt+un.sessionIds.length)%un.sessionIds.length,Ut=un.sessionIds[yt];if(!Ut)return;Je(Ut);return}Ee.key==="Backspace"&&(Ee.preventDefault(),Ee.stopPropagation(),dn(vt.current??void 0))};return window.addEventListener("keydown",re,!0),()=>window.removeEventListener("keydown",re,!0)},[Je,un,dn,fe]);const dr=re=>{const Ee=rs.getState().sessions.get(re.id);return Dc(re,Ee?.activeProgram??null,Ee?.cwd??null,void 0,Ee?.shellTitle??null,Ee?.promptState??null)},jr=(re,Ee={})=>{const Qe=re.id===T,je=u&&oQ({sessionId:re.id,foregroundSessionId:en,visibleSessionIds:Oe,deferredViewportSessionIds:de,isMobileLayout:fe}),bt=iQ({sessionId:re.id,foregroundSessionId:en,foregroundReady:Cn})&&u,yt=aQ({sessionId:re.id,foregroundSessionId:en,requestToken:P.token,foregroundCompletedToken:H})&&u,Ut=re.id===en?0:kn.get(re.id)??Bm;return o.jsx("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${Ee.hidden?"invisible pointer-events-none":""}`,style:Ee.containerStyle,"aria-hidden":Ee.hidden||void 0,onPointerDown:()=>{Qe||Je(re.id)},onWheelCapture:()=>{d$(Qe,()=>Je(re.id))},children:o.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:je&&o.jsx(XQ,{sessionId:re.id,mode:re.mode,tmuxSessionName:re.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:n,isActive:Qe,initialConnectEnabled:bt,resumeRequestEnabled:yt,suppressKeyboard:Ee.suppressKeyboard,keyboardPortalTarget:Ee.keyboardPortalTarget,sharedMobileKeyboardLayout:Ee.sharedMobileKeyboardLayout,suppressPageFlipRefresh:Ee.suppressPageFlipRefresh,focusRequestToken:z?.sessionId===re.id?z.token:0,resumeRequestToken:P.token,resumeRequestReason:P.reason,forceResumeReconnect:P.forceForegroundReconnect&&re.id===en,resumeRequestDelayMs:re.id===en?0:Ee.hidden?Bm:kn.get(re.id)??Bm,initialConnectDelayMs:Ut,onStreamReadyChange:Rt,onStreamConnected:Ln,onViewportReadyChange:qn,onKeyboardVisibilityChange:Bt,showDebug:r,onStatusChange:Qe?f:void 0})})},re.id)};return o.jsxs("div",{className:"relative h-full flex flex-col",children:[gr&&o.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:o.jsx(Vg,{size:18})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:g("tab.tmuxRecoveryTitle",{count:gr.sessions.length})}),o.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:g("tab.tmuxRecoveryHint")}),o.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:gr.sessions.map(re=>re.name).join(" · ")}),at&&o.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:at}),o.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[o.jsxs("button",{type:"button",disabled:Z!==null,onClick:()=>{Br()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[o.jsx(m8,{size:13,className:Z==="restore"?"animate-spin":""}),g(Z==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),o.jsx("button",{type:"button",disabled:Z!==null,onClick:()=>{Nr()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:g("tab.tmuxRecoveryDismiss")})]})]})]})}),o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsx($h,{onSwiper:re=>{ie.current=re,re.allowTouchMove=Et.length>1&&!te&&!Ce,Xt("[swiper:on-swiper]",{allowTouchMove:re.allowTouchMove}),requestAnimationFrame(()=>st("on-swiper"))},onSlideChange:$e,onTouchStart:(re,Ee)=>{const Qe=q3(Ee),je=Qe==="touch"||Qe==="pen"||Qe==="unknown";v("[swipe:touch-start]",{pointerType:Qe,allowed:je}),Xt("[swiper:touch-start]",{pointerType:Qe,allowed:je}),je&&(wn(),Fe.current=!0)},onTouchEnd:(re,Ee)=>{const Qe=q3(Ee),je=Qe==="touch"||Qe==="pen"||Qe==="unknown";v("[swipe:touch-end]",{pointerType:Qe,allowed:je}),Xt("[swiper:touch-end]",{pointerType:Qe,allowed:je}),je&&Kr("touch-end")},onTransitionEnd:()=>{const re=ie.current;if(Fe.current&&re&&!R$(re,an.current)){Xt("[swiper:transition-end-deferred]");return}wn(),Fe.current=!1,Xt("[swiper:transition-end]")},initialSlide:Math.max(0,kr),speed:D2,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"h-full",children:Et.map(re=>{const Ee=re.workspace,Qe=!!Ee&&re.sessions.length>=2,je=fe?Ye?"horizontal":"vertical":Ee?.layout??"horizontal",bt=je==="vertical",yt=Ee?.ratios.length===re.sessions.length?Ee.ratios:$c(re.sessions.length),Ut=Xe?re.sessions.findIndex(xn=>xn.id===Xe):-1,Kt=fe&&Xe?re.sessions.some(xn=>xn.id===Xe):!1,nn=re.sessions.some(xn=>xn.id===T)?T:re.sessions[0]?.id,hn=yt.flatMap((xn,Fr)=>[Kt&&Fr!==Ut?"0px":`minmax(0, ${xn}fr)`,...Fr<yt.length-1?[Kt?"0px":"1px"]:[]]).join(" "),Mn=Math.ceil(Math.sqrt(re.sessions.length)),Wn=re.sessions.length%Mn,fr={...je==="grid"?{gridTemplateColumns:`repeat(${Mn}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${Math.ceil(re.sessions.length/Mn)}, minmax(0, 1fr))`,gap:"1px"}:bt?{gridTemplateRows:hn}:{gridTemplateColumns:hn},...fe?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:{}};return o.jsx(od,{className:"h-full",children:Qe?o.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:fe?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[o.jsx("div",{"data-split-container":"true",className:"grid min-h-0 min-w-0 flex-1 overflow-hidden",style:fr,children:re.sessions.map((xn,Fr)=>o.jsxs(M.Fragment,{children:[jr(xn,{suppressKeyboard:fe&&xn.id!==nn,keyboardPortalTarget:fe?q:null,sharedMobileKeyboardLayout:fe,suppressPageFlipRefresh:!0,hidden:Kt&&Ut!==Fr,containerStyle:je==="grid"&&Wn>0&&Fr===re.sessions.length-1?{gridColumn:`span ${Mn-Wn+1}`}:void 0}),je!=="grid"&&Fr<re.sessions.length-1&&Ee&&o.jsx("button",{type:"button",className:`swiper-no-swiping relative z-20 touch-none select-none bg-[var(--border-strong)] transition-colors hover:bg-primary active:bg-primary ${bt?"cursor-row-resize":"cursor-col-resize"} ${Kt?"invisible pointer-events-none":""}`,onPointerDownCapture:_r=>{const fn=_r.currentTarget.closest('[data-split-container="true"]');fn instanceof HTMLDivElement&&qt(_r,fn,bt,Ee.id,Fr)},onDoubleClick:_r=>{fe||(_r.preventDefault(),_r.stopPropagation(),he(fn=>fn.map(Ft=>Ft.id===Ee.id?{...Ft,ratios:$c(Ft.sessionIds.length)}:Ft)))},onContextMenu:_r=>{fe&&_r.preventDefault()},"aria-label":g("tab.split"),children:o.jsx("span",{"aria-hidden":"true","data-split-divider-hitarea":"true",className:`absolute ${bt?"inset-x-0":"inset-y-0"}`,style:bt?{top:-12,bottom:-12}:{left:-12,right:-12}})})]},xn.id))}),fe&&o.jsx("div",{ref:ue,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):jr(re.sessions[0])},re.key)})})}),Ce&&T&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>xe(!1),"aria-label":g("common.close")}),o.jsxs("section",{className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":g("tab.splitTitle"),children:[o.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[o.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:o.jsx(b0,{size:17})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:g("tab.splitTitle")}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:g("tab.splitExistingHint")})]}),o.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>xe(!1),"aria-label":g("common.close"),children:o.jsx(es,{size:16})})]}),o.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[o.jsxs("button",{type:"button",disabled:be,onClick:()=>{Xn()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[o.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:o.jsx($o,{size:17})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:g("tab.splitNew")}),o.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:g("tab.splitNewHint")})]})]}),ge.filter(re=>re.id!==un?.id).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:g("tab.splitExistingGroups")}),ge.filter(re=>re.id!==un?.id).map((re,Ee)=>{const Qe=re.sessionIds.flatMap(yt=>{const Ut=S.find(Kt=>Kt.id===yt);return Ut?[Ut]:[]});if(Qe.length<2)return null;const je=re.name||`${g("tab.splitWorkspace")} ${Ee+1}`,bt=Qe.map(yt=>dr(yt).primary).join(" · ");return o.jsxs("button",{type:"button",onClick:()=>tn(Qe[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(b0,{size:15})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:je}),o.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:g("tab.splitOccupied")})]}),o.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[g("tab.sessionCount",{count:Qe.length})," · ",bt]})]}),o.jsx(va,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},re.id)})]}),o.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:g("tab.splitAvailableSessions")}),S.filter(re=>!ge.some(Ee=>Ee.sessionIds.includes(re.id))&&re.id!==T).length===0&&ge.filter(re=>re.id!==un?.id).length===0?o.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:g("tab.splitNoOtherSessions")}):S.filter(re=>!ge.some(Ee=>Ee.sessionIds.includes(re.id))&&re.id!==T).map(re=>{const Ee=Nt.get(re.id)??null,Qe=dr(re);return o.jsxs("button",{type:"button",onClick:()=>tn(re.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:Ee?o.jsx(bu,{size:15}):o.jsx(b0,{size:15})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:Qe.primary}),o.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:Ee?hc(Ee)??Ee:re.name})]}),o.jsx(va,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},re.id)})]})]})]}),ae&&o.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:ae})]})},B$={sm:"h-4 w-7",md:"h-6 w-10"},F$={sm:"h-3 w-3",md:"h-5 w-5"},O$={sm:"translate-x-3",md:"translate-x-4"};function jc({checked:e,disabled:t=!1,size:n="md",className:r=""}){return o.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${B$[n]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${r}`,children:o.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${F$[n]} ${e?O$[n]:""}`})})}function ia(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Q$=typeof Symbol=="function"&&Symbol.observable||"@@observable",Y3=Q$,X3=()=>Math.random().toString(36).substring(7).split("").join("."),$$={INIT:`@@redux/INIT${X3()}`,REPLACE:`@@redux/REPLACE${X3()}`},Z3=$$;function H$(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function HA(e,t,n){if(typeof e!="function")throw new Error(ia(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ia(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ia(1));return n(HA)(e,t)}let r=e,s=t,i=new Map,a=i,c=0,u=!1;function f(){a===i&&(a=new Map,i.forEach((T,L)=>{a.set(L,T)}))}function p(){if(u)throw new Error(ia(3));return s}function g(T){if(typeof T!="function")throw new Error(ia(4));if(u)throw new Error(ia(5));let L=!0;f();const E=c++;return a.set(E,T),function(){if(L){if(u)throw new Error(ia(6));L=!1,f(),a.delete(E),i=null}}}function y(T){if(!H$(T))throw new Error(ia(7));if(typeof T.type>"u")throw new Error(ia(8));if(typeof T.type!="string")throw new Error(ia(17));if(u)throw new Error(ia(9));try{u=!0,s=r(s,T)}finally{u=!1}return(i=a).forEach(E=>{E()}),T}function v(T){if(typeof T!="function")throw new Error(ia(10));r=T,y({type:Z3.REPLACE})}function S(){const T=g;return{subscribe(L){if(typeof L!="object"||L===null)throw new Error(ia(11));function E(){const P=L;P.next&&P.next(p())}return E(),{unsubscribe:T(E)}},[Y3](){return this}}}return y({type:Z3.INIT}),{dispatch:y,subscribe:g,getState:p,replaceReducer:v,[Y3]:S}}function J3(e,t){return function(...n){return t(e.apply(this,n))}}function e6(e,t){if(typeof e=="function")return J3(e,t);if(typeof e!="object"||e===null)throw new Error(ia(16));const n={};for(const r in e){const s=e[r];typeof s=="function"&&(n[r]=J3(s,t))}return n}function UA(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function U$(...e){return t=>(n,r)=>{const s=t(n,r);let i=()=>{throw new Error(ia(15))};const a={getState:s.getState,dispatch:(u,...f)=>i(u,...f)},c=e.map(u=>u(a));return i=UA(...c)(s.dispatch),{...s,dispatch:i}}}var Wx={exports:{}},Vx={};var t6;function z$(){if(t6)return Vx;t6=1;var e=Bg();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Vx.useSyncExternalStoreWithSelector=function(u,f,p,g,y){var v=s(null);if(v.current===null){var S={hasValue:!1,value:null};v.current=S}else S=v.current;v=a(function(){function T(F){if(!L){if(L=!0,E=F,F=g(F),y!==void 0&&S.hasValue){var j=S.value;if(y(j,F))return D=j}return D=F}if(j=D,n(E,F))return j;var A=g(F);return y!==void 0&&y(j,A)?(E=F,j):(E=F,D=A)}var L=!1,E,D,P=p===void 0?null:p;return[function(){return T(f())},P===null?void 0:function(){return T(P())}]},[f,p,g,y]);var C=r(u,v[0],v[1]);return i(function(){S.hasValue=!0,S.value=C},[C]),c(C),C},Vx}var n6;function G$(){return n6||(n6=1,Wx.exports=z$()),Wx.exports}G$();var W$=x.version.startsWith("19"),V$=Symbol.for(W$?"react.transitional.element":"react.element"),q$=Symbol.for("react.portal"),K$=Symbol.for("react.fragment"),Y$=Symbol.for("react.strict_mode"),X$=Symbol.for("react.profiler"),Z$=Symbol.for("react.consumer"),J$=Symbol.for("react.context"),zA=Symbol.for("react.forward_ref"),eH=Symbol.for("react.suspense"),tH=Symbol.for("react.suspense_list"),ov=Symbol.for("react.memo"),nH=Symbol.for("react.lazy"),rH=zA,sH=ov;function iH(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case V$:switch(e=e.type,e){case K$:case X$:case Y$:case eH:case tH:return e;default:switch(e=e&&e.$$typeof,e){case J$:case zA:case nH:case ov:return e;case Z$:return e;default:return t}}case q$:return t}}}function oH(e){return iH(e)===ov}function aH(e,t,n,r,{areStatesEqual:s,areOwnPropsEqual:i,areStatePropsEqual:a}){let c=!1,u,f,p,g,y;function v(E,D){return u=E,f=D,p=e(u,f),g=t(r,f),y=n(p,g,f),c=!0,y}function S(){return p=e(u,f),t.dependsOnOwnProps&&(g=t(r,f)),y=n(p,g,f),y}function C(){return e.dependsOnOwnProps&&(p=e(u,f)),t.dependsOnOwnProps&&(g=t(r,f)),y=n(p,g,f),y}function T(){const E=e(u,f),D=!a(E,p);return p=E,D&&(y=n(p,g,f)),y}function L(E,D){const P=!i(D,f),F=!s(E,u,D,f);return u=E,f=D,P&&F?S():P?C():F?T():y}return function(D,P){return c?L(D,P):v(D,P)}}function lH(e,{initMapStateToProps:t,initMapDispatchToProps:n,initMergeProps:r,...s}){const i=t(e,s),a=n(e,s),c=r(e,s);return aH(i,a,c,e,s)}function cH(e,t){const n={};for(const r in e){const s=e[r];typeof s=="function"&&(n[r]=(...i)=>t(s(...i)))}return n}function B2(e){return function(n){const r=e(n);function s(){return r}return s.dependsOnOwnProps=!1,s}}function r6(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function GA(e,t){return function(r,{displayName:s}){const i=function(c,u){return i.dependsOnOwnProps?i.mapToProps(c,u):i.mapToProps(c,void 0)};return i.dependsOnOwnProps=!0,i.mapToProps=function(c,u){i.mapToProps=e,i.dependsOnOwnProps=r6(e);let f=i(c,u);return typeof f=="function"&&(i.mapToProps=f,i.dependsOnOwnProps=r6(f),f=i(c,u)),f},i}}function av(e,t){return(n,r)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${r.wrappedComponentName}.`)}}function uH(e){return e&&typeof e=="object"?B2(t=>cH(e,t)):e?typeof e=="function"?GA(e):av(e,"mapDispatchToProps"):B2(t=>({dispatch:t}))}function dH(e){return e?typeof e=="function"?GA(e):av(e,"mapStateToProps"):B2(()=>({}))}function fH(e,t,n){return{...n,...e,...t}}function hH(e){return function(n,{displayName:r,areMergedPropsEqual:s}){let i=!1,a;return function(u,f,p){const g=e(u,f,p);return i?s(g,a)||(a=g):(i=!0,a=g),a}}}function pH(e){return e?typeof e=="function"?hH(e):av(e,"mergeProps"):()=>fH}function mH(e){e()}function gH(){let e=null,t=null;return{clear(){e=null,t=null},notify(){mH(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const s=t={callback:n,next:null,prev:t};return s.prev?s.prev.next=s:e=s,function(){!r||e===null||(r=!1,s.next?s.next.prev=s.prev:t=s.prev,s.prev?s.prev.next=s.next:e=s.next)}}}}var s6={notify(){},get:()=>[]};function WA(e,t){let n,r=s6,s=0,i=!1;function a(C){p();const T=r.subscribe(C);let L=!1;return()=>{L||(L=!0,T(),g())}}function c(){r.notify()}function u(){S.onStateChange&&S.onStateChange()}function f(){return i}function p(){s++,n||(n=t?t.addNestedSub(u):e.subscribe(u),r=gH())}function g(){s--,n&&s===0&&(n(),n=void 0,r.clear(),r=s6)}function y(){i||(i=!0,p())}function v(){i&&(i=!1,g())}const S={addNestedSub:a,notifyNestedSubs:c,handleChangeWrapper:u,isSubscribed:f,trySubscribe:y,tryUnsubscribe:v,getListeners:()=>r};return S}var xH=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bH=xH(),yH=()=>typeof navigator<"u"&&navigator.product==="ReactNative",vH=yH(),wH=()=>bH||vH?x.useLayoutEffect:x.useEffect,cg=wH();function i6(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function qx(e,t){if(i6(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++)if(!Object.prototype.hasOwnProperty.call(t,n[s])||!i6(e[n[s]],t[n[s]]))return!1;return!0}var SH={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},AH={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},TH={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},VA={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},CH={[rH]:TH,[sH]:VA};function o6(e){return oH(e)?VA:CH[e.$$typeof]||SH}var kH=Object.defineProperty,_H=Object.getOwnPropertyNames,a6=Object.getOwnPropertySymbols,LH=Object.getOwnPropertyDescriptor,EH=Object.getPrototypeOf,l6=Object.prototype;function F2(e,t){if(typeof t!="string"){if(l6){const i=EH(t);i&&i!==l6&&F2(e,i)}let n=_H(t);a6&&(n=n.concat(a6(t)));const r=o6(e),s=o6(t);for(let i=0;i<n.length;++i){const a=n[i];if(!AH[a]&&!(s&&s[a])&&!(r&&r[a])){const c=LH(t,a);try{kH(e,a,c)}catch{}}}}return e}var IH=Symbol.for("react-redux-context"),RH=typeof globalThis<"u"?globalThis:{};function NH(){if(!x.createContext)return{};const e=RH[IH]??=new Map;let t=e.get(x.createContext);return t||(t=x.createContext(null),e.set(x.createContext,t)),t}var qA=NH(),MH=[null,null];function DH(e,t,n){cg(()=>e(...t),n)}function jH(e,t,n,r,s,i){e.current=r,n.current=!1,s.current&&(s.current=null,i())}function PH(e,t,n,r,s,i,a,c,u,f,p){if(!e)return()=>{};let g=!1,y=null;const v=()=>{if(g||!c.current)return;const C=t.getState();let T,L;try{T=r(C,s.current)}catch(E){L=E,y=E}L||(y=null),T===i.current?a.current||f():(i.current=T,u.current=T,a.current=!0,p())};return n.onStateChange=v,n.trySubscribe(),v(),()=>{if(g=!0,n.tryUnsubscribe(),n.onStateChange=null,y)throw y}}function BH(e,t){return e===t}function FH(e,t,n,{pure:r,areStatesEqual:s=BH,areOwnPropsEqual:i=qx,areStatePropsEqual:a=qx,areMergedPropsEqual:c=qx,forwardRef:u=!1,context:f=qA}={}){const p=f,g=dH(e),y=uH(t),v=pH(n),S=!!e;return T=>{const L=T.displayName||T.name||"Component",E=`Connect(${L})`,D={shouldHandleStateChanges:S,displayName:E,wrappedComponentName:L,WrappedComponent:T,initMapStateToProps:g,initMapDispatchToProps:y,initMergeProps:v,areStatesEqual:s,areStatePropsEqual:a,areOwnPropsEqual:i,areMergedPropsEqual:c};function P(A){const[H,Q,K]=x.useMemo(()=>{const{reactReduxForwardedRef:Be,...fe}=A;return[A.context,Be,fe]},[A]),W=x.useMemo(()=>{let Be=p;return H?.Consumer,Be},[H,p]),de=x.useContext(W),X=!!A.store&&!!A.store.getState&&!!A.store.dispatch,pe=!!de&&!!de.store,ye=X?A.store:de.store,Ae=pe?de.getServerState:ye.getState,ie=x.useMemo(()=>lH(ye.dispatch,D),[ye]),[V,z]=x.useMemo(()=>{if(!S)return MH;const Be=WA(ye,X?void 0:de.subscription),fe=Be.notifyNestedSubs.bind(Be);return[Be,fe]},[ye,X,de]),ce=x.useMemo(()=>X?de:{...de,subscription:V},[X,de,V]),ge=x.useRef(void 0),he=x.useRef(K),Ce=x.useRef(void 0),xe=x.useRef(!1),ae=x.useRef(!1),Le=x.useRef(void 0);cg(()=>(ae.current=!0,()=>{ae.current=!1}),[]);const Z=x.useMemo(()=>()=>Ce.current&&K===he.current?Ce.current:ie(ye.getState(),K),[ye,K]),Ze=x.useMemo(()=>fe=>V?PH(S,ye,V,ie,he,ge,xe,ae,Ce,z,fe):()=>{},[V]);DH(jH,[he,ge,xe,K,Ce,z]);let at;try{at=x.useSyncExternalStore(Ze,Z,Ae?()=>ie(Ae(),K):Z)}catch(Be){throw Le.current&&(Be.message+=`
79
79
  The error may be correlated with this previous error:
80
80
  ${Le.current.stack}
81
81
 
@@ -179,12 +179,12 @@ ${z.desc}`:""}`,"aria-pressed":T===z.key,onPointerEnter:()=>C(z.key),onPointerLe
179
179
 
180
180
  `;return`${e}${r}${n}`}function xee(e,t){const n=e.trim();return n?t?`${n}\r`:/\s$/.test(e)?e:`${n} `:""}const my="termdock:right-sidebar:html-view-mode-by-file:v1";function bee(e){return e==="preview"||e==="source"}function vC(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(bee)}function wC(e,t){if(!t)return null;const n=e&&!t.startsWith("/")?`${e}/${t}`:t;return e?`${e}::${n}`:n}function yS(e,t){const n=wC(e,t);return n?Hr(my,vC)?.[n]??"source":"source"}function yee(e,t,n){const r=wC(e,t);if(!r)return;const s=Hr(my,vC)??{};On(my,{...s,[r]:n})}function Tb(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"),a=String(s).padStart(2,"0");return n>0?`${n}:${i}:${a}`:`${i}:${a}`}function vee(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 wee=350,See=12,Aee=90;function Tee({url:e,onLoadError:t}){const{t:n}=Vn(),r=x.useRef(null),s=x.useRef(null),i=x.useRef(null),a=x.useRef(null),c=x.useRef(!1),u=x.useRef(null),f=x.useRef(null),p=x.useRef(0),g=x.useRef(!1),y=x.useRef(!1),v=x.useRef(!1),S=x.useRef(null),C=x.useRef(null),T=x.useRef(!1),L=x.useRef(1),E=x.useRef(!1),[D,P]=x.useState(0),[F,j]=x.useState(0),[A,H]=x.useState(!1),[Q,K]=x.useState(!1),[W,de]=x.useState(null),[X,pe]=x.useState(!1),[ye,Ae]=x.useState(0),[ie,V]=x.useState(!1),[z,ce]=x.useState({width:0,height:0}),ge=x.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),he=x.useCallback(()=>{if(ge(),C.current=null,!T.current)return!1;const Ne=i.current;return Ne&&(Ne.playbackRate=L.current),T.current=!1,pe(!1),!0},[ge]);x.useEffect(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),f.current!==null&&clearTimeout(f.current),ge();const Ne=i.current;Ne&&T.current&&(Ne.playbackRate=L.current)},[ge]),x.useEffect(()=>{const Ne=s.current;if(!Ne||typeof ResizeObserver>"u")return;const Ge=new ResizeObserver(([Fe])=>{Fe&&ce({width:Fe.contentRect.width,height:Fe.contentRect.height})});return Ge.observe(Ne),()=>Ge.disconnect()},[]),x.useEffect(()=>{const Ne=()=>V(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",Ne),()=>document.removeEventListener("fullscreenchange",Ne)},[]);const Ce=x.useCallback((Ne,Ge=!1)=>{const Fe=i.current;if(!Fe)return!1;const ft=Number.isFinite(Fe.duration)?Fe.duration:Ne,it=Math.min(Math.max(Ne,0),ft);if(j(it),Math.abs(Fe.currentTime-it)<1/120)return!1;const Mt=Fe.fastSeek;return Ge&&typeof Mt=="function"?Mt.call(Fe,it):Fe.currentTime=it,!0},[]),xe=x.useCallback(()=>{u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null;const Ne=i.current;if(!Ne||!g.current||y.current||Ne.seeking)return;const Ge=v.current;v.current=!1,y.current=Ce(p.current,!Ge)}))},[Ce]),ae=x.useCallback(Ne=>{const Ge=a.current,Fe=i.current;if(!Ge||!Fe)return;const ft=Ge.getBoundingClientRect(),it=vee(Ne,ft,Fe.duration);p.current=it,de(it),v.current=!1,xe(),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,v.current=!0,xe()},Aee)},[xe]),Le=x.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,Ce(p.current)},[Ce]),Z=x.useCallback(Ne=>{const Ge=i.current;if(!(!Ge||!Number.isFinite(Ge.duration)||Ge.duration<=0)){c.current=!Ge.paused,Ge.pause(),g.current=!0,K(!0);try{Ne.currentTarget.setPointerCapture(Ne.pointerId)}catch{}ae(Ne.clientX)}},[ae]),Ze=x.useCallback(()=>{g.current=!1,Le(),K(!1),de(null);const Ne=i.current;Ne&&c.current&&!Ne.ended&&Ne.play().catch(()=>{}),c.current=!1},[Le]),at=x.useCallback(()=>{const Ne=i.current;if(Ne){if(E.current){E.current=!1;return}Ne.paused?Ne.play().catch(()=>{}):Ne.pause()}},[]),He=x.useCallback(Ne=>{const Ge=i.current;!Ge||Ge.paused||Ne.button!==0||(ge(),C.current={id:Ne.pointerId,x:Ne.clientX,y:Ne.clientY},S.current=setTimeout(()=>{S.current=null,L.current=Ge.playbackRate,Ge.playbackRate=2,T.current=!0,pe(!0)},wee))},[ge]),be=x.useCallback(Ne=>{const Ge=C.current;!Ge||Ge.id!==Ne.pointerId||T.current||Math.hypot(Ne.clientX-Ge.x,Ne.clientY-Ge.y)>See&&(ge(),C.current=null)},[ge]),Be=x.useCallback(()=>{he()&&(E.current=!0)},[he]);x.useEffect(()=>(window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Be),()=>{window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Be)}),[Be]);const fe=x.useCallback(async()=>{const Ne=r.current,Ge=i.current;if(!(!Ne||!Ge))try{document.fullscreenElement===Ne?await document.exitFullscreen():Ne.requestFullscreen?await Ne.requestFullscreen():Ge.webkitEnterFullscreen?.()}catch{Ge.webkitEnterFullscreen?.()}},[]),Ke=x.useCallback(()=>Ae(Ne=>(Ne+90)%360),[]),Ye=x.useCallback(Ne=>{const Ge=i.current;if(!Ge||!Number.isFinite(Ge.duration))return;const Fe=Ne.shiftKey?10:5;let ft=null;Ne.key==="ArrowLeft"?ft=Ge.currentTime-Fe:Ne.key==="ArrowRight"?ft=Ge.currentTime+Fe:Ne.key==="Home"?ft=0:Ne.key==="End"&&(ft=Ge.duration),ft!==null&&(Ne.preventDefault(),Ce(ft))},[Ce]),et=Q&&W!==null?W:F,q=D>0?Math.min(1,Math.max(0,et/D)):0,Xe=(ye===90||ye===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":ye,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:{...Xe,transform:`translate(-50%, -50%) rotate(${ye}deg)`},src:e,preload:"auto",playsInline:!0,onClick:at,onPointerDown:He,onPointerMove:be,onPointerUp:Be,onPointerCancel:Be,onContextMenu:Ne=>{T.current&&Ne.preventDefault()},onPlay:()=>H(!0),onPause:()=>H(!1),onTimeUpdate:Ne=>j(Ne.currentTarget.currentTime),onSeeked:Ne=>{const Ge=Ne.currentTarget;if(j(Ge.currentTime),y.current=!1,!g.current)return;const Fe=Ge.requestVideoFrameCallback;typeof Fe=="function"?Fe.call(Ge,()=>{g.current&&xe()}):requestAnimationFrame(()=>{g.current&&xe()})},onLoadedMetadata:Ne=>P(Number.isFinite(Ne.currentTarget.duration)?Ne.currentTarget.duration:0),onDurationChange:Ne=>P(Number.isFinite(Ne.currentTarget.duration)?Ne.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&&W!==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:`${q*100}%`},"data-testid":"file-preview-video-scrub-time",children:Tb(W)})]}),o.jsx("div",{"data-testid":"file-preview-video-controls",className:`shrink-0 border-t border-border/60 bg-background px-2 py-1.5 ${hT}`,[pT]:"",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:at,"aria-label":n(A?"rightSidebar.videoPause":"rightSidebar.videoPlay"),title:n(A?"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:A?o.jsx(h8,{size:14}):o.jsx(i2,{size:14})}),o.jsxs("div",{ref:a,role:"slider","aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(D),"aria-valuenow":Math.floor(et),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:Z,onPointerMove:Ne=>{Q&&ae(Ne.clientX)},onPointerUp:Ze,onPointerCancel:Ze,onKeyDown:Ye,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:`${q*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:`${q*100}%`}})]}),o.jsxs("div",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground","data-testid":"file-preview-video-time",children:[Tb(et)," / ",Tb(D)]}),o.jsx("button",{type:"button",onClick:Ke,"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(pD,{size:14})}),o.jsx("button",{type:"button",onClick:()=>{fe()},"aria-label":n(ie?"rightSidebar.videoFullscreenExit":"rightSidebar.videoFullscreenEnter"),title:n(ie?"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:ie?o.jsx(UM,{size:14}):o.jsx(FM,{size:14})})]})})]})}function Cee(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 h1({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:Cee(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(Hl,{size:11}),t]})}function kee(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,a=r.height*s,c=n.left+(n.width-i)/2,u=n.top+(n.height-a)/2,f=e-c,p=t-u;if(f<0||p<0||f>i||p>a)return null;const g=f/i*100,y=p/a*100;return{x:r.x+r.width*g/100,y:r.y+r.height*y/100,xPercent:g,yPercent:y}}function _ee(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 Lee(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(),a=s.value.trim();(i.startsWith("on")||(i==="href"||i.endsWith(":href"))&&a&&!a.startsWith("#"))&&r.removeAttribute(s.name)}}),n.removeAttribute("width"),n.removeAttribute("height"),n.setAttribute("preserveAspectRatio","xMidYMid meet"),new XMLSerializer().serializeToString(n)}function Eee(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 a=Number(s.getAttribute("x")),c=Number(s.getAttribute("y"));if(!Number.isFinite(a)||!Number.isFinite(c))continue;const u=Math.hypot(a-t,c-n);(!r||u<r.distance)&&(r={text:i,distance:u})}return r?.text.slice(0,120)}function SC({blobUrl:e,filePath:t,viewLabel:n,onInsertAnnotation:r}){const s=x.useRef(null),i=x.useRef(null),[a,c]=x.useState(null),[u,f]=x.useState(null),[p,g]=x.useState(1),[y,v]=x.useState(!1),[S,C]=x.useState(null),T=x.useRef(new Map),L=x.useRef(null),E=x.useRef(!1),D=x.useRef(null),P=x.useRef(p);P.current=p,x.useEffect(()=>{const ie=new AbortController;return c(null),f(null),C(null),g(1),fetch(e,{signal:ie.signal}).then(V=>V.text()).then(V=>c(Lee(V))).catch(V=>{ie.signal.aborted||f(V instanceof Error?V.message:"SVG preview failed")}),()=>ie.abort()},[e]),x.useEffect(()=>{if(!y)return;const ie=V=>{V.key==="Escape"&&v(!1)};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[y]),x.useLayoutEffect(()=>{const ie=i.current,V=ie?.querySelector("[data-svg-document] > svg");if(!ie||!V)return;let z;try{z=V.getBBox()}catch{return}if(!z.width||!z.height)return;const ce=Math.max(2,Math.min(z.width,z.height)*.025);V.setAttribute("viewBox",`${z.x-ce} ${z.y-ce} ${z.width+2*ce} ${z.height+2*ce}`),V.style.width=`${p*100}%`,V.style.height=`${p*100}%`,V.style.minWidth=`${p*100}%`,V.style.minHeight=`${p*100}%`,V.style.display="block"},[a,p]);const F=x.useMemo(()=>S?_ee(t,n,S):null,[t,S,n]),j=ie=>{if(E.current){E.current=!1;return}const V=i.current,z=V?.querySelector("[data-svg-document] > svg"),ce=s.current;if(!V||!z||!ce)return;const ge=z.viewBox.baseVal,he=kee(ie.clientX,ie.clientY,z.getBoundingClientRect(),ge);if(!he)return;const Ce=ce.getBoundingClientRect();C({...he,nearestText:Eee(z,he.x,he.y),stageX:ie.clientX-Ce.left,stageY:ie.clientY-Ce.top,stageXPercent:(ie.clientX-Ce.left)/Ce.width*100,stageYPercent:(ie.clientY-Ce.top)/Ce.height*100})},A=ie=>Math.max(1,Math.min(12,ie)),H=(ie,V)=>{const z=A(V),ce=ie.querySelector("[data-svg-document] > svg");if(!ce)return z;const ge=`${z*100}%`;return ce.style.width=ge,ce.style.height=ge,ce.style.minWidth=ge,ce.style.minHeight=ge,P.current=z,z},Q=(ie,V,z,ce)=>{const ge=P.current,he=ie.getBoundingClientRect(),Ce=z-he.left,xe=ce-he.top,ae=(ie.scrollLeft+Ce)/ge,Le=(ie.scrollTop+xe)/ge,Z=H(ie,V);return ie.scrollLeft=ae*Z-Ce,ie.scrollTop=Le*Z-xe,Z},K=()=>{const ie=Array.from(T.current.values());return ie.length>=2?Math.hypot(ie[0].x-ie[1].x,ie[0].y-ie[1].y):0},W=ie=>{if(ie.pointerType==="mouse"&&ie.button!==0)return;const V=i.current;V&&(T.current.set(ie.pointerId,{x:ie.clientX,y:ie.clientY}),V.setPointerCapture?.(ie.pointerId),T.current.size>=2?(L.current={kind:"pinch",startX:ie.clientX,startY:ie.clientY,startScrollLeft:V.scrollLeft,startScrollTop:V.scrollTop,startDistance:K(),startZoom:P.current,moved:!1},E.current=!0):P.current>1&&(L.current={kind:"pan",startX:ie.clientX,startY:ie.clientY,startScrollLeft:V.scrollLeft,startScrollTop:V.scrollTop,startZoom:P.current,moved:!1}))},de=ie=>{if(!T.current.has(ie.pointerId))return;T.current.set(ie.pointerId,{x:ie.clientX,y:ie.clientY});const V=i.current,z=L.current;if(!(!V||!z)){if(T.current.size>=2&&z.kind==="pinch"){const ce=K();if(!z.startDistance||!ce)return;const ge=A(z.startZoom*ce/z.startDistance);if(Math.abs(ge-P.current)<.01)return;const he=Array.from(T.current.values()),Ce=(he[0].x+he[1].x)/2,xe=(he[0].y+he[1].y)/2;z.moved=!0,E.current=!0,Q(V,ge,Ce,xe),ie.preventDefault();return}if(z.kind==="pan"&&T.current.size===1){const ce=ie.clientX-z.startX,ge=ie.clientY-z.startY;if(!z.moved&&Math.hypot(ce,ge)<6)return;z.moved=!0,E.current=!0,V.scrollLeft=z.startScrollLeft-ce,V.scrollTop=z.startScrollTop-ge,ie.preventDefault()}}},X=ie=>{const V=i.current,z=L.current,ce=T.current.size===1&&!z?.moved;T.current.delete(ie.pointerId);try{V?.releasePointerCapture?.(ie.pointerId)}catch{}if(T.current.size===1&&z?.kind==="pinch"){const Ce=Array.from(T.current.values())[0];L.current=V?{kind:"pan",startX:Ce.x,startY:Ce.y,startScrollLeft:V.scrollLeft,startScrollTop:V.scrollTop,startZoom:P.current,moved:!1}:null;return}if(T.current.size>0||(L.current=null,z?.kind==="pinch"&&g(P.current),!ce||E.current))return;const ge=Date.now(),he=D.current;he&&ge-he.time<350&&Math.hypot(ie.clientX-he.x,ie.clientY-he.y)<24?(D.current=null,E.current=!0,g(Ce=>Ce>1?1:2.5)):D.current={time:ge,x:ie.clientX,y:ie.clientY}},pe=ie=>{if(!ie.ctrlKey&&!ie.metaKey)return;const V=i.current;if(!V)return;ie.preventDefault();const z=Q(V,P.current*Math.exp(-ie.deltaY*.01),ie.clientX,ie.clientY);g(z)},ye=()=>{g(1),P.current=1,i.current&&(i.current.scrollLeft=0,i.current.scrollTop=0)},Ae=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:j,onDoubleClick:ie=>{ie.preventDefault(),g(V=>V>1?1:2.5)},onPointerDown:W,onPointerMove:de,onPointerUp:X,onPointerCancel:X,onWheel:pe,onScroll:()=>C(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}):a?o.jsx("div",{"data-svg-document":!0,className:"h-full min-h-[240px] w-full",dangerouslySetInnerHTML:{__html:a}}):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(h1,{anchor:{xPercent:S.stageXPercent,yPercent:S.stageYPercent},title:"引用 SVG 标注",onClick:()=>{r?.(F,`svg:${S.x.toFixed(2)}:${S.y.toFixed(2)}`),C(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:ie=>{ie.stopPropagation(),ye()},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(xD,{size:14})}),o.jsx("button",{type:"button","aria-label":y?"退出全屏 SVG":"全屏 SVG",title:y?"退出全屏 SVG":"全屏 SVG",onClick:ie=>{ie.stopPropagation(),v(V=>!V)},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(zy,{size:14}):o.jsx(Uy,{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?ui.createPortal(Ae,document.body):Ae}function Vm(e){switch(e){case"schematic":return"原理图第1页";case"pcb-front":return"PCB正面";case"pcb-back":return"PCB背面(镜像)";case"pcb-3d":return"PCB 3D正面"}}function Iee(e,t,n,r){const s=[`电子标注: ${e}`,`视图: ${Vm(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 Ree({blobUrl:e,filePath:t,view:n,board:r,onViewChange:s,onInsertAnnotation:i,onRefresh:a,interactive3d:c}){const{t:u}=Vn(),f=x.useRef(null),p=x.useRef(null),g=x.useRef(null),[y,v]=x.useState(null),[S,C]=x.useState(!1);x.useEffect(()=>(g.current?.abort(),v(null),C(!1),()=>g.current?.abort()),[e,n]);const T=x.useMemo(()=>y?Iee(t,n,y,y.inspection):null,[t,y,n]),L=D=>{const P=f.current,F=p.current;if(!P||!F||!F.naturalWidth||!F.naturalHeight)return;const j=P.getBoundingClientRect(),A=Math.min(j.width/F.naturalWidth,j.height/F.naturalHeight),H=F.naturalWidth*A,Q=F.naturalHeight*A,K=j.left+(j.width-H)/2,W=j.top+(j.height-Q)/2,de=D.clientX-K,X=D.clientY-W;if(de<0||X<0||de>H||X>Q)return;const pe={xPercent:Math.max(0,Math.min(100,de/H*100)),yPercent:Math.max(0,Math.min(100,X/Q*100)),stageXPercent:(D.clientX-j.left)/j.width*100,stageYPercent:(D.clientY-j.top)/j.height*100,inspecting:r&&n!=="pcb-3d"};if(v(pe),g.current?.abort(),!pe.inspecting)return;const ye=new AbortController;g.current=ye,YI(t,n,pe.xPercent,pe.yPercent,ye.signal).then(Ae=>v(ie=>ie===pe?{...ie,inspection:Ae,inspecting:!1}:ie)).catch(()=>{ye.signal.aborted||v(Ae=>Ae===pe?{...Ae,inspection:{available:!1},inspecting:!1}:Ae)})},E=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:E.map(D=>o.jsx("button",{type:"button",onClick:()=>s(D),className:`h-8 shrink-0 rounded-full px-3 text-xs font-semibold transition active:scale-95 ${D===n?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,children:Vm(D)},D))}),o.jsx("button",{type:"button",onClick:a,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(Bs,{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:D=>{D.key!=="Enter"&&D.key!==" "||(D.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} ${Vm(n)}`,onLoad:()=>C(!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(h1,{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(SC,{blobUrl:e,filePath:t,viewLabel:Vm(n),onInsertAnnotation:i})})]})}function Nee(e){const t=[];let n=[],r="",s=!1;for(let i=0;i<e.length;i+=1){const a=e[i];s?a==='"'&&e[i+1]==='"'?(r+='"',i+=1):a==='"'?s=!1:r+=a:a==='"'?s=!0:a===","?(n.push(r),r=""):a===`
181
181
  `?(n.push(r.replace(/\r$/,"")),t.push(n),n=[],r=""):r+=a}return(r||n.length>0)&&(n.push(r.replace(/\r$/,"")),t.push(n)),t}function Mee(e,t,n,r,s){const i=t[s]||`第${s+1}列`,a=n[s]??"",c=t.map((u,f)=>`${u||`第${f+1}列`}=${n[f]??""}`).join(";");return`"表格标注: ${e} / 数据行: ${r+1} / 列: ${i} / 值: ${a} / 记录: ${c}"`}function Dee({content:e,filePath:t,onInsertAnnotation:n}){const{t:r}=Vn(),s=x.useMemo(()=>Nee(e),[e]),i=s[0]??[],a=s.slice(1),c=x.useRef(null),[u,f]=x.useState(null),p=u?a[u.row]:null,g=u&&p?Mee(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:a.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,C)=>{const T=u?.row===v&&u.column===C;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 E=c.current?.getBoundingClientRect(),D=L.currentTarget.getBoundingClientRect();if(!E?.width||!E.height)return;const P=L.clientX||D.left+D.width/2,F=L.clientY||D.top+D.height/2;f({row:v,column:C,xPercent:(P-E.left)/E.width*100,yPercent:(F-E.top)/E.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[C]||" "})},`cell:${v}:${C}`)})]},`row:${v}`))})]})}),u&&g&&o.jsx(h1,{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:a.length,columns:i.length})})})]})}function Jd(e,t){let n=e;for(const r of t){if(!n||typeof n!="object")return;n=n[r]}return n}function jee(e,t){const n=JSON.parse(e),r=Jd(n,["meta","version"]);if(t)return[{label:"文件性质",value:"KiCad 本机界面状态,不属于电气设计源文件"},{label:"格式版本",value:String(r??"未知")},{label:"活动层编号",value:String(Jd(n,["board","active_layer"])??"未知")},{label:"可见层掩码",value:String(Jd(n,["board","visible_layers"])??"未知")},{label:"Git 集成",value:Jd(n,["git","integration_disabled"])===!0?"已禁用":"未禁用"}];const s=Jd(n,["net_settings","classes"]),i=Array.isArray(s)?s.find(c=>c&&typeof c=="object"&&c.name==="Default"):void 0,a=Jd(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(a)?a.length:0)}]}function Pee(e,t){return`"KiCad项目标注: ${e} / 项: ${t.label} / 值: ${t.value}"`}function Bee({content:e,filePath:t,localState:n,onInsertAnnotation:r}){const{t:s}=Vn(),i=x.useRef(null),[a,c]=x.useState(null),u=x.useMemo(()=>{try{return{items:jee(e,n),error:null}}catch(p){return{items:[],error:p instanceof Error?p.message:String(p)}}},[e,n]),f=a===null?null:u.items[a.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 C=y.clientX||S.left+S.width/2,T=y.clientY||S.top+S.height/2;c({index:g,xPercent:(C-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 ${a?.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&&a&&o.jsx(h1,{anchor:{xPercent:a.xPercent,yPercent:a.yPercent},title:s("rightSidebar.kicadInsertSetting"),onClick:()=>{r?.(Pee(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 Fee=x.forwardRef(function({src:t,title:n,exitFullscreenLabel:r,onFullscreenChange:s},i){const a=x.useRef(null),[c,u]=x.useState(!1),[f,p]=x.useState(!1),g=c||f;x.useEffect(()=>{s?.(g)},[g,s]),x.useEffect(()=>{const S=()=>{u(document.fullscreenElement===a.current)};return document.addEventListener("fullscreenchange",S),()=>document.removeEventListener("fullscreenchange",S)},[]),x.useEffect(()=>{if(!f)return;const S=C=>{C.key==="Escape"&&p(!1)};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[f]);const y=x.useCallback(async()=>{const S=a.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]);x.useImperativeHandle(i,()=>({toggleFullscreen:y}),[y]);const v=o.jsxs("div",{ref:a,"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(zy,{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?ui.createPortal(v,document.body):v}),AC="termdock-file-search-match",gy="termdock-file-search-current";function Oee(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 Qee(e){return e.parentElement?.closest("[data-markdown-preview-block-start], [data-file-preview-line]")??null}function $ee(e,t){const n=t.trim().toLocaleLowerCase();if(!n)return[];const r=[];let s="",i=null;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let p=a.nextNode();p;p=a.nextNode()){if(!(p instanceof Text)||!p.data)continue;const g=Qee(p);if(!g)continue;i&&i!==g&&(s+=`
182
- `);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 TC(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function gm(){const e=TC();e?.delete(AC),e?.delete(gy)}function vS(e,t){const n=TC();if(!n||typeof Highlight>"u")return;n.set(AC,new Highlight(...e));const r=e[t];r?n.set(gy,new Highlight(r)):n.delete(gy)}function wS(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Hee(e){return Array.from(new Set(e.split(/[\n,]/).map(t=>t.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Uee(e,t){const n=t.trim();return!n||n==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(n)?n.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${n.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function zee(e,t){if(t===e)return".";const n=`${e.replace(/[\\/]+$/,"")}/`;return t.startsWith(n)?t.slice(n.length):t}const Wv="termdock:right-sidebar:file-tree-scroll:v1",Vv="termdock:right-sidebar:file-preview-reading-state:v1",sh="termdock:right-sidebar:file-tree-width:v1",CC="termdock:right-sidebar:markdown-view-mode:v1",kC="termdock:right-sidebar:diff-change-list-mode:v1",_C="termdock:right-sidebar:diff-wrap:v1",LC="termdock:diff-viewer:view-type:v1",EC="termdock:right-sidebar:file-search-mode:v1",Cb="termdock:right-sidebar:collapsed-git-repo-groups:v1",SS="termdock:right-sidebar:collapsed-diff-directories:v1",kb="termdock:right-sidebar:branch-audit-module-open:v1",IC="termdock:right-sidebar:branch-audit-module:v1",Gee=150,RC="termdock:right-sidebar:active-git-repo:v1",AS="termdock:right-sidebar:context-draft-enabled:v1",TS="termdock:right-sidebar:context-draft-collapsed:v1",CS="termdock:right-sidebar:context-draft-auto-collapse:v1",_b="termdock:right-sidebar:context-draft-text:v1",Wee=300,Vee=20,qee=120,Kee=250,Yee=250,Xee=120,Zee=700,Lb=600,kS=[2e3,5e3,15e3,3e4],Jee=320,ete=500,tte=20,nte=12e3,xy=300,_S=240,rte=560,NC="border-r px-2 py-1.5 sm:px-3 sm:py-2",Ig="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",MC=`${NC} border-b border-border/15 font-semibold last:border-r-0`,DC=`${NC} border-border/10 align-top text-muted-foreground last:border-r-0`,qv="termdock-file-preview-horizontal-scroll",LS=x.lazy(()=>B0(()=>import("./ModelPreview-N79HO2Xj.js"),__vite__mapDeps([2,3,1,4]))),jC=`${qv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function ste(e,t,n){return e&&!t?"unified":n}const ite=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function ote(e){return e==="preview"||e==="source"}function ate(e){return e==="list"||e==="tree"||e==="ai"}function ES(){return Hr(CC,ote)??"preview"}function lte(){return Hr(kC,ate)??"tree"}function ih(e){return typeof e=="boolean"}function cte(e){return typeof e=="string"}function ute(){return Hr(_C,ih)??!0}function dte(e){return e==="unified"||e==="split"}function fte(){return Hr(LC,dte)??"unified"}function hte(e){return e==="name"||e==="content"||e==="regex"}function pte(){return Hr(EC,hte)??"name"}function PC(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Po(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function mte(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function BC(){return Hr(RC,mte)??{}}function IS(e){if(!e)return;const t=BC();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Eb(e,t){e&&On(RC,{...BC(),[e]:t})}function gte(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 by(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function RS(e){const t=Hr(e,by);return t?new Set(t):new Set}function Ib(e,t){On(e,[...t])}function xte(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 bte(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||by(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(xte))&&(t.commits===void 0||by(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 yte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&bte(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function vte(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(yte))&&(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 NS(){return Hr(IC,vte)??{}}function MS(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function DS(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function FC(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||DS(n)===DS(r)}function jS(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!FC(r,t))??""}function yy(e,t){const n=Math.max(_S,t-320),r=Math.min(rte,n);return Math.min(r,Math.max(_S,e))}function wte(e){return typeof e=="number"&&Number.isFinite(e)}function Ste(e){return yy(Hr(sh,wte)??xy,e)}function OC(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function Gf(e){return ite.has(OC(e))}function QC(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function vy(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||QC(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function Ate(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const $C=x.createContext(null);function qm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function HC(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function UC(e){return e.replace(/\s+#+\s*$/,"").trim()}function wy(e,t){const r=HC(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 PS(e){return HC(e)||e.trim()}function Rg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=Ay(t[2]);return n?{id:qm(t[1]),definition:{href:n.href,title:n.title}}:null}function Tte(e){const t=new Map;for(const n of e){const r=Rg(n);r&&t.set(r.id,r.definition)}return t}function zC(e){return e.trim().toLowerCase()}function GC(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:zC(t[1]),text:t[2]}:null}function Cte(e){const t=new Map;let n=null;for(const r of e){const s=GC(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 kte(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(GC(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function _te(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 WC(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function bh(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 Lte(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,a=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=a?decodeURIComponent(a):null}catch{return null}const p=n?bh(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=bh(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=bh(`${WC(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function Ete(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!jy(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=bh(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=bh(`${WC(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const Sy=128,Ite=360,Rb=480;function Kv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function Rte(e,t,n,r){if(!t||!n)return null;let s,i;return Kv(e)?(i=Math.min(Math.max(n,Sy),Ite),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Rb&&(s=s*Rb/i,i=Rb),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function Nte(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function VC(e){const t=Nte(e),n=ut(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function Mte({src:e,alt:t,title:n}){const r=Kv(e),s=VC(e),i=x.useRef(null),[a,c]=x.useState(!1),[u,f]=x.useState(0),[p,g]=x.useState({status:"loading"}),[y,v]=x.useState(null);x.useLayoutEffect(()=>{const T=i.current,L=T?.parentElement?.parentElement??T?.parentElement;if(!L)return;const E=()=>f(L.clientWidth);if(E(),typeof ResizeObserver>"u")return;const D=new ResizeObserver(E);return D.observe(L),()=>D.disconnect()},[]),x.useEffect(()=>{if(a)return;const T=i.current;if(!T||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(E=>{E.some(D=>D.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(T),()=>L.disconnect()},[a]),x.useEffect(()=>{if(!a)return;const T=new AbortController;let L=null;g({status:"loading"});const E=window.setTimeout(()=>{T.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:T.signal}).then(async D=>{if(!D.ok)throw new Error(`HTTP ${D.status}`);const P=Number(D.headers.get("X-Image-Width"))||0,F=Number(D.headers.get("X-Image-Height"))||0;return{blob:await D.blob(),width:P,height:F}}).then(({blob:D,width:P,height:F})=>{T.signal.aborted||(L=URL.createObjectURL(D),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const D=T.signal.reason;T.signal.aborted&&!(D instanceof DOMException&&D.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),T.abort(),L&&URL.revokeObjectURL(L)}},[a,s]);const S=Rte(e,y?.width??0,y?.height??0,u),C=S??{width:Sy*2,height:Sy};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:C.width,height:C.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Nb(e,t,n,r,s){const i=Ete(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const a=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(Mte,{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?.(a)},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 Mb(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function BS(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function Ay(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 qC="",Dte=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function jte(e){return e.replace(Dte,(t,n)=>`${qC}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function FS(e){return e.replace(new RegExp(`${qC}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function Pte(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const KC={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 xm=null;function YC(){return xm||(xm=B0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw xm=null,e})),xm}function XC({html:e}){const{t}=Vn(),[n,r]=x.useState(null);return x.useEffect(()=>{let s=!1;return r(null),YC().then(i=>{s||r(i.sanitize(e,KC))}).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 Bte({html:e}){const[t,n]=x.useState(null);return x.useEffect(()=>{let r=!1;return n(null),YC().then(s=>{r||n(s.sanitize(e,KC))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function ZC(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 bm=null;function Fte(){return bm||(bm=Promise.all([B0(()=>import("./katex-DnlPpQZa.js"),[]),B0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw bm=null,e})),bm}function Oh({tex:e,display:t=!1}){const[n,r]=x.useState(null),[s,i]=x.useState(!1);if(x.useEffect(()=>{let c=!1;return r(null),i(!1),Fte().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 a=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:a,dangerouslySetInnerHTML:{__html:n}})}function Ote(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(Bte,{html:e},t):null;const s=r[1].toLowerCase(),i=Ei(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 Ei(e,t,n=!0,r){const s=jte(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,a=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&a.push(FS(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?Ote(f,p,r):null;if(g)a.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))a.push(o.jsx(Oh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))a.push(o.jsx(Oh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;a.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:Pte(f.slice(y,-y))},p))}else if(f.startsWith("~~"))a.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:Ei(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))a.push(o.jsx("strong",{className:"font-semibold text-foreground",children:Ei(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))a.push(o.jsx("em",{className:"italic",children:Ei(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 C=Ay(y[2]);a.push(C?Nb(p,y[1],C.href,C.title,r):f)}else if(v){const C=v[2]||v[1],T=r.referenceDefinitions.get(qm(C));a.push(T?Nb(p,v[1],T.href,T.title,r):f)}else if(S){const C=r.referenceDefinitions.get(qm(S[1]));a.push(C?Nb(p,S[1],C.href,C.title,r):f)}else a.push(f)}else if(f.startsWith("[^")){const y=zC(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);a.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);a.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(">")&&BS(f.slice(1,-1))){const y=f.slice(1,-1);a.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(BS(Mb(f).linkText)){const{linkText:y,suffix:v}=Mb(f);a.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&&a.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=Mb(f),S=y.startsWith("www.")?`https://${y}`:y;a.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&&a.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),C=v?v[2]||v[1]:S?.[1]??null,T=C?r.referenceDefinitions.get(qm(C)):null,L=y?Ay(y[2]):null,E=L?.href??T?.href??null,D=E?Ate(E):null,P=y?.[1]??v?.[1]??S?.[1]??"";a.push(D?o.jsx("a",{href:D,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:Ei(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&a.push(FS(s.slice(c))),a.length>0?a:[e]}function JC(e){return/(?: {2,}|\\)$/.test(e)}function ek(e){return e.replace(/(?: {2,}|\\)$/,"")}function Ng(e){return/^(?: {4}|\t)/.test(e)}function tk(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function nk(e,t,n){const r=[];return e.forEach((s,i)=>{const a=JC(s);r.push(...Ei(ek(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(a?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function Ty(e,t,n){const r=[],s=[];return e.forEach((i,a)=>{s.push(JC(i)),r.push(Ei(ek(i),`${t}-${a}`,!0,n))}),{perLine:r,hardBreaks:s}}function Cy(e,t,n,r,s){const i=[];return e.forEach((a,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:a},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function Qh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,a=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==="["?a+=1:i===0&&u==="]"&&a>0&&(a-=1),u==="|"&&i===0&&a===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function rk(e){return Qh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function Mg(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Dg(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Qte(e,t){return e>96||e>44&&t>.35}function Yv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Xv(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 sk(e,t,n,r,s,i=new Set){const a=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(Rg(f)||i.has(u))){u+=1;continue}const p=Xv(f),g=Yv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(C=>C.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const C of c)C.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):a.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:a,nextIndex:u}}function Zv(e,t,n,r=0){return e.map((s,i)=>{const a=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!a,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[a?o.jsx("input",{type:"checkbox",checked:a[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,Ei(a?.[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:Ei(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:$te(s.children,`${t}-${i}`,n,r)}})}function $te(e,t,n,r=0){const s=[];for(const i of e){const a=s[s.length-1];a&&a.ordered===i.ordered?a.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,a)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:Zv(i.items,`${t}-g${a}`,n,r)}))}function Jv(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&&Hte(n.groups,t)]},n.key)})}function Hte(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:Jv(n.items,t)},`nested-${r}`)})}function Ute(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:[Ei(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 zte(e,t,n,r){const s=[];let i=0;const a=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 E="Details";const D=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?E=P[1].trim()||E:D.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:Ei(E,`${t}-details-${L}-summary`,!0,n)}),D.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:nk(D,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=ZC(c);if(f){const L=[c],E=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(XC,{html:L.join(`
182
+ `);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 TC(){return typeof CSS<"u"&&CSS.highlights?CSS.highlights:null}function gm(){const e=TC();e?.delete(AC),e?.delete(gy)}function vS(e,t){const n=TC();if(!n||typeof Highlight>"u")return;n.set(AC,new Highlight(...e));const r=e[t];r?n.set(gy,new Highlight(r)):n.delete(gy)}function wS(e){e?.startContainer.parentElement?.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}function Hee(e){return Array.from(new Set(e.split(/[\n,]/).map(t=>t.trim().replace(/^!+/,"")).filter(Boolean))).slice(0,24)}function Uee(e,t){const n=t.trim();return!n||n==="."?e:/^(?:[/\\]|[A-Za-z]:[/\\])/.test(n)?n.replace(/[\\/]+$/,""):`${e.replace(/[\\/]+$/,"")}/${n.replace(/^\.?[\\/]+/,"").replace(/[\\/]+$/,"")}`}function zee(e,t){if(t===e)return".";const n=`${e.replace(/[\\/]+$/,"")}/`;return t.startsWith(n)?t.slice(n.length):t}const Wv="termdock:right-sidebar:file-tree-scroll:v1",Vv="termdock:right-sidebar:file-preview-reading-state:v1",sh="termdock:right-sidebar:file-tree-width:v1",CC="termdock:right-sidebar:markdown-view-mode:v1",kC="termdock:right-sidebar:diff-change-list-mode:v1",_C="termdock:right-sidebar:diff-wrap:v1",LC="termdock:diff-viewer:view-type:v1",EC="termdock:right-sidebar:file-search-mode:v1",Cb="termdock:right-sidebar:collapsed-git-repo-groups:v1",SS="termdock:right-sidebar:collapsed-diff-directories:v1",kb="termdock:right-sidebar:branch-audit-module-open:v1",IC="termdock:right-sidebar:branch-audit-module:v1",Gee=150,RC="termdock:right-sidebar:active-git-repo:v1",AS="termdock:right-sidebar:context-draft-enabled:v1",TS="termdock:right-sidebar:context-draft-collapsed:v1",CS="termdock:right-sidebar:context-draft-auto-collapse:v1",_b="termdock:right-sidebar:context-draft-text:v1",Wee=300,Vee=20,qee=120,Kee=250,Yee=250,Xee=120,Zee=700,Lb=600,kS=[2e3,5e3,15e3,3e4],Jee=320,ete=500,tte=20,nte=12e3,xy=300,_S=240,rte=560,NC="border-r px-2 py-1.5 sm:px-3 sm:py-2",Ig="max-w-[18rem] whitespace-normal break-words sm:max-w-[27rem]",MC=`${NC} border-b border-border/15 font-semibold last:border-r-0`,DC=`${NC} border-border/10 align-top text-muted-foreground last:border-r-0`,qv="termdock-file-preview-horizontal-scroll",LS=x.lazy(()=>B0(()=>import("./ModelPreview-B_15098g.js"),__vite__mapDeps([2,3,1,4]))),jC=`${qv} termdock-md-table-scroll max-w-full overflow-x-auto overflow-y-hidden rounded-lg border border-border/20 bg-surface`;function ste(e,t,n){return e&&!t?"unified":n}const ite=new Set([".md",".markdown",".mdown",".mkdn",".mkd"]);function ote(e){return e==="preview"||e==="source"}function ate(e){return e==="list"||e==="tree"||e==="ai"}function ES(){return Hr(CC,ote)??"preview"}function lte(){return Hr(kC,ate)??"tree"}function ih(e){return typeof e=="boolean"}function cte(e){return typeof e=="string"}function ute(){return Hr(_C,ih)??!0}function dte(e){return e==="unified"||e==="split"}function fte(){return Hr(LC,dte)??"unified"}function hte(e){return e==="name"||e==="content"||e==="regex"}function pte(){return Hr(EC,hte)??"name"}function PC(e){return e.repositories??(e.context?.root?[{id:e.context.root,root:e.context.root,relativeRoot:".",name:Po(e.context.root)||e.context.root,depth:0,nested:!1,available:e.available,files:e.files,context:e.context,error:e.error}]:[])}function mte(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>t===null||typeof t=="string")}function BC(){return Hr(RC,mte)??{}}function IS(e){if(!e)return;const t=BC();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Eb(e,t){e&&On(RC,{...BC(),[e]:t})}function gte(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 by(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function RS(e){const t=Hr(e,by);return t?new Set(t):new Set}function Ib(e,t){On(e,[...t])}function xte(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 bte(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||by(t.files))&&(t.hunks===void 0||Array.isArray(t.hunks)&&t.hunks.every(xte))&&(t.commits===void 0||by(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 yte(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.key=="string"&&bte(t.diff)&&typeof t.repoLabel=="string"&&typeof t.createdAt=="number"}function vte(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(yte))&&(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 NS(){return Hr(IC,vte)??{}}function MS(e){return[e.repoRoot,e.baseRef,e.branchName??"",e.headRef??"",e.diffFingerprint??""].join("\0")}function DS(e){const t=e?.trim()??"",n=t.indexOf("/");return n>=0?t.slice(n+1):t}function FC(e,t){const n=e?.trim(),r=t?.trim();return!n||!r?!1:n===r||DS(n)===DS(r)}function jS(e){const t=e?.branch??null;return[e?.upstream,...e?.remoteBranches??[],...e?.branches??[]].find(r=>r&&!FC(r,t))??""}function yy(e,t){const n=Math.max(_S,t-320),r=Math.min(rte,n);return Math.min(r,Math.max(_S,e))}function wte(e){return typeof e=="number"&&Number.isFinite(e)}function Ste(e){return yy(Hr(sh,wte)??xy,e)}function OC(e){const t=e.split(/[\\/]/).pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n).toLowerCase():""}function Gf(e){return ite.has(OC(e))}function QC(e){const t=e.trim().replace(/\s+/g,"");return/^-{3,}$/.test(t)||/^\*{3,}$/.test(t)||/^_{3,}$/.test(t)}function vy(e){const t=e.trim();return/^#{1,6}\s+/.test(t)||QC(e)||/^>\s?/.test(t)||/^(```|~~~)/.test(t)||/^(?:[-+*]|\d+[.)])\s+/.test(t)}function Ate(e){const t=e.trim();return/^(https?:|mailto:|#|\/|\.\/|\.\.\/)/i.test(t)||!/^[a-z][a-z0-9+.-]*:/i.test(t)&&!/[<>]/.test(t)?t:null}const $C=x.createContext(null);function qm(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function HC(e){return e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\[[^\]]*\]/g,"$1").replace(/[`*_~]/g,"").replace(/<[^>]+>/g,"").trim()}function UC(e){return e.replace(/\s+#+\s*$/,"").trim()}function wy(e,t){const r=HC(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 PS(e){return HC(e)||e.trim()}function Rg(e){const t=e.match(/^\s{0,3}\[([^\]]+)\]:\s+(.+?)\s*$/);if(!t)return null;const n=Ay(t[2]);return n?{id:qm(t[1]),definition:{href:n.href,title:n.title}}:null}function Tte(e){const t=new Map;for(const n of e){const r=Rg(n);r&&t.set(r.id,r.definition)}return t}function zC(e){return e.trim().toLowerCase()}function GC(e){const t=e.match(/^\s{0,3}\[\^([^\]]+)\]:\s+(.+)\s*$/);return t?{id:zC(t[1]),text:t[2]}:null}function Cte(e){const t=new Map;let n=null;for(const r of e){const s=GC(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 kte(e){const t=new Set;let n=!1;return e.forEach((r,s)=>{if(GC(r)){t.add(s),n=!0;return}if(n&&/^\s{4,}\S/.test(r)){t.add(s);return}r.trim()&&(n=!1)}),t}function _te(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 WC(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n<=0?n===0?"/":"":t.slice(0,n)}function bh(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 Lte(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,a=s>=0?r.slice(s+1):"",c=i.split("?",1)[0];if(!c)return null;let u,f=null;try{u=decodeURIComponent(c),f=a?decodeURIComponent(a):null}catch{return null}const p=n?bh(n):null;let g;if(u.startsWith("/")){const y=p&&(u===p||u.startsWith(`${p}/`));g=bh(p&&!y?`${p}/${u.slice(1)}`:u)}else{if(!t)return null;g=bh(`${WC(t)}/${u}`)}return p&&g!==p&&!g.startsWith(`${p}/`)?null:{path:g,fragment:f,directory:/\/$/.test(c)}}function Ete(e,t,n){const r=e.trim();if(!r||/^(?:javascript|data):/i.test(r))return null;if(/^https?:\/\//i.test(r))return r;if(!jy(r.split(/[?#]/,1)[0]))return null;let s;if(r.startsWith("/")){const i=n&&(r===n||r.startsWith(`${n}/`));s=bh(n&&!i?`${n}/${r.slice(1)}`:r)}else{if(!t)return null;s=bh(`${WC(t)}/${r}`)}return`/api/terminal/fs/blob?path=${encodeURIComponent(s)}`}const Sy=128,Ite=360,Rb=480;function Kv(e){try{return/\.svg(?=$|[?#&])/i.test(decodeURIComponent(e))}catch{return!1}}function Rte(e,t,n,r){if(!t||!n)return null;let s,i;return Kv(e)?(i=Math.min(Math.max(n,Sy),Ite),s=t*i/n):(s=t,i=n),r>0&&s>r&&(i=i*r/s,s=r),i>Rb&&(s=s*Rb/i,i=Rb),{width:Math.max(1,Math.round(s)),height:Math.max(1,Math.round(i))}}function Nte(e){if(!e.startsWith("/api/terminal/fs/blob?"))return null;try{return new URLSearchParams(e.slice(e.indexOf("?"))).get("path")}catch{return null}}function VC(e){const t=Nte(e),n=ut(r=>t?(r.fileChangeVersions.get(t)??0)+r.fileWatchEpoch:0);return t&&n>0?`${e}&v=${n}`:e}function Mte({src:e,alt:t,title:n}){const r=Kv(e),s=VC(e),i=x.useRef(null),[a,c]=x.useState(!1),[u,f]=x.useState(0),[p,g]=x.useState({status:"loading"}),[y,v]=x.useState(null);x.useLayoutEffect(()=>{const T=i.current,L=T?.parentElement?.parentElement??T?.parentElement;if(!L)return;const E=()=>f(L.clientWidth);if(E(),typeof ResizeObserver>"u")return;const D=new ResizeObserver(E);return D.observe(L),()=>D.disconnect()},[]),x.useEffect(()=>{if(a)return;const T=i.current;if(!T||typeof IntersectionObserver>"u"){c(!0);return}const L=new IntersectionObserver(E=>{E.some(D=>D.isIntersecting)&&(c(!0),L.disconnect())},{rootMargin:"400px"});return L.observe(T),()=>L.disconnect()},[a]),x.useEffect(()=>{if(!a)return;const T=new AbortController;let L=null;g({status:"loading"});const E=window.setTimeout(()=>{T.abort(new DOMException("Image fetch timed out","TimeoutError"))},15e3);return fetch(s,{signal:T.signal}).then(async D=>{if(!D.ok)throw new Error(`HTTP ${D.status}`);const P=Number(D.headers.get("X-Image-Width"))||0,F=Number(D.headers.get("X-Image-Height"))||0;return{blob:await D.blob(),width:P,height:F}}).then(({blob:D,width:P,height:F})=>{T.signal.aborted||(L=URL.createObjectURL(D),P>0&&F>0&&v({width:P,height:F}),g({status:"ready",objectUrl:L}))}).catch(()=>{const D=T.signal.reason;T.signal.aborted&&!(D instanceof DOMException&&D.name==="TimeoutError")||g({status:"fallback"})}).finally(()=>{window.clearTimeout(E)}),()=>{window.clearTimeout(E),T.abort(),L&&URL.revokeObjectURL(L)}},[a,s]);const S=Rte(e,y?.width??0,y?.height??0,u),C=S??{width:Sy*2,height:Sy};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:C.width,height:C.height},children:o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:t||"…"})})})}function Nb(e,t,n,r,s){const i=Ete(n,s.markdownFilePath,s.rootPath);if(!i)return`![${t}](${n})`;const a=s.images.length;s.images.push({kind:"image",src:i,alt:t,title:r});const c=o.jsx(Mte,{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?.(a)},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 Mb(e){let t=e,n="";for(;/[.,;:!?)]$/.test(t);)n=`${t.slice(-1)}${n}`,t=t.slice(0,-1);return{linkText:t,suffix:n}}function BS(e){return/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(e)}function Ay(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 qC="",Dte=/\\([\\`*{}\[\]#+\-.!_|~>$])/g;function jte(e){return e.replace(Dte,(t,n)=>`${qC}${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function FS(e){return e.replace(new RegExp(`${qC}([0-9a-f]{4})`,"g"),(t,n)=>String.fromCharCode(Number.parseInt(n,16))).replace(/\\([()])/g,"$1")}function Pte(e){const t=e.replace(/[\r\n]+/g," ");return/^ .+ $/.test(t)&&/[^ ]/.test(t.slice(1,-1))?t.slice(1,-1):t}const KC={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 xm=null;function YC(){return xm||(xm=B0(()=>import("./purify.es-CC4Brkr_.js"),[]).then(e=>e.default??e).catch(e=>{throw xm=null,e})),xm}function XC({html:e}){const{t}=Vn(),[n,r]=x.useState(null);return x.useEffect(()=>{let s=!1;return r(null),YC().then(i=>{s||r(i.sanitize(e,KC))}).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 Bte({html:e}){const[t,n]=x.useState(null);return x.useEffect(()=>{let r=!1;return n(null),YC().then(s=>{r||n(s.sanitize(e,KC))}).catch(()=>{r||n("")}),()=>{r=!0}},[e]),t===null?null:t?o.jsx("span",{dangerouslySetInnerHTML:{__html:t}}):e}function ZC(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 bm=null;function Fte(){return bm||(bm=Promise.all([B0(()=>import("./katex-DnlPpQZa.js"),[]),B0(()=>Promise.resolve({}),__vite__mapDeps([5]))]).then(([e])=>e.default??e).catch(e=>{throw bm=null,e})),bm}function Oh({tex:e,display:t=!1}){const[n,r]=x.useState(null),[s,i]=x.useState(!1);if(x.useEffect(()=>{let c=!1;return r(null),i(!1),Fte().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 a=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:a,dangerouslySetInnerHTML:{__html:n}})}function Ote(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(Bte,{html:e},t):null;const s=r[1].toLowerCase(),i=Ei(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 Ei(e,t,n=!0,r){const s=jte(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,a=[];let c=0,u;for(;(u=i.exec(s))!==null;){u.index>c&&a.push(FS(s.slice(c,u.index)));const f=u[0],p=`${t}-${u.index}`,g=f.startsWith("<")?Ote(f,p,r):null;if(g)a.push(g);else if(f.startsWith("\\(")&&f.endsWith("\\)"))a.push(o.jsx(Oh,{tex:f.slice(2,-2)},p));else if(f.startsWith("$")&&f.endsWith("$"))a.push(o.jsx(Oh,{tex:f.slice(1,-1)},p));else if(f.startsWith("`")){const y=f.match(/^`+/)?.[0].length??1;a.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:Pte(f.slice(y,-y))},p))}else if(f.startsWith("~~"))a.push(o.jsx("del",{className:"text-muted-foreground decoration-border-strong",children:Ei(f.slice(2,-2),`${p}-del`,n,r)},p));else if(f.startsWith("**")||f.startsWith("__"))a.push(o.jsx("strong",{className:"font-semibold text-foreground",children:Ei(f.slice(2,-2),`${p}-strong`,n,r)},p));else if(f.startsWith("*")||f.startsWith("_"))a.push(o.jsx("em",{className:"italic",children:Ei(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 C=Ay(y[2]);a.push(C?Nb(p,y[1],C.href,C.title,r):f)}else if(v){const C=v[2]||v[1],T=r.referenceDefinitions.get(qm(C));a.push(T?Nb(p,v[1],T.href,T.title,r):f)}else if(S){const C=r.referenceDefinitions.get(qm(S[1]));a.push(C?Nb(p,S[1],C.href,C.title,r):f)}else a.push(f)}else if(f.startsWith("[^")){const y=zC(f.slice(2,-1)),v=r.footnoteDefinitions.get(y);a.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);a.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(">")&&BS(f.slice(1,-1))){const y=f.slice(1,-1);a.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(BS(Mb(f).linkText)){const{linkText:y,suffix:v}=Mb(f);a.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&&a.push(v)}else if(f.startsWith("http")||f.startsWith("www.")){const{linkText:y,suffix:v}=Mb(f),S=y.startsWith("www.")?`https://${y}`:y;a.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&&a.push(v)}else{const y=f.match(/^\[([^\]]+)\]\((.*)\)$/),v=f.match(/^\[([^\]]+)\]\[([^\]]*)\]$/),S=f.match(/^\[([^\]]+)\]$/),C=v?v[2]||v[1]:S?.[1]??null,T=C?r.referenceDefinitions.get(qm(C)):null,L=y?Ay(y[2]):null,E=L?.href??T?.href??null,D=E?Ate(E):null,P=y?.[1]??v?.[1]??S?.[1]??"";a.push(D?o.jsx("a",{href:D,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:Ei(P,`${p}-link`,n,r)},p):f)}c=i.lastIndex}return c<s.length&&a.push(FS(s.slice(c))),a.length>0?a:[e]}function JC(e){return/(?: {2,}|\\)$/.test(e)}function ek(e){return e.replace(/(?: {2,}|\\)$/,"")}function Ng(e){return/^(?: {4}|\t)/.test(e)}function tk(e){return e.startsWith(" ")?e.slice(1):e.replace(/^ {4}/,"")}function nk(e,t,n){const r=[];return e.forEach((s,i)=>{const a=JC(s);r.push(...Ei(ek(s),`${t}-${i}`,!0,n)),i<e.length-1&&r.push(a?o.jsx("br",{},`${t}-${i}-br`):" ")}),r}function Ty(e,t,n){const r=[],s=[];return e.forEach((i,a)=>{s.push(JC(i)),r.push(Ei(ek(i),`${t}-${a}`,!0,n))}),{perLine:r,hardBreaks:s}}function Cy(e,t,n,r,s){const i=[];return e.forEach((a,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:a},`${r}-ref-${c}`)),c<e.length-1&&i.push(t[c]?o.jsx("br",{},`${r}-${c}-br`):" ")}),i}function Qh(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="",s=!1,i=0,a=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==="["?a+=1:i===0&&u==="]"&&a>0&&(a-=1),u==="|"&&i===0&&a===0){n.push(r.trim()),r="";continue}r+=u}return s&&(r+="\\"),n.push(r.trim()),n}function rk(e){return Qh(e).map(t=>/^:-+:$/.test(t)?"center":/^-+:$/.test(t)?"right":/^:-+$/.test(t)?"left":null)}function Mg(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Dg(e){return/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)*\|?$/.test(e.trim())}function Qte(e,t){return e>96||e>44&&t>.35}function Yv(e){return(e.match(/^\s*/)?.[0]??"").replace(/\t/g," ").length}function Xv(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 sk(e,t,n,r,s,i=new Set){const a=[],c=[];let u=t;for(;u<e.length;){const f=e[u];if(s&&(Rg(f)||i.has(u))){u+=1;continue}const p=Xv(f),g=Yv(f);if(!p){if(g>n&&c.length>0){([...c].reverse().find(C=>C.indent<g)?.item??c[c.length-1].item).paragraphs.push(f.trim());for(const C of c)C.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):a.push(y),c.push({indent:g,item:y});for(const S of c)S.item.lineEnd=u+1;u+=1}return{items:a,nextIndex:u}}function Zv(e,t,n,r=0){return e.map((s,i)=>{const a=s.content.match(/^\[([ xX])\]\s+(.+)$/);return{key:`item-${i}`,taskItem:!!a,refStart:s.lineStart+r,refEnd:s.lineEnd+r,content:o.jsxs(o.Fragment,{children:[a?o.jsx("input",{type:"checkbox",checked:a[1].toLowerCase()==="x",readOnly:!0,className:"mr-2 align-[-2px] accent-primary"}):null,Ei(a?.[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:Ei(c,`li-${t}-${i}-p-${u}`,!0,n)},`paragraph-${u}`))})]}),groups:$te(s.children,`${t}-${i}`,n,r)}})}function $te(e,t,n,r=0){const s=[];for(const i of e){const a=s[s.length-1];a&&a.ordered===i.ordered?a.items.push(i):s.push({ordered:i.ordered,items:[i]})}return s.map((i,a)=>({ordered:i.ordered,start:i.ordered?i.items[0]?.start:void 0,items:Zv(i.items,`${t}-g${a}`,n,r)}))}function Jv(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&&Hte(n.groups,t)]},n.key)})}function Hte(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:Jv(n.items,t)},`nested-${r}`)})}function Ute(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:[Ei(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 zte(e,t,n,r){const s=[];let i=0;const a=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 E="Details";const D=[];for(i+=1;i<e.length&&!/^<\/details>\s*$/i.test(e[i].trim());){const P=e[i].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);P?E=P[1].trim()||E:D.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:Ei(E,`${t}-details-${L}-summary`,!0,n)}),D.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:nk(D,`${t}-details-${L}`,n)})]},`${t}-details-${L}`)});continue}const f=ZC(c);if(f){const L=[c],E=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(XC,{html:L.join(`
183
183
  `)},`${t}-html-${E}`)});continue}const p=u.match(/^(```|~~~)\s*(.*)$/);if(p){const L=[],E=p[1],D=p[2]?.trim(),P=i;for(i+=1;i<e.length&&!e[i].trim().startsWith(E);)L.push(e[i]),i+=1;i<e.length&&(i+=1),D.toLowerCase()==="mermaid"?s.push({kind:"static",node:o.jsx(ok,{code:L.join(`
184
184
  `),blockKey:`${t}-code-${P}`},`${t}-code-${P}`)}):["math","latex","tex"].includes(D.toLowerCase())?s.push({kind:"static",node:o.jsx(Oh,{tex:L.join(`
185
185
  `),display:!0},`${t}-code-${P}`)}):s.push({kind:"code",key:`${t}-code-${P}`,code:L.join(`
186
186
  `),lang:D,blockKey:`${t}-code-${P}`,codeStartLine:a(P)+1});continue}if(Ng(c)){const L=[],E=i;for(;i<e.length&&(Ng(e[i])||!e[i].trim());)L.push(e[i].trim()?tk(e[i]):""),i+=1;s.push({kind:"code",key:`${t}-indented-code-${E}`,code:L.join(`
187
- `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${E}`,codeStartLine:a(E)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const E=`h${Math.min(6,g[1].length+1)}`,D=UC(g[2]),P=wy(D,n);s.push({kind:"static",node:o.jsx(E,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:Ei(D,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&Dg(e[i+1])){const L=Qh(c),E=rk(e[i+1]),D=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)D.push(Qh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:jC,"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,j)=>o.jsx("th",{className:`${MC} ${Mg(E[j]??null)}`,children:o.jsx("div",{className:Ig,children:Ei(F,`${t}-th-${P}-${j}`,!0,n)})},`h-${j}`))})}),o.jsx("tbody",{children:D.map((F,j)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((A,H)=>o.jsx("td",{className:`${DC} ${Mg(E[H]??null)}`,children:o.jsx("div",{className:Ig,children:Ei(F[H]??"",`${t}-td-${P}-${j}-${H}`,!0,n)})},`c-${H}`))},`r-${j}`))})]})},`${t}-table-${P}`)});continue}const y=Xv(c);if(y){const L=y.ordered,E=Yv(c),D=y.start,P=i,F=sk(e,i,E,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?D:void 0,renders:Zv(F.items,`${t}-list-${P}`,n,a(0)-1)});continue}const v=[c.trimStart()],S=[a(i)],C=i;for(i+=1;i<e.length&&e[i].trim()&&!vy(e[i])&&!(i+1<e.length&&e[i].includes("|")&&Dg(e[i+1]));)v.push(e[i].trimStart()),S.push(a(i)),i+=1;const T=Ty(v,`${t}-p-${C}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${C}`,perLine:T.perLine,hardBreaks:T.hardBreaks,lineNums:S})}return s}function Gte(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:Cy(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:Jv(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(jg,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let ym=null,OS=!1;const vm=16,ik=192;function Wte(){return ym||(ym=B0(()=>import("./mermaid.core-9k4zR2lI.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw ym=null,e})),ym}function Vte(e){OS||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),OS=!0)}function qte(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 a=Math.max(ik,Math.ceil(s)),c=Math.ceil(a/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${a}" height="${c}">`)}function Kte(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-vm,s=n.y-vm,i=n.width+vm*2,a=n.height+vm*2,c=Math.max(ik,Math.ceil(i)),u=Math.ceil(c/i*a);t.setAttribute("viewBox",`${r} ${s} ${i} ${a}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function Yte(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return A0(`code.${n}`)??n}function ok({code:e,blockKey:t}){const{t:n}=Vn(),[r,s]=x.useState(null),[i,a]=x.useState(!1),c=x.useRef(null),u=x.useContext($C);x.useEffect(()=>{let p=!1;return s(null),a(!1),Wte().then(async g=>{Vte(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(qte(v))}).catch(()=>{p||a(!0)}),()=>{p=!0}},[t,e]),x.useLayoutEffect(()=>{r&&Kte(c.current)},[r]);const f=x.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(jg,{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 jg({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=Yte(t),[a,c]=x.useState(null);x.useEffect(()=>{if(!i||!tC(e)){c(null);return}let f=!1;return nC().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(rC(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=a??(e||" ").split(`
187
+ `).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${E}`,codeStartLine:a(E)});continue}const g=u.match(/^(#{1,6})\s+(.+)$/);if(g){const E=`h${Math.min(6,g[1].length+1)}`,D=UC(g[2]),P=wy(D,n);s.push({kind:"static",node:o.jsx(E,{id:P,className:"scroll-mt-16 font-semibold text-foreground",children:Ei(D,`${t}-heading-${i}`,!0,n)},`${t}-heading-${i}`)}),i+=1;continue}if(i+1<e.length&&c.includes("|")&&Dg(e[i+1])){const L=Qh(c),E=rk(e[i+1]),D=[],P=i;for(i+=2;i<e.length&&e[i].includes("|")&&e[i].trim();)D.push(Qh(e[i])),i+=1;s.push({kind:"static",node:o.jsx("div",{className:jC,"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,j)=>o.jsx("th",{className:`${MC} ${Mg(E[j]??null)}`,children:o.jsx("div",{className:Ig,children:Ei(F,`${t}-th-${P}-${j}`,!0,n)})},`h-${j}`))})}),o.jsx("tbody",{children:D.map((F,j)=>o.jsx("tr",{className:"border-t border-border/10",children:L.map((A,H)=>o.jsx("td",{className:`${DC} ${Mg(E[H]??null)}`,children:o.jsx("div",{className:Ig,children:Ei(F[H]??"",`${t}-td-${P}-${j}-${H}`,!0,n)})},`c-${H}`))},`r-${j}`))})]})},`${t}-table-${P}`)});continue}const y=Xv(c);if(y){const L=y.ordered,E=Yv(c),D=y.start,P=i,F=sk(e,i,E,L,!1);i=F.nextIndex,s.push({kind:"list",keyPrefix:`${t}-list-${P}`,ordered:L,start:L?D:void 0,renders:Zv(F.items,`${t}-list-${P}`,n,a(0)-1)});continue}const v=[c.trimStart()],S=[a(i)],C=i;for(i+=1;i<e.length&&e[i].trim()&&!vy(e[i])&&!(i+1<e.length&&e[i].includes("|")&&Dg(e[i+1]));)v.push(e[i].trimStart()),S.push(a(i)),i+=1;const T=Ty(v,`${t}-p-${C}`,n);s.push({kind:"paragraph",keyPrefix:`${t}-p-${C}`,perLine:T.perLine,hardBreaks:T.hardBreaks,lineNums:S})}return s}function Gte(e,t){return e.map(n=>{switch(n.kind){case"static":return n.node;case"paragraph":return o.jsx("p",{children:Cy(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:Jv(n.renders,t)},n.keyPrefix)}case"code":return o.jsx(jg,{code:n.code,lang:n.lang,blockKey:n.blockKey,codeStartLine:n.codeStartLine,lineRange:t},n.key)}})}let ym=null,OS=!1;const vm=16,ik=192;function Wte(){return ym||(ym=B0(()=>import("./mermaid.core-0rN8fFng.js").then(e=>e.aJ),__vite__mapDeps([6,1,7])).then(e=>e.default??e).catch(e=>{throw ym=null,e})),ym}function Vte(e){OS||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),OS=!0)}function qte(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 a=Math.max(ik,Math.ceil(s)),c=Math.ceil(a/s*i);return e.replace(/<svg\b([^>]*)>/i,(u,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${a}" height="${c}">`)}function Kte(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-vm,s=n.y-vm,i=n.width+vm*2,a=n.height+vm*2,c=Math.max(ik,Math.ceil(i)),u=Math.ceil(c/i*a);t.setAttribute("viewBox",`${r} ${s} ${i} ${a}`),t.setAttribute("width",String(c)),t.setAttribute("height",String(u)),t.removeAttribute("style")}function Yte(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const n=t.replace(/^language-/,"");return A0(`code.${n}`)??n}function ok({code:e,blockKey:t}){const{t:n}=Vn(),[r,s]=x.useState(null),[i,a]=x.useState(!1),c=x.useRef(null),u=x.useContext($C);x.useEffect(()=>{let p=!1;return s(null),a(!1),Wte().then(async g=>{Vte(g);const y=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:v}=await g.render(y,e);p||s(qte(v))}).catch(()=>{p||a(!0)}),()=>{p=!0}},[t,e]),x.useLayoutEffect(()=>{r&&Kte(c.current)},[r]);const f=x.useCallback(()=>{const p=c.current?.querySelector("svg")?.outerHTML??r;p&&u?.(p)},[u,r]);return i?o.jsx(jg,{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 jg({code:e,lang:t,blockKey:n,codeStartLine:r,lineRange:s}){const i=Yte(t),[a,c]=x.useState(null);x.useEffect(()=>{if(!i||!tC(e)){c(null);return}let f=!1;return nC().then(p=>{if(f||!p.registered(i)){f||c(null);return}try{c(rC(p,e,i))}catch{f||c(null)}}).catch(()=>{f||c(null)}),()=>{f=!0}},[n,e,i]);const u=a??(e||" ").split(`
188
188
  `).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:`${qv} 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?`
189
189
  `:null]},`${n}-line-${p}`)})})})]})}function Xte(e,t,n,r,s){e=_te(e);const i=Tte(e),a=kte(e),c=[],u={markdownFilePath:t,rootPath:n,referenceDefinitions:i,footnoteDefinitions:Cte(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)||a.has(p)){p+=1;continue}if(!v){p+=1;continue}if(/^<details>\s*$/i.test(v)){const j=p;let A="Details";const H=[];for(p+=1;p<e.length&&!/^<\/details>\s*$/i.test(e[p].trim());){const Q=e[p].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);Q?A=Q[1].trim()||A:H.push(e[p].trimStart()),p+=1}p<e.length&&(p+=1),f.push({key:`details-${j}`,startLine:j+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:Ei(A,`details-${j}-summary`,!0,u)}),H.length>0&&o.jsx("div",{className:"mt-2 text-sm leading-6",children:nk(H,`details-${j}`,u)})]})});continue}const S=ZC(y);if(S){const j=[y],A=p;for(p+=1;p<e.length&&!S.selfContained&&!new RegExp(`</${S.tag}>`,"i").test(e[p]);)j.push(e[p]),p+=1;p<e.length&&!S.selfContained&&(j.push(e[p]),p+=1),f.push({key:`html-${A}`,startLine:A+1,endLine:p,content:o.jsx(XC,{html:j.join(`
190
190
  `)})});continue}const C=v.match(/^(```|~~~)\s*(.*)$/);if(C){const j=[],A=C[1],H=C[2]?.trim(),Q=p;for(p+=1;p<e.length&&!e[p].trim().startsWith(A);)j.push(e[p]),p+=1;p<e.length&&(p+=1),f.push({key:`code-${Q}`,startLine:Q+1,endLine:p,fineGrained:H.toLowerCase()!=="mermaid"&&!["math","latex","tex"].includes(H.toLowerCase()),content:H.toLowerCase()==="mermaid"?o.jsx(ok,{code:j.join(`
@@ -628,4 +628,4 @@ new file mode 100644
628
628
  @@ -0,0 +1,2 @@
629
629
  +export const second = true;
630
630
  +announce(second);`}};function u7(){if(typeof window>"u")return"kotlin";const t=new URLSearchParams(window.location.search).get("fixture");return t&&t in Ly?t:"kotlin"}function d7(){return typeof window>"u"?"unified":new URLSearchParams(window.location.search).get("view")==="split"?"split":"unified"}function f7(){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 h7(){return typeof window>"u"?!0:new URLSearchParams(window.location.search).get("wrap")!=="off"}function ure(){const[e,t]=x.useState(()=>u7()),[n,r]=x.useState(()=>d7()),[s,i]=x.useState(()=>mC()),[a,c]=x.useState(()=>f7()),[u,f]=x.useState(()=>h7()),p=Ly[e],g=x.useMemo(()=>Object.entries(Ly),[]),y=n==="split"&&!s?"unified":n;return x.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const v=window.matchMedia(Gv),S=()=>i(v.matches);return S(),v.addEventListener?.("change",S),()=>v.removeEventListener?.("change",S)},[]),x.useEffect(()=>{if(typeof window>"u")return;let v=window.location.search;const S=()=>{window.location.search!==v&&(v=window.location.search,t(u7()),r(d7()),c(f7()),f(h7()))};window.addEventListener("popstate",S),window.addEventListener("pageshow",S),window.addEventListener("focus",S);const C=window.setInterval(S,250);return()=>{window.removeEventListener("popstate",S),window.removeEventListener("pageshow",S),window.removeEventListener("focus",S),window.clearInterval(C)}},[]),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":y,"data-diff-lab-requested-view":n,"data-diff-lab-inline":a,"data-diff-lab-wrap":u?"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:v=>t(v.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:g.map(([v,S])=>o.jsx("option",{value:v,children:S.label},v))}),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"),"aria-pressed":y==="unified",className:`rounded-full px-3 text-xs font-semibold ${y==="unified"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Unified"}),o.jsx("button",{type:"button",onClick:()=>r("split"),disabled:!s,"aria-pressed":y==="split",className:`rounded-full px-3 text-xs font-semibold ${y==="split"?"bg-surface-elevated text-foreground":"text-muted-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,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(v=>o.jsx("button",{type:"button",onClick:()=>c(v),className:`rounded-full px-3 text-xs font-semibold ${a===v?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:v},v))}),o.jsxs("button",{type:"button",onClick:()=>f(v=>!v),className:`h-8 rounded-full px-3 text-xs font-semibold ${u?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:["Wrap ",u?"on":"off"]})]})]}),o.jsx("main",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border/20 bg-surface",children:o.jsx(gC,{filePath:p.path,repoRoot:"/tmp/termdock-diff-lab",changedFile:{path:p.path,absolutePath:`/tmp/termdock-diff-lab/${p.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:p.diff,oldSourceOverride:p.oldSource,active:!0,wrap:u,showScrollHint:!u,viewType:y,inlineMode:a})})]})})}const vk=40,Ey="/tmp/termdock-diff-review-lab";function p7(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(`
631
- `)}function dre(e,t){return Array.from({length:vk},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,a=`${Ey}/${i}`,c=p7(i,s),u=p7(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:Ey,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function fre(){const e=x.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),E=L===null?0:Number.parseInt(L,10);return Number.isInteger(E)&&E>0?E:0},[]),t=e>0,[n,r]=x.useState(()=>new Set);x.useEffect(()=>{if(!t)return;const L=Array.from({length:vk},(E,D)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(D),F})},e+D*20));return()=>L.forEach(E=>window.clearTimeout(E))},[t,e]);const s=x.useMemo(()=>dre(n,t),[n,t]),i=x.useMemo(()=>[{key:"mock-repo",root:Ey,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]),a=x.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const E=Number.parseInt(L,10);return Number.isInteger(E)&&E>=0&&E<s.length?E:null},[s.length]),[c,u]=x.useState(()=>a!==null?s[a].key:null),[f,p]=x.useState(()=>({key:a!==null?s[a].key:null,nonce:a!==null?1:0})),[g,y]=x.useState("list"),[v,S]=x.useState(new Set),[C,T]=x.useState(a!==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 ",C]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(_g,{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(E=>{const D=new Set(E);return D.has(L)?D.delete(L):D.add(L),D}),onSelectFile:L=>{u(L.key),p(E=>({key:L.key,nonce:E.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 hre=6e4,zb="termdock:build-id:v1";let m7=!1;function g7(){m7||(m7=!0,window.setTimeout(()=>{window.location.reload()},80))}function Iy(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function pre(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function mre(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Iy(e)})})}function gre(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788415469216",t=window.localStorage.getItem(zb);if(t&&t!==e){pre().finally(()=>{window.localStorage.setItem(zb,e),g7()});return}t!==e&&window.localStorage.setItem(zb,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",g7),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{mre(r),Iy(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Iy(r)).catch(()=>{})};s(),n=window.setInterval(s,hre),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}XO();gre();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,J9(e))}catch{}function xre(){const{t:e}=Vn(),[t,n]=x.useState(null),[r,s]=x.useState(null),i=x.useCallback(async()=>{try{const a=await yI();n(a),s(null)}catch(a){s(a instanceof Error?a.message:"Failed to query auth status")}},[]);return x.useEffect(()=>{i()},[i]),x.useEffect(()=>{const a=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(yh,a),()=>window.removeEventListener(yh,a)},[]),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(lre,{onLoginSuccess:i}):o.jsx(ore,{})}O_.createRoot(document.getElementById("root")).render(o.jsx(M.StrictMode,{children:o.jsx(sN,{children:o.jsx(sA,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(cre,{}):e.get("diff-review-lab")==="1"?o.jsx(fre,{}):e.get("diff-lab")==="1"?o.jsx(ure,{}):o.jsx(xre,{})})()})})}));export{FM as M,Bs as R,ID as S,B0 as _,UM as a,GM as b,_t as c,o as j,Vn as u,vE as v};
631
+ `)}function dre(e,t){return Array.from({length:vk},(n,r)=>{const s=6+r*7%60,i=`src/module${String(r).padStart(2,"0")}/File${r}.ts`,a=`${Ey}/${i}`,c=p7(i,s),u=p7(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:Ey,displayName:`File${r}.ts`,displayDir:`src/module${String(r).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(r)?c:u,auditRecords:[]}})}function fre(){const e=x.useMemo(()=>{if(typeof window>"u")return 0;const L=new URLSearchParams(window.location.search).get("delay"),E=L===null?0:Number.parseInt(L,10);return Number.isInteger(E)&&E>0?E:0},[]),t=e>0,[n,r]=x.useState(()=>new Set);x.useEffect(()=>{if(!t)return;const L=Array.from({length:vk},(E,D)=>window.setTimeout(()=>{r(P=>{const F=new Set(P);return F.add(D),F})},e+D*20));return()=>L.forEach(E=>window.clearTimeout(E))},[t,e]);const s=x.useMemo(()=>dre(n,t),[n,t]),i=x.useMemo(()=>[{key:"mock-repo",root:Ey,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]),a=x.useMemo(()=>{if(typeof window>"u")return null;const L=new URLSearchParams(window.location.search).get("select");if(L===null)return null;const E=Number.parseInt(L,10);return Number.isInteger(E)&&E>=0&&E<s.length?E:null},[s.length]),[c,u]=x.useState(()=>a!==null?s[a].key:null),[f,p]=x.useState(()=>({key:a!==null?s[a].key:null,nonce:a!==null?1:0})),[g,y]=x.useState("list"),[v,S]=x.useState(new Set),[C,T]=x.useState(a!==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 ",C]}),o.jsx("div",{className:"min-h-0 flex-1",children:o.jsx(_g,{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(E=>{const D=new Set(E);return D.has(L)?D.delete(L):D.add(L),D}),onSelectFile:L=>{u(L.key),p(E=>({key:L.key,nonce:E.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 hre=6e4,zb="termdock:build-id:v1";let m7=!1;function g7(){m7||(m7=!0,window.setTimeout(()=>{window.location.reload()},80))}function Iy(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function pre(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function mre(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&Iy(e)})})}function gre(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1788422476850",t=window.localStorage.getItem(zb);if(t&&t!==e){pre().finally(()=>{window.localStorage.setItem(zb,e),g7()});return}t!==e&&window.localStorage.setItem(zb,e);let n=null;navigator.serviceWorker.addEventListener("controllerchange",g7),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(r=>{mre(r),Iy(r);const s=()=>{document.visibilityState==="visible"&&r.update().then(()=>Iy(r)).catch(()=>{})};s(),n=window.setInterval(s,hre),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{n!==null&&window.clearInterval(n)})}XO();gre();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,J9(e))}catch{}function xre(){const{t:e}=Vn(),[t,n]=x.useState(null),[r,s]=x.useState(null),i=x.useCallback(async()=>{try{const a=await yI();n(a),s(null)}catch(a){s(a instanceof Error?a.message:"Failed to query auth status")}},[]);return x.useEffect(()=>{i()},[i]),x.useEffect(()=>{const a=()=>{n(c=>c&&{...c,authenticated:!1})};return window.addEventListener(yh,a),()=>window.removeEventListener(yh,a)},[]),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(lre,{onLoginSuccess:i}):o.jsx(ore,{})}O_.createRoot(document.getElementById("root")).render(o.jsx(M.StrictMode,{children:o.jsx(sN,{children:o.jsx(sA,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?o.jsx(cre,{}):e.get("diff-review-lab")==="1"?o.jsx(fre,{}):e.get("diff-lab")==="1"?o.jsx(ure,{}):o.jsx(xre,{})})()})})}));export{FM as M,Bs as R,ID as S,B0 as _,UM as a,GM as b,_t as c,o as j,Vn as u,vE as v};