termdock 1.4.24 → 1.4.25
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.
- package/dist/client/assets/{abnfDiagram-VRR7QNED-eiL9uKOz.js → abnfDiagram-VRR7QNED-DLIM-UM-.js} +1 -1
- package/dist/client/assets/{arc-UAsUQb_y.js → arc-BuroUKdb.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZJ3FMSHR-_cG5L7fQ.js → architectureDiagram-ZJ3FMSHR-Bc6fmXxr.js} +1 -1
- package/dist/client/assets/{blockDiagram-677ZJIJ3-Dsxx2V_6.js → blockDiagram-677ZJIJ3-Bothvfu7.js} +1 -1
- package/dist/client/assets/{c4Diagram-LMCZKHZV-C95kCKbZ.js → c4Diagram-LMCZKHZV-DReXnSzr.js} +1 -1
- package/dist/client/assets/channel-DTeOUf8Q.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-Dl8Tgars.js → chunk-2Q5K7J3B-B9Ha_NZX.js} +1 -1
- package/dist/client/assets/{chunk-32BRIVSS-CF1pWlER.js → chunk-32BRIVSS-Ovzr_jMz.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-skt4BwDO.js → chunk-5VM5RSS4-Dw9eskV3.js} +1 -1
- package/dist/client/assets/{chunk-EX3LRPZG-DbpkxRAB.js → chunk-EX3LRPZG-Bo8XHkwe.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-CWg1iuHX.js → chunk-JWPE2WC7-BhYttHrO.js} +1 -1
- package/dist/client/assets/{chunk-MOJQB5TN-muIh8WZB.js → chunk-MOJQB5TN-CQNeI5Vl.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-CuNz5ge0.js → chunk-RYQCIY6F-D8H2Ipu9.js} +1 -1
- package/dist/client/assets/{chunk-V7JOEXUC-CwlOQp0g.js → chunk-V7JOEXUC-CXs3VjLv.js} +1 -1
- package/dist/client/assets/{chunk-VR4S4FIN-WcTwG3ou.js → chunk-VR4S4FIN-pxEhrCjf.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-DiMgCsVK.js → chunk-XXDRQBXY-NWOQcaZx.js} +1 -1
- package/dist/client/assets/classDiagram-OUVF2IWQ-BHWT0Pdt.js +1 -0
- package/dist/client/assets/classDiagram-v2-EOCWNBFH-BHWT0Pdt.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-rKlFRS_v.js → cose-bilkent-JH36ORCC-B3yV-ocL.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-19W3wHkH.js → cynefin-VYW2F7L2-Cw747dzr.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-TSTJHNR4-BnqoiRm3.js → cynefinDiagram-TSTJHNR4-_vQCFcA4.js} +1 -1
- package/dist/client/assets/{dagre-VKFMJZFB-DESawRgV.js → dagre-VKFMJZFB-4kmrz4Bm.js} +1 -1
- package/dist/client/assets/{diagram-FQU43EPY-CArnQEV-.js → diagram-FQU43EPY-C9LHhpjR.js} +1 -1
- package/dist/client/assets/{diagram-G47NLZAW-CAJMh8yl.js → diagram-G47NLZAW-DYabfxcr.js} +1 -1
- package/dist/client/assets/{diagram-NH7WQ7WH-Dg3Kr8SD.js → diagram-NH7WQ7WH-D8lguB3v.js} +1 -1
- package/dist/client/assets/{diagram-OA4YK3LP-eRazOoG1.js → diagram-OA4YK3LP-BkxTyIB1.js} +1 -1
- package/dist/client/assets/{diagram-WEI45ONY-CM7yVYi9.js → diagram-WEI45ONY-DMlA_4lo.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-CCIWWBDH-Dcryh45T.js → ebnfDiagram-CCIWWBDH-vJo6it78.js} +1 -1
- package/dist/client/assets/{erDiagram-Q63AITRT-Ba4aZkMD.js → erDiagram-Q63AITRT-wBRZUZ-Z.js} +1 -1
- package/dist/client/assets/{flowDiagram-23GEKE2U-DjnK-A_R.js → flowDiagram-23GEKE2U-Dgve0mmH.js} +1 -1
- package/dist/client/assets/{ganttDiagram-NO4QXBWP-CYSkKKTJ.js → ganttDiagram-NO4QXBWP-B_MRYQpB.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-IHSO6WYX-9rgo0rSa.js → gitGraphDiagram-IHSO6WYX-By7_E9uR.js} +1 -1
- package/dist/client/assets/{index-kPqgo8Wb.js → index-WdIr2iXH.js} +4 -4
- package/dist/client/assets/{infoDiagram-FWYZ7A6U-D1O7KdvB.js → infoDiagram-FWYZ7A6U-_9FCvkT7.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-FXEZZL3T-CJBgSYK-.js → ishikawaDiagram-FXEZZL3T-B8FB83CA.js} +1 -1
- package/dist/client/assets/{journeyDiagram-5HDEW3XC-BbBvHRyH.js → journeyDiagram-5HDEW3XC-nFRNxNhN.js} +1 -1
- package/dist/client/assets/{kanban-definition-HUTT4EX6-cPpU7e7Y.js → kanban-definition-HUTT4EX6-DfBG3g7l.js} +1 -1
- package/dist/client/assets/{linear-DKCnwjes.js → linear-CYUtB_6e.js} +1 -1
- package/dist/client/assets/{mermaid.core-o-IwuLPX.js → mermaid.core-DQW1U4Sy.js} +4 -4
- package/dist/client/assets/{mindmap-definition-LN4V7U3C-Cg4h9fnP.js → mindmap-definition-LN4V7U3C-D5OqKl68.js} +1 -1
- package/dist/client/assets/{pegDiagram-2B236MQR-B3qG8LC9.js → pegDiagram-2B236MQR-ByiRTrRq.js} +1 -1
- package/dist/client/assets/{pieDiagram-ENE6RG2P-DS8e_EO2.js → pieDiagram-ENE6RG2P-x5zh8_pP.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-ABIIQ3AL-C3TiOMky.js → quadrantDiagram-ABIIQ3AL-drhDTRfA.js} +1 -1
- package/dist/client/assets/{railroadDiagram-RFXS5EU6-VAL-gsC9.js → railroadDiagram-RFXS5EU6-CJtqq9oL.js} +1 -1
- package/dist/client/assets/{requirementDiagram-TGXJPOKE-BRisK4In.js → requirementDiagram-TGXJPOKE-B3NSwMiv.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-HTMAVEWB-BQIJ5m7L.js → sankeyDiagram-HTMAVEWB-DaAfeKlJ.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-DBY2YBRQ-DDTB827U.js → sequenceDiagram-DBY2YBRQ-kuu3Z4cH.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-JX2GlWSO.js → sizeCapture-X5ZJPWSS-BfQu-v3Y.js} +1 -1
- package/dist/client/assets/{stateDiagram-2N3HPSRC-Br-rHQjP.js → stateDiagram-2N3HPSRC-BZfT37eR.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-6OUMAXLB-CkqISltE.js +1 -0
- package/dist/client/assets/{swimlanes-5IMT3BWC-BMaWcX8Y.js → swimlanes-5IMT3BWC-B5fZzxgX.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-G3AALYLV-LUG4O_Oq.js +8 -0
- package/dist/client/assets/{timeline-definition-FHXFAJF6-BTRMaBCo.js → timeline-definition-FHXFAJF6-COBJ0JVn.js} +1 -1
- package/dist/client/assets/{vennDiagram-L72KCM5P-DobBEeTW.js → vennDiagram-L72KCM5P-BEpmSxGf.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-EHGQE667-JS_rrvwZ.js → wardleyDiagram-EHGQE667-DzinqlCM.js} +1 -1
- package/dist/client/assets/{xychartDiagram-FW5EYKEG-d6NunS30.js → xychartDiagram-FW5EYKEG-DZYSufru.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/sw.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/channel-DpwuuVsx.js +0 -1
- package/dist/client/assets/classDiagram-OUVF2IWQ-CmqqvcR1.js +0 -1
- package/dist/client/assets/classDiagram-v2-EOCWNBFH-CmqqvcR1.js +0 -1
- package/dist/client/assets/stateDiagram-v2-6OUMAXLB-BzcEmcZ6.js +0 -1
- package/dist/client/assets/swimlanesDiagram-G3AALYLV-Cpop92_G.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/katex-55ZPZeOF.css","assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Ca-rq7yX.js","assets/react-XDCjal2T.js","assets/katex-55ZPZeOF.css","assets/mermaid.core-DQW1U4Sy.js","assets/purify.es-CC4Brkr_.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as _p,a as CT,g as b6}from"./react-XDCjal2T.js";import{b as A,R as P,r as o0,a as _T}from"./dnd-BCFAPC0L.js";import{L as LT,l as kT}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"]'))n(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"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(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 n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();var Fm={exports:{}},G0={};var rb;function ET(){if(rb)return G0;rb=1;var e=_p(),t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=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(u,d,f){var b,g={},y=null,v=null;f!==void 0&&(y=""+f),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(v=d.ref);for(b in d)n.call(d,b)&&!i.hasOwnProperty(b)&&(g[b]=d[b]);if(u&&u.defaultProps)for(b in d=u.defaultProps,d)g[b]===void 0&&(g[b]=d[b]);return{$$typeof:t,type:u,key:y,ref:v,props:g,_owner:s.current}}return G0.Fragment=r,G0.jsx=a,G0.jsxs=a,G0}var nb;function IT(){return nb||(nb=1,Fm.exports=ET()),Fm.exports}var c=IT(),jh={},sb;function MT(){if(sb)return jh;sb=1;var e=CT();return jh.createRoot=e.createRoot,jh.hydrateRoot=e.hydrateRoot,jh}var RT=MT();const NT=b6(RT);function ib(e){return e!==null&&typeof e=="object"&&"constructor"in e&&e.constructor===Object}function _2(e={},t={}){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(n=>r.indexOf(n)<0).forEach(n=>{typeof e[n]>"u"?e[n]=t[n]:ib(t[n])&&ib(e[n])&&Object.keys(t[n]).length>0&&_2(e[n],t[n])})}const x6={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 Pc(){const e=typeof document<"u"?document:{};return _2(e,x6),e}const DT={document:x6,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 Yi(){const e=typeof window<"u"?window:{};return _2(e,DT),e}function BT(e=""){return e.trim().split(" ").filter(t=>!!t.trim())}function PT(e){const t=e;Object.keys(t).forEach(r=>{try{t[r]=null}catch{}try{delete t[r]}catch{}})}function y6(e,t=0){return setTimeout(e,t)}function Wf(){return Date.now()}function jT(e){const t=Yi();let r;return t.getComputedStyle&&(r=t.getComputedStyle(e,null)),!r&&e.currentStyle&&(r=e.currentStyle),r||(r=e.style),r}function QT(e,t="x"){const r=Yi();let n,s,i;const a=jT(e);return r.WebKitCSSMatrix?(s=a.transform||a.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(u=>u.replace(",",".")).join(", ")),i=new r.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,"),n=i.toString().split(",")),t==="x"&&(r.WebKitCSSMatrix?s=i.m41:n.length===16?s=parseFloat(n[12]):s=parseFloat(n[4])),t==="y"&&(r.WebKitCSSMatrix?s=i.m42:n.length===16?s=parseFloat(n[13]):s=parseFloat(n[5])),s||0}function Qh(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"}function FT(e){return typeof window<"u"&&typeof window.HTMLElement<"u"?e instanceof HTMLElement:e&&(e.nodeType===1||e.nodeType===11)}function So(...e){const t=Object(e[0]);for(let r=1;r<e.length;r+=1){const n=e[r];if(n!=null&&!FT(n)){const s=Object.keys(Object(n)).filter(i=>i!=="__proto__"&&i!=="constructor"&&i!=="prototype");for(let i=0,a=s.length;i<a;i+=1){const u=s[i],d=Object.getOwnPropertyDescriptor(n,u);d!==void 0&&d.enumerable&&(Qh(t[u])&&Qh(n[u])?n[u].__swiper__?t[u]=n[u]:So(t[u],n[u]):!Qh(t[u])&&Qh(n[u])?(t[u]={},n[u].__swiper__?t[u]=n[u]:So(t[u],n[u])):t[u]=n[u])}}}return t}function fu(e,t,r){e.style.setProperty(t,r)}function v6({swiper:e,targetPosition:t,side:r}){const n=Yi(),s=-e.translate;let i=null,a;const u=e.params.speed;e.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(e.cssModeFrameID);const d=t>s?"next":"prev",f=(g,y)=>d==="next"&&g>=y||d==="prev"&&g<=y,b=()=>{a=new Date().getTime(),i===null&&(i=a);const g=Math.max(Math.min((a-i)/u,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({[r]:v}),f(v,t)){e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[r]:v})}),n.cancelAnimationFrame(e.cssModeFrameID);return}e.cssModeFrameID=n.requestAnimationFrame(b)};b()}function rl(e,t=""){const r=Yi(),n=[...e.children];return r.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(s=>s.matches(t)):n}function OT(e,t){const r=[t];for(;r.length>0;){const n=r.shift();if(e===n)return!0;r.push(...n.children,...n.shadowRoot?n.shadowRoot.children:[],...n.assignedElements?n.assignedElements():[])}}function $T(e,t){const r=Yi();let n=t.contains(e);return!n&&r.HTMLSlotElement&&t instanceof HTMLSlotElement&&(n=[...t.assignedElements()].includes(e),n||(n=OT(e,t))),n}function Vf(e){try{console.warn(e);return}catch{}}function g1(e,t=[]){const r=document.createElement(e);return r.classList.add(...Array.isArray(t)?t:BT(t)),r}function HT(e,t){const r=[];for(;e.previousElementSibling;){const n=e.previousElementSibling;t?n.matches(t)&&r.push(n):r.push(n),e=n}return r}function UT(e,t){const r=[];for(;e.nextElementSibling;){const n=e.nextElementSibling;t?n.matches(t)&&r.push(n):r.push(n),e=n}return r}function Ql(e,t){return Yi().getComputedStyle(e,null).getPropertyValue(t)}function ob(e){let t=e,r;if(t){for(r=0;(t=t.previousSibling)!==null;)t.nodeType===1&&(r+=1);return r}}function GT(e,t){const r=[];let n=e.parentElement;for(;n;)r.push(n),n=n.parentElement;return r}function ab(e,t,r){const n=Yi();return e[t==="width"?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue(t==="width"?"margin-left":"margin-bottom"))}function lb(e,t=""){typeof trustedTypes<"u"?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:r=>r}).createHTML(t):e.innerHTML=t}let Om;function zT(){const e=Yi(),t=Pc();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}function w6(){return Om||(Om=zT()),Om}let $m;function WT({userAgent:e}={}){const t=w6(),r=Yi(),n=r.navigator.platform,s=e||r.navigator.userAgent,i={ios:!1,android:!1},a=r.screen.width,u=r.screen.height,d=s.match(/(Android);?[\s\/]+([\d.]+)?/);let f=s.match(/(iPad)(?!\1).*OS\s([\d_]+)/);const b=s.match(/(iPod)(.*OS\s([\d_]+))?/),g=!f&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),y=n==="Win32";let v=n==="MacIntel";const w=["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"];return!f&&v&&t.touch&&w.indexOf(`${a}x${u}`)>=0&&(f=s.match(/(Version)\/([\d.]+)/),f||(f=[0,1,"13_0_0"]),v=!1),d&&!y&&(i.os="android",i.android=!0),(f||g||b)&&(i.os="ios",i.ios=!0),i}function A6(e={}){return $m||($m=WT(e)),$m}let Hm;function VT(){const e=Yi(),t=A6();let r=!1;function n(){const u=e.navigator.userAgent.toLowerCase();return u.indexOf("safari")>=0&&u.indexOf("chrome")<0&&u.indexOf("android")<0}if(n()){const u=String(e.navigator.userAgent);if(u.includes("Version/")){const[d,f]=u.split("Version/")[1].split(" ")[0].split(".").map(b=>Number(b));r=d<16||d===16&&f<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),i=n(),a=i||s&&t.ios;return{isSafari:r||i,needPerspectiveFix:r,need3dFix:a,isWebView:s}}function T6(){return Hm||(Hm=VT()),Hm}function qT({swiper:e,on:t,emit:r}){const n=Yi();let s=null,i=null;const a=()=>{!e||e.destroyed||!e.initialized||(r("beforeResize"),r("resize"))},u=()=>{!e||e.destroyed||!e.initialized||(s=new ResizeObserver(b=>{i=n.requestAnimationFrame(()=>{const{width:g,height:y}=e;let v=g,w=y;b.forEach(({contentBoxSize:T,contentRect:C,target:E})=>{E&&E!==e.el||(v=C?C.width:(T[0]||T).inlineSize,w=C?C.height:(T[0]||T).blockSize)}),(v!==g||w!==y)&&a()})}),s.observe(e.el))},d=()=>{i&&n.cancelAnimationFrame(i),s&&s.unobserve&&e.el&&(s.unobserve(e.el),s=null)},f=()=>{!e||e.destroyed||!e.initialized||r("orientationchange")};t("init",()=>{if(e.params.resizeObserver&&typeof n.ResizeObserver<"u"){u();return}n.addEventListener("resize",a),n.addEventListener("orientationchange",f)}),t("destroy",()=>{d(),n.removeEventListener("resize",a),n.removeEventListener("orientationchange",f)})}function YT({swiper:e,extendParams:t,on:r,emit:n}){const s=[],i=Yi(),a=(f,b={})=>{const g=i.MutationObserver||i.WebkitMutationObserver,y=new g(v=>{if(e.__preventObserver__)return;if(v.length===1){n("observerUpdate",v[0]);return}const w=function(){n("observerUpdate",v[0])};i.requestAnimationFrame?i.requestAnimationFrame(w):i.setTimeout(w,0)});y.observe(f,{attributes:typeof b.attributes>"u"?!0:b.attributes,childList:e.isElement||(typeof b.childList>"u"?!0:b).childList,characterData:typeof b.characterData>"u"?!0:b.characterData}),s.push(y)},u=()=>{if(e.params.observer){if(e.params.observeParents){const f=GT(e.hostEl);for(let b=0;b<f.length;b+=1)a(f[b])}a(e.hostEl,{childList:e.params.observeSlideChildren}),a(e.wrapperEl,{attributes:!1})}},d=()=>{s.forEach(f=>{f.disconnect()}),s.splice(0,s.length)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),r("init",u),r("destroy",d)}var ZT={on(e,t,r){const n=this;if(!n.eventsListeners||n.destroyed||typeof t!="function")return n;const s=r?"unshift":"push";return e.split(" ").forEach(i=>{n.eventsListeners[i]||(n.eventsListeners[i]=[]),n.eventsListeners[i][s](t)}),n},once(e,t,r){const n=this;if(!n.eventsListeners||n.destroyed||typeof t!="function")return n;function s(...i){n.off(e,s),s.__emitterProxy&&delete s.__emitterProxy,t.apply(n,i)}return s.__emitterProxy=t,n.on(e,s,r)},onAny(e,t){const r=this;if(!r.eventsListeners||r.destroyed||typeof e!="function")return r;const n=t?"unshift":"push";return r.eventsAnyListeners.indexOf(e)<0&&r.eventsAnyListeners[n](e),r},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsAnyListeners)return t;const r=t.eventsAnyListeners.indexOf(e);return r>=0&&t.eventsAnyListeners.splice(r,1),t},off(e,t){const r=this;return!r.eventsListeners||r.destroyed||!r.eventsListeners||e.split(" ").forEach(n=>{typeof t>"u"?r.eventsListeners[n]=[]:r.eventsListeners[n]&&r.eventsListeners[n].forEach((s,i)=>{(s===t||s.__emitterProxy&&s.__emitterProxy===t)&&r.eventsListeners[n].splice(i,1)})}),r},emit(...e){const t=this;if(!t.eventsListeners||t.destroyed||!t.eventsListeners)return t;let r,n,s;return typeof e[0]=="string"||Array.isArray(e[0])?(r=e[0],n=e.slice(1,e.length),s=t):(r=e[0].events,n=e[0].data,s=e[0].context||t),n.unshift(s),(Array.isArray(r)?r:r.split(" ")).forEach(a=>{t.eventsAnyListeners&&t.eventsAnyListeners.length&&t.eventsAnyListeners.forEach(u=>{u.apply(s,[a,...n])}),t.eventsListeners&&t.eventsListeners[a]&&t.eventsListeners[a].forEach(u=>{u.apply(s,n)})}),t}};function KT(){const e=this;let t,r;const n=e.el;typeof e.params.width<"u"&&e.params.width!==null?t=e.params.width:t=n.clientWidth,typeof e.params.height<"u"&&e.params.height!==null?r=e.params.height:r=n.clientHeight,!(t===0&&e.isHorizontal()||r===0&&e.isVertical())&&(t=t-parseInt(Ql(n,"padding-left")||0,10)-parseInt(Ql(n,"padding-right")||0,10),r=r-parseInt(Ql(n,"padding-top")||0,10)-parseInt(Ql(n,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=0),Object.assign(e,{width:t,height:r,size:e.isHorizontal()?t:r}))}function XT(){const e=this;function t(U,W){return parseFloat(U.getPropertyValue(e.getDirectionLabel(W))||0)}const r=e.params,{wrapperEl:n,slidesEl:s,rtlTranslate:i,wrongRTL:a}=e,u=e.virtual&&r.virtual.enabled,d=u?e.virtual.slides.length:e.slides.length,f=rl(s,`.${e.params.slideClass}, swiper-slide`),b=u?e.virtual.slides.length:f.length;let g=[];const y=[],v=[];let w=r.slidesOffsetBefore;typeof w=="function"&&(w=r.slidesOffsetBefore.call(e));let T=r.slidesOffsetAfter;typeof T=="function"&&(T=r.slidesOffsetAfter.call(e));const C=e.snapGrid.length,E=e.slidesGrid.length,N=e.size-w-T;let D=r.spaceBetween,R=-w,_=0,M=0;if(typeof N>"u")return;typeof D=="string"&&D.indexOf("%")>=0?D=parseFloat(D.replace("%",""))/100*N:typeof D=="string"&&(D=parseFloat(D)),e.virtualSize=-D-w-T,f.forEach(U=>{i?U.style.marginLeft="":U.style.marginRight="",U.style.marginBottom="",U.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(fu(n,"--swiper-centered-offset-before",""),fu(n,"--swiper-centered-offset-after","")),r.cssMode&&(fu(n,"--swiper-slides-offset-before",`${w}px`),fu(n,"--swiper-slides-offset-after",`${T}px`));const Q=r.grid&&r.grid.rows>1&&e.grid;Q?e.grid.initSlides(f):e.grid&&e.grid.unsetSlides();let H;const G=r.slidesPerView==="auto"&&r.breakpoints&&Object.keys(r.breakpoints).filter(U=>typeof r.breakpoints[U].slidesPerView<"u").length>0;for(let U=0;U<b;U+=1){H=0;const W=f[U];if(!(W&&(Q&&e.grid.updateSlide(U,W,f),Ql(W,"display")==="none"))){if(u&&r.slidesPerView==="auto")r.virtual.slidesPerViewAutoSlideSize&&(H=r.virtual.slidesPerViewAutoSlideSize),H&&W&&(r.roundLengths&&(H=Math.floor(H)),W.style[e.getDirectionLabel("width")]=`${H}px`);else if(r.slidesPerView==="auto"){G&&(W.style[e.getDirectionLabel("width")]="");const J=getComputedStyle(W),ee=W.style.transform,ae=W.style.webkitTransform;if(ee&&(W.style.transform="none"),ae&&(W.style.webkitTransform="none"),r.roundLengths)H=e.isHorizontal()?ab(W,"width"):ab(W,"height");else{const Se=t(J,"width"),Le=t(J,"padding-left"),_e=t(J,"padding-right"),se=t(J,"margin-left"),ie=t(J,"margin-right"),fe=J.getPropertyValue("box-sizing");if(fe&&fe==="border-box")H=Se+se+ie;else{const{clientWidth:Qe,offsetWidth:de}=W;H=Se+Le+_e+se+ie+(de-Qe)}}ee&&(W.style.transform=ee),ae&&(W.style.webkitTransform=ae),r.roundLengths&&(H=Math.floor(H))}else H=(N-(r.slidesPerView-1)*D)/r.slidesPerView,r.roundLengths&&(H=Math.floor(H)),W&&(W.style[e.getDirectionLabel("width")]=`${H}px`);W&&(W.swiperSlideSize=H),v.push(H),r.centeredSlides?(R=R+H/2+_/2+D,_===0&&U!==0&&(R=R-N/2-D),U===0&&(R=R-N/2-D),Math.abs(R)<1/1e3&&(R=0),r.roundLengths&&(R=Math.floor(R)),M%r.slidesPerGroup===0&&g.push(R),y.push(R)):(r.roundLengths&&(R=Math.floor(R)),(M-Math.min(e.params.slidesPerGroupSkip,M))%e.params.slidesPerGroup===0&&g.push(R),y.push(R),R=R+H+D),e.virtualSize+=H+D,_=H,M+=1}}if(e.virtualSize=Math.max(e.virtualSize,N)+T,i&&a&&(r.effect==="slide"||r.effect==="coverflow")&&(n.style.width=`${e.virtualSize+D}px`),r.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+D}px`),Q&&e.grid.updateWrapperSize(H,g),!r.centeredSlides){const U=r.slidesPerView!=="auto"&&r.slidesPerView%1!==0,W=r.snapToSlideEdge&&!r.loop&&(r.slidesPerView==="auto"||U);let J=g.length;if(W){let ae;if(r.slidesPerView==="auto"){ae=1;let Se=0;for(let Le=v.length-1;Le>=0&&(Se+=v[Le]+(Le<v.length-1?D:0),Se<=N);Le-=1)ae=v.length-Le}else ae=Math.floor(r.slidesPerView);J=Math.max(b-ae,0)}const ee=[];for(let ae=0;ae<g.length;ae+=1){let Se=g[ae];r.roundLengths&&(Se=Math.floor(Se)),W?ae<=J&&ee.push(Se):g[ae]<=e.virtualSize-N&&ee.push(Se)}g=ee,Math.floor(e.virtualSize-N)-Math.floor(g[g.length-1])>1&&(W||g.push(e.virtualSize-N))}if(u&&r.loop){const U=v[0]+D;if(r.slidesPerGroup>1){const W=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/r.slidesPerGroup),J=U*r.slidesPerGroup;for(let ee=0;ee<W;ee+=1)g.push(g[g.length-1]+J)}for(let W=0;W<e.virtual.slidesBefore+e.virtual.slidesAfter;W+=1)r.slidesPerGroup===1&&g.push(g[g.length-1]+U),y.push(y[y.length-1]+U),e.virtualSize+=U}if(g.length===0&&(g=[0]),D!==0){const U=e.isHorizontal()&&i?"marginLeft":e.getDirectionLabel("marginRight");f.filter((W,J)=>!r.cssMode||r.loop?!0:J!==f.length-1).forEach(W=>{W.style[U]=`${D}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let U=0;v.forEach(J=>{U+=J+(D||0)}),U-=D;const W=U>N?U-N:0;g=g.map(J=>J<=0?-w:J>W?W+T:J)}if(r.centerInsufficientSlides){let U=0;if(v.forEach(W=>{U+=W+(D||0)}),U-=D,U<N){const W=(N-U)/2;g.forEach((J,ee)=>{g[ee]=J-W}),y.forEach((J,ee)=>{y[ee]=J+W})}}if(Object.assign(e,{slides:f,snapGrid:g,slidesGrid:y,slidesSizesGrid:v}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){fu(n,"--swiper-centered-offset-before",`${-g[0]}px`),fu(n,"--swiper-centered-offset-after",`${e.size/2-v[v.length-1]/2}px`);const U=-e.snapGrid[0],W=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(J=>J+U),e.slidesGrid=e.slidesGrid.map(J=>J+W)}if(b!==d&&e.emit("slidesLengthChange"),g.length!==C&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),y.length!==E&&e.emit("slidesGridLengthChange"),r.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!u&&!r.cssMode&&(r.effect==="slide"||r.effect==="fade")){const U=`${r.containerModifierClass}backface-hidden`,W=e.el.classList.contains(U);b<=r.maxBackfaceHiddenSlides?W||e.el.classList.add(U):W&&e.el.classList.remove(U)}}function JT(e){const t=this,r=[],n=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=u=>n?t.slides[t.getSlideIndexByData(u)]:t.slides[u];if(t.params.slidesPerView!=="auto"&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(u=>{r.push(u)});else for(i=0;i<Math.ceil(t.params.slidesPerView);i+=1){const u=t.activeIndex+i;if(u>t.slides.length&&!n)break;r.push(a(u))}else r.push(a(t.activeIndex));for(i=0;i<r.length;i+=1)if(typeof r[i]<"u"){const u=r[i].offsetHeight;s=u>s?u:s}(s||s===0)&&(t.wrapperEl.style.height=`${s}px`)}function eS(){const e=this,t=e.slides,r=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-r-e.cssOverflowAdjustment()}const cb=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};function tS(e=this&&this.translate||0){const t=this,r=t.params,{slides:n,rtlTranslate:s,snapGrid:i}=t;if(n.length===0)return;typeof n[0].swiperSlideOffset>"u"&&t.updateSlidesOffset();let a=-e;s&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let u=r.spaceBetween;typeof u=="string"&&u.indexOf("%")>=0?u=parseFloat(u.replace("%",""))/100*t.size:typeof u=="string"&&(u=parseFloat(u));for(let d=0;d<n.length;d+=1){const f=n[d];let b=f.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(b-=n[0].swiperSlideOffset);const g=(a+(r.centeredSlides?t.minTranslate():0)-b)/(f.swiperSlideSize+u),y=(a-i[0]+(r.centeredSlides?t.minTranslate():0)-b)/(f.swiperSlideSize+u),v=-(a-b),w=v+t.slidesSizesGrid[d],T=v>=0&&v<=t.size-t.slidesSizesGrid[d],C=v>=0&&v<t.size-1||w>1&&w<=t.size||v<=0&&w>=t.size;C&&(t.visibleSlides.push(f),t.visibleSlidesIndexes.push(d)),cb(f,C,r.slideVisibleClass),cb(f,T,r.slideFullyVisibleClass),f.progress=s?-g:g,f.originalProgress=s?-y:y}}function rS(e){const t=this;if(typeof e>"u"){const b=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*b||0}const r=t.params,n=t.maxTranslate()-t.minTranslate();let{progress:s,isBeginning:i,isEnd:a,progressLoop:u}=t;const d=i,f=a;if(n===0)s=0,i=!0,a=!0;else{s=(e-t.minTranslate())/n;const b=Math.abs(e-t.minTranslate())<1,g=Math.abs(e-t.maxTranslate())<1;i=b||s<=0,a=g||s>=1,b&&(s=0),g&&(s=1)}if(r.loop){const b=t.getSlideIndexByData(0),g=t.getSlideIndexByData(t.slides.length-1),y=t.slidesGrid[b],v=t.slidesGrid[g],w=t.slidesGrid[t.slidesGrid.length-1],T=Math.abs(e);T>=y?u=(T-y)/w:u=(T+w-v)/w,u>1&&(u-=1)}Object.assign(t,{progress:s,progressLoop:u,isBeginning:i,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),i&&!d&&t.emit("reachBeginning toEdge"),a&&!f&&t.emit("reachEnd toEdge"),(d&&!i||f&&!a)&&t.emit("fromEdge"),t.emit("progress",s)}const Um=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};function nS(){const e=this,{slides:t,params:r,slidesEl:n,activeIndex:s}=e,i=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,u=g=>rl(n,`.${r.slideClass}${g}, swiper-slide${g}`)[0];let d,f,b;if(i)if(r.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),d=u(`[data-swiper-slide-index="${g}"]`)}else d=u(`[data-swiper-slide-index="${s}"]`);else a?(d=t.find(g=>g.column===s),b=t.find(g=>g.column===s+1),f=t.find(g=>g.column===s-1)):d=t[s];d&&(a||(b=UT(d,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!b&&(b=t[0]),f=HT(d,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!f===0&&(f=t[t.length-1]))),t.forEach(g=>{Um(g,g===d,r.slideActiveClass),Um(g,g===b,r.slideNextClass),Um(g,g===f,r.slidePrevClass)}),e.emitSlidesClasses()}const Cf=(e,t)=>{if(!e||e.destroyed||!e.params)return;const r=()=>e.isElement?"swiper-slide":`.${e.params.slideClass}`,n=t.closest(r());if(n){let s=n.querySelector(`.${e.params.lazyPreloaderClass}`);!s&&e.isElement&&(n.shadowRoot?s=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{n.shadowRoot&&(s=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),s&&!s.lazyPreloaderManaged&&s.remove())})),s&&!s.lazyPreloaderManaged&&s.remove()}},Gm=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},b1=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const r=e.slides.length;if(!r||!t||t<0)return;t=Math.min(t,r);const n=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,u=[a-t];u.push(...Array.from({length:t}).map((d,f)=>a+n+f)),e.slides.forEach((d,f)=>{u.includes(d.column)&&Gm(e,f)});return}const i=s+n-1;if(e.params.rewind||e.params.loop)for(let a=s-t;a<=i+t;a+=1){const u=(a%r+r)%r;(u<s||u>i)&&Gm(e,u)}else for(let a=Math.max(s-t,0);a<=Math.min(i+t,r-1);a+=1)a!==s&&(a>i||a<s)&&Gm(e,a)};function sS(e){const{slidesGrid:t,params:r}=e,n=e.rtlTranslate?e.translate:-e.translate;let s;for(let i=0;i<t.length;i+=1)typeof t[i+1]<"u"?n>=t[i]&&n<t[i+1]-(t[i+1]-t[i])/2?s=i:n>=t[i]&&n<t[i+1]&&(s=i+1):n>=t[i]&&(s=i);return r.normalizeSlideIndex&&(s<0||typeof s>"u")&&(s=0),s}function iS(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:n,params:s,activeIndex:i,realIndex:a,snapIndex:u}=t;let d=e,f;const b=v=>{let w=v-t.virtual.slidesBefore;return w<0&&(w=t.virtual.slides.length+w),w>=t.virtual.slides.length&&(w-=t.virtual.slides.length),w};if(typeof d>"u"&&(d=sS(t)),n.indexOf(r)>=0)f=n.indexOf(r);else{const v=Math.min(s.slidesPerGroupSkip,d);f=v+Math.floor((d-v)/s.slidesPerGroup)}if(f>=n.length&&(f=n.length-1),d===i&&!t.params.loop){f!==u&&(t.snapIndex=f,t.emit("snapIndexChange"));return}if(d===i&&t.params.loop&&t.virtual&&t.params.virtual.enabled){t.realIndex=b(d);return}const g=t.grid&&s.grid&&s.grid.rows>1;let y;if(t.virtual&&s.virtual.enabled)s.loop?y=b(d):y=d;else if(g){const v=t.slides.find(T=>T.column===d);let w=parseInt(v.getAttribute("data-swiper-slide-index"),10);Number.isNaN(w)&&(w=Math.max(t.slides.indexOf(v),0)),y=Math.floor(w/s.grid.rows)}else if(t.slides[d]){const v=t.slides[d].getAttribute("data-swiper-slide-index");v?y=parseInt(v,10):y=d}else y=d;Object.assign(t,{previousSnapIndex:u,snapIndex:f,previousRealIndex:a,realIndex:y,previousIndex:i,activeIndex:d}),t.initialized&&b1(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==y&&t.emit("realIndexChange"),t.emit("slideChange"))}function oS(e,t){const r=this,n=r.params;let s=e.closest(`.${n.slideClass}, swiper-slide`);!s&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(u=>{!s&&u.matches&&u.matches(`.${n.slideClass}, swiper-slide`)&&(s=u)});let i=!1,a;if(s){for(let u=0;u<r.slides.length;u+=1)if(r.slides[u]===s){i=!0,a=u;break}}if(s&&i)r.clickedSlide=s,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=a;else{r.clickedSlide=void 0,r.clickedIndex=void 0;return}n.slideToClickedSlide&&r.clickedIndex!==void 0&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}var aS={updateSize:KT,updateSlides:XT,updateAutoHeight:JT,updateSlidesOffset:eS,updateSlidesProgress:tS,updateProgress:rS,updateSlidesClasses:nS,updateActiveIndex:iS,updateClickedSlide:oS};function lS(e=this.isHorizontal()?"x":"y"){const t=this,{params:r,rtlTranslate:n,translate:s,wrapperEl:i}=t;if(r.virtualTranslate)return n?-s:s;if(r.cssMode)return s;let a=QT(i,e);return a+=t.cssOverflowAdjustment(),n&&(a=-a),a||0}function cS(e,t){const r=this,{rtlTranslate:n,params:s,wrapperEl:i,progress:a}=r;let u=0,d=0;const f=0;r.isHorizontal()?u=n?-e:e:d=e,s.roundLengths&&(u=Math.floor(u),d=Math.floor(d)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?u:d,s.cssMode?i[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-u:-d:s.virtualTranslate||(r.isHorizontal()?u-=r.cssOverflowAdjustment():d-=r.cssOverflowAdjustment(),i.style.transform=`translate3d(${u}px, ${d}px, ${f}px)`);let b;const g=r.maxTranslate()-r.minTranslate();g===0?b=0:b=(e-r.minTranslate())/g,b!==a&&r.updateProgress(e),r.emit("setTranslate",r.translate,t)}function uS(){return-this.snapGrid[0]}function dS(){return-this.snapGrid[this.snapGrid.length-1]}function hS(e=0,t=this.params.speed,r=!0,n=!0,s){const i=this,{params:a,wrapperEl:u}=i;if(i.animating&&a.preventInteractionOnTransition)return!1;const d=i.minTranslate(),f=i.maxTranslate();let b;if(n&&e>d?b=d:n&&e<f?b=f:b=e,i.updateProgress(b),a.cssMode){const g=i.isHorizontal();if(t===0)u[g?"scrollLeft":"scrollTop"]=-b;else{if(!i.support.smoothScroll)return v6({swiper:i,targetPosition:-b,side:g?"left":"top"}),!0;u.scrollTo({[g?"left":"top"]:-b,behavior:"smooth"})}return!0}return t===0?(i.setTransition(0),i.setTranslate(b),r&&(i.emit("beforeTransitionStart",t,s),i.emit("transitionEnd"))):(i.setTransition(t),i.setTranslate(b),r&&(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,r&&i.emit("transitionEnd"))}),i.wrapperEl.addEventListener("transitionend",i.onTranslateToWrapperTransitionEnd))),!0}var fS={getTranslate:lS,setTranslate:cS,minTranslate:uS,maxTranslate:dS,translateTo:hS};function pS(e,t){const r=this;r.params.cssMode||(r.wrapperEl.style.transitionDuration=`${e}ms`,r.wrapperEl.style.transitionDelay=e===0?"0ms":""),r.emit("setTransition",e,t)}function S6({swiper:e,runCallbacks:t,direction:r,step:n}){const{activeIndex:s,previousIndex:i}=e;let a=r;a||(s>i?a="next":s<i?a="prev":a="reset"),e.emit(`transition${n}`),t&&a==="reset"?e.emit(`slideResetTransition${n}`):t&&s!==i&&(e.emit(`slideChangeTransition${n}`),a==="next"?e.emit(`slideNextTransition${n}`):e.emit(`slidePrevTransition${n}`))}function mS(e=!0,t){const r=this,{params:n}=r;n.cssMode||(n.autoHeight&&r.updateAutoHeight(),S6({swiper:r,runCallbacks:e,direction:t,step:"Start"}))}function gS(e=!0,t){const r=this,{params:n}=r;r.animating=!1,!n.cssMode&&(r.setTransition(0),S6({swiper:r,runCallbacks:e,direction:t,step:"End"}))}var bS={setTransition:pS,transitionStart:mS,transitionEnd:gS};function xS(e=0,t,r=!0,n,s){typeof e=="string"&&(e=parseInt(e,10));const i=this;let a=e;a<0&&(a=0);const{params:u,snapGrid:d,slidesGrid:f,previousIndex:b,activeIndex:g,rtlTranslate:y,wrapperEl:v,enabled:w}=i;if(!w&&!n&&!s||i.destroyed||i.animating&&u.preventInteractionOnTransition)return!1;typeof t>"u"&&(t=i.params.speed);const T=Math.min(i.params.slidesPerGroupSkip,a);let C=T+Math.floor((a-T)/i.params.slidesPerGroup);C>=d.length&&(C=d.length-1);const E=-d[C];if(u.normalizeSlideIndex)for(let Q=0;Q<f.length;Q+=1){const H=-Math.floor(E*100),G=Math.floor(f[Q]*100),U=Math.floor(f[Q+1]*100);typeof f[Q+1]<"u"?H>=G&&H<U-(U-G)/2?a=Q:H>=G&&H<U&&(a=Q+1):H>=G&&(a=Q)}if(i.initialized&&a!==g&&(!i.allowSlideNext&&(y?E>i.translate&&E>i.minTranslate():E<i.translate&&E<i.minTranslate())||!i.allowSlidePrev&&E>i.translate&&E>i.maxTranslate()&&(g||0)!==a))return!1;a!==(b||0)&&r&&i.emit("beforeSlideChangeStart"),i.updateProgress(E);let N;a>g?N="next":a<g?N="prev":N="reset";const D=i.virtual&&i.params.virtual.enabled;if(!(D&&s)&&(y&&-E===i.translate||!y&&E===i.translate))return i.updateActiveIndex(a),u.autoHeight&&i.updateAutoHeight(),i.updateSlidesClasses(),u.effect!=="slide"&&i.setTranslate(E),N!=="reset"&&(i.transitionStart(r,N),i.transitionEnd(r,N)),!1;if(u.cssMode){const Q=i.isHorizontal(),H=y?E:-E;if(t===0)D&&(i.wrapperEl.style.scrollSnapType="none",i._immediateVirtual=!0),D&&!i._cssModeVirtualInitialSet&&i.params.initialSlide>0?(i._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{v[Q?"scrollLeft":"scrollTop"]=H})):v[Q?"scrollLeft":"scrollTop"]=H,D&&requestAnimationFrame(()=>{i.wrapperEl.style.scrollSnapType="",i._immediateVirtual=!1});else{if(!i.support.smoothScroll)return v6({swiper:i,targetPosition:H,side:Q?"left":"top"}),!0;v.scrollTo({[Q?"left":"top"]:H,behavior:"smooth"})}return!0}const M=T6().isSafari;return D&&!s&&M&&i.isElement&&i.virtual.update(!1,!1,a),i.setTransition(t),i.setTranslate(E),i.updateActiveIndex(a),i.updateSlidesClasses(),i.emit("beforeTransitionStart",t,n),i.transitionStart(r,N),t===0?i.transitionEnd(r,N):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(r,N))}),i.wrapperEl.addEventListener("transitionend",i.onSlideToWrapperTransitionEnd)),!0}function yS(e=0,t,r=!0,n){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 u;if(i){const T=a*s.params.grid.rows;u=s.slides.find(C=>C.getAttribute("data-swiper-slide-index")*1===T).column}else u=s.getSlideIndexByData(a);const d=i?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:f,slidesOffsetBefore:b,slidesOffsetAfter:g}=s.params,y=f||!!b||!!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 w=d-u<v;if(y&&(w=w||u<Math.ceil(v/2)),n&&y&&s.params.slidesPerView!=="auto"&&!i&&(w=!1),w){const T=y?u<s.activeIndex?"prev":"next":u-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:T,slideTo:!0,activeSlideIndex:T==="next"?u+1:u-d+1,slideRealIndex:T==="next"?s.realIndex:void 0})}if(i){const T=a*s.params.grid.rows;a=s.slides.find(C=>C.getAttribute("data-swiper-slide-index")*1===T).column}else a=s.getSlideIndexByData(a)}return requestAnimationFrame(()=>{s.slideTo(a,t,r,n)}),s}function vS(e,t=!0,r){const n=this,{enabled:s,params:i,animating:a}=n;if(!s||n.destroyed)return n;typeof e>"u"&&(e=n.params.speed);let u=i.slidesPerGroup;i.slidesPerView==="auto"&&i.slidesPerGroup===1&&i.slidesPerGroupAuto&&(u=Math.max(n.slidesPerViewDynamic("current",!0),1));const d=n.activeIndex<i.slidesPerGroupSkip?1:u,f=n.virtual&&i.virtual.enabled;if(i.loop){if(a&&!f&&i.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&i.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+d,e,t,r)}),!0}return i.rewind&&n.isEnd?n.slideTo(0,e,t,r):n.slideTo(n.activeIndex+d,e,t,r)}function wS(e,t=!0,r){const n=this,{params:s,snapGrid:i,slidesGrid:a,rtlTranslate:u,enabled:d,animating:f}=n;if(!d||n.destroyed)return n;typeof e>"u"&&(e=n.params.speed);const b=n.virtual&&s.virtual.enabled;if(s.loop){if(f&&!b&&s.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}const g=u?n.translate:-n.translate;function y(N){return N<0?-Math.floor(Math.abs(N)):Math.floor(N)}const v=y(g),w=i.map(N=>y(N)),T=s.freeMode&&s.freeMode.enabled;let C=i[w.indexOf(v)-1];if(typeof C>"u"&&(s.cssMode||T)){let N;i.forEach((D,R)=>{v>=D&&(N=R)}),typeof N<"u"&&(C=T?i[N]:i[N>0?N-1:N])}let E=0;if(typeof C<"u"&&(E=a.indexOf(C),E<0&&(E=n.activeIndex-1),s.slidesPerView==="auto"&&s.slidesPerGroup===1&&s.slidesPerGroupAuto&&(E=E-n.slidesPerViewDynamic("previous",!0)+1,E=Math.max(E,0))),s.rewind&&n.isBeginning){const N=n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1;return n.slideTo(N,e,t,r)}else if(s.loop&&n.activeIndex===0&&s.cssMode)return requestAnimationFrame(()=>{n.slideTo(E,e,t,r)}),!0;return n.slideTo(E,e,t,r)}function AS(e,t=!0,r){const n=this;if(!n.destroyed)return typeof e>"u"&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,r)}function TS(e,t=!0,r,n=.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),u=a+Math.floor((i-a)/s.params.slidesPerGroup),d=s.rtlTranslate?s.translate:-s.translate;if(d>=s.snapGrid[u]){const f=s.snapGrid[u],b=s.snapGrid[u+1];d-f>(b-f)*n&&(i+=s.params.slidesPerGroup)}else{const f=s.snapGrid[u-1],b=s.snapGrid[u];d-f<=(b-f)*n&&(i-=s.params.slidesPerGroup)}return i=Math.max(i,0),i=Math.min(i,s.slidesGrid.length-1),s.slideTo(i,e,t,r)}function SS(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:r}=e,n=t.slidesPerView==="auto"?e.slidesPerViewDynamic():t.slidesPerView;let s=e.getSlideIndexWhenGrid(e.clickedIndex),i;const a=e.isElement?"swiper-slide":`.${t.slideClass}`,u=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>(u?(e.slides.length-n)/2-(e.params.grid.rows-1):e.slides.length-n)?(e.loopFix(),s=e.getSlideIndex(rl(r,`${a}[data-swiper-slide-index="${i}"]`)[0]),y6(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}var CS={slideTo:xS,slideToLoop:yS,slideNext:vS,slidePrev:wS,slideReset:AS,slideToClosest:TS,slideToClickedSlide:SS};function _S(e,t){const r=this,{params:n,slidesEl:s}=r;if(!n.loop||r.virtual&&r.params.virtual.enabled)return;const i=()=>{rl(s,`.${n.slideClass}, swiper-slide`).forEach((w,T)=>{w.setAttribute("data-swiper-slide-index",T)})},a=()=>{const v=rl(s,`.${n.slideBlankClass}`);v.forEach(w=>{w.remove()}),v.length>0&&(r.recalcSlides(),r.updateSlides())},u=r.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||u)&&a();const d=n.slidesPerGroup*(u?n.grid.rows:1),f=r.slides.length%d!==0,b=u&&r.slides.length%n.grid.rows!==0,g=v=>{for(let w=0;w<v;w+=1){const T=r.isElement?g1("swiper-slide",[n.slideBlankClass]):g1("div",[n.slideClass,n.slideBlankClass]);r.slidesEl.append(T)}};if(f){if(n.loopAddBlankSlides){const v=d-r.slides.length%d;g(v),r.recalcSlides(),r.updateSlides()}else Vf("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(b){if(n.loopAddBlankSlides){const v=n.grid.rows-r.slides.length%n.grid.rows;g(v),r.recalcSlides(),r.updateSlides()}else Vf("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=n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter;r.loopFix({slideRealIndex:e,direction:y?void 0:"next",initial:t})}function LS({slideRealIndex:e,slideTo:t=!0,direction:r,setTranslate:n,activeSlideIndex:s,initial:i,byController:a,byMousewheel:u}={}){const d=this;if(!d.params.loop)return;d.emit("beforeLoopFix");const{slides:f,allowSlidePrev:b,allowSlideNext:g,slidesEl:y,params:v}=d,{centeredSlides:w,slidesOffsetBefore:T,slidesOffsetAfter:C,initialSlide:E}=v,N=w||!!T||!!C;if(d.allowSlidePrev=!0,d.allowSlideNext=!0,d.virtual&&v.virtual.enabled){t&&(!N&&d.snapIndex===0?d.slideTo(d.virtual.slides.length,0,!1,!0):N&&d.snapIndex<v.slidesPerView?d.slideTo(d.virtual.slides.length+d.snapIndex,0,!1,!0):d.snapIndex===d.snapGrid.length-1&&d.slideTo(d.virtual.slidesBefore,0,!1,!0)),d.allowSlidePrev=b,d.allowSlideNext=g,d.emit("loopFix");return}let D=v.slidesPerView;D==="auto"?D=d.slidesPerViewDynamic():(D=Math.ceil(parseFloat(v.slidesPerView,10)),N&&D%2===0&&(D=D+1));const R=v.slidesPerGroupAuto?D:v.slidesPerGroup;let _=N?Math.max(R,Math.ceil(D/2)):R;_%R!==0&&(_+=R-_%R),_+=v.loopAdditionalSlides,d.loopedSlides=_;const M=d.grid&&v.grid&&v.grid.rows>1;f.length<D+_||d.params.effect==="cards"&&f.length<D+_*2?Vf("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"):M&&v.grid.fill==="row"&&Vf("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const Q=[],H=[],G=M?Math.ceil(f.length/v.grid.rows):f.length,U=i&&G-E<D&&!N;let W=U?E:d.activeIndex;typeof s>"u"?s=d.getSlideIndex(f.find(se=>se.classList.contains(v.slideActiveClass))):W=s;const J=r==="next"||!r,ee=r==="prev"||!r;let ae=0,Se=0;const _e=(M?f[s].column:s)+(N&&typeof n>"u"?-D/2+.5:0);if(_e<_){ae=Math.max(_-_e,R);for(let se=0;se<_-_e;se+=1){const ie=se-Math.floor(se/G)*G;if(M){const fe=G-ie-1;for(let Qe=f.length-1;Qe>=0;Qe-=1)f[Qe].column===fe&&Q.push(Qe)}else Q.push(G-ie-1)}}else if(_e+D>G-_){Se=Math.max(_e-(G-_*2),R),U&&(Se=Math.max(Se,D-G+E+1));for(let se=0;se<Se;se+=1){const ie=se-Math.floor(se/G)*G;M?f.forEach((fe,Qe)=>{fe.column===ie&&H.push(Qe)}):H.push(ie)}}if(d.__preventObserver__=!0,requestAnimationFrame(()=>{d.__preventObserver__=!1}),d.params.effect==="cards"&&f.length<D+_*2&&(H.includes(s)&&H.splice(H.indexOf(s),1),Q.includes(s)&&Q.splice(Q.indexOf(s),1)),ee&&Q.forEach(se=>{f[se].swiperLoopMoveDOM=!0,y.prepend(f[se]),f[se].swiperLoopMoveDOM=!1}),J&&H.forEach(se=>{f[se].swiperLoopMoveDOM=!0,y.append(f[se]),f[se].swiperLoopMoveDOM=!1}),d.recalcSlides(),v.slidesPerView==="auto"?d.updateSlides():M&&(Q.length>0&&ee||H.length>0&&J)&&d.slides.forEach((se,ie)=>{d.grid.updateSlide(ie,se,d.slides)}),v.watchSlidesProgress&&d.updateSlidesOffset(),t){if(Q.length>0&&ee){if(typeof e>"u"){const se=d.slidesGrid[W],fe=d.slidesGrid[W+ae]-se;u?d.setTranslate(d.translate-fe):(d.slideTo(W+Math.ceil(ae),0,!1,!0),n&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-fe,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-fe))}else if(n){const se=M?Q.length/v.grid.rows:Q.length;d.slideTo(d.activeIndex+se,0,!1,!0),d.touchEventsData.currentTranslate=d.translate}}else if(H.length>0&&J)if(typeof e>"u"){const se=d.slidesGrid[W],fe=d.slidesGrid[W-Se]-se;u?d.setTranslate(d.translate-fe):(d.slideTo(W-Se,0,!1,!0),n&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-fe,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-fe))}else{const se=M?H.length/v.grid.rows:H.length;d.slideTo(d.activeIndex-se,0,!1,!0)}}if(d.allowSlidePrev=b,d.allowSlideNext=g,d.controller&&d.controller.control&&!a){const se={slideRealIndex:e,direction:r,setTranslate:n,activeSlideIndex:s,byController:!0};Array.isArray(d.controller.control)?d.controller.control.forEach(ie=>{!ie.destroyed&&ie.params.loop&&ie.loopFix({...se,slideTo:ie.params.slidesPerView===v.slidesPerView?t:!1})}):d.controller.control instanceof d.constructor&&d.controller.control.params.loop&&d.controller.control.loopFix({...se,slideTo:d.controller.control.params.slidesPerView===v.slidesPerView?t:!1})}d.emit("loopFix")}function kS(){const e=this,{params:t,slidesEl:r}=e;if(!t.loop||!r||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const n=[];e.slides.forEach(s=>{const i=typeof s.swiperSlideIndex>"u"?s.getAttribute("data-swiper-slide-index")*1:s.swiperSlideIndex;n[i]=s}),e.slides.forEach(s=>{s.removeAttribute("data-swiper-slide-index")}),n.forEach(s=>{r.append(s)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}var ES={loopCreate:_S,loopFix:LS,loopDestroy:kS};function IS(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const r=t.params.touchEventsTarget==="container"?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),r.style.cursor="move",r.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}function MS(){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 RS={setGrabCursor:IS,unsetGrabCursor:MS};function NS(e,t=this){function r(n){if(!n||n===Pc()||n===Yi())return null;n.assignedSlot&&(n=n.assignedSlot);const s=n.closest(e);return!s&&!n.getRootNode?null:s||r(n.getRootNode().host)}return r(t)}function ub(e,t,r){const n=Yi(),{params:s}=e,i=s.edgeSwipeDetection,a=s.edgeSwipeThreshold;return i&&(r<=a||r>=n.innerWidth-a)?i==="prevent"?(t.preventDefault(),!0):!1:!0}function DS(e){const t=this;if(t.destroyed)return;const r=Pc();let n=e;n.originalEvent&&(n=n.originalEvent);const s=t.touchEventsData;if(n.type==="pointerdown"){if(s.pointerId!==null&&s.pointerId!==n.pointerId)return;s.pointerId=n.pointerId}else n.type==="touchstart"&&n.targetTouches.length===1&&(s.touchId=n.targetTouches[0].identifier);if(n.type==="touchstart"){ub(t,n,n.targetTouches[0].pageX);return}const{params:i,touches:a,enabled:u}=t;if(!u||!i.simulateTouch&&n.pointerType==="mouse"||t.animating&&i.preventInteractionOnTransition)return;!t.animating&&i.cssMode&&i.loop&&t.loopFix();let d=n.target;if(i.touchEventsTarget==="wrapper"&&!$T(d,t.wrapperEl)||"which"in n&&n.which===3||"button"in n&&n.button>0||s.isTouched&&s.isMoved)return;const f=!!i.noSwipingClass&&i.noSwipingClass!=="",b=n.composedPath?n.composedPath():n.path;f&&n.target&&n.target.shadowRoot&&b&&(d=b[0]);const g=i.noSwipingSelector?i.noSwipingSelector:`.${i.noSwipingClass}`,y=!!(n.target&&n.target.shadowRoot);if(i.noSwiping&&(y?NS(g,d):d.closest(g))){t.allowClick=!0;return}if(i.swipeHandler&&!d.closest(i.swipeHandler))return;a.currentX=n.pageX,a.currentY=n.pageY;const v=a.currentX,w=a.currentY;if(!ub(t,n,v))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=v,a.startY=w,s.touchStartTime=Wf(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,i.threshold>0&&(s.allowThresholdMove=!1);let T=!0;d.matches(s.focusableElements)&&(T=!1,d.nodeName==="SELECT"&&(s.isTouched=!1)),r.activeElement&&r.activeElement.matches(s.focusableElements)&&r.activeElement!==d&&(n.pointerType==="mouse"||n.pointerType!=="mouse"&&!d.matches(s.focusableElements))&&r.activeElement.blur();const C=T&&t.allowTouchMove&&i.touchStartPreventDefault;(i.touchStartForcePreventDefault||C)&&!d.isContentEditable&&n.preventDefault(),i.freeMode&&i.freeMode.enabled&&t.freeMode&&t.animating&&!i.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}function BS(e){const t=Pc(),r=this;if(r.destroyed)return;const n=r.touchEventsData,{params:s,touches:i,rtlTranslate:a,enabled:u}=r;if(!u||!s.simulateTouch&&e.pointerType==="mouse")return;let d=e;if(d.originalEvent&&(d=d.originalEvent),d.type==="pointermove"&&(n.touchId!==null||d.pointerId!==n.pointerId))return;let f;if(d.type==="touchmove"){if(f=[...d.changedTouches].find(_=>_.identifier===n.touchId),!f||f.identifier!==n.touchId)return}else f=d;if(!n.isTouched){n.startMoving&&n.isScrolling&&r.emit("touchMoveOpposite",d);return}const b=f.pageX,g=f.pageY;if(d.preventedByNestedSwiper){i.startX=b,i.startY=g;return}if(!r.allowTouchMove){d.target.matches(n.focusableElements)||(r.allowClick=!1),n.isTouched&&(Object.assign(i,{startX:b,startY:g,currentX:b,currentY:g}),n.touchStartTime=Wf());return}if(s.touchReleaseOnEdges&&!s.loop)if(r.isVertical()){if(g<i.startY&&r.translate<=r.maxTranslate()||g>i.startY&&r.translate>=r.minTranslate()){n.isTouched=!1,n.isMoved=!1;return}}else{if(a&&(b>i.startX&&-r.translate<=r.maxTranslate()||b<i.startX&&-r.translate>=r.minTranslate()))return;if(!a&&(b<i.startX&&r.translate<=r.maxTranslate()||b>i.startX&&r.translate>=r.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==d.target&&d.pointerType!=="mouse"&&t.activeElement.blur(),t.activeElement&&d.target===t.activeElement&&d.target.matches(n.focusableElements)){n.isMoved=!0,r.allowClick=!1;return}n.allowTouchCallbacks&&r.emit("touchMove",d),i.previousX=i.currentX,i.previousY=i.currentY,i.currentX=b,i.currentY=g;const y=i.currentX-i.startX,v=i.currentY-i.startY;if(r.params.threshold&&Math.sqrt(y**2+v**2)<r.params.threshold)return;if(typeof n.isScrolling>"u"){let _;r.isHorizontal()&&i.currentY===i.startY||r.isVertical()&&i.currentX===i.startX?n.isScrolling=!1:y*y+v*v>=25&&(_=Math.atan2(Math.abs(v),Math.abs(y))*180/Math.PI,n.isScrolling=r.isHorizontal()?_>s.touchAngle:90-_>s.touchAngle)}if(n.isScrolling&&r.emit("touchMoveOpposite",d),typeof n.startMoving>"u"&&(i.currentX!==i.startX||i.currentY!==i.startY)&&(n.startMoving=!0),n.isScrolling||d.type==="touchmove"&&n.preventTouchMoveFromPointerMove){n.isTouched=!1;return}if(!n.startMoving)return;r.allowClick=!1,!s.cssMode&&d.cancelable&&d.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&d.stopPropagation();let w=r.isHorizontal()?y:v,T=r.isHorizontal()?i.currentX-i.previousX:i.currentY-i.previousY;s.oneWayMovement&&(w=Math.abs(w)*(a?1:-1),T=Math.abs(T)*(a?1:-1)),i.diff=w,w*=s.touchRatio,a&&(w=-w,T=-T);const C=r.touchesDirection;r.swipeDirection=w>0?"prev":"next",r.touchesDirection=T>0?"prev":"next";const E=r.params.loop&&!s.cssMode,N=r.touchesDirection==="next"&&r.allowSlideNext||r.touchesDirection==="prev"&&r.allowSlidePrev;if(!n.isMoved){if(E&&N&&r.loopFix({direction:r.swipeDirection}),n.startTranslate=r.getTranslate(),r.setTransition(0),r.animating){const _=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});r.wrapperEl.dispatchEvent(_)}n.allowMomentumBounce=!1,s.grabCursor&&(r.allowSlideNext===!0||r.allowSlidePrev===!0)&&r.setGrabCursor(!0),r.emit("sliderFirstMove",d)}if(new Date().getTime(),s._loopSwapReset!==!1&&n.isMoved&&n.allowThresholdMove&&C!==r.touchesDirection&&E&&N&&Math.abs(w)>=1){Object.assign(i,{startX:b,startY:g,currentX:b,currentY:g,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,n.startTranslate=n.currentTranslate;return}r.emit("sliderMove",d),n.isMoved=!0,n.currentTranslate=w+n.startTranslate;let D=!0,R=s.resistanceRatio;if(s.touchReleaseOnEdges&&(R=0),w>0?(E&&N&&n.allowThresholdMove&&n.currentTranslate>(s.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-(s.slidesPerView!=="auto"&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.activeIndex+1]+r.params.spaceBetween:0)-r.params.spaceBetween:r.minTranslate())&&r.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>r.minTranslate()&&(D=!1,s.resistance&&(n.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+n.startTranslate+w)**R))):w<0&&(E&&N&&n.allowThresholdMove&&n.currentTranslate<(s.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+(s.slidesPerView!=="auto"&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween:0):r.maxTranslate())&&r.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:r.slides.length-(s.slidesPerView==="auto"?r.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),n.currentTranslate<r.maxTranslate()&&(D=!1,s.resistance&&(n.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-n.startTranslate-w)**R))),D&&(d.preventedByNestedSwiper=!0),!r.allowSlideNext&&r.swipeDirection==="next"&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!r.allowSlidePrev&&r.swipeDirection==="prev"&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),!r.allowSlidePrev&&!r.allowSlideNext&&(n.currentTranslate=n.startTranslate),s.threshold>0)if(Math.abs(w)>s.threshold||n.allowThresholdMove){if(!n.allowThresholdMove){n.allowThresholdMove=!0,i.startX=i.currentX,i.startY=i.currentY,n.currentTranslate=n.startTranslate,i.diff=r.isHorizontal()?i.currentX-i.startX:i.currentY-i.startY;return}}else{n.currentTranslate=n.startTranslate;return}!s.followFinger||s.cssMode||((s.freeMode&&s.freeMode.enabled&&r.freeMode||s.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(n.currentTranslate),r.setTranslate(n.currentTranslate))}function PS(e){const t=this;if(t.destroyed)return;const r=t.touchEventsData;let n=e;n.originalEvent&&(n=n.originalEvent);let s;if(n.type==="touchend"||n.type==="touchcancel"){if(s=[...n.changedTouches].find(_=>_.identifier===r.touchId),!s||s.identifier!==r.touchId)return}else{if(r.touchId!==null||n.pointerId!==r.pointerId)return;s=n}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(n.type)&&!(["pointercancel","contextmenu"].includes(n.type)&&(t.browser.isSafari||t.browser.isWebView)))return;r.pointerId=null,r.touchId=null;const{params:a,touches:u,rtlTranslate:d,slidesGrid:f,enabled:b}=t;if(!b||!a.simulateTouch&&n.pointerType==="mouse")return;if(r.allowTouchCallbacks&&t.emit("touchEnd",n),r.allowTouchCallbacks=!1,!r.isTouched){r.isMoved&&a.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,r.startMoving=!1;return}a.grabCursor&&r.isMoved&&r.isTouched&&(t.allowSlideNext===!0||t.allowSlidePrev===!0)&&t.setGrabCursor(!1);const g=Wf(),y=g-r.touchStartTime;if(t.allowClick){const _=n.path||n.composedPath&&n.composedPath();t.updateClickedSlide(_&&_[0]||n.target,_),t.emit("tap click",n),y<300&&g-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=Wf(),y6(()=>{t.destroyed||(t.allowClick=!0)}),!r.isTouched||!r.isMoved||!t.swipeDirection||u.diff===0&&!r.loopSwapReset||r.currentTranslate===r.startTranslate&&!r.loopSwapReset){r.isTouched=!1,r.isMoved=!1,r.startMoving=!1;return}r.isTouched=!1,r.isMoved=!1,r.startMoving=!1;let v;if(a.followFinger?v=d?t.translate:-t.translate:v=-r.currentTranslate,a.cssMode)return;if(a.freeMode&&a.freeMode.enabled){t.freeMode.onTouchEnd({currentPos:v});return}const w=v>=-t.maxTranslate()&&!t.params.loop;let T=0,C=t.slidesSizesGrid[0];for(let _=0;_<f.length;_+=_<a.slidesPerGroupSkip?1:a.slidesPerGroup){const M=_<a.slidesPerGroupSkip-1?1:a.slidesPerGroup;typeof f[_+M]<"u"?(w||v>=f[_]&&v<f[_+M])&&(T=_,C=f[_+M]-f[_]):(w||v>=f[_])&&(T=_,C=f[f.length-1]-f[f.length-2])}let E=null,N=null;a.rewind&&(t.isBeginning?N=a.virtual&&a.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(E=0));const D=(v-f[T])/C,R=T<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?E:T+R):t.slideTo(T)),t.swipeDirection==="prev"&&(D>1-a.longSwipesRatio?t.slideTo(T+R):N!==null&&D<0&&Math.abs(D)>a.longSwipesRatio?t.slideTo(N):t.slideTo(T))}else{if(!a.shortSwipes){t.slideTo(t.activeIndex);return}t.navigation&&(n.target===t.navigation.nextEl||n.target===t.navigation.prevEl)?n.target===t.navigation.nextEl?t.slideTo(T+R):t.slideTo(T):(t.swipeDirection==="next"&&t.slideTo(E!==null?E:T+R),t.swipeDirection==="prev"&&t.slideTo(N!==null?N:T))}}function db(){const e=this,{params:t,el:r}=e;if(r&&r.offsetWidth===0)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:n,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 u=a&&t.loop;if((t.slidesPerView==="auto"||t.slidesPerView>1)&&e.isEnd&&!e.isBeginning&&!e.params.centeredSlides&&!u){const d=a?e.virtual.slides:e.slides;e.slideTo(d.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=n,e.params.watchOverflow&&i!==e.snapGrid&&e.checkOverflow()}function jS(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 QS(){const e=this;if(e.destroyed)return;const{wrapperEl:t,rtlTranslate:r,enabled:n}=e;if(!n)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(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function FS(e){const t=this;t.destroyed||(Cf(t,e.target),!(t.params.cssMode||t.params.slidesPerView!=="auto"&&!t.params.autoHeight)&&t.update())}function OS(){const e=this;e.destroyed||e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const C6=(e,t)=>{const r=Pc(),{params:n,el:s,wrapperEl:i,device:a}=e,u=!!n.nested,d=t==="on"?"addEventListener":"removeEventListener",f=t;!s||typeof s=="string"||(r[d]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:u}),s[d]("touchstart",e.onTouchStart,{passive:!1}),s[d]("pointerdown",e.onTouchStart,{passive:!1}),r[d]("touchmove",e.onTouchMove,{passive:!1,capture:u}),r[d]("pointermove",e.onTouchMove,{passive:!1,capture:u}),r[d]("touchend",e.onTouchEnd,{passive:!0}),r[d]("pointerup",e.onTouchEnd,{passive:!0}),r[d]("pointercancel",e.onTouchEnd,{passive:!0}),r[d]("touchcancel",e.onTouchEnd,{passive:!0}),r[d]("pointerout",e.onTouchEnd,{passive:!0}),r[d]("pointerleave",e.onTouchEnd,{passive:!0}),r[d]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&s[d]("click",e.onClick,!0),n.cssMode&&i[d]("scroll",e.onScroll),n.updateOnWindowResize?e[f](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",db,!0):e[f]("observerUpdate",db,!0),s[d]("load",e.onLoad,{capture:!0}))};function $S(){const e=this,{params:t}=e;e.onTouchStart=DS.bind(e),e.onTouchMove=BS.bind(e),e.onTouchEnd=PS.bind(e),e.onDocumentTouchStart=OS.bind(e),t.cssMode&&(e.onScroll=QS.bind(e)),e.onClick=jS.bind(e),e.onLoad=FS.bind(e),C6(e,"on")}function HS(){C6(this,"off")}var US={attachEvents:$S,detachEvents:HS};const hb=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;function GS(){const e=this,{realIndex:t,initialized:r,params:n,el:s}=e,i=n.breakpoints;if(!i||i&&Object.keys(i).length===0)return;const a=Pc(),u=n.breakpointsBase==="window"||!n.breakpointsBase?n.breakpointsBase:"container",d=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:a.querySelector(n.breakpointsBase),f=e.getBreakpoint(i,u,d);if(!f||e.currentBreakpoint===f)return;const g=(f in i?i[f]:void 0)||e.originalParams,y=hb(e,n),v=hb(e,g),w=e.params.grabCursor,T=g.grabCursor,C=n.enabled;y&&!v?(s.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!y&&v&&(s.classList.add(`${n.containerModifierClass}grid`),(g.grid.fill&&g.grid.fill==="column"||!g.grid.fill&&n.grid.fill==="column")&&s.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),w&&!T?e.unsetGrabCursor():!w&&T&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(M=>{if(typeof g[M]>"u")return;const Q=n[M]&&n[M].enabled,H=g[M]&&g[M].enabled;Q&&!H&&e[M].disable(),!Q&&H&&e[M].enable()});const E=g.direction&&g.direction!==n.direction,N=n.loop&&(g.slidesPerView!==n.slidesPerView||E),D=n.loop;E&&r&&e.changeDirection(),So(e.params,g);const R=e.params.enabled,_=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),C&&!R?e.disable():!C&&R&&e.enable(),e.currentBreakpoint=f,e.emit("_beforeBreakpoint",g),r&&(N?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!D&&_?(e.loopCreate(t),e.updateSlides()):D&&!_&&e.loopDestroy()),e.emit("breakpoint",g)}function zS(e,t="window",r){if(!e||t==="container"&&!r)return;let n=!1;const s=Yi(),i=t==="window"?s.innerHeight:r.clientHeight,a=Object.keys(e).map(u=>{if(typeof u=="string"&&u.indexOf("@")===0){const d=parseFloat(u.substr(1));return{value:i*d,point:u}}return{value:u,point:u}});a.sort((u,d)=>parseInt(u.value,10)-parseInt(d.value,10));for(let u=0;u<a.length;u+=1){const{point:d,value:f}=a[u];t==="window"?s.matchMedia(`(min-width: ${f}px)`).matches&&(n=d):f<=r.clientWidth&&(n=d)}return n||"max"}var WS={setBreakpoint:GS,getBreakpoint:zS};function VS(e,t){const r=[];return e.forEach(n=>{typeof n=="object"?Object.keys(n).forEach(s=>{n[s]&&r.push(t+s)}):typeof n=="string"&&r.push(t+n)}),r}function qS(){const e=this,{classNames:t,params:r,rtl:n,el:s,device:i}=e,a=VS(["initialized",r.direction,{"free-mode":e.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:n},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&r.grid.fill==="column"},{android:i.android},{ios:i.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),s.classList.add(...t),e.emitContainerClasses()}function YS(){const e=this,{el:t,classNames:r}=e;!t||typeof t=="string"||(t.classList.remove(...r),e.emitContainerClasses())}var ZS={addClasses:qS,removeClasses:YS};function KS(){const e=this,{isLocked:t,params:r}=e,{slidesOffsetBefore:n}=r;if(n){const s=e.slides.length-1,i=e.slidesGrid[s]+e.slidesSizesGrid[s]+n*2;e.isLocked=e.size>i}else e.isLocked=e.snapGrid.length===1;r.allowSlideNext===!0&&(e.allowSlideNext=!e.isLocked),r.allowSlidePrev===!0&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}var XS={checkOverflow:KS},x1={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 JS(e,t){return function(n={}){const s=Object.keys(n)[0],i=n[s];if(typeof i!="object"||i===null){So(t,n);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)){So(t,n);return}typeof e[s]=="object"&&!("enabled"in e[s])&&(e[s].enabled=!0),e[s]||(e[s]={enabled:!1}),So(t,n)}}const zm={eventsEmitter:ZT,update:aS,translate:fS,transition:bS,slide:CS,loop:ES,grabCursor:RS,events:US,breakpoints:WS,checkOverflow:XS,classes:ZS},Wm={};let L2=class tl{constructor(...t){let r,n;t.length===1&&t[0].constructor&&Object.prototype.toString.call(t[0]).slice(8,-1)==="Object"?n=t[0]:[r,n]=t,n||(n={}),n=So({},n),r&&!n.el&&(n.el=r);const s=Pc();if(n.el&&typeof n.el=="string"&&s.querySelectorAll(n.el).length>1){const d=[];return s.querySelectorAll(n.el).forEach(f=>{const b=So({},n,{el:f});d.push(new tl(b))}),d}const i=this;i.__swiper__=!0,i.support=w6(),i.device=A6({userAgent:n.userAgent}),i.browser=T6(),i.eventsListeners={},i.eventsAnyListeners=[],i.modules=[...i.__modules__],n.modules&&Array.isArray(n.modules)&&n.modules.forEach(d=>{typeof d=="function"&&i.modules.indexOf(d)<0&&i.modules.push(d)});const a={};i.modules.forEach(d=>{d({params:n,swiper:i,extendParams:JS(n,a),on:i.on.bind(i),once:i.once.bind(i),off:i.off.bind(i),emit:i.emit.bind(i)})});const u=So({},x1,a);return i.params=So({},u,Wm,n),i.originalParams=So({},i.params),i.passedParams=So({},n),i.params&&i.params.on&&Object.keys(i.params.on).forEach(d=>{i.on(d,i.params.on[d])}),i.params&&i.params.onAny&&i.onAny(i.params.onAny),Object.assign(i,{enabled:i.params.enabled,el:r,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:r,params:n}=this,s=rl(r,`.${n.slideClass}, swiper-slide`),i=ob(s[0]);return ob(t)-i}getSlideIndexByData(t){return this.getSlideIndex(this.slides.find(r=>r.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:r,params:n}=t;t.slides=rl(r,`.${n.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,r){const n=this;t=Math.min(Math.max(t,0),1);const s=n.minTranslate(),a=(n.maxTranslate()-s)*t+s;n.translateTo(a,typeof r>"u"?0:r),n.updateActiveIndex(),n.updateSlidesClasses()}emitContainerClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const r=t.el.className.split(" ").filter(n=>n.indexOf("swiper")===0||n.indexOf(t.params.containerModifierClass)===0);t.emit("_containerClasses",r.join(" "))}getSlideClasses(t){const r=this;return r.destroyed?"":t.className.split(" ").filter(n=>n.indexOf("swiper-slide")===0||n.indexOf(r.params.slideClass)===0).join(" ")}emitSlidesClasses(){const t=this;if(!t.params._emitClasses||!t.el)return;const r=[];t.slides.forEach(n=>{const s=t.getSlideClasses(n);r.push({slideEl:n,classNames:s}),t.emit("_slideClass",n,s)}),t.emit("_slideClasses",r)}slidesPerViewDynamic(t="current",r=!1){const n=this,{params:s,slides:i,slidesGrid:a,slidesSizesGrid:u,size:d,activeIndex:f}=n;let b=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),b+=1,g>d&&(y=!0));for(let v=f-1;v>=0;v-=1)i[v]&&!y&&(g+=i[v].swiperSlideSize,b+=1,g>d&&(y=!0))}else if(t==="current")for(let g=f+1;g<i.length;g+=1)(r?a[g]+u[g]-a[f]<d:a[g]-a[f]<d)&&(b+=1);else for(let g=f-1;g>=0;g-=1)a[f]-a[g]<d&&(b+=1);return b}update(){const t=this;if(!t||t.destroyed)return;const{snapGrid:r,params:n}=t;n.breakpoints&&t.setBreakpoint(),[...t.el.querySelectorAll('[loading="lazy"]')].forEach(a=>{a.complete&&Cf(t,a)}),t.updateSize(),t.updateSlides(),t.updateProgress(),t.updateSlidesClasses();function s(){const a=t.rtlTranslate?t.translate*-1:t.translate,u=Math.min(Math.max(a,t.maxTranslate()),t.minTranslate());t.setTranslate(u),t.updateActiveIndex(),t.updateSlidesClasses()}let i;if(n.freeMode&&n.freeMode.enabled&&!n.cssMode)s(),n.autoHeight&&t.updateAutoHeight();else{if((n.slidesPerView==="auto"||n.slidesPerView>1)&&t.isEnd&&!n.centeredSlides){const a=t.virtual&&n.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()}n.watchOverflow&&r!==t.snapGrid&&t.checkOverflow(),t.emit("update")}changeDirection(t,r=!0){const n=this,s=n.params.direction;return t||(t=s==="horizontal"?"vertical":"horizontal"),t===s||t!=="horizontal"&&t!=="vertical"||(n.el.classList.remove(`${n.params.containerModifierClass}${s}`),n.el.classList.add(`${n.params.containerModifierClass}${t}`),n.emitContainerClasses(),n.params.direction=t,n.slides.forEach(i=>{t==="vertical"?i.style.width="":i.style.height=""}),n.emit("changeDirection"),r&&n.update()),n}changeLanguageDirection(t){const r=this;r.rtl&&t==="rtl"||!r.rtl&&t==="ltr"||(r.rtl=t==="rtl",r.rtlTranslate=r.params.direction==="horizontal"&&r.rtl,r.rtl?(r.el.classList.add(`${r.params.containerModifierClass}rtl`),r.el.dir="rtl"):(r.el.classList.remove(`${r.params.containerModifierClass}rtl`),r.el.dir="ltr"),r.update())}mount(t){const r=this;if(r.mounted)return!0;let n=t||r.params.el;if(typeof n=="string"&&(n=document.querySelector(n)),!n)return!1;n.swiper=r,n.parentNode&&n.parentNode.host&&n.parentNode.host.nodeName===r.params.swiperElementNodeName.toUpperCase()&&(r.isElement=!0);const s=()=>`.${(r.params.wrapperClass||"").trim().split(" ").join(".")}`;let a=n&&n.shadowRoot&&n.shadowRoot.querySelector?n.shadowRoot.querySelector(s()):rl(n,s())[0];return!a&&r.params.createElements&&(a=g1("div",r.params.wrapperClass),n.append(a),rl(n,`.${r.params.slideClass}`).forEach(u=>{a.append(u)})),Object.assign(r,{el:n,wrapperEl:a,slidesEl:r.isElement&&!n.parentNode.host.slideSlots?n.parentNode.host:a,hostEl:r.isElement?n.parentNode.host:n,mounted:!0,rtl:n.dir.toLowerCase()==="rtl"||Ql(n,"direction")==="rtl",rtlTranslate:r.params.direction==="horizontal"&&(n.dir.toLowerCase()==="rtl"||Ql(n,"direction")==="rtl"),wrongRTL:Ql(a,"display")==="-webkit-box"}),!0}init(t){const r=this;if(r.initialized||r.mount(t)===!1)return r;r.emit("beforeInit"),r.params.breakpoints&&r.setBreakpoint(),r.addClasses(),r.updateSize(),r.updateSlides(),r.params.watchOverflow&&r.checkOverflow(),r.params.grabCursor&&r.enabled&&r.setGrabCursor(),r.params.loop&&r.virtual&&r.params.virtual.enabled?r.slideTo(r.params.initialSlide+r.virtual.slidesBefore,0,r.params.runCallbacksOnInit,!1,!0):r.slideTo(r.params.initialSlide,0,r.params.runCallbacksOnInit,!1,!0),r.params.loop&&r.loopCreate(void 0,!0),r.attachEvents();const s=[...r.el.querySelectorAll('[loading="lazy"]')];return r.isElement&&s.push(...r.hostEl.querySelectorAll('[loading="lazy"]')),s.forEach(i=>{i.complete?Cf(r,i):i.addEventListener("load",a=>{Cf(r,a.target)})}),b1(r),r.initialized=!0,b1(r),r.emit("init"),r.emit("afterInit"),r}destroy(t=!0,r=!0){const n=this,{params:s,el:i,wrapperEl:a,slides:u}=n;return typeof n.params>"u"||n.destroyed||(n.emit("beforeDestroy"),n.initialized=!1,n.detachEvents(),s.loop&&n.loopDestroy(),r&&(n.removeClasses(),i&&typeof i!="string"&&i.removeAttribute("style"),a&&a.removeAttribute("style"),u&&u.length&&u.forEach(d=>{d.classList.remove(s.slideVisibleClass,s.slideFullyVisibleClass,s.slideActiveClass,s.slideNextClass,s.slidePrevClass),d.removeAttribute("style"),d.removeAttribute("data-swiper-slide-index")})),n.emit("destroy"),Object.keys(n.eventsListeners).forEach(d=>{n.off(d)}),t!==!1&&(n.el&&typeof n.el!="string"&&(n.el.swiper=null),PT(n)),n.destroyed=!0),null}static extendDefaults(t){So(Wm,t)}static get extendedDefaults(){return Wm}static get defaults(){return x1}static installModule(t){tl.prototype.__modules__||(tl.prototype.__modules__=[]);const r=tl.prototype.__modules__;typeof t=="function"&&r.indexOf(t)<0&&r.push(t)}static use(t){return Array.isArray(t)?(t.forEach(r=>tl.installModule(r)),tl):(tl.installModule(t),tl)}};Object.keys(zm).forEach(e=>{Object.keys(zm[e]).forEach(t=>{L2.prototype[t]=zm[e][t]})});L2.use([qT,YT]);const _6=["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 Ec(e){return typeof e=="object"&&e!==null&&e.constructor&&Object.prototype.toString.call(e).slice(8,-1)==="Object"&&!e.__swiper__}function Ou(e,t){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(n=>r.indexOf(n)<0).forEach(n=>{typeof e[n]>"u"?e[n]=t[n]:Ec(t[n])&&Ec(e[n])&&Object.keys(t[n]).length>0?t[n].__swiper__?e[n]=t[n]:Ou(e[n],t[n]):e[n]=t[n]})}function L6(e={}){return e.navigation&&typeof e.navigation.nextEl>"u"&&typeof e.navigation.prevEl>"u"}function k6(e={}){return e.pagination&&typeof e.pagination.el>"u"}function E6(e={}){return e.scrollbar&&typeof e.scrollbar.el>"u"}function I6(e=""){const t=e.split(" ").map(n=>n.trim()).filter(n=>!!n),r=[];return t.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r.join(" ")}function eC(e=""){return e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function tC({swiper:e,slides:t,passedParams:r,changedParams:n,nextEl:s,prevEl:i,scrollbarEl:a,paginationEl:u}){const d=n.filter(H=>H!=="children"&&H!=="direction"&&H!=="wrapperClass"),{params:f,pagination:b,navigation:g,scrollbar:y,virtual:v,thumbs:w}=e;let T,C,E,N,D,R,_,M;n.includes("thumbs")&&r.thumbs&&r.thumbs.swiper&&!r.thumbs.swiper.destroyed&&f.thumbs&&(!f.thumbs.swiper||f.thumbs.swiper.destroyed)&&(T=!0),n.includes("controller")&&r.controller&&r.controller.control&&f.controller&&!f.controller.control&&(C=!0),n.includes("pagination")&&r.pagination&&(r.pagination.el||u)&&(f.pagination||f.pagination===!1)&&b&&!b.el&&(E=!0),n.includes("scrollbar")&&r.scrollbar&&(r.scrollbar.el||a)&&(f.scrollbar||f.scrollbar===!1)&&y&&!y.el&&(N=!0),n.includes("navigation")&&r.navigation&&(r.navigation.prevEl||i)&&(r.navigation.nextEl||s)&&(f.navigation||f.navigation===!1)&&g&&!g.prevEl&&!g.nextEl&&(D=!0);const Q=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))};n.includes("loop")&&e.isElement&&(f.loop&&!r.loop?R=!0:!f.loop&&r.loop?_=!0:M=!0),d.forEach(H=>{if(Ec(f[H])&&Ec(r[H]))Object.assign(f[H],r[H]),(H==="navigation"||H==="pagination"||H==="scrollbar")&&"enabled"in r[H]&&!r[H].enabled&&Q(H);else{const G=r[H];(G===!0||G===!1)&&(H==="navigation"||H==="pagination"||H==="scrollbar")?G===!1&&Q(H):f[H]=r[H]}}),d.includes("controller")&&!C&&e.controller&&e.controller.control&&f.controller&&f.controller.control&&(e.controller.control=f.controller.control),n.includes("children")&&t&&v&&f.virtual.enabled?(v.slides=t,v.update(!0)):n.includes("virtual")&&v&&f.virtual.enabled&&(t&&(v.slides=t),v.update(!0)),n.includes("children")&&t&&f.loop&&(M=!0),T&&w.init()&&w.update(!0),C&&(e.controller.control=f.controller.control),E&&(e.isElement&&(!u||typeof u=="string")&&(u=document.createElement("div"),u.classList.add("swiper-pagination"),u.part.add("pagination"),e.el.appendChild(u)),u&&(f.pagination.el=u),b.init(),b.render(),b.update()),N&&(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"),lb(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"),lb(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()),n.includes("allowSlideNext")&&(e.allowSlideNext=r.allowSlideNext),n.includes("allowSlidePrev")&&(e.allowSlidePrev=r.allowSlidePrev),n.includes("direction")&&e.changeDirection(r.direction,!1),(R||M)&&e.loopDestroy(),(_||M)&&e.loopCreate(),e.update()}function rC(e={},t=!0){const r={on:{}},n={},s={};Ou(r,x1),r._emitClasses=!0,r.init=!1;const i={},a=_6.map(d=>d.replace(/_/,"")),u=Object.assign({},e);return Object.keys(u).forEach(d=>{typeof e[d]>"u"||(a.indexOf(d)>=0?Ec(e[d])?(r[d]={},s[d]={},Ou(r[d],e[d]),Ou(s[d],e[d])):(r[d]=e[d],s[d]=e[d]):d.search(/on[A-Z]/)===0&&typeof e[d]=="function"?t?n[`${d[2].toLowerCase()}${d.substr(3)}`]=e[d]:r.on[`${d[2].toLowerCase()}${d.substr(3)}`]=e[d]:i[d]=e[d])}),["navigation","pagination","scrollbar"].forEach(d=>{r[d]===!0&&(r[d]={}),r[d]===!1&&delete r[d]}),{params:r,passedParams:s,rest:i,events:n}}function nC({el:e,nextEl:t,prevEl:r,paginationEl:n,scrollbarEl:s,swiper:i},a){L6(a)&&t&&r&&(i.params.navigation.nextEl=t,i.originalParams.navigation.nextEl=t,i.params.navigation.prevEl=r,i.originalParams.navigation.prevEl=r),k6(a)&&n&&(i.params.pagination.el=n,i.originalParams.pagination.el=n),E6(a)&&s&&(i.params.scrollbar.el=s,i.originalParams.scrollbar.el=s),i.init(e)}function sC(e,t,r,n,s){const i=[];if(!t)return i;const a=d=>{i.indexOf(d)<0&&i.push(d)};if(r&&n){const d=n.map(s),f=r.map(s);d.join("")!==f.join("")&&a("children"),n.length!==r.length&&a("children")}return _6.filter(d=>d[0]==="_").map(d=>d.replace(/_/,"")).forEach(d=>{if(d in e&&d in t)if(Ec(e[d])&&Ec(t[d])){const f=Object.keys(e[d]),b=Object.keys(t[d]);f.length!==b.length?a(d):(f.forEach(g=>{e[d][g]!==t[d][g]&&a(d)}),b.forEach(g=>{e[d][g]!==t[d][g]&&a(d)}))}else e[d]!==t[d]&&a(d)}),i}const iC=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 qf(){return qf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},qf.apply(this,arguments)}function M6(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function R6(e){const t=[];return P.Children.toArray(e).forEach(r=>{M6(r)?t.push(r):r.props&&r.props.children&&R6(r.props.children).forEach(n=>t.push(n))}),t}function oC(e){const t=[],r={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return P.Children.toArray(e).forEach(n=>{if(M6(n))t.push(n);else if(n.props&&n.props.slot&&r[n.props.slot])r[n.props.slot].push(n);else if(n.props&&n.props.children){const s=R6(n.props.children);s.length>0?s.forEach(i=>t.push(i)):r["container-end"].push(n)}else r["container-end"].push(n)}),{slides:t,slots:r}}function aC(e,t,r){if(!r)return null;const n=b=>{let g=b;return b<0?g=t.length+b:g>=t.length&&(g=g-t.length),g},s=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${r.offset}px`}:{top:`${r.offset}px`},{from:i,to:a}=r,u=e.params.loop?-t.length:0,d=e.params.loop?t.length*2:t.length,f=[];for(let b=u;b<d;b+=1)b>=i&&b<=a&&f.push(t[n(b)]);return f.map((b,g)=>P.cloneElement(b,{swiper:e,style:s,key:b.props.virtualIndex||b.key||`slide-${g}`}))}function Td(e,t){return typeof window>"u"?A.useEffect(e,t):A.useLayoutEffect(e,t)}const fb=A.createContext(null),lC=A.createContext(null),sh=A.forwardRef(({className:e,tag:t="div",wrapperTag:r="div",children:n,onSwiper:s,...i}={},a)=>{let u=!1;const[d,f]=A.useState("swiper"),[b,g]=A.useState(null),[y,v]=A.useState(!1),w=A.useRef(!1),T=A.useRef(null),C=A.useRef(null),E=A.useRef(null),N=A.useRef(null),D=A.useRef(null),R=A.useRef(null),_=A.useRef(null),M=A.useRef(null),{params:Q,passedParams:H,rest:G,events:U}=rC(i),{slides:W,slots:J}=oC(n),ee=()=>{v(!y)};Object.assign(Q.on,{_containerClasses(se,ie){f(ie)}});const ae=()=>{Object.assign(Q.on,U),u=!0;const se={...Q};if(delete se.wrapperClass,C.current=new L2(se),C.current.virtual&&C.current.params.virtual.enabled){C.current.virtual.slides=W;const ie={cache:!1,slides:W,renderExternal:g,renderExternalUpdate:!1};Ou(C.current.params.virtual,ie),Ou(C.current.originalParams.virtual,ie)}};T.current||ae(),C.current&&C.current.on("_beforeBreakpoint",ee);const Se=()=>{u||!U||!C.current||Object.keys(U).forEach(se=>{C.current.on(se,U[se])})},Le=()=>{!U||!C.current||Object.keys(U).forEach(se=>{C.current.off(se,U[se])})};A.useEffect(()=>()=>{C.current&&C.current.off("_beforeBreakpoint",ee)}),A.useEffect(()=>{!w.current&&C.current&&(C.current.emitSlidesClasses(),w.current=!0)}),Td(()=>{if(a&&(a.current=T.current),!!T.current)return C.current.destroyed&&ae(),nC({el:T.current,nextEl:D.current,prevEl:R.current,paginationEl:_.current,scrollbarEl:M.current,swiper:C.current},Q),s&&!C.current.destroyed&&s(C.current),()=>{C.current&&!C.current.destroyed&&C.current.destroy(!0,!1)}},[]),Td(()=>{Se();const se=sC(H,E.current,W,N.current,ie=>ie.key);return E.current=H,N.current=W,se.length&&C.current&&!C.current.destroyed&&tC({swiper:C.current,slides:W,passedParams:H,changedParams:se,nextEl:D.current,prevEl:R.current,scrollbarEl:M.current,paginationEl:_.current}),()=>{Le()}}),Td(()=>{iC(C.current)},[b]);function _e(){return Q.virtual?aC(C.current,W,b):W.map((se,ie)=>P.cloneElement(se,{swiper:C.current,swiperSlideIndex:ie}))}return P.createElement(t,qf({ref:T,className:I6(`${d}${e?` ${e}`:""}`)},G),P.createElement(lC.Provider,{value:C.current},J["container-start"],P.createElement(r,{className:eC(Q.wrapperClass)},J["wrapper-start"],_e(),J["wrapper-end"]),L6(Q)&&P.createElement(P.Fragment,null,P.createElement("div",{ref:R,className:"swiper-button-prev"}),P.createElement("div",{ref:D,className:"swiper-button-next"})),E6(Q)&&P.createElement("div",{ref:M,className:"swiper-scrollbar"}),k6(Q)&&P.createElement("div",{ref:_,className:"swiper-pagination"}),J["container-end"]))});sh.displayName="Swiper";const Ic=A.forwardRef(({tag:e="div",children:t,className:r="",swiper:n,zoom:s,lazy:i,virtualIndex:a,swiperSlideIndex:u,...d}={},f)=>{const b=A.useRef(null),[g,y]=A.useState("swiper-slide"),[v,w]=A.useState(!1);function T(D,R,_){R===b.current&&y(_)}Td(()=>{if(typeof u<"u"&&(b.current.swiperSlideIndex=u),f&&(f.current=b.current),!(!b.current||!n)){if(n.destroyed){g!=="swiper-slide"&&y("swiper-slide");return}return n.on("_slideClass",T),()=>{n&&n.off("_slideClass",T)}}}),Td(()=>{n&&b.current&&!n.destroyed&&y(n.getSlideClasses(b.current))},[n]);const C={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},E=()=>typeof t=="function"?t(C):t,N=()=>{w(!0)};return P.createElement(e,qf({ref:b,className:I6(`${g}${r?` ${r}`:""}`),"data-swiper-slide-index":a,onLoad:N},d),s&&P.createElement(fb.Provider,{value:C},P.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":typeof s=="number"?s:void 0},E(),i&&!v&&P.createElement("div",{className:"swiper-lazy-preloader",ref:D=>{D&&(D.lazyPreloaderManaged=!0)}}))),!s&&P.createElement(fb.Provider,{value:C},E(),i&&!v&&P.createElement("div",{className:"swiper-lazy-preloader",ref:D=>{D&&(D.lazyPreloaderManaged=!0)}})))});Ic.displayName="SwiperSlide";const mi=[];for(let e=0;e<256;++e)mi.push((e+256).toString(16).slice(1));function cC(e,t=0){return(mi[e[t+0]]+mi[e[t+1]]+mi[e[t+2]]+mi[e[t+3]]+"-"+mi[e[t+4]]+mi[e[t+5]]+"-"+mi[e[t+6]]+mi[e[t+7]]+"-"+mi[e[t+8]]+mi[e[t+9]]+"-"+mi[e[t+10]]+mi[e[t+11]]+mi[e[t+12]]+mi[e[t+13]]+mi[e[t+14]]+mi[e[t+15]]).toLowerCase()}let Vm;const uC=new Uint8Array(16);function dC(){if(!Vm){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Vm=crypto.getRandomValues.bind(crypto)}return Vm(uC)}const hC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pb={randomUUID:hC};function fC(e,t,r){e=e||{};const n=e.random??e.rng?.()??dC();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,cC(n)}function pC(e,t,r){return pb.randomUUID&&!e?pb.randomUUID():fC(e)}const mC={},mb=e=>{let t;const r=new Set,n=(b,g)=>{const y=typeof b=="function"?b(t):b;if(!Object.is(y,t)){const v=t;t=g??(typeof y!="object"||y===null)?y:Object.assign({},t,y),r.forEach(w=>w(t,v))}},s=()=>t,d={setState:n,getState:s,getInitialState:()=>f,subscribe:b=>(r.add(b),()=>r.delete(b)),destroy:()=>{(mC?"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."),r.clear()}},f=t=e(n,s,d);return d},gC=e=>e?mb(e):mb;var qm={exports:{}},Ym={},Zm={exports:{}},Km={};var gb;function bC(){if(gb)return Km;gb=1;var e=_p();function t(g,y){return g===y&&(g!==0||1/g===1/y)||g!==g&&y!==y}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,s=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function u(g,y){var v=y(),w=n({inst:{value:v,getSnapshot:y}}),T=w[0].inst,C=w[1];return i(function(){T.value=v,T.getSnapshot=y,d(T)&&C({inst:T})},[g,v,y]),s(function(){return d(T)&&C({inst:T}),g(function(){d(T)&&C({inst:T})})},[g]),a(v),v}function d(g){var y=g.getSnapshot;g=g.value;try{var v=y();return!r(g,v)}catch{return!0}}function f(g,y){return y()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return Km.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:b,Km}var bb;function xC(){return bb||(bb=1,Zm.exports=bC()),Zm.exports}var xb;function yC(){if(xb)return Ym;xb=1;var e=_p(),t=xC();function r(f,b){return f===b&&(f!==0||1/f===1/b)||f!==f&&b!==b}var n=typeof Object.is=="function"?Object.is:r,s=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,u=e.useMemo,d=e.useDebugValue;return Ym.useSyncExternalStoreWithSelector=function(f,b,g,y,v){var w=i(null);if(w.current===null){var T={hasValue:!1,value:null};w.current=T}else T=w.current;w=u(function(){function E(M){if(!N){if(N=!0,D=M,M=y(M),v!==void 0&&T.hasValue){var Q=T.value;if(v(Q,M))return R=Q}return R=M}if(Q=R,n(D,M))return Q;var H=y(M);return v!==void 0&&v(Q,H)?(D=M,Q):(D=M,R=H)}var N=!1,D,R,_=g===void 0?null:g;return[function(){return E(b())},_===null?void 0:function(){return E(_())}]},[b,g,y,v]);var C=s(f,w[0],w[1]);return a(function(){T.hasValue=!0,T.value=C},[C]),d(C),C},Ym}var yb;function vC(){return yb||(yb=1,qm.exports=yC()),qm.exports}var wC=vC();const AC=b6(wC),N6={},{useDebugValue:TC}=P,{useSyncExternalStoreWithSelector:SC}=AC;let vb=!1;const CC=e=>e;function _C(e,t=CC,r){(N6?"production":void 0)!=="production"&&r&&!vb&&(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"),vb=!0);const n=SC(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return TC(n),n}const wb=e=>{(N6?"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"?gC(e):e,r=(n,s)=>_C(t,n,s);return Object.assign(r,t),r},D6=e=>e?wb(e):wb,Yf="auth:unauthorized";let Pu=null;class B6 extends Error{constructor(t,r,n){super(t),this.status=r,this.code=n,this.name="TerminalApiError"}status;code}const a0=8e3,Pa=1e4,$u=45e3;let LC=0;const _f=[];let Xm=!1;function El(e,t={}){if(typeof window>"u")return;const r=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:++LC,ts:Date.now(),...t}});_f.push(r),kC()}async function kC(){if(!Xm){Xm=!0;try{for(;_f.length>0;){const e=_f[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),_f.shift()}catch{break}}}finally{Xm=!1}}}function EC(e,t,r){const n=new AbortController;let s=setTimeout(()=>{n.abort(new DOMException(r,"TimeoutError"))},t);const i=()=>n.abort(e?.reason);return e&&(e.aborted?i():e.addEventListener("abort",i,{once:!0})),{signal:n.signal,cleanup:()=>{s&&(clearTimeout(s),s=null),e?.removeEventListener("abort",i)}}}async function ti(e,t,r,n){const{signal:s,cleanup:i}=EC(t?.signal??void 0,r,n);try{return await fetch(e,{...t,signal:s})}catch(a){throw a instanceof DOMException&&a.name==="TimeoutError"?new Error(n):a}finally{i()}}async function IC(e,t,r){let n=null;const s=new Promise((i,a)=>{n=setTimeout(()=>a(new Error(r)),t)});try{return await Promise.race([e.text(),s])}finally{n&&clearTimeout(n)}}if(typeof window<"u"&&!window.__termdockFetchPatched){window.__termdockFetchPatched=!0;const e=window.fetch.bind(window);window.fetch=async(...t)=>{const r=await e(...t);if(r.status===401){Pu=null;try{window.dispatchEvent(new CustomEvent(Yf))}catch{}}return r}}async function rn(){if(Pu)return Pu;const e=await fetch("/api/csrf-token");if(!e.ok)throw new Error("Failed to get CSRF token");return Pu=(await e.json()).csrfToken,Pu}function P6(){Pu=null}const MC=2e4,Ab=8e3,RC=1500,Io=new Map,NC=24,DC=40,BC=40;function PC(e){return e.retryState.retryCount>=2||e.pendingInputs.length>=BC?"congested":e.retryState.retryCount>=1||e.pendingInputs.length>=8?"degraded":"good"}function Tb(e){if(e.pendingInputs.length===0||e.ws.readyState!==WebSocket.OPEN)return;const t=e.pendingInputs.splice(0);for(const r of t)try{e.ws.send(JSON.stringify({type:"input",data:r}))}catch{}}function j6(e){if(e.ws.readyState!==WebSocket.OPEN)return;const t=PC(e);if(t==="good"){Tb(e);return}if(e.inputFlushTimer)return;const r=t==="congested"?DC:NC;e.inputFlushTimer=setTimeout(()=>{e.inputFlushTimer=null,Tb(e)},r)}const Sd=new Map;function jC(e,t,r,n){const s=Sd.get(e);s&&(Sd.delete(e),t?s.resolve({success:!0,layout:r}):s.reject(new Error(n||"Tmux action failed")))}function QC(e,t){const n=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/terminal/${e}/ws`;return t>0?`${n}?since=${t}`:n}const Sb=new Map;async function FC(e){const t=await rn(),r=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(!r.ok){const n=await r.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(n.error||"Failed to create terminal session")}return r.json()}function OC(e,t,r,n={}){const{maxRetries:s=10,initialRetryDelay:i=1e3,maxRetryDelay:a=2e4,connectionTimeout:u=15e3}=n,d={maxRetries:s,initialDelayMs:i,maxDelayMs:a,connectionTimeoutMs:u,retryCount:0,retryTimeout:null,connectionTimeoutId:null,isClosed:!1};let f=null,b=Sb.get(e)??0;Sb.delete(e);const g=[];let y=!1,v=null;const w=new WeakSet,T=()=>{d.retryTimeout&&(clearTimeout(d.retryTimeout),d.retryTimeout=null),d.connectionTimeoutId&&(clearTimeout(d.connectionTimeoutId),d.connectionTimeoutId=null),v&&(clearTimeout(v),v=null)},C=_=>{_.heartbeatTimer&&(clearInterval(_.heartbeatTimer),_.heartbeatTimer=null),_.pongTimer&&(clearTimeout(_.pongTimer),_.pongTimer=null),_.inputFlushTimer&&(clearTimeout(_.inputFlushTimer),_.inputFlushTimer=null)},E=_=>{C(_),_.heartbeatTimer=setInterval(()=>{if(_.ws.readyState===WebSocket.OPEN){try{_.ws.send(JSON.stringify({type:"ping"}))}catch{}_.pongTimer&&clearTimeout(_.pongTimer),_.pongTimer=setTimeout(()=>{if(Date.now()-_.lastInboundAt>=Ab)try{_.ws.close()}catch{}},Ab)}},MC)},N=()=>{if(d.isClosed=!0,T(),f){C(f),Io.delete(e);try{f.ws.close()}catch{}f=null}},D=()=>{if(d.isClosed)return;if(f){w.add(f.ws),C(f);try{f.ws.close()}catch{}}const _=QC(e,b),M=new WebSocket(_);y=!1,d.connectionTimeoutId=setTimeout(()=>{M.readyState!==WebSocket.OPEN&&(M.close(),R(new Error("WebSocket connection timeout"),!1))},u);const Q={ws:M,onEvent:t,onError:r,reconnectNow:()=>{if(!d.isClosed&&!v){if(T(),f){w.add(f.ws),C(f);try{f.ws.close()}catch{}}t({type:"reconnecting",attempt:Math.min(d.retryCount+1,s),maxAttempts:s}),d.retryCount=Math.min(d.retryCount+1,s),y=!0,v=setTimeout(()=>{v=null,y=!1,D()},0)}},retryState:d,lastSeq:b,pendingInputs:g,inputFlushTimer:null,heartbeatTimer:null,pongTimer:null,lastInboundAt:Date.now()};M.onopen=()=>{T(),d.retryCount=0,Q.lastInboundAt=Date.now(),E(Q),j6(Q)},M.onmessage=H=>{Q.lastInboundAt=Date.now();try{const G=JSON.parse(H.data);if(G.type==="pong"){Q.pongTimer&&(clearTimeout(Q.pongTimer),Q.pongTimer=null);return}if(G.type==="tmux-result"&&G.reqId){jC(G.reqId,G.success!==!1,G.layout,G.error);return}if(G.type==="tmux-layout"&&G.layout){t({type:"tmux-layout",layout:G.layout});return}if(G.type==="active-program"){t({type:"active-program",activeProgram:G.activeProgram,activeProgramRaw:G.activeProgramRaw,activeProgramSource:G.activeProgramSource});return}if(G.type==="cwd"){t({type:"cwd",cwd:G.cwd});return}if(G.type==="agent-status"){t({type:"agent-status",agentStatus:G.agentStatus??null,agentIndicator:G.agentIndicator??null,agent:G.agent??null,agentMessage:G.agentMessage??null,agentNativeSessionId:G.agentNativeSessionId??null,agentRich:G.agentRich===!0,agentActivity:typeof G.agentActivity=="number"?G.agentActivity:0,agentCwd:G.agentCwd??null,reviewed:typeof G.reviewed=="boolean"?G.reviewed:null});return}if(G.type==="git-status"){t({type:"git-status",gitStatus:G.gitStatus??null});return}if(G.type==="focus-mode"){t({type:"focus-mode",focusTrackingRequested:G.focusTrackingRequested===!0});return}if(G.type==="resize-ack"){t({type:"resize-ack",seq:typeof G.seq=="number"?G.seq:void 0,cols:typeof G.cols=="number"?G.cols:void 0,rows:typeof G.rows=="number"?G.rows:void 0,ok:G.ok!==!1,error:typeof G.error=="string"?G.error:void 0});return}if(G.type==="pty-size"){t({type:"pty-size",cols:typeof G.cols=="number"?G.cols:void 0,rows:typeof G.rows=="number"?G.rows:void 0,source:typeof G.source=="string"?G.source:void 0});return}if(G.type==="shell-title"){t({type:"shell-title",title:typeof G.title=="string"?G.title:""});return}if(G.type==="prompt-state"){t({type:"prompt-state",state:G.state==="running"?"running":"idle",exitCode:typeof G.exitCode=="number"?G.exitCode:void 0});return}const U=G;if(U.type==="connected"){typeof U.replayLastSeq=="number"&&U.replayLastSeq>0&&(b=U.replayLastSeq,Q.lastSeq=b),t(U);return}if(U.type==="exit"){N(),t(U);return}t(U),U.type==="data"&&typeof U.seq=="number"&&Number.isFinite(U.seq)&&U.seq>b&&(b=U.seq,Q.lastSeq=b)}catch(G){r?.(G,!1)}},M.onerror=()=>{w.has(M)||(T(),C(Q),y||(y=!0,R(new Error("WebSocket connection error"),!1)))},M.onclose=H=>{if(!w.has(M)&&(T(),C(Q),!d.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}),R(new Error("Session not found on server"),!0);return}if(H.code===4003||H.code===4401){try{window.dispatchEvent(new CustomEvent(Yf))}catch{}R(new Error("Authentication required"),!0);return}R(new Error("WebSocket connection closed"),!1)}},f=Q,Io.set(e,f)},R=(_,M)=>{if(!d.isClosed)if(d.retryCount<s&&!M){d.retryCount++;const Q=Math.min(i*Math.pow(2,d.retryCount-1),a);t({type:"reconnecting",attempt:d.retryCount,maxAttempts:s}),d.retryTimeout=setTimeout(()=>{d.isClosed||D()},Q)}else r?.(_,M||d.retryCount>=s),N()};return D(),N}async function $C(e,t){const r=Io.get(e);if(r){if(r.ws.readyState===WebSocket.OPEN){r.pendingInputs.push(t),j6(r);return}if(r.ws.readyState===WebSocket.CONNECTING){r.pendingInputs.push(t);return}}const n=await rn(),s=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain","X-XSRF-TOKEN":n},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 HC(e){const t=Io.get(e);if(!t)return!1;if(t.ws.readyState!==WebSocket.OPEN)return t.reconnectNow(),!0;const r=t.lastInboundAt;try{t.ws.send(JSON.stringify({type:"ping"}))}catch{}return setTimeout(()=>{t.lastInboundAt<=r&&t.reconnectNow()},RC),!0}function UC(e,t,r){const n=Io.get(e);if(!(!n||n.ws.readyState!==WebSocket.OPEN))try{n.ws.send(JSON.stringify({type:"focus",focused:t,reason:r}))}catch{}}function Cb(e){const t=Io.get(e);if(!(!t||t.ws.readyState!==WebSocket.OPEN))try{t.ws.send(JSON.stringify({type:"agent-review-ack"}))}catch{}}function _b(e,t,r){const n=Io.get(e);if(!(!n||n.ws.readyState!==WebSocket.OPEN))try{n.ws.send(JSON.stringify({type:"flow-control",paused:t,reason:r}))}catch{}}async function GC(e,t,r,n){const s=Io.get(e);if(s&&s.ws.readyState===WebSocket.OPEN)try{s.ws.send(JSON.stringify({type:"resize",cols:t,rows:r,seq:n}));return}catch{}const i=await rn(),a=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":i},body:JSON.stringify({cols:t,rows:r,seq:n})});if(!a.ok){const d=await a.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(d.error||"Failed to resize terminal")}const u=await a.json().catch(()=>({success:!0}));if(u?.success===!1||u?.ok===!1)throw new Error(u?.error||"Failed to resize terminal")}async function zC(e,t){const r=Io.get(e);if(r&&r.ws.readyState===WebSocket.OPEN)return t.action==="scroll"?(r.ws.send(JSON.stringify({type:"tmux",...t})),{success:!0}):new Promise((i,a)=>{const u=Math.random().toString(36).substring(7);Sd.set(u,{resolve:i,reject:a}),r.ws.send(JSON.stringify({type:"tmux",reqId:u,...t})),setTimeout(()=>{Sd.has(u)&&(Sd.delete(u),a(new Error("Tmux action timed out")))},3e4)});const n=await rn(),s=await fetch(`/api/terminal/${e}/tmux`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},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 Q6(e){const t=Io.get(e);if(t){t.retryState.isClosed=!0;try{t.ws.close()}catch{}Io.delete(e)}const r=await rn(),n=await fetch(`/api/terminal/${e}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":r}});if(n.status!==404&&!n.ok){const s=await n.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(s.error||"Failed to close terminal")}}async function WC(e,t){const r=Io.get(e);if(r){r.retryState.isClosed=!0;try{r.ws.close()}catch{}Io.delete(e)}const n=await rn(),s=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},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 VC(e){const t=await fetch(`/api/terminal/${e}/health`,{method:"GET"});if(!t.ok){if(t.status===404)return{healthy:!1,sessionId:e};const r=await t.json().catch(()=>({error:"Failed to check terminal health"}));throw new Error(r.error||"Failed to check terminal health")}return t.json()}async function qC(e){const t=await rn(),r=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(n.error||"Failed to force kill terminal")}}async function y1(){const e=await fetch("/api/terminal/tmux/sessions",{method:"GET"});if(!e.ok){const r=await e.json().catch(()=>({error:"Failed to list tmux sessions"}));throw new Error(r.error||"Failed to list tmux sessions")}const t=await e.json();return Array.isArray(t.sessions)?t.sessions:[]}async function v1(){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 F6(e){const t=e.trim();if(!t)throw new Error("tmux session name is required");const r=await rn(),n=await fetch(`/api/terminal/tmux/sessions/${encodeURIComponent(t)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":r}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to kill tmux session"}));throw new Error(i.error||"Failed to kill tmux session")}const s=await n.json();return{cleanedSessions:Array.isArray(s.cleanedSessions)?s.cleanedSessions:[],alreadyGone:!!s.alreadyGone}}const Fh=new Map;function YC(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 ZC(){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 O6(e){const t=YC(e),r=Fh.get(t);if(r)return r;const n=await rn(),s=fetch("/api/terminal/session-inventory/open",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":n},body:JSON.stringify(e)}).then(async i=>{if(!i.ok){const a=await i.json().catch(()=>({error:"Failed to open session"}));throw new B6(a.error||"Failed to open session",i.status,typeof a.code=="string"?a.code:void 0)}return i.json()}).finally(()=>{Fh.get(t)===s&&Fh.delete(t)});return Fh.set(t,s),s}async function Lf(e,t){const r=await rn(),n=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":r},body:JSON.stringify(t)});if(!n.ok){const s=await n.json().catch(()=>({error:"Failed to update session"}));throw new Error(s.error||"Failed to update session")}return n.json()}async function KC(e){const t=await rn(),r=await fetch("/api/terminal/session-inventory/reorder",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({sessionIds:e})});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to reorder sessions"}));throw new Error(n.error||"Failed to reorder sessions")}return r.json()}async function XC(e){const t=await rn(),r=await fetch(`/api/terminal/session-inventory/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to remove session"}));throw new Error(n.error||"Failed to remove session")}}async function JC(){const e=await rn(),t=await fetch("/api/terminal/session-inventory/sessions",{method:"DELETE",headers:{"X-XSRF-TOKEN":e}});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to clear sessions"}));throw new Error(r.error||"Failed to clear sessions")}}async function Lb(){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 e_(e){const t=await rn(),r=await fetch("/api/terminal/toolbar-presets",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to save toolbar presets"})),s=new Error(n.error||"Failed to save toolbar presets");throw s.current=n.current,s.code=n.code,s}return r.json()}async function t_(){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 Jm(e){const t=await rn(),r=await fetch("/api/terminal/settings",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to update settings"}));throw new Error(n.error||"Failed to update settings")}return r.json()}async function r_(){const e=await fetch("/api/terminal/settings/activity-reorder",{method:"GET"});return e.ok?(await e.json()).enabled!==!1:!0}async function n_(e){const t=await rn(),r=await fetch("/api/terminal/settings/activity-reorder",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify({enabled:e})});return r.ok?(await r.json()).enabled:e}async function s_(){const e=await fetch("/api/auth/status");if(!e.ok)throw new Error("Failed to query auth status");return e.json()}async function i_(e){const t=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})});if(t.ok)return P6(),{ok:!0};const r=await t.json().catch(()=>null);return t.status===429?{ok:!1,rateLimited:!0,retryAfterMs:typeof r?.retryAfterMs=="number"?r.retryAfterMs:void 0,error:r?.error||"Too many failed attempts. Please wait and try again."}:{ok:!1,error:r?.error||"Login failed"}}async function o_(){const e=await rn();await fetch("/api/auth/logout",{method:"POST",headers:{"X-XSRF-TOKEN":e}}),P6()}async function a_(){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 l_(e){const t=await rn(),r=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/install`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n.error||"Failed to install agent hooks");return{summary:n.summary??"Installed",devMode:n.devMode===!0}}async function c_(e){const t=await rn(),r=await fetch(`/api/terminal/agent-hooks/${encodeURIComponent(e)}/uninstall`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n.error||"Failed to uninstall agent hooks");return n.summary??"Removed"}async function u_(){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 d_(e){const t=await rn(),r=await fetch("/api/terminal/agent-plugins",{method:"POST",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)}),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n.error||"Failed to create agent plugin");return n}async function h_(e){const t=await rn(),r=await fetch(`/api/terminal/agent-plugins/${encodeURIComponent(e)}`,{method:"DELETE",headers:{"X-XSRF-TOKEN":t}});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(n.error||"Failed to delete agent plugin")}}async function f_(e){const t=await rn(),r=await fetch(`/api/terminal/${encodeURIComponent(e)}/agent-resume`,{method:"POST",headers:{"X-XSRF-TOKEN":t}}),n=await r.json().catch(()=>({}));if(!r.ok)throw new Error(n.error||"Failed to resume agent session");return{command:n.command??""}}async function pu(e){const t=await rn(),r=await fetch("/api/terminal/program-rules",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to update program rules"}));throw new Error(n.error||"Failed to update program rules")}return r.json()}async function p_(){const e=await rn(),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 m_(){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 kb(e){const t=await rn(),r=await fetch("/api/terminal/program-detection",{method:"PUT",headers:{"Content-Type":"application/json","X-XSRF-TOKEN":t},body:JSON.stringify(e)});if(!r.ok)throw new Error("Failed to save program detection config");return r.json()}async function g_(){const e=await rn(),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 b_={".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"};function $6(e){const t=e.lastIndexOf(".");return t<0?null:b_[e.slice(t).toLowerCase()]??null}function k2(e){return $6(e)!==null}async function H6(e,t,r,n="list_directory",s){const i=new URLSearchParams({path:e});r&&i.set("showHidden","true"),i.set("action",n),s&&i.set("requestSlotId",s);const a=await ti(`/api/terminal/fs/list?${i}`,{signal:t},a0,"Directory listing took too long. The folder may be on slow storage or blocked by another process.");if(!a.ok){const u=await a.json().catch(()=>({error:"Failed to list directory"}));throw new Error(u.error||"Failed to list directory")}return a.json()}async function x_(e,t,r,n,s,i="name",a){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);const d=await fetch(`/api/terminal/fs/search?${u}`,{signal:n});if(!d.ok||!d.body){const v=await d.json().catch(()=>({error:"Failed to search files"}));throw new Error(v.error||"Failed to search files")}const f=d.body.getReader(),b=new TextDecoder;let g="";const y=v=>{if(!v.trim())return;const w=JSON.parse(v);if(w.type==="meta")r({path:w.path,query:w.query,engine:w.engine,mode:w.mode,limited:w.limited});else if(w.type==="batch")r({entries:w.entries??[]});else if(w.type==="content-batch")r({contentEntries:w.contentEntries??[]});else{if(w.type==="error")throw new Error(w.message||"Search failed");w.type==="done"&&r({total:w.total,truncated:w.truncated,limited:w.limited,engine:w.engine,mode:w.mode,done:!0})}};for(;;){const{value:v,done:w}=await f.read();if(w)break;g+=b.decode(v,{stream:!0});let T=g.indexOf(`
|
|
3
3
|
`);for(;T>=0;)y(g.slice(0,T)),g=g.slice(T+1),T=g.indexOf(`
|
|
4
4
|
`)}g+=b.decode(),y(g)}async function y_(e,t,r){const n=new URLSearchParams;n.set("roots",e.join("|"));const s=await fetch(`/api/terminal/fs/watch?${n}`,{signal:r});if(!s.ok||!s.body){const f=await s.json().catch(()=>({error:"Failed to watch files"}));throw new Error(f.error||"Failed to watch files")}const i=s.body.getReader(),a=new TextDecoder;let u="";const d=f=>{if(!f.trim())return;const b=JSON.parse(f);b.type==="events"&&b.events?.length&&t(b.events)};for(;;){const{value:f,done:b}=await i.read();if(b)break;u+=a.decode(f,{stream:!0});let g=u.indexOf(`
|
|
@@ -68,7 +68,7 @@ void main() {
|
|
|
68
68
|
`&&(r+=s),n=!1;else switch(s){case t:return r;case"\\":n=!0;break;default:r+=s}}throw new Error("Unterminated string")}function BM(e){let t="",r=!1;for(;e.offset<e.input.length;){let n=e.input[e.offset++];if(r)/[\dA-Fa-f]/.test(n)?(e.offset--,t+=Ow(e)):t+=n,r=!1;else switch(n){case"\\":r=!0;break;case",":return t;default:/\s/.test(n)?t.endsWith(" ")||(t+=" "):t+=n}}return t}function Ow(e){let t="";for(;e.offset<e.input.length;){let r=e.input[e.offset++];if(/\s/.test(r))return _g(t);if(t.length>=6||!/[\dA-Fa-f]/.test(r))return e.offset--,_g(t);t+=r}return _g(t)}function _g(e){return String.fromCodePoint(parseInt(e,16))}var nd;async function PM(e,t){if(!nd){if(typeof navigator<"u"&&"fonts"in navigator){try{let s=await navigator.permissions.request?.({name:"local-fonts"});if(s&&s.state!=="granted")throw new Error("Permission to access local fonts not granted.")}catch(s){if(s instanceof Error&&s.name!=="TypeError")throw s}let n={};try{let s=await navigator.fonts.query();for(let i of s)n.hasOwnProperty(i.family)||(n[i.family]=[]),n[i.family].push(i);nd=Promise.resolve(n)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}else if(typeof window<"u"&&"queryLocalFonts"in window){let n={};try{let s=await window.queryLocalFonts();for(let i of s)n.hasOwnProperty(i.family)||(n[i.family]=[]),n[i.family].push(i);nd=Promise.resolve(n)}catch(s){s instanceof Error&&console.error(s.name,s.message)}}nd??=Promise.resolve({})}let r=await nd;for(let n of NM(e)){if(jM.includes(n))return;if(r.hasOwnProperty(n)&&r[n].length>0){let s=r[n][0];if("blob"in s){let i=await(await s.blob()).arrayBuffer();return RM(i,{cacheSize:t})}return}}}var jM=["serif","sans-serif","cursive","fantasy","monospace","system-ui","emoji","math","fangsong"],QM=1e5;function FM(e,t=[]){let r,n,s=0,i;return e.registerCharacterJoiner(a=>{let u=e.options.fontFamily;if(u&&(s===0||r!==u)){n=void 0,s=1,r=u;let d=r;PM(d,QM).then(f=>{d===e.options.fontFamily&&(s=2,n=f,f&&e.refresh(0,e.rows-1))}).catch(f=>{d===e.options.fontFamily&&(s=3,e.options.logLevel==="debug"&&console.debug(i,new Error("Failure while loading font")),n=void 0,i=f)})}return n&&s===2?n.findLigatureRanges(a).map(d=>[d[0],d[1]]):OM(a,t)})}function OM(e,t){let r=[];for(let n=0;n<e.length;n++)for(let s=0;s<t.length;s++)if(e.startsWith(t[s],n)){r.push([n,n+t[s].length]),n+=t[s].length-1;break}return r}var $M=class{constructor(e){this._fallbackLigatures=(e?.fallbackLigatures??["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!===","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"]).sort((t,r)=>r.length-t.length),this._fontFeatureSettings=e?.fontFeatureSettings}activate(e){if(!e.element)throw new Error("Cannot activate LigaturesAddon before open is called");this._terminal=e,this._characterJoinerId=FM(e,this._fallbackLigatures),e.element.style.fontFeatureSettings=this._fontFeatureSettings??'"calt" on'}dispose(){this._characterJoinerId!==void 0&&(this._terminal?.deregisterCharacterJoiner(this._characterJoinerId),this._characterJoinerId=void 0),this._terminal?.element&&(this._terminal.element.style.fontFeatureSettings="")}};function _x(e){let t=0;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<48||57<n)return-1;t=t*10+n-48}return t}var HM=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,t=>{if(!t.startsWith("4;"))return!1;let r=t.split(";");if(r.length>3)return!0;r.length===2&&r.push("");let n=_x(r[1]),s=_x(r[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(s<0)return!0;this.progress={state:n,value:s};break;case 2:case 4:if(s<0)return!0;this.progress={state:n,value:s||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn("progress state out of bounds, not applied");return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};const D1="termdock-settings",UM=6,GM=100,zM='"calt" on',WM=["<--","<---","<<-","<-","->","->>","-->","--->","<==","<===","<<=","<=","=>","=>>","==>","===>",">=",">>=","<->","<-->","<--->","<---->","<=>","<==>","<===>","<====>","::",":::","<~~","</","</>","/>","~~>","==","!=","/=","~=","<>","===","!==","!==","<:",":=","*=","*+","<*","<*>","*>","<|","<|>","|>","+*","=*","=:",":>","/*","*/","+++","<!--","<!---"];function VM(){if(typeof window>"u")return 13;const e=window.matchMedia("(max-width: 767px)").matches,t=window.matchMedia("(pointer: coarse)").matches;return e||t?10:13}function $2(){return{fontFamily:"var(--font-mono)",fontSize:VM(),rendererMode:"auto",fontWeight:"normal",fontWeightBold:"bold",letterSpacing:1,lineHeight:1.05,minimumContrastRatio:4.5,drawBoldTextInBrightColors:!0,unicodeVersion:"11",customGlyphs:!0,rescaleOverlappingGlyphs:!1,fontLigatures:!0,enableImages:!0,smoothScrolling:!0}}function Zh(e,t,r,n){return typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(r,e)):n}function Lx(e,t){return e==="normal"||e==="bold"?e:typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.min(1e3,Math.round(e))):t}function Uu(e){const t=$2(),r=e&&typeof e=="object"?e:{},n=r.rendererMode??r.renderer;return{fontFamily:typeof r.fontFamily=="string"&&r.fontFamily.trim()?r.fontFamily.trim():t.fontFamily,fontSize:Zh(r.fontSize,UM,GM,t.fontSize),rendererMode:n==="auto"||n==="webgl"||n==="canvas"?n:t.rendererMode,fontWeight:Lx(r.fontWeight,t.fontWeight),fontWeightBold:Lx(r.fontWeightBold,t.fontWeightBold),letterSpacing:Math.round(Zh(r.letterSpacing,-5,10,t.letterSpacing)),lineHeight:Zh(r.lineHeight,1,2,t.lineHeight),minimumContrastRatio:Zh(r.minimumContrastRatio,1,21,t.minimumContrastRatio),drawBoldTextInBrightColors:t.drawBoldTextInBrightColors,unicodeVersion:t.unicodeVersion,customGlyphs:t.customGlyphs,rescaleOverlappingGlyphs:t.rescaleOverlappingGlyphs,fontLigatures:t.fontLigatures,enableImages:t.enableImages,smoothScrolling:t.smoothScrolling}}function Kh(e){return e.pointerType==="touch"||e.pointerType==="pen"}class qM{handlers=new Map;active=new Map;pointerStates=new Map;sorted=[];sortedDirty=!1;listenersRegistered=!1;changeListeners=new Set;constructor(){this.ensureListeners()}register(t){return this.handlers.has(t.name)&&this.log("replace",t.name),this.handlers.set(t.name,t),this.sortedDirty=!0,this.log("register",t.name,`prio=${t.priority}`),()=>{this.unregister(t.name)}}unregister(t){this.handlers.delete(t),this.sortedDirty=!0;for(const[r,n]of this.active)n===t&&(this.active.delete(r),this.pointerStates.delete(r));this.log("unregister",t)}getHandlers(){return this.sortedHandlers().map(t=>({name:t.name,priority:t.priority,hasContainer:t.container!=null}))}getClaimedHandler(t){return this.active.get(t)??null}isClaimedBy(t,r){return this.active.get(t)===r}isAnyPointerClaimed(){return this.active.size>0}onChange(t){return this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}}emitChange(t,r,n){this.changeListeners.size!==0&&this.changeListeners.forEach(s=>{try{s({type:t,pointerId:r,handler:n})}catch{}})}log(t,r,n=""){if(typeof window<"u"&&window.__TERMDOCK_GESTURE_DEBUG__){const s=performance.now().toFixed(0);console.debug(`[GestureManager ${s}] ${t} ${r} ${n}`)}}sortedHandlers(){return this.sortedDirty&&(this.sorted=[...this.handlers.values()].sort((t,r)=>r.priority-t.priority),this.sortedDirty=!1),this.sorted}ensureListeners(){this.listenersRegistered||(this.listenersRegistered=!0,document.addEventListener("pointerdown",this.handlePointerDown,{capture:!0,passive:!1}),document.addEventListener("pointermove",this.handlePointerMove,{capture:!0,passive:!1}),document.addEventListener("pointerup",this.handlePointerUp,{capture:!0,passive:!1}),document.addEventListener("pointercancel",this.handlePointerCancel,{capture:!0,passive:!1}))}handlePointerDown=t=>{if(!Kh(t))return;const r={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now()};this.pointerStates.set(t.pointerId,r);let n=!1;for(const s of this.sortedHandlers()){if(!this.handlerMatchesContainer(s,t)){this.log("skip-container",s.name);continue}s.onPointerDown(t,r)&&!n&&(this.active.set(t.pointerId,s.name),n=!0,this.log("claim",s.name,`pid=${t.pointerId} onPointerDown`),this.emitChange("claim",t.pointerId,s.name))}n&&t.preventDefault()};handlePointerMove=t=>{if(!Kh(t)||!this.pointerStates.has(t.pointerId))return;let r=!1;for(const n of this.sortedHandlers()){if(!this.handlerMatchesContainer(n,t))continue;const s=this.active.get(t.pointerId)===n.name,i=n.onPointerMove(t,s);if(i==="claim"&&!r){const a=this.active.get(t.pointerId)??null;this.active.set(t.pointerId,n.name),r=!0,t.preventDefault(),a&&a!==n.name&&this.log("handoff",`${a}->${n.name}`,`pid=${t.pointerId}`),this.log("claim",n.name,`pid=${t.pointerId} onPointerMove`),this.emitChange("claim",t.pointerId,n.name)}if(i==="release"&&s&&!r){const a=this.active.get(t.pointerId);this.active.delete(t.pointerId),this.log("release",n.name,`pid=${t.pointerId}`),this.emitChange("release",t.pointerId,a??null)}}};handlePointerUp=t=>{if(!Kh(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerUp(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlePointerCancel=t=>{if(!Kh(t))return;for(const n of this.sortedHandlers())this.handlerMatchesContainer(n,t)&&n.onPointerCancel(t);const r=this.active.get(t.pointerId)??null;this.active.delete(t.pointerId),this.pointerStates.delete(t.pointerId),this.emitChange("complete",t.pointerId,r)};handlerMatchesContainer(t,r){return t.container?t.container.contains(r.target):!0}}const $w=new qM,YM=90,ZM=80,KM=70,XM=(e,t)=>{const{scrollMultiplier:r=1.2,maxScrollBoost:n=.8,boostDenominator:s=50,velocityAlpha:i=.15,maxVelocity:a=15,minVelocity:u=.3,decelerationRate:d=.998,enableKinetic:f=!0,shouldCaptureTouch:b,canStartScrollGesture:g,onScroll:y,onScrollWithCoords:v,onTap:w,onClickWithCoords:T,onClaimChange:C,tapThreshold:E=10,gestureName:N="normal-scroll"}=t,D=1.06,R=P.useRef({lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1,pointerId:null,isCurrentlyScrolling:!1,gestureAxis:null}),_=P.useRef(0),M=P.useRef(0),Q=P.useRef(0),H=P.useRef(null),G=P.useRef(0),U=P.useRef(!1),W=P.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),J=P.useCallback(()=>{H.current=null,_.current!==0&&(v&&M.current>0&&Q.current>0?v(_.current,M.current,Q.current):y&&y(_.current),_.current=0,M.current=0,Q.current=0)},[y,v]),ee=P.useCallback(()=>{H.current===null&&typeof window<"u"&&(H.current=window.requestAnimationFrame(J))},[J]),ae=P.useCallback((Ee,ce,je)=>{_.current+=Ee,ce!==void 0&&je!==void 0&&(M.current=ce,Q.current=je),ee()},[ee]),Se=P.useCallback(Ee=>{if(!Ee||!y)return!1;const ce=y(Ee);return ce?G.current=0:G.current++,ce},[y]),Le=P.useCallback(Ee=>{U.current!==Ee&&(U.current=Ee,C?.(Ee))},[C]),_e=P.useCallback(()=>{const Ee=R.current;Ee.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ee.rafId),Ee.rafId=null,H.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(H.current),H.current=null,_.current=0},[]),se=P.useRef(w);se.current=w;const ie=P.useRef(T);ie.current=T;const fe=P.useRef(b);fe.current=b;const Qe=P.useCallback(()=>{const Ee=e.current;if(!Ee||!("PointerEvent"in window))return()=>{};const ce=R.current,je={name:N,priority:KM,get container(){return e.current??void 0},onPointerDown:(ge,Me)=>(ge.pointerType!=="touch"||(ce.pointerId=ge.pointerId,ce.startX=Me.startX,ce.startY=Me.startY,ce.didMove=!1,ce.gestureAxis=null,ce.lastY=ge.clientY,ce.lastTime=W(),ce.velocity=0,_e()),!1),onPointerMove:(ge,Me)=>{if(ge.pointerType!=="touch"||ce.pointerId!==ge.pointerId||!ce.lastY||!ce.lastTime)return"neutral";const ct=ge.clientX,Ae=ge.clientY,Ve=W(),We=Ve-ce.lastTime,he=Ae-ce.lastY;if(ce.startX!==null&&ce.startY!==null){const Ce=ct-ce.startX,nt=Ae-ce.startY;if(!ce.didMove&&Math.hypot(Ce,nt)>=E&&(ce.didMove=!0),ce.gestureAxis===null&&ce.didMove){const kt=Math.abs(Ce),vt=Math.abs(nt);kt>vt*D?ce.gestureAxis="x":vt>kt*D&&(ce.gestureAxis="y")}if(ce.gestureAxis==="x")return ce.isCurrentlyScrolling=!1,Le(!1),ce.lastY=Ae,ce.lastTime=Ve,Me?"release":"neutral";if(ce.gestureAxis===null)return ce.lastY=Ae,ce.lastTime=Ve,"neutral"}if(ce.gestureAxis==="y"&&!Me&&!(g?.()??!0))return ce.lastY=Ae,ce.lastTime=Ve,Le(!1),"neutral";const Be=he/Math.max(We,1);if(ce.velocity=ce.velocity*(1-i)+Be*i,ce.velocity=Math.max(-a,Math.min(a,ce.velocity)),Math.abs(he)>1){if(!Me)return Le(!0),ce.lastY=Ae,ce.lastTime=Ve,"claim";ce.isCurrentlyScrolling=!0;const Ce=r+Math.min(n,Math.abs(he)/s),nt=-he*Ce;ae(nt,ct,Ae),Le(!0)}return ce.lastY=Ae,ce.lastTime=Ve,Me?"claim":"neutral"},onPointerUp:ge=>{if(ge.pointerType!=="touch"||ce.pointerId!==ge.pointerId)return;const Me=ce.isCurrentlyScrolling;ce.isCurrentlyScrolling=!1,Le(!1);const ct=ce.rafId!==null||H.current!==null;!ce.didMove&&!ct&&ce.startX!==null&&ce.startY!==null&&se.current?.(ce.startX,ce.startY),!ce.didMove&&!ct&&ce.startX!==null&&ce.startY!==null&&ie.current?.(ce.startX,ce.startY),ce.pointerId=null,ce.startX=null,ce.startY=null;const Ae=ce.gestureAxis==="x";if(ce.gestureAxis=null,f&&Me&&!Ae&&Math.abs(ce.velocity)>u&&ce.didMove){const Ve=()=>{const We=W(),he=We-(ce.lastTime||We);if(ce.lastTime=We,ce.velocity*=Math.pow(d,he),Math.abs(ce.velocity)<u){ce.velocity=0,_e();return}if(!Se(-ce.velocity*he)&&G.current>2){ce.velocity=0,_e();return}ce.rafId=requestAnimationFrame(Ve)};ce.rafId=requestAnimationFrame(Ve)}},onPointerCancel:ge=>{ge.pointerType!=="touch"||ce.pointerId!==ge.pointerId||(ce.isCurrentlyScrolling=!1,Le(!1),ce.pointerId=null,ce.startX=null,ce.startY=null,ce.gestureAxis=null,_e())}},De=$w.register(je),ke=Ee.style.touchAction;return Ee.style.touchAction="none",()=>{Le(!1),De(),Ee.style.touchAction=ke,_e()}},[e,N,r,n,s,i,a,u,d,W,_e,Se,ae,E,f,Le,g]),de=P.useCallback(()=>{const Ee=e.current;if(!Ee)return()=>{};const ce=R.current,je=Me=>{Me.touches.length===1&&((b?.()??!0)&&Me.cancelable&&Me.preventDefault(),ce.isCurrentlyScrolling=!1,ce.gestureAxis=null,ce.lastY=Me.touches[0].clientY,ce.startX=Me.touches[0].clientX,ce.startY=Me.touches[0].clientY,ce.didMove=!1,ce.velocity=0,_e())},De=Me=>{if(Me.touches.length!==1)return;const ct=Me.touches[0].clientX,Ae=Me.touches[0].clientY;if(ce.startX!==null&&ce.startY!==null){const We=ct-ce.startX,he=Ae-ce.startY;if(!ce.didMove&&Math.hypot(We,he)>=E&&(ce.didMove=!0),ce.gestureAxis===null&&ce.didMove){const Be=Math.abs(We),Ce=Math.abs(he);Be>Ce*D?ce.gestureAxis="x":Ce>Be*D&&(ce.gestureAxis="y")}if(ce.gestureAxis==="x"){ce.isCurrentlyScrolling=!1,ce.lastY=Ae;return}if(ce.gestureAxis===null){(b?.()??!1)&&Me.cancelable&&Me.preventDefault(),ce.lastY=Ae;return}}if(Me.preventDefault(),!ce.lastY){ce.lastY=Ae;return}const Ve=Ae-ce.lastY;if(Math.abs(Ve)>1){ce.isCurrentlyScrolling=!0;const We=r+Math.min(n,Math.abs(Ve)/s),he=-Ve*We;ae(he,ct,Ae)}ce.lastY=Ae},ke=Me=>{if(!Me.changedTouches?.[0])return;const Ae=ce.isCurrentlyScrolling;ce.isCurrentlyScrolling=!1;const Ve=ce.rafId!==null||H.current!==null;!ce.didMove&&!Ve&&w&&ce.startX!==null&&ce.startY!==null&&w(ce.startX,ce.startY),!ce.didMove&&!Ve&&T&&ce.startX!==null&&ce.startY!==null&&T(ce.startX,ce.startY),ce.startX=null,ce.startY=null;const We=ce.gestureAxis==="x";if(ce.gestureAxis=null,f&&Ae&&!We&&ce.didMove&&Math.abs(ce.velocity)>u){const he=()=>{if(ce.velocity*=Math.pow(d,16),Math.abs(ce.velocity)<u){ce.velocity=0,_e();return}if(!Se(-ce.velocity*16)&&G.current>2){ce.velocity=0,_e();return}ce.rafId=requestAnimationFrame(he)};ce.rafId=requestAnimationFrame(he)}};Ee.addEventListener("touchstart",je,{passive:!1}),Ee.addEventListener("touchmove",De,{passive:!1}),Ee.addEventListener("touchend",ke,{passive:!1}),Ee.addEventListener("touchcancel",ke,{passive:!1});const ge=Ee.style.touchAction;return Ee.style.touchAction="none",()=>{Ee.removeEventListener("touchstart",je),Ee.removeEventListener("touchmove",De),Ee.removeEventListener("touchend",ke),Ee.removeEventListener("touchcancel",ke),Ee.style.touchAction=ge,_e()}},[e,r,n,s,u,d,_e,Se,ae,w,T,E,b,f]),Fe=P.useCallback(()=>{_e();const Ee=typeof window<"u"&&"PointerEvent"in window,ce=Ee?Qe():()=>{},je=Ee?()=>{}:de();return()=>{ce(),je(),_e()}},[Qe,de,_e]),rt=P.useCallback(()=>R.current.isCurrentlyScrolling||R.current.rafId!==null||H.current!==null,[]),ht=P.useCallback(()=>{_e();const Ee=R.current;Ee.isCurrentlyScrolling=!1,Ee.velocity=0,Ee.lastY=null,Ee.lastTime=null,Ee.startX=null,Ee.startY=null,Ee.pointerId=null,Ee.didMove=!1,Ee.gestureAxis=null},[_e]);return{setupTouchScroll:Fe,isScrolling:rt,stopAllScroll:ht}};function kx(e){const{name:t,priority:r}=e,n=A.useRef(e.onPointerDown),s=A.useRef(e.onPointerMove),i=A.useRef(e.onPointerUp),a=A.useRef(e.onPointerCancel),u=A.useRef(e.container);n.current=e.onPointerDown,s.current=e.onPointerMove,i.current=e.onPointerUp,a.current=e.onPointerCancel,u.current=e.container,A.useEffect(()=>{const d={name:t,priority:r,get container(){const b=u.current;return typeof b=="function"?b():b},onPointerDown(b,g){return n.current?.(b,g)??!1},onPointerMove(b,g){return s.current?.(b,g)??"neutral"},onPointerUp(b){i.current?.(b)},onPointerCancel(b){a.current?.(b)}};return $w.register(d)},[t,r])}var Ls;(function(e){e.Light="light",e.Medium="medium",e.Heavy="heavy",e.Success="success",e.Warning="warning",e.Error="error"})(Ls||(Ls={}));Ls.Light,Ls.Medium,Ls.Heavy,Ls.Success,Ls.Warning,Ls.Error;Ls.Light,Ls.Medium,Ls.Heavy,Ls.Success,Ls.Warning,Ls.Error;Ls.Light,Ls.Medium,Ls.Heavy,Ls.Success,Ls.Warning,Ls.Error;const JM=()=>typeof navigator<"u"&&typeof navigator.vibrate=="function",eR=()=>typeof document<"u"&&!!document.body,tR=()=>{if(eR())try{const e=document.createElement("label");e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;";const t=document.createElement("input");t.type="checkbox",t.setAttribute("switch",""),e.appendChild(t),document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch{}},Ex=e=>Array.isArray(e)?[...e]:[e],rR=e=>{if(JM()){try{const s=Ex(e),i=s.length===1?s[0]:s;navigator.vibrate(i)}catch{}return}const t=Ex(e),r=Array.from({length:Math.ceil(t.length/2)},(s,i)=>[t[i*2]??0,t[i*2+1]??0]);let n=0;for(const[s,i]of r)s>0&&setTimeout(tR,n),n+=s+i},jl=e=>rR(e),nR=({message:e="Loading terminal..."})=>c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[c.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:e})]})}),sR=()=>c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("div",{className:"rounded-full bg-surface-2 px-4 py-2 flex items-center gap-3 shadow-sm",children:[c.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Initializing terminal engine..."})]})}),iR=({message:e,onRetry:t})=>c.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4",children:c.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[c.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:c.jsxs("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,role:"img","aria-label":"Error",children:[c.jsx("title",{children:"Error"}),c.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"})]})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("h3",{className:"font-medium text-foreground",children:"Failed to load terminal"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e||"An unknown error occurred"})]}),t&&c.jsx("button",{type:"button",onClick:t,className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:"Retry"})]})}),oR="debug",aR="termdock:debug";function Ix(e){return e?new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean)):new Set}function lR(){if(typeof window>"u")return new Set;const e=Ix(new URLSearchParams(window.location.search).get(oR));let t=new Set;try{t=Ix(window.localStorage.getItem(aR))}catch{t=new Set}const r=new Set([...e,...t]);return r.has("1")||r.has("true")||r.has("*")||r.has("all")?new Set(["*"]):r}function cR(e){const t=lR();return t.has("*")||t.has(e)}function Dc(e){const t=cR(e);return(...r)=>{t&&console.log(`[debug:${e}]`,...r)}}function Df(e){return Array.from(e)}function Mx(e,t,r){return Math.max(t,Math.min(r,e))}function uR(e,t,r,n){const s=Df(e),i=Df(t);let a=Mx(r,0,s.length);const u=Mx(n,0,i.length);let d=0;for(;d<s.length&&d<i.length&&s[d]===i[d];)d++;let f=0;for(;f<s.length-d&&f<i.length-d&&s[s.length-1-f]===i[i.length-1-f];)f++;const b=s.length-d-f,g=i.slice(d,i.length-f).join(""),y=[];if(b>0||g){const v=d+b;a>v?y.push({left:a-v}):a<v&&y.push({right:v-a}),a=v,b>0&&(y.push({backspace:b}),a=d),g&&(y.push({insert:g}),a+=Df(g).length)}return a>u?y.push({left:a-u}):a<u&&y.push({right:u-a}),a=u,{ops:y,cursor:a}}function Rx(e){const t=e.value,r=e.selectionStart??t.length;return Df(t.slice(0,r)).length}const Au=8,Nx=10,dR=1.08,hR=1.16,Xh=6,fR=.94,pR=.08,mR=.12,Dx=88,Bx=36,Jh=10,Px=14;function ef(e){return e?e.replace(/\r\n|\r|\n/g,"\r").replace(/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g," ").replace(/[\u200B-\u200D\uFEFF]/g,""):""}const gR=80,bR=8,jx={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"};function Fl(e,t){return e.modes?.applicationCursorKeysMode===!0?`\x1BO${t}`:`\x1B[${t}`}function xR(e,t){switch(e.key){case"ArrowUp":return Fl(t,"A");case"ArrowDown":return Fl(t,"B");case"ArrowRight":return Fl(t,"C");case"ArrowLeft":return Fl(t,"D");case"Home":return"\x1B[H";case"End":return"\x1B[F";case"PageUp":return"\x1B[5~";case"PageDown":return"\x1B[6~";case"Insert":return"\x1B[2~";case"Delete":return"\x1B[3~";case"Tab":return" ";case"Escape":return"\x1B";default:return jx[e.key]?jx[e.key]:null}}function yR(e){return e.nativeEvent.isComposing||e.isComposing===!0||e.keyCode===229}function vR(e){try{const t=atob(e),r=Uint8Array.from(t,n=>n.charCodeAt(0));return new TextDecoder("utf-8").decode(r)}catch{return null}}function wR(e){const t="\x1B]52;";let r=0,n="";for(;r<e.length;){const s=e.indexOf(t,r);if(s===-1)return n+=e.slice(r),{cleaned:n,remainder:""};n+=e.slice(r,s);let i=-1,a=1;for(let f=s+t.length;f<e.length;f+=1){const b=e.charCodeAt(f);if(b===7){i=f,a=1;break}if(b===27&&f+1<e.length&&e[f+1]==="\\"){i=f,a=2;break}}if(i===-1)return{cleaned:n,remainder:e.slice(s)};const u=e.slice(s+t.length,i),d=u.indexOf(";");if(d>=0){const f=u.slice(d+1);if(f&&f!=="?"){const b=vR(f);b!==null&&navigator.clipboard?.writeText(b).catch(()=>{})}}r=i+a}return{cleaned:n,remainder:""}}function AR(e){if(typeof window>"u")return null;const t=[e,...Array.from(e.querySelectorAll("*"))];let r=null;for(const n of t){const i=window.getComputedStyle(n).overflowY;if(!(i!=="auto"&&i!=="scroll")){if(n.scrollHeight-n.clientHeight>2)return n;r||(r=n)}}return r}const TR=new Set(["visibility","bfcache","online"]),SR=5e5,CR=1e5,sd=260,id=140,Qx=80;function _R(e){return!e}let Tu=null;const LR=[{font:'400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'italic 400 13px "Termdock Mono"',text:"Termdock 0123456789 ~!@#$%^&*()[]{}"},{font:'700 italic 13px "Termdock Mono"',text:"Termdock 0123456789 ❖ "},{font:'400 13px "Noto Sans Symbols 2"',text:"⏺⏸⏹✓✗"},{font:'400 13px "Termdock Star Symbol"',text:"✦✧"},{font:'400 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"},{font:'700 13px "Noto Sans Mono CJK SC"',text:"终端中文路径"}],kR=()=>{if(Tu)return Tu;if(typeof document>"u"||!("fonts"in document))return Tu=Promise.resolve(),Tu;const e=document.fonts;return Tu=Promise.allSettled(LR.map(({font:r,text:n})=>e.load(r,n))).then(()=>e.ready).then(()=>{}).catch(()=>{}),Tu},Fx=e=>{if((!e||e.includes("var("))&&typeof window<"u"){const t=getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim();if(t)return t}return e};function Ox(e){return e==="normal"||e==="bold"?e:Math.max(1,Math.min(1e3,Math.round(e)))}function pc(e,t,r){const n=e?.dimensions?.css.cell.height;return Math.max(8,Math.round(n||t*r))}function ER(e){return{background:e.background,foreground:e.foreground,cursor:e.cursor||e.foreground,cursorAccent:e.cursorAccent||e.background,selectionBackground:e.selectionBackground||"rgba(0, 0, 0, 0.3)",selectionForeground:e.selectionForeground||e.foreground,black:e.black||"#6F6E69",red:e.red||"#AF3029",green:e.green||"#66800B",yellow:e.yellow||"#AD8301",blue:e.blue||"#205EA6",magenta:e.magenta||"#A02F6F",cyan:e.cyan||"#24837B",white:e.white||"#CECDC3",brightBlack:e.brightBlack||"#6F6E69",brightRed:e.brightRed||"#D14D41",brightGreen:e.brightGreen||"#879A39",brightYellow:e.brightYellow||"#D0A215",brightBlue:e.brightBlue||"#4385BE",brightMagenta:e.brightMagenta||"#CE5D97",brightCyan:e.brightCyan||"#3AA99F",brightWhite:e.brightWhite||"#FFFCF0"}}const $x=new Map;function IR(e,t,r,n,s){if(typeof window>"u"||typeof document>"u")return null;const i=e.getBoundingClientRect();if(i.width<24||i.height<24)return null;const a=window.devicePixelRatio||1,u=`${r}::${n}::${s}::${a}::${t}`;let d=$x.get(u);if(!d)try{const y=document.createElement("canvas").getContext("2d");if(!y)return null;y.font=`${r}px ${t}`;const v=y.measureText("M"),T=(Math.floor(v.width*a)+Math.round(n))/a,C=v.actualBoundingBoxAscent??r*.8,E=v.actualBoundingBoxDescent??r*.2,N=Math.floor(Math.ceil(C+E)*s);T>=1&&N>=1&&(d={cellWidth:T,cellHeight:N},$x.set(u,d))}catch{return null}if(!d)return null;const f=Math.max(2,Math.floor(i.width/d.cellWidth)),b=Math.max(2,Math.floor(i.height/d.cellHeight));return!Number.isFinite(f)||!Number.isFinite(b)?null:{cols:f,rows:b}}async function Hx(e){if(!e)return!1;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();const r=document.execCommand("copy");return t.remove(),r}catch{return!1}}}function MR(e){const t=e.buffer.active,r=t.viewportY,n=Math.min(t.length,r+e.rows),s=[];for(let i=r;i<n;i+=1){const a=t.getLine(i);a&&s.push(a.translateToString(!0))}return s.join(`
|
|
69
69
|
`).replace(/\s+$/g,"")}function Lg(e,t,r){const n=e.element;if(!n||!e.cols||!e.rows)return null;const s=n.getBoundingClientRect();if(!s.width||!s.height)return null;const i=t-s.left,a=r-s.top,u=n.offsetWidth/e.cols||s.width/e.cols,d=n.offsetHeight/e.rows||s.height/e.rows,f=Math.max(0,Math.min(e.cols-1,Math.floor(i/u))),b=Math.max(0,Math.min(e.rows-1,Math.floor(a/d)));return{col:f,row:e.buffer.active.viewportY+b}}function Ux(e,t,r){const n=t.row*e.cols+t.col,s=r.row*e.cols+r.col;if(n===s)return e.clearSelection(),!1;const i=Math.min(n,s),a=Math.max(n,s)+1,u=i%e.cols,d=Math.floor(i/e.cols);return e.select(u,d,a-i),!0}function Gx(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e)||"0");return Number.isFinite(t)?t:0}function RR(e,t){if(typeof window>"u")return{left:0,top:0};const r=window.visualViewport,n=r?.offsetLeft??0,s=r?.offsetTop??0,i=r?.width??window.innerWidth,a=r?.height??window.innerHeight,u=Gx("--safe-top-inset"),d=Gx("--safe-bottom-inset"),f=n+Jh,b=n+i-Dx-Jh,g=s+u+Jh,y=s+a-d-Bx-Jh,v=e-Dx/2,w=Math.max(f,Math.min(v,Math.max(f,b))),T=t-Bx-Px,C=t+Px,E=T>=g?T:C,N=Math.max(g,Math.min(E,Math.max(g,y)));return{left:Math.round(w),top:Math.round(N)}}const Hw=P.forwardRef(({sessionKey:e,chunks:t,onInput:r,onResize:n,onFlowControl:s,onTmuxScroll:i,tmuxScrollSensitivity:a=.55,onDoubleTap:u,onInputFocusChange:d,onMobileLongPressCopyResult:f,onMobilePasteResult:b,terminalSettings:g,theme:y,className:v,enableTouchScroll:w,mobileLongPressMode:T="arrows",autoFocus:C=!0},E)=>{const N=P.useRef(null),D=P.useRef(null),R=P.useRef(null),_=P.useRef(null),M=P.useRef(r),Q=P.useRef(n),H=P.useRef(d),G=P.useRef(s),U=P.useRef(g.rendererMode),W=P.useRef(null),J=P.useRef(""),ee=P.useRef(0),ae=P.useRef(!1),Se=P.useRef(null),Le=P.useRef(!1),_e=P.useRef(null),se=P.useRef(null),ie=P.useRef(null),fe=P.useRef(null),Qe=P.useRef(!1),de=P.useRef(0),Fe=P.useRef(""),rt=P.useRef(null),ht=P.useRef(null),Ee=P.useRef(!1),ce=P.useRef(typeof window<"u"?window.devicePixelRatio:1),je=P.useRef(null),De=P.useRef(!1),ke=P.useRef(!1),ge=P.useRef(null),Me=P.useRef(""),ct=P.useRef(0),Ae=P.useRef(null),Ve=P.useRef(null),We=P.useRef(null),he=P.useRef(0),Be=P.useRef(0),Ce=P.useRef(0),nt=P.useRef(null),kt=P.useRef(0),vt=P.useRef(!1),wt=P.useRef(0),[,Xe]=P.useReducer($=>$+1,0),[$e,lt]=P.useReducer($=>$+1,0),[$t,Ht]=P.useState("loading"),[St,ut]=P.useState(null),Oe=P.useMemo(()=>Dc("terminal"),[]),[It,it]=P.useState(!0),[Re,ne]=P.useState(!1),[be,Te]=P.useState({visible:!1,activeDir:""}),[ue,ot]=P.useState(null),xt=P.useRef(null),Rt=P.useRef(!1),[at,Ye]=P.useState({x:0,y:0,cellW:8,cellH:17}),st=P.useRef(null),[mt,Ze]=P.useState({active:!1,text:""}),rr=P.useRef(null),Tt=P.useRef(null);M.current=r,Q.current=n,H.current=d,G.current=s,U.current=g.rendererMode;const yr=P.useRef(C);yr.current=C;const cn=P.useRef(w);cn.current=w;const le=_R(!!i),{rendererMode:Yt,fontFamily:et,fontSize:Ct,fontWeight:Fn,fontWeightBold:On,letterSpacing:lr,lineHeight:Bt,minimumContrastRatio:nn,drawBoldTextInBrightColors:qn,unicodeVersion:ri,customGlyphs:Hr,rescaleOverlappingGlyphs:Rr,fontLigatures:un,enableImages:_n,smoothScrolling:Sr}=g,sn=Yt==="webgl",Dr=P.useCallback(()=>{xt.current!==null&&(clearTimeout(xt.current),xt.current=null),ot(null)},[]),on=P.useCallback($=>{xt.current!==null&&clearTimeout(xt.current),Rt.current=!1,ot($),xt.current=setTimeout(()=>{xt.current=null,ot(null)},3e3)},[]);P.useEffect(()=>{if(!ue)return;const $=()=>Dr();return window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),document.addEventListener("visibilitychange",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$),document.removeEventListener("visibilitychange",$)}},[Dr,ue]),P.useEffect(()=>()=>{xt.current!==null&&(clearTimeout(xt.current),xt.current=null)},[]),P.useEffect(()=>{w||H.current?.(!1)},[w]);const Yn=P.useCallback(($,V,z)=>{const re=(z.element?.offsetWidth||0)/z.cols||8,Ge=(z.element?.offsetHeight||0)/z.rows||16,He=Math.max(1,Math.min(z.cols,Math.floor($/re)+1)),ze=Math.max(1,Math.min(z.rows,Math.floor(V/Ge)+1));return{x:He,y:ze}},[]),ts=P.useCallback(($,V,z)=>{const re=R.current;if(!re)return!1;const Ge=$>0?-1:1;if(re.modes?.mouseTrackingMode!=="none"){let He,ze;if(V!==void 0&&z!==void 0){const ar=Yn(V,z,re);He=ar.x,ze=ar.y}else He=re.buffer.active.cursorX+1,ze=re.buffer.active.cursorY+1;const Pt=`\x1B[<${Ge>0?64:65};${He};${ze}M`;return M.current(Pt),!0}if(re.buffer.active.type==="alternate"){const He=Ge>0?"\x1B[A":"\x1B[B";return M.current(He),!0}return null},[Yn]),Fs=P.useCallback($=>{const V=R.current;if(!V)return!1;const z=pc(R.current,Ct,Bt),re=de.current+$,Ge=Math.trunc(re/z);return de.current=re-Ge*z,Ge!==0?(V.scrollLines(Ge),!0):!1},[Ct,Bt]),ks=P.useCallback($=>{if(!R.current)return!1;const re=pc(R.current,Ct,Bt)/Math.max(.1,a),Ge=de.current+$;let He=Math.trunc(Ge/re);if(de.current=Ge-He*re,He===0&&Math.abs(Ge)>=re/3&&(He=Ge>0?1:-1,de.current=0),He===0)return!1;const ze=He>0?"down":"up",qe=Math.max(1,Math.min(Math.abs(He),10));return i(ze,qe),!0},[Ct,Bt,i,a]),ni=P.useRef(ts);ni.current=ts;const dn=P.useRef(Fs);dn.current=Fs;const Cr=P.useRef(ks);Cr.current=ks;const cr=P.useRef(i);cr.current=i;const Kr=P.useRef({pointerId:null,tmuxActiveAtDown:!1});P.useEffect(()=>{if(!w)return;const $=N.current;if(!$)return;const V=re=>{re.pointerType==="touch"&&(Kr.current.pointerId=re.pointerId,Kr.current.tmuxActiveAtDown=!!cr.current)},z=re=>{re.pointerType==="touch"&&Kr.current.pointerId===re.pointerId&&(Kr.current.pointerId=null,Kr.current.tmuxActiveAtDown=!1)};return $.addEventListener("pointerdown",V,{capture:!0,passive:!0}),$.addEventListener("pointerup",z,{capture:!0,passive:!0}),$.addEventListener("pointercancel",z,{capture:!0,passive:!0}),()=>{$.removeEventListener("pointerdown",V,!0),$.removeEventListener("pointerup",z,!0),$.removeEventListener("pointercancel",z,!0)}},[w]);const Br=P.useCallback(()=>{if(vt.current)return!1;const $=Kr.current;return $.pointerId!==null?!$.tmuxActiveAtDown:!cr.current},[]),Qr=P.useCallback(($,V,z)=>{const re=ni.current($,V,z);return re!==null?re:cr.current?Cr.current($):dn.current($)},[]),Os=P.useCallback(($,V)=>{const z=R.current;if(z&&z.modes?.mouseTrackingMode!=="none"){const re=Yn($,V,z),Ge=re.x,He=re.y,ze=`\x1B[<0;${Ge};${He}M`,qe=`\x1B[<0;${Ge};${He}m`;M.current(ze),M.current(qe)}},[Yn]),dr=P.useCallback(()=>typeof performance<"u"?performance.now():Date.now(),[]),gr=P.useCallback(($=700)=>{nt.current=null,kt.current=dr()+$},[dr]),Es=P.useCallback(()=>cn.current&&dr()<=kt.current,[dr]),Fr=P.useCallback(()=>{const $=ie.current;return!$||typeof document>"u"?!1:document.activeElement===$},[]),hn=P.useCallback(()=>{if(typeof window>"u")return!1;const $=qe=>{if(typeof document>"u")return 0;const Pt=Number.parseFloat(document.documentElement.style.getPropertyValue(qe)||"0");return Number.isFinite(Pt)?Pt:0},V=$("--kb-height");if(V>0)return V>=Qx;const z=window.visualViewport;if(!z)return!1;const re=$("--app-base-vh")||window.innerHeight,Ge=$("--safe-bottom-inset"),He=z.height+z.offsetTop;return Math.max(0,Math.round(re-He-Ge))>=Qx},[]),$n=P.useCallback(()=>{Ae.current!==null&&(clearTimeout(Ae.current),Ae.current=null),Ve.current=null},[]),ta=P.useCallback($=>{const V=R.current;let z="";for(const re of $)re.left&&(z+=(V?Fl(V,"D"):"\x1B[D").repeat(re.left)),re.right&&(z+=(V?Fl(V,"C"):"\x1B[C").repeat(re.right)),re.backspace&&(z+="".repeat(re.backspace)),re.insert&&(z+=re.insert);return z},[]),vr=P.useCallback($=>{const V=$.value,z=ef(V),re=Me.current;if(!(cn.current&&!z.includes("\r")&&!re.includes("\r"))){if(z===re)return;let ar=0;for(;ar<re.length&&ar<z.length&&re[ar]===z[ar];)ar++;const qr=re.length-ar;qr>0&&M.current("".repeat(qr));const wr=z.slice(ar);if(wr){try{R.current?.clearSelection()}catch{}M.current(wr)}Me.current=z,ct.current=Array.from(z).length;return}const He=Rx($),{ops:ze,cursor:qe}=uR(re,z,ct.current,He),Pt=ta(ze);if(Pt){if(ze.some(ar=>ar.insert))try{R.current?.clearSelection()}catch{}M.current(Pt)}Me.current=z,ct.current=qe},[ta]),Xr=P.useCallback(($,V)=>{const z=$.value,re=ef(z),Ge=Me.current;if(re===Ge){$n();return}let He=0;for(;He<Ge.length&&He<re.length&&Ge[He]===re[He];)He++;const ze=Ge.length-He;if(w&&!V?.immediate&&ze>=bR){Ve.current=$,Ae.current!==null&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>{Ae.current=null;const Pt=Ve.current;Ve.current=null,Pt&&vr(Pt)},gR);return}$n(),vr($)},[$n,w,vr]),Jr=P.useCallback($=>{Xr($,{immediate:!0}),M.current("\r"),$.value="",Me.current="",ct.current=0},[Xr]),Pr=P.useCallback(($,V,z)=>{if(!$)return;$n();const re=V??ie.current;re&&(re.value=""),Me.current="",ct.current=0;try{R.current?.clearSelection()}catch{}M.current($,{skipModifierTransform:!0,consumeModifier:z?.consumeModifier})},[$n]),fn=P.useCallback(($,V)=>{const z=ef($);return z?(Pr(z,V),Dr(),!0):!1},[Dr,Pr]),co=P.useCallback(async $=>{try{if(!navigator.clipboard?.readText)return!1;const V=await navigator.clipboard.readText();return fn(V,$)}catch{return!1}},[fn]),uo=P.useCallback(()=>{if(w||st.current)return;const $=R.current;if(!$||!$.element)return;let V=8,z=17;try{const ze=$.element.querySelector(".xterm-rows"),qe=ze?.firstElementChild;qe&&qe.offsetHeight>0&&(z=qe.offsetHeight),ze&&ze.offsetWidth>0&&$.cols>0&&(V=ze.offsetWidth/$.cols)}catch{}if(V<=0||z<=0){const ze=$.element.getBoundingClientRect();ze.width>0&&$.cols>0&&(V=ze.width/$.cols),ze.height>0&&$.rows>0&&(z=ze.height/$.rows)}const re=$.buffer.active,Ge=Math.round(re.cursorX*V),He=Math.round(re.cursorY*z);Ye(ze=>Math.abs(ze.x-Ge)<.5&&Math.abs(ze.y-He)<.5&&Math.abs(ze.cellW-V)<.5&&Math.abs(ze.cellH-z)<.5?ze:{x:Ge,y:He,cellW:V,cellH:z})},[w]),Ur=P.useRef(uo);Ur.current=uo;const _r=P.useCallback($=>{let V=0;for(const z of $){const re=z.codePointAt(0)??0,Ge=re>=4352&&re<=4447||re>=11904&&re<=12350||re>=12353&&re<=13311||re>=13312&&re<=19903||re>=19968&&re<=40959||re>=40960&&re<=42191||re>=44032&&re<=55203||re>=63744&&re<=64255||re>=65072&&re<=65103||re>=65280&&re<=65376||re>=65504&&re<=65510||re>=127744&&re<=129791;V+=Ge?2:1}return V},[]),Hn=P.useCallback($=>{const V=R.current,{cellW:z,cellH:re}=at;if(!V||!$)return{width:Math.max(1,Math.round(z)),height:Math.max(1,Math.round(re)),whiteSpace:"pre"};const Ge=st.current,He=Ge?Math.floor(Ge.x/Math.max(1,z)):V.buffer.active.cursorX,ze=Math.max(1,V.cols),qe=Math.max(1,_r($)),Pt=Math.max(1,ze-He);if(qe<=Pt)return{width:Math.max(1,Math.round(qe*z)),height:Math.max(1,Math.round(re)),whiteSpace:"pre"};const ar=qe-Pt,wr=1+Math.ceil(ar/ze);return{width:Math.max(1,Math.round(Pt*z)),height:Math.max(1,Math.round(wr*re)),whiteSpace:"pre-wrap"}},[at,_r]),Mo=P.useCallback(()=>{st.current={...at}},[at]),si=P.useCallback(()=>{st.current=null},[]),Ai=P.useCallback(($,V)=>{const z=ie.current;if(z)try{z.removeAttribute("readonly");const Ge=typeof document<"u"&&document.activeElement===z&&!hn(),He=dr(),ze=He-wt.current;wt.current=He,Ge&&ze>600?(z.blur(),z.removeAttribute("readonly"),z.focus(),wt.current=dr()):z.focus()}catch{}},[hn,dr]),ms=P.useCallback($=>{Be.current=dr()+$},[dr]),rs=P.useCallback(()=>w?dr()<=Be.current:!1,[w,dr]),yn=P.useCallback($=>{ms($),Ce.current=dr()},[ms,dr]),Is=P.useCallback(()=>{w&&ie.current?.removeAttribute("readonly")},[w]),ii=P.useCallback($=>$ instanceof HTMLElement&&($.closest('[data-terminal-copy-popover="true"]')!==null||$.closest('[data-mobile-copy-button="true"]')!==null),[]),oi=P.useCallback($=>{if(Is(),yn(sd),!w||$.pointerType!=="touch"){nt.current=null;return}const V=$.target;if(ii(V)){gr();return}ue&&!(V instanceof HTMLElement&&V.closest('[data-terminal-copy-popover="true"]'))&&Dr(),nt.current={pointerId:$.pointerId,startX:$.clientX,startY:$.clientY,moved:!1}},[Dr,w,yn,ii,ue,Is,gr]),Sn=P.useCallback($=>{yn(sd);const V=nt.current;!V||V.pointerId!==$.pointerId||Math.hypot($.clientX-V.startX,$.clientY-V.startY)>12&&(V.moved=!0)},[yn]),ho=P.useCallback($=>{yn(id);const V=nt.current;nt.current=null,!(!w||$.pointerType!=="touch")&&(!V||V.pointerId!==$.pointerId||V.moved||Es()||Ai($.clientX,$.clientY))},[w,yn,Ai,Es]),ai=P.useCallback(()=>{nt.current=null,yn(id)},[yn]),Mn=P.useMemo(()=>({enableKinetic:!0}),[]),Ti=P.useRef(()=>!1),Ei=P.useRef(Ai);Ei.current=Ai;const nr=P.useCallback(($,V)=>{Es()||Ei.current($,V)},[Es]),Ii=P.useRef(u);Ii.current=u;const li=P.useRef(f);li.current=f;const us=P.useRef(b);us.current=b;const Lr=P.useCallback(()=>{if(Rt.current)return;Rt.current=!0,gr();const $=R.current,V=$?.hasSelection()?$.getSelection():"";try{$?.clearSelection()}catch{}o0.flushSync(()=>{Dr()}),(async()=>{const z=await Hx(V);li.current?.(z)})()},[Dr,gr]),Ms=P.useCallback($=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:$}}))},[]),{setupTouchScroll:Zi,stopAllScroll:en}=XM(N,{...Mn,shouldCaptureTouch:Ti.current,canStartScrollGesture:Br,onScroll:Qr,onScrollWithCoords:Qr,onClickWithCoords:Os,onTap:nr,onClaimChange:Ms,tapThreshold:12,gestureName:`normal-scroll:${e}`});P.useEffect(()=>{if(!w)return;ie.current?.setAttribute("readonly","");const $=Zi();return()=>{$()}},[w,Zi]),P.useEffect(()=>{if(!w)return;let $=hn();const V=()=>{const z=hn();if($&&!z){const re=ie.current;re&&typeof document<"u"&&document.activeElement===re&&(re.setAttribute("readonly",""),re.blur())}$=z};return window.visualViewport?.addEventListener("resize",V),window.visualViewport?.addEventListener("scroll",V),document.addEventListener("termdock:viewport-keyboard-change",V),()=>{window.visualViewport?.removeEventListener("resize",V),window.visualViewport?.removeEventListener("scroll",V),document.removeEventListener("termdock:viewport-keyboard-change",V)}},[w,hn]),P.useEffect(()=>{if(!w)return;const $=N.current;if(!$)return;const V=re=>{const He=re.sourceCapabilities?.firesTouchEvents===!0,ze=dr()-Ce.current<=1200;return!He&&!ze?!1:$.contains(re.target)},z=re=>{V(re)&&(re.cancelable&&re.preventDefault(),re.stopImmediatePropagation(),re.stopPropagation())};return $.addEventListener("mousedown",z,{capture:!0,passive:!1}),$.addEventListener("mouseup",z,{capture:!0,passive:!1}),$.addEventListener("click",z,{capture:!0,passive:!1}),document.addEventListener("mouseup",z,{capture:!0,passive:!1}),()=>{$.removeEventListener("mousedown",z,!0),$.removeEventListener("mouseup",z,!0),$.removeEventListener("click",z,!0),document.removeEventListener("mouseup",z,!0)}},[w,dr]);const pn=P.useRef({pointerId:null,lastX:null,lastY:null,startX:null,startY:null,gestureAxis:null,remainder:0,didScroll:!1,rafId:null,velocity:0,instantSpeed:0}),Ln=P.useCallback(()=>{const $=pn.current;$.rafId!==null&&(cancelAnimationFrame($.rafId),$.rafId=null)},[]),Si=P.useCallback(($,V,z)=>{const re=R.current;if(!re||!re.element||!re.cols||!re.rows)return null;const Ge=pn.current,He=re.element.getBoundingClientRect(),ze=V??Ge.lastX??He.left+He.width/2,qe=z??Ge.lastY??He.top+He.height/2,Pt=ze-He.left,ar=qe-He.top,qr=re.element.offsetWidth/re.cols||8,wr=re.element.offsetHeight/re.rows||16,ys=Math.max(1,Math.min(re.cols,Math.floor(Pt/qr)+1)),er=Math.max(1,Math.min(re.rows,Math.floor(ar/wr)+1));return`\x1B[<${$==="up"?64:65};${ys};${er}M`},[]),ns=P.useCallback(($,V,z,re)=>{if(V<=0)return;const Ge=Si($,z,re);Ge&&M.current(V===1?Ge:Ge.repeat(V))},[Si]),Ki=P.useRef(ns);Ki.current=ns;const ds=P.useCallback(()=>{const V=pc(R.current,Ct,Bt)/Math.max(.1,a),z=1+pn.current.instantSpeed*.1;return V/Math.min(6,z)},[Ct,Bt,a]),gs=P.useCallback(()=>{const $=pn.current;$.rafId=null;const V=ds();let z=0,re=0;for(;z+re<Xh&&$.remainder>=V;)$.remainder-=V,re++;for(;z+re<Xh&&$.remainder<=-V;)$.remainder+=V,z++;if(re>0&&ns("down",re),z>0&&ns("up",z),z+re>0)$.rafId=requestAnimationFrame(gs);else if($.pointerId!==null&&Math.abs($.remainder)>=V/3){const He=$.remainder>0?"down":"up";$.remainder=0,ns(He,1),$.rafId=requestAnimationFrame(gs)}},[ds,ns]),ve=P.useCallback(()=>{const $=pn.current;$.rafId===null&&typeof requestAnimationFrame<"u"&&($.rafId=requestAnimationFrame(gs))},[gs]),Je=P.useCallback($=>{if($.pointerType!=="touch")return!1;Ln();const V=pn.current;return V.pointerId=$.pointerId,V.lastX=$.clientX,V.lastY=$.clientY,V.startX=$.clientX,V.startY=$.clientY,V.gestureAxis=null,V.remainder=0,V.velocity=0,V.instantSpeed=0,V.didScroll=!1,!1},[Ln]),ft=P.useCallback(($,V)=>{if(vt.current)return V?"release":"neutral";const z=pn.current;if($.pointerType!=="touch"||$.pointerId!==z.pointerId||z.lastY==null)return"neutral";if(z.gestureAxis===null&&z.startX!==null&&z.startY!==null){const He=Math.abs($.clientX-z.startX),ze=Math.abs($.clientY-z.startY);if(He>Nx||ze>Nx){if(He>ze*dR)return z.gestureAxis="x","release";ze>He*hR&&(z.gestureAxis="y")}}if(z.gestureAxis==="x")return z.lastX=$.clientX,z.lastY=$.clientY,"release";if(z.gestureAxis===null)return z.lastX=$.clientX,z.lastY=$.clientY,"neutral";const re=$.clientY-z.lastY;z.lastX=$.clientX,z.lastY=$.clientY;const Ge=-re;if(z.remainder+=Ge,z.instantSpeed=Math.abs(Ge),z.velocity=z.velocity*.45+Ge*.55,V){const ze=pc(R.current,Ct,Bt)/Math.max(.1,a);Math.abs(z.remainder)>=ze/3&&(z.didScroll=!0,ve())}return"claim"},[Ct,Bt,a,ve]),Pe=P.useCallback($=>{const V=pn.current;if($.pointerType!=="touch"||$.pointerId!==V.pointerId)return;if(Ln(),V.pointerId=null,V.lastX=null,V.lastY=null,V.startX=null,V.startY=null,V.instantSpeed=0,V.gestureAxis==="x"){V.gestureAxis=null;return}V.gestureAxis=null;const re=pc(R.current,Ct,Bt)/Math.max(.1,a);if(V.didScroll&&Math.abs(V.velocity)>re*pR){const Ge=()=>{V.velocity*=fR,V.remainder+=V.velocity;const He=1+Math.abs(V.velocity)*.1,ze=re/Math.min(6,He);if(Math.abs(V.velocity)<re*mR){if(Math.abs(V.remainder)>=ze/3){const ar=V.remainder>0?"down":"up";ns(ar,1),V.remainder=0}V.velocity=0,V.rafId=null;return}let qe=0,Pt=0;for(;qe+Pt<Xh&&V.remainder>=ze;)V.remainder-=ze,Pt++;for(;qe+Pt<Xh&&V.remainder<=-ze;)V.remainder+=ze,qe++;Pt>0&&ns("down",Pt),qe>0&&ns("up",qe),V.rafId=requestAnimationFrame(Ge)};V.rafId=requestAnimationFrame(Ge)}else Math.abs(V.remainder)>=re/3&&ve();V.didScroll&&$.stopImmediatePropagation()},[Ln,ns,ve,a,Ct,Bt]),Et=P.useCallback($=>{const V=pn.current;$.pointerType!=="touch"||$.pointerId!==V.pointerId||(Ln(),V.pointerId=null,V.lastX=null,V.lastY=null,V.startX=null,V.startY=null,V.gestureAxis=null,V.remainder=0,V.velocity=0,V.didScroll=!1)},[Ln]);kx({name:`tmux-scroll:${e}`,priority:ZM,container:()=>N.current,onPointerDown:w&&i?Je:void 0,onPointerMove:w&&i?ft:void 0,onPointerUp:w&&i?Pe:void 0,onPointerCancel:w&&i?Et:void 0});const Mt=P.useRef({pointerId:null,originX:0,originY:0,holdTimer:null,mode:"idle",longPressMode:"arrows",copyStart:null,copyDidSelect:!1,gestureLocked:!1,joystickDir:"",joystickRepeatTimer:null,repeatIntervalMs:260,lastHapticTime:0,lastTapTime:0,lastTapX:0,lastTapY:0,tapStartX:0,tapStartY:0,tapDidMove:!1}),br=P.useRef(null);br.current=N.current;const Ar=br,vn=M,Gr=P.useRef(T);Gr.current=T;const zr=P.useCallback($=>{const V=Mt.current;V.gestureLocked!==$&&(V.gestureLocked=$,Ms($))},[Ms]),ss=P.useCallback($=>{if($.pointerType!=="touch")return!1;const V=Ar.current;if(!V)return!1;const z=$.target;if(!(z instanceof HTMLElement)||!V.contains(z)||z.closest('[data-mobile-keyboard="true"]'))return!1;const re=Mt.current;if(re.longPressMode=Gr.current,re.pointerId!==null)return!0;if(vt.current=!1,Ii.current){const Ge=performance.now(),He=$.clientX,ze=$.clientY;if(re.lastTapTime!==0&&Ge-re.lastTapTime<=150&&Math.hypot(He-re.lastTapX,ze-re.lastTapY)<=25)return jl(Au),Ii.current?.(),ne(!0),Tt.current&&clearTimeout(Tt.current),Tt.current=setTimeout(()=>ne(!1),400),re.lastTapTime=0,!0}return re.holdTimer!==null&&(clearTimeout(re.holdTimer),re.holdTimer=null),re.joystickRepeatTimer!==null&&(clearTimeout(re.joystickRepeatTimer),re.joystickRepeatTimer=null),re.joystickDir="",re.copyStart=null,re.copyDidSelect=!1,re.pointerId=$.pointerId,re.originX=$.clientX,re.originY=$.clientY,re.tapStartX=$.clientX,re.tapStartY=$.clientY,re.tapDidMove=!1,re.mode="holding",re.longPressMode==="copy"&&zr(!0),re.holdTimer=setTimeout(()=>{if(re.holdTimer=null,re.mode==="holding"){if(re.longPressMode==="copy"){const Ge=R.current,He=Ge?Lg(Ge,re.tapStartX,re.tapStartY):null;if(!Ge||!He){re.mode="idle";return}re.mode="copy",vt.current=!0,gr(1800),re.copyStart=He,re.copyDidSelect=!1,en(),Ln(),Ge.clearSelection(),jl(Au),zr(!0);return}re.mode="arrow",vt.current=!0,gr(1e3),en(),Ln(),jl(Au),zr(!0),requestAnimationFrame(()=>{Te({visible:!0,activeDir:""})})}},350),!0},[zr]),ma=P.useCallback(($,V)=>{if($.pointerType!=="touch")return"neutral";const z=Mt.current;if(z.mode==="arrow"&&$.pointerId!==z.pointerId||z.mode==="copy"&&$.pointerId!==z.pointerId||z.mode!=="arrow"&&z.mode!=="copy"&&$.pointerId!==z.pointerId)return"neutral";const re=$.clientX-z.tapStartX,Ge=$.clientY-z.tapStartY;if(Math.hypot(re,Ge)>10&&(z.tapDidMove=!0),z.mode==="holding"){if(!V)return z.holdTimer!==null&&(clearTimeout(z.holdTimer),z.holdTimer=null),zr(!1),vt.current=!1,z.mode="idle","neutral";const He=$.clientX-z.originX,ze=$.clientY-z.originY;return z.longPressMode==="copy"&&Math.hypot(He,ze)>20?(z.holdTimer!==null&&(clearTimeout(z.holdTimer),z.holdTimer=null),zr(!1),vt.current=!1,z.mode="idle","release"):Math.hypot(He,ze)>20?(z.holdTimer!==null&&(clearTimeout(z.holdTimer),z.holdTimer=null),zr(!1),z.mode="idle","release"):"claim"}if(z.mode==="copy"){if(!V)return"claim";en();const He=R.current;if(!He||!z.copyStart)return"claim";const ze=Lg(He,$.clientX,$.clientY);return ze&&(z.copyDidSelect=Ux(He,z.copyStart,ze)||z.copyDidSelect),"claim"}if(z.mode==="arrow"){if(!V)return"claim";const He={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},ze=$.clientX-z.tapStartX,qe=$.clientY-z.tapStartY,Pt=Math.hypot(ze,qe),ar=Math.abs(ze),qr=Math.abs(qe);let wr="";if(Pt>12&&(ar>=qr*1.5?wr=ze>0?"right":"left":qr>=ar*1.5&&(wr=qe>0?"down":"up")),wr&&wr!==z.joystickDir&&(z.originX=$.clientX,z.originY=$.clientY),wr){const ys=$.clientX-z.originX,er=$.clientY-z.originY,fr=Math.hypot(ys,er),Ri=260-Math.min(fr-12,68)/68*180;if(z.repeatIntervalMs=Ri,wr!==z.joystickDir){z.joystickRepeatTimer!==null&&clearTimeout(z.joystickRepeatTimer);const O=z.joystickDir==="";z.joystickDir=wr,vn.current(He[wr]);const K=performance.now();K-z.lastHapticTime>120&&(jl(Au),z.lastHapticTime=K);const Ie=O?400:300;z.joystickRepeatTimer=setTimeout(function Ke(){if(z.joystickDir!==wr)return;vn.current(He[wr]);const Lt=performance.now();Lt-z.lastHapticTime>120&&(jl(Au),z.lastHapticTime=Lt),z.joystickRepeatTimer=setTimeout(Ke,z.repeatIntervalMs)},Ie)}Te({visible:!0,activeDir:wr})}else z.joystickRepeatTimer!==null&&(clearTimeout(z.joystickRepeatTimer),z.joystickRepeatTimer=null),z.joystickDir="",Te({visible:!0,activeDir:""});return"claim"}return"neutral"},[zr]),fo=P.useCallback($=>{if($.pointerType!=="touch"||$.pointerId!==Mt.current.pointerId)return;const V=Mt.current;if(V.mode==="copy"){en(),Ln(),zr(!1);const re=R.current;if(re&&V.copyStart){const Ge=Lg(re,$.clientX,$.clientY);Ge&&(V.copyDidSelect=Ux(re,V.copyStart,Ge)||V.copyDidSelect)}re&&V.copyDidSelect&&re.hasSelection()?(on(RR($.clientX,$.clientY)),gr(1800),jl(Au)):li.current?.(!1),V.holdTimer!==null&&(clearTimeout(V.holdTimer),V.holdTimer=null),V.copyStart=null,V.copyDidSelect=!1,V.pointerId=null,V.mode="idle",vt.current=!1;return}if(V.mode==="arrow"){en(),Ln(),zr(!1),Te({visible:!1,activeDir:""}),V.holdTimer!==null&&(clearTimeout(V.holdTimer),V.holdTimer=null),V.joystickRepeatTimer!==null&&(clearTimeout(V.joystickRepeatTimer),V.joystickRepeatTimer=null),V.joystickDir="",V.pointerId=null,V.mode="idle",vt.current=!1;return}const z=Ar.current;if(z&&!V.tapDidMove){const re=$.target;re instanceof HTMLElement&&z.contains(re)&&!re.closest('[data-mobile-keyboard="true"]')&&(V.lastTapTime=performance.now(),V.lastTapX=$.clientX,V.lastTapY=$.clientY)}else V.tapDidMove&&(V.lastTapTime=0);V.holdTimer!==null&&(clearTimeout(V.holdTimer),V.holdTimer=null),V.joystickRepeatTimer!==null&&(clearTimeout(V.joystickRepeatTimer),V.joystickRepeatTimer=null),V.joystickDir="",zr(!1),vt.current=!1,V.copyStart=null,V.copyDidSelect=!1,V.pointerId=null,V.mode="idle"},[zr,en,gr]),ga=P.useCallback(()=>{const $=Mt.current;zr(!1),$.mode==="arrow"&&Te({visible:!1,activeDir:""}),$.holdTimer!==null&&(clearTimeout($.holdTimer),$.holdTimer=null),$.joystickRepeatTimer!==null&&(clearTimeout($.joystickRepeatTimer),$.joystickRepeatTimer=null),$.joystickDir="",vt.current=!1,$.copyStart=null,$.copyDidSelect=!1,$.pointerId=null,$.tapDidMove=!1,$.mode="idle"},[zr]);kx({name:`long-press:${e}`,priority:YM,container:()=>N.current,onPointerDown:w?ss:void 0,onPointerMove:w?ma:void 0,onPointerUp:w?fo:void 0,onPointerCancel:w?ga:void 0});const Zn=P.useCallback(($={})=>{J.current="",ee.current=0,ae.current&&(ae.current=!1,$.notifyFlowResume===!0&&G.current?.(!1)),Se.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Se.current),Se.current=null,Le.current=!1,_e.current=null,Fe.current=""},[]),yt=P.useCallback(($="unknown")=>{const V=_.current,z=R.current,re=N.current;if(!V||!z||!re||!z.element||!z.cols||!z.rows)return;const Ge=re.getBoundingClientRect();if(Ge.width<24||Ge.height<24){Oe("skip fit: container too small",{reason:$,width:Math.round(Ge.width),height:Math.round(Ge.height)});return}try{const He={cols:z.cols,rows:z.rows};V.fit();const ze={cols:z.cols,rows:z.rows},qe=W.current;Oe("fit",{reason:$,backend:"xterm",width:Math.round(Ge.width),height:Math.round(Ge.height),before:He,next:ze,changed:He.cols!==ze.cols||He.rows!==ze.rows}),(!qe||qe.cols!==ze.cols||qe.rows!==ze.rows)&&(W.current=ze,de.current=0,Q.current(ze.cols,ze.rows))}catch{}},[Oe]),xr=P.useCallback($=>{const V=R.current;if(V)try{V.refresh(0,Math.max(0,V.rows-1)),Oe("terminal refreshed (sync)",{reason:$,cols:V.cols,rows:V.rows,hasWebgl:!!rt.current})}catch(z){Oe("terminal refresh (sync) failed",{reason:$,error:z})}},[Oe]),Rs=P.useCallback($=>{const V=ht.current;if(V){try{V.dispose()}catch{}ht.current=null}const z=rt.current;if(!z)return!1;try{z.dispose()}catch{}return rt.current=null,Oe("renderer disposed",{type:"webgl",reason:$}),!0},[Oe]),Mi=P.useCallback(($,V)=>{if(rt.current)return!0;try{const z=new ZE({customGlyphs:Hr});return ht.current=z.onContextLoss(()=>{Oe("webgl context loss",{reason:"onContextLoss"}),Ee.current=!0,typeof window<"u"&&window.setTimeout(()=>{hr("webgl-context-loss",{forceRendererRecreate:!0})},0)}),$.loadAddon(z),rt.current=z,Ee.current=!1,Oe("renderer",{type:"webgl",reason:V,mobile:w,mode:U.current}),xr(`webgl-enabled:${V}`),yt(`webgl-enabled:${V}`),bs.current=!0,!0}catch(z){return Oe("webgl load failed, fallback to dom renderer",{reason:V,error:z,mobile:w,mode:U.current}),!1}},[Oe,Hr,w,yt,xr]),is=90,Wr=200,pe=P.useRef(0),ci=P.useRef(new Map),po=P.useRef(null),Or=P.useRef(null),ra=P.useRef(new Map),bs=P.useRef(!1),xs=P.useRef(!1),Vr=P.useCallback($=>{const V=ci.current,z=V.get($);z!==void 0&&(cancelAnimationFrame(z),V.delete($))},[]),Un=P.useCallback(()=>{const $=ci.current;$.forEach(V=>cancelAnimationFrame(V)),$.clear()},[]),Kn=P.useCallback(()=>{po.current!==null&&(window.clearTimeout(po.current),po.current=null)},[]),Fa=P.useCallback(($,V,z)=>{Kn();const re=Or.current;if(!(re&&re.cols===$&&re.rows===V)&&xs.current){if(z<=0||re===null){Or.current={cols:$,rows:V},Q.current($,V);return}po.current=window.setTimeout(()=>{po.current=null,Or.current={cols:$,rows:V},Q.current($,V)},z)}},[Kn]),Ot=1500,na=400,ui=P.useRef(0),ba=P.useRef(0),Gn=P.useCallback(($,V,z)=>{if(!Number.isFinite($)||!Number.isFinite(V)||$<=0||V<=0)return;const re=Math.floor($),Ge=Math.floor(V);Kn(),Or.current={cols:re,rows:Ge},ui.current=Date.now(),Oe("pty-size broadcast received",{cols:re,rows:Ge,source:z??"unknown"})},[Kn,Oe]),Xi=P.useCallback($=>{const V=R.current;if(!V||!V.cols||!V.rows||!xs.current||typeof document<"u"&&document.visibilityState!=="visible")return;const z=Date.now();if(z-ui.current<Ot||z-ba.current<na)return;const re=V.cols,Ge=V.rows,He=Or.current;He&&He.cols===re&&He.rows===Ge||(ba.current=z,Oe("ensureSizeMatches push",{reason:$,cols:re,rows:Ge,lastServerSize:He}),Or.current={cols:re,rows:Ge},Q.current(re,Ge))},[Oe]),Ci=P.useCallback(($,V)=>{const z=R.current,re=_.current;if(!z||!re)return;if(!bs.current){Oe("refresh skipped: renderer not ready",{reason:$});return}if(V.dedupeKey!==void 0){if(ra.current.get($)===V.dedupeKey){Oe("refresh deduped",{reason:$,dedupeKey:V.dedupeKey});return}ra.current.set($,V.dedupeKey)}Oe("refresh",{reason:$,options:V}),V.forceRendererRecreate===!0||Ee.current||sn&&!!rt.current&&TR.has($)?(Ee.current=!1,sn?(Rs(`refresh:${$}`),Mi(z,`refresh:${$}`)||xr(`refresh:${$}:webgl-fallback`)):xr(`refresh:${$}`)):rt.current&&sn?Oe("webgl refresh skipped: renderer alive",{reason:$}):xr(`refresh:${$}`);const He={cols:z.cols,rows:z.rows};yt(`refresh:${$}`);const ze={cols:z.cols,rows:z.rows};if(!V.skipResizePush){if(V.candidateSize){const qe=V.candidateSize;if(!(qe.cols<ze.cols||qe.rows<ze.rows)){const Pt=V.resizeDebounceMs??is;Fa(qe.cols,qe.rows,Pt)}}else if(He.cols!==ze.cols||He.rows!==ze.rows||Or.current===null){const qe=V.resizeDebounceMs??is;Fa(ze.cols,ze.rows,qe)}}if(!V.skipScrollToBottom){const qe=requestAnimationFrame(()=>{const qr=R.current;if(qr&&qr.buffer.active.type!=="alternate")try{qr.scrollToBottom()}catch{}}),Pt=ci.current,ar=Pt.get($);ar!==void 0&&cancelAnimationFrame(ar),Pt.set($,qe)}},[Oe,sn,Rs,Mi,xr,yt,Fa]),hr=P.useCallback(($,V={})=>{if(R.current,$==="session-key-change"&&(Or.current=null,ra.current.clear(),Kn(),Un()),!V.force&&($==="visibility"||$==="bfcache"||$==="online")){const re=Date.now();if(re-pe.current<Wr){Oe("refresh throttled",{reason:$});return}pe.current=re}Vr($);const z=requestAnimationFrame(()=>{ci.current.delete($),Ci($,V)});ci.current.set($,z)},[Oe,Vr,Un,Kn,Ci]);P.useEffect(()=>()=>{Un(),Kn(),fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)},[e,Un,Kn]),P.useEffect(()=>{Or.current=null,ra.current.clear(),Kn()},[e,Kn]);const di=P.useCallback(()=>{if(Le.current)return;const $=R.current;if(!$){Zn();return}if(!J.current)return;const V=J.current,z=V.length;J.current="",Le.current=!0,$.write(V,()=>{Le.current=!1,ee.current-=z,ee.current<0&&(ee.current=0),ae.current&&ee.current<CR&&(ae.current=!1,G.current?.(!1)),J.current&&(typeof window<"u"?Se.current=window.requestAnimationFrame(()=>{Se.current=null,di()}):di())})},[Zn]),mo=P.useCallback(()=>{Se.current===null&&(typeof window<"u"?Se.current=window.requestAnimationFrame(()=>{Se.current=null,di()}):di())},[di]),Ro=P.useCallback($=>{$&&(J.current+=$,ee.current+=$.length,!ae.current&&ee.current>=SR&&(ae.current=!0,G.current?.(!0)),mo())},[mo]);return P.useEffect(()=>{let $=!1,V=null,z=null,re=[];const Ge=N.current;return Ge?(Ge.tabIndex=w?-1:0,(async()=>{if(Ht("loading"),ut(null),it(!0),await kR(),!$)try{const ze=IR(Ge,Fx(et),Ct,lr,Bt),qe=new LT({...ze?{cols:ze.cols,rows:ze.rows}:{},allowProposedApi:!0,fontFamily:Fx(et),fontSize:Ct,fontWeight:Ox(Fn),fontWeightBold:Ox(On),theme:ER(y),logLevel:"off",cursorBlink:!sn,cursorStyle:"block",cursorInactiveStyle:"bar",scrollback:i?2e3:5e3,allowTransparency:_n,convertEol:le,drawBoldTextInBrightColors:qn,rescaleOverlappingGlyphs:Rr,minimumContrastRatio:nn,letterSpacing:lr,lineHeight:Bt,smoothScrollDuration:Sr?125:0,scrollOnEraseInDisplay:!0,tabStopWidth:8,vtExtensions:{kittyKeyboard:!0},windowOptions:{getWinSizePixels:!0,getCellSizePixels:!0,getWinSizeChars:!0}}),Pt=new kT,ar=Pt.proposeDimensions.bind(Pt);Pt.proposeDimensions=()=>{const er=qe.options.scrollback;qe.options.scrollback=0;const fr=ar();return qe.options.scrollback=er,fr},qe.loadAddon(Pt),qe.loadAddon(new rI);const qr=new cI;qe.loadAddon(qr),qe.unicode.activeVersion=ri,qe.loadAddon(new bI({highlightLimit:1e3})),qe.loadAddon(new AI),qe.loadAddon(new HM);try{qe.loadAddon(new SI(void 0,new kw))}catch(er){Oe("clipboard addon skipped",{error:er})}V=qe,R.current=qe,_.current=Pt,ce.current=typeof window<"u"?window.devicePixelRatio:1,je.current=qe.buffer.active.type,qe.open(Ge),un&&qe.loadAddon(new $M({fontFeatureSettings:zM,fallbackLigatures:WM}));try{const er=qe._core;er?.coreService&&(er.coreService.isCursorInitialized=!0),qe.refresh(0,qe.rows-1)}catch{}if(sn?(Mi(qe,"init"),bs.current=!0):(Oe("renderer",{type:"dom",reason:"renderer-mode-dom-fallback",mobile:w,mode:Yt}),bs.current=!0),it(!1),lt(),w){const er=fr=>{if(fr.ctrlKey||fr.metaKey){fr.preventDefault();const Nr=fr.deltaY>0?-1:1,zn=Math.max(8,Math.min(32,Ct+Nr));zn!==Ct&&Ge.dispatchEvent(new CustomEvent("termfontchange",{detail:zn}))}};We.current=er,Ge.addEventListener("wheel",er,{passive:!1})}if(!w){let er=0,fr=null,Nr=null,zn=null;const Ri=()=>{zn=null;const O=pc(R.current,Ct,Bt),K=he.current+er;er=0;const Ie=Math.trunc(K/O);if(he.current=K-Ie*O,Ie!==0){const Ke=Ie>0?"down":"up",Lt=R.current,Zt=Math.max(3,Math.floor((Lt?.rows??24)/2)),or=Math.abs(Ie);or>Zt&&(he.current=0),Ki.current(Ke,Math.min(or,Zt),fr??void 0,Nr??void 0)}};qe.attachCustomWheelEventHandler(O=>{if(O.ctrlKey||O.metaKey||O.shiftKey)return!0;if(O.deltaY===0)return!1;if(!R.current||!cr.current)return!0;const Ie=pc(R.current,Ct,Bt);let Ke=O.deltaY;return O.deltaMode===1?Ke=O.deltaY*Ie:O.deltaMode===2&&(Ke=O.deltaY*(Ge.clientHeight||Ie*20)),er+=Ke,fr=O.clientX,Nr=O.clientY,zn===null&&(zn=requestAnimationFrame(Ri)),O.preventDefault(),!1})}const wr=AR(Ge);if(wr?(wr.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),D.current=wr,Xe()):D.current=null,hr("mount",{skipResizePush:!0,skipScrollToBottom:!0}),yr.current&&(w?qe.focus():ie.current?.focus({preventScroll:!0})),w||Ur.current(),re.push(qe.onRender(()=>{const er=qe.buffer.active.type;je.current!==er&&(je.current=er,xr(`buffer-type-change:${er}`)),w||Ur.current()})),!w){try{const er=qe.textarea;if(er){er.tabIndex=-1,er.setAttribute("aria-hidden","true"),er.setAttribute("readonly",""),er.value="";const fr=()=>{ie.current?.focus({preventScroll:!0})};er.addEventListener("focus",fr),re.push({dispose:()=>er.removeEventListener("focus",fr)})}}catch{}try{re.push(qe.onCursorMove(()=>Ur.current())),re.push(qe.onResize(()=>Ur.current()))}catch{}}re.push(qe.onData(er=>{M.current(er)}));const ys=er=>{const fr=typeof window<"u"?window.devicePixelRatio:1,Nr=Math.abs(fr-ce.current)>.001;return Nr&&(ce.current=fr,Oe("device pixel ratio changed",{value:fr,source:er})),Nr};if(z=new ResizeObserver(er=>{const fr=er[0];fr&&Oe("resize observer",{width:Math.round(fr.contentRect.width),height:Math.round(fr.contentRect.height)}),ys("resize-observer")?hr("dpr-change",{resizeDebounceMs:0}):hr("resize")}),z.observe(Ge),typeof window<"u"){const er=()=>{ys("window-resize")&&hr("dpr-change",{resizeDebounceMs:0})};window.addEventListener("resize",er),re.push({dispose:()=>window.removeEventListener("resize",er)});const fr=window.visualViewport;if(fr){const Nr=()=>{ys("visual-viewport-resize")&&hr("dpr-change",{resizeDebounceMs:0})};fr.addEventListener("resize",Nr),re.push({dispose:()=>fr.removeEventListener("resize",Nr)})}}typeof window<"u"&&window.setTimeout(()=>{hr("init-fit",{skipScrollToBottom:!0})},0),Ht("ready")}catch(ze){console.error("Failed to initialize terminal:",ze),it(!1),Ht("error"),ut(ze instanceof Error?ze.message:"Failed to load terminal")}})(),()=>{$=!0,H.current?.(!1),se.current?.(),se.current=null,De.current=!1,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),ke.current=!1,st.current=null,$n(),Ze({active:!1,text:""});for(const ze of re)ze.dispose();z?.disconnect(),We.current&&(Ge.removeEventListener("wheel",We.current),We.current=null),Rs("component-unmount"),V?.dispose(),R.current=null,_.current=null,D.current=null,je.current=null,W.current=null,Zn({notifyFlowResume:!0})}):void 0},[yt,et,Ct,Fn,On,lr,Bt,nn,qn,ri,Hr,Rr,un,_n,Sr,y,Zn,$n,w,Mi,Rs,Oe]),P.useEffect(()=>{const $=R.current;if($){if(sn){if($.options.cursorBlink=!1,Mi($,"renderer-mode-change")&&_n&&!Qe.current)try{$.loadAddon(new tM({storageLimit:64,pixelLimit:1<<24,sixelSupport:!0,iipSupport:!0,kittySupport:!0})),Qe.current=!0}catch(z){Oe("image addon skipped",{error:z})}return}$.options.cursorBlink=!0,Rs("renderer-mode-change")&&(xr("renderer-mode-change:webgl-disabled"),yt("renderer-mode-change:webgl-disabled"))}},[sn,_n,Mi,Rs,xr,yt,Oe]),P.useEffect(()=>{const $=R.current;$&&($.reset(),Zn(),W.current=null,Me.current="",ct.current=0,ie.current&&(ie.current.value=""),hr("session-reset",{skipScrollToBottom:!0}),yr.current&&(cn.current?$.focus():ie.current?.focus({preventScroll:!0})))},[e,$e,hr,Zn]),P.useEffect(()=>{if(!w||typeof document>"u")return;let $=null;const V=()=>{$=null;const re=ie.current;if(!re||document.activeElement!==re||De.current)return;const Ge=Me.current,He=ef(re.value);if(He!==Ge||He.includes("\r")||!hn())return;const ze=Math.min(Rx(re),Array.from(He).length),qe=ze-ct.current;if(qe===0)return;const Pt=R.current,ar=qe<0?(Pt?Fl(Pt,"D"):"\x1B[D").repeat(-qe):(Pt?Fl(Pt,"C"):"\x1B[C").repeat(qe);M.current(ar),ct.current=ze},z=()=>{$===null&&($=requestAnimationFrame(V))};return document.addEventListener("selectionchange",z),()=>{document.removeEventListener("selectionchange",z),$!==null&&cancelAnimationFrame($)}},[w,hn]),P.useEffect(()=>{if(!w)return;const $=Zi();return se.current=$,()=>{$(),se.current=null}},[w,Zi]),P.useEffect(()=>{const $=R.current;if($)try{$.options.scrollback=i?0:1e3}catch{}},[i,$e]),P.useEffect(()=>{const $=R.current;if(!$)return;if(t.length===0){_e.current!==null&&($.reset(),Zn(),hr("buffer-reset",{skipResizePush:!0,skipScrollToBottom:!0}));return}const V=_e.current;let z;if(V===null)z=t;else{const re=t.findIndex(Ge=>Ge.id===V);z=re>=0?t.slice(re+1):t}if(z.length>0){const re=z.map(qe=>qe.data).join(""),Ge=Fe.current+re,{cleaned:He,remainder:ze}=wR(Ge);Fe.current=ze,He&&Ro(He)}_e.current=t[t.length-1].id},[t,$e,Ro,hr,Zn]),P.useImperativeHandle(E,()=>({focus:()=>{if(cn.current){Ai();return}ie.current?.focus({preventScroll:!0})},blur:()=>{const $=ie.current;$&&typeof document<"u"&&document.activeElement===$&&$.blur(),cn.current&&$?.setAttribute("readonly",""),H.current?.(!1)},clear:()=>{const $=R.current;$&&($.reset(),Zn(),hr("clear",{skipResizePush:!0,skipScrollToBottom:!0}))},copySelectionOrViewport:async()=>{const $=R.current;if(!$)return!1;const V=$.hasSelection()?$.getSelection():MR($),z=await Hx(V);return z&&$.hasSelection()&&Dr(),z},pasteClipboardText:async()=>{gr();const $=await co(ie.current);return us.current?.($),$},sendSequence:($,V)=>{Pr($,null,V)},getDimensions:()=>{const $=R.current;return!$||!$.cols||!$.rows?null:{cols:$.cols,rows:$.rows}},requestRefresh:hr,setSessionReady:$=>{xs.current=$},notifyServerSize:Gn,ensureSizeMatches:Xi}),[w,Ai,Zn,co,Pr,hr,Gn,Xi]),c.jsxs("div",{ref:N,className:`relative h-full w-full terminal-viewport-container ${v||""}`,style:{backgroundColor:y.background,touchAction:be.visible?"none":void 0},role:"button",tabIndex:-1,onPointerDownCapture:oi,onPointerMoveCapture:Sn,onPointerUpCapture:ho,onPointerCancelCapture:ai,onTouchStartCapture:$=>{if(ii($.target)){gr(),yn(sd);return}Is(),yn(sd)},onTouchMoveCapture:()=>yn(sd),onTouchEndCapture:()=>yn(id),onTouchCancelCapture:()=>yn(id),onMouseDown:$=>{w||$.button===0&&(fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null),requestAnimationFrame(()=>{try{ie.current?.focus({preventScroll:!0})}catch{}}))},onMouseUp:$=>{w||$.button===0&&(fe.current!==null&&window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>{fe.current=null;try{ie.current?.focus({preventScroll:!0})}catch{}},0))},children:[ue&&c.jsxs("button",{type:"button","data-terminal-copy-popover":"true",className:"fixed z-chrome-hint inline-flex h-9 w-[88px] select-none items-center justify-center gap-1.5 rounded-full border border-white/15 bg-[rgb(28_28_30_/_0.92)] px-3 text-[13px] font-semibold text-white shadow-[0_10px_28px_rgb(0_0_0_/_0.32),0_2px_8px_rgb(0_0_0_/_0.18)] backdrop-blur-xl transition-transform duration-100 ease-out active:scale-[0.96]",style:{left:ue.left,top:ue.top,WebkitBackdropFilter:"blur(18px)"},onPointerDown:$=>{gr(),$.stopPropagation()},onPointerUp:$=>{$.preventDefault(),$.stopPropagation(),Lr()},onTouchStart:$=>{gr(),$.stopPropagation()},onTouchEnd:$=>{$.preventDefault(),$.stopPropagation(),Lr()},onClick:$=>{$.preventDefault(),$.stopPropagation(),Lr()},children:[c.jsx(M2,{size:14,strokeWidth:2.4}),c.jsx("span",{children:"Copy"})]}),It&&c.jsx(sR,{}),$t==="loading"&&!It&&c.jsx(nR,{}),$t==="error"&&c.jsx(iR,{message:St||void 0,onRetry:()=>{window.location.reload()}}),$t==="ready"&&c.jsxs(c.Fragment,{children:[c.jsx("textarea",{ref:ie,"aria-label":"Terminal input","data-terminal-input-anchor":"true",inputMode:"text",enterKeyHint:"enter",autoCapitalize:"off",autoComplete:"nope",autoCorrect:"off",spellCheck:!1,tabIndex:-1,style:{position:"absolute",opacity:0,zIndex:20,background:"transparent",color:"transparent",caretColor:"transparent",resize:"none",overflow:"hidden",border:"none",padding:0,margin:0,outline:"none",...w?{inset:0,touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",pointerEvents:"auto",fontSize:"16px"}:(()=>{const $=N.current?.getBoundingClientRect(),V=Math.round(($?.left??0)+at.x),z=Math.round(($?.top??0)+at.y),re={position:"fixed",left:V,top:z,pointerEvents:"none",touchAction:"auto",fontSize:`${Ct}px`,fontFamily:et,lineHeight:"1",whiteSpace:"pre",boxSizing:"content-box",width:Math.max(1,Math.round(at.cellW)),height:Math.max(1,Math.round(at.cellH))};if(!mt.active)return re;const Ge=Hn(mt.text);return{...re,opacity:1,color:y.foreground,background:y.background,caretColor:y.cursor||y.foreground,textDecorationLine:"underline",textDecorationStyle:"solid",textDecorationColor:y.foreground,wordBreak:"break-all",zIndex:21,width:Ge.width,height:Ge.height,whiteSpace:Ge.whiteSpace}})()},onContextMenu:$=>{$.preventDefault()},onFocus:()=>{Oe("input anchor focus"),hr("focus",{skipResizePush:!0,skipScrollToBottom:!0}),H.current?.(!0)},onBlur:()=>{const $=rs(),V=typeof document<"u"?document.activeElement:null;if(Oe("input anchor blur",{guarded:$,activeTag:V?.tagName??null,activeClass:V?.className??null}),hr("blur",{skipResizePush:!0,skipScrollToBottom:!0}),!$){w&&ie.current?.setAttribute("readonly",""),H.current?.(!1);return}if(typeof window>"u"){H.current?.(!1);return}window.setTimeout(()=>{Fr()||hn()||(w&&ie.current?.setAttribute("readonly",""),H.current?.(!1))},id)},onBeforeInput:$=>{if(De.current)return;const V=$.nativeEvent;if(V instanceof InputEvent){if(V.inputType==="insertLineBreak"){if(ke.current){ke.current=!1,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),$.preventDefault();return}$.preventDefault(),Jr($.currentTarget);return}if(V.inputType==="deleteContentBackward"||V.inputType==="deleteContentForward"||V.inputType==="deleteByCut"){if(!$.currentTarget.value){$.preventDefault(),M.current("");return}if(V.inputType==="deleteContentBackward"&&$.currentTarget.selectionStart===0&&$.currentTarget.selectionEnd===0){$.preventDefault(),M.current("");return}return}}},onInput:$=>{De.current||Xr($.currentTarget)},onPaste:$=>{const V=$.clipboardData.getData("text/plain");if(!V)return;$.preventDefault();const z=fn(V,$.currentTarget);w&&us.current?.(z)},onKeyDown:$=>{const V=yR($);if(!w){const z=R.current,re=$.metaKey,Ge=$.ctrlKey,He=$.altKey,ze=$.shiftKey,qe=$.key;if(re&&!Ge&&!He&&!ze&&qe==="Enter"){$.preventDefault(),Jr($.currentTarget);return}if((re||Ge)&&!He&&!ze&&(qe==="v"||qe==="V")){$.preventDefault(),co($.currentTarget);return}if(re&&!Ge&&!He&&!ze&&(qe==="c"||qe==="C")){$.preventDefault();const Pt=z?.hasSelection()?z.getSelection():"";Pt&&navigator.clipboard?.writeText(Pt).catch(()=>{});return}if((re||Ge)&&!He&&!ze&&(qe==="k"||qe==="K")){$.preventDefault(),z&&(z.reset(),Zn(),hr("clear",{skipResizePush:!0,skipScrollToBottom:!0})),$.currentTarget.value="",Me.current="",ct.current=0;return}if(re&&!Ge&&!He&&!ze&&qe==="Backspace"){$.preventDefault(),Pr("",$.currentTarget);return}if(re&&!Ge&&!He&&!ze&&qe==="Delete"){$.preventDefault(),Pr("\v",$.currentTarget);return}if(re&&!Ge&&!He&&!ze&&qe==="ArrowLeft"){$.preventDefault(),Pr("",$.currentTarget);return}if(re&&!Ge&&!He&&!ze&&qe==="ArrowRight"){$.preventDefault(),Pr("",$.currentTarget);return}if(re)return;if(Ge&&!He&&!ze&&qe===" "){$.preventDefault(),Pr("\0",$.currentTarget);return}if(Ge&&!He&&!re&&qe.length===1){const Pt=qe.toLowerCase().charCodeAt(0);if(Pt>=64&&Pt<=127){$.preventDefault(),Pr(String.fromCharCode(Pt&31),$.currentTarget);return}}if(He&&!Ge&&!re&&!ze&&qe==="Backspace"){$.preventDefault(),Pr("\x1B",$.currentTarget);return}if(He&&!Ge&&!re&&!ze&&qe==="Delete"){$.preventDefault(),Pr("\x1Bd",$.currentTarget);return}if(He&&!Ge&&!re&&!ze&&qe==="ArrowLeft"){$.preventDefault(),Pr("\x1Bb",$.currentTarget);return}if(He&&!Ge&&!re&&!ze&&qe==="ArrowRight"){$.preventDefault(),Pr("\x1Bf",$.currentTarget);return}if(He&&!Ge&&!re&&qe.length===1){$.preventDefault(),Pr(`\x1B${qe}`,$.currentTarget);return}if(V||De.current)return;if(z){const Pt=xR($,z);if(Pt!==null){$.preventDefault(),Pr(Pt,$.currentTarget);return}}}if($.key==="Enter"||$.key==="Go"||$.key==="done"||$.key==="send"){if(V||De.current){$.preventDefault();return}if(ke.current){ke.current=!1,ge.current!==null&&(clearTimeout(ge.current),ge.current=null),$.preventDefault();return}$.preventDefault(),Jr($.currentTarget);return}if($.key==="Backspace"){if(De.current)return;if(!$.currentTarget.value){$.preventDefault(),M.current("");return}if($.currentTarget.selectionStart===0&&$.currentTarget.selectionEnd===0){$.preventDefault(),M.current("");return}}},onCompositionStart:()=>{De.current=!0,Mo(),Ze({active:!0,text:""})},onCompositionUpdate:$=>{De.current=!0;const V=$.data??$.currentTarget.value;Ze(z=>z.active&&z.text===V?z:{active:!0,text:V})},onCompositionEnd:$=>{De.current=!1,ke.current=!0,ge.current!==null&&clearTimeout(ge.current),ge.current=setTimeout(()=>{ke.current=!1,ge.current=null},50),Ze({active:!1,text:""}),Xr($.currentTarget),si()}}),c.jsx("div",{"aria-hidden":!0,className:`absolute left-1/2 -translate-x-1/2 top-6 z-30 pointer-events-none
|
|
70
70
|
rounded-full bg-[var(--surface-elevated)] px-4 py-1.5 text-sm font-semibold text-foreground
|
|
71
|
-
shadow-lg transition-all duration-150 ease-out`,style:{opacity:Re?1:0,transform:Re?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),c.jsx("div",{ref:rr,"aria-hidden":!0,className:"fixed left-1/2 top-6 z-chrome-hint pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:be.visible?1:0,transform:be.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:be.visible&&(()=>{const{activeDir:$}=be,V=z=>$===z;return c.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),c.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:c.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});Hw.displayName="TerminalViewport";const NR=Hw,DR={background:"#1C1B1A",foreground:"#CECDC3",cursor:"#CECDC3",cursorAccent:"#1C1B1A",selectionBackground:"#403E3C",selectionForeground:"#CECDC3",selectionInactiveBackground:"#403E3C50",black:"#6F6E69",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#CECDC3",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#FFFCF0"},BR={background:"#FFFCF0",foreground:"#100F0F",cursor:"#100F0F",cursorAccent:"#FFFCF0",selectionBackground:"#CECDC3",selectionForeground:"#100F0F",selectionInactiveBackground:"#CECDC350",black:"#100F0F",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#575653",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#100F0F"};function PR(e){return e==="light"?BR:DR}const H2=new Set(["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"]);function Ol(e){if(!e)return null;if(e==="/")return"/";const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function Bf(e,t,r,n=H2,s=null,i=null){if(e.customName)return{primary:e.name,secondary:Ol(r)};if(s){const u=Ol(r),d=s===r||s===u;if(i!=="idle"&&!n.has(s)&&!d)return{primary:s,secondary:u}}if(t&&!n.has(t))return{primary:t,secondary:Ol(r)};const a=Ol(r);return a?{primary:a,secondary:null}:{primary:e.name,secondary:null}}function jR(e,t,r,n=H2,s=null,i=null){return Bf(e,t,r,n,s,i).primary}function U2(e,t,r){const n=[],s=new Map;for(const i of e){const a=t(i),u=a&&a.trim().length>0?a:"";let d=s.get(u);d||(d={key:u,label:u?Ol(u)??u:r,sessions:[]},s.set(u,d),n.push(d)),d.sessions.push(i)}return n.sort((i,a)=>(i.key===""?1:0)-(a.key===""?1:0))}function QR(e){return e&&e.trim().length>0?e:""}function Uw(e,t,r){const n=[...e],[s]=n.splice(t,1);return s?(n.splice(r,0,s),n.flatMap(i=>i.sessions.map(a=>a.id))):e.flatMap(i=>i.sessions.map(a=>a.id))}function Gw(e,t,r,n){return e.flatMap(s=>{if(s.key!==t)return s.sessions.map(u=>u.id);const i=s.sessions.map(u=>u.id),[a]=i.splice(r,1);return a===void 0?s.sessions.map(u=>u.id):(i.splice(n,0,a),i)})}function zw(e,t,r,n){if(!r)return{arranged:e,groups:[]};const s=U2(e,t,n);return{arranged:s.flatMap(a=>a.sessions),groups:s}}function FR(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}const OR=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},$R=()=>({async createSession(e){return FC(e)},connect(e,t,r){const n=OC(e,t.onEvent,t.onError,OR(r));return{close:()=>n()}},async sendInput(e,t){await $C(e,t)},async resize(e){await GC(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await Q6(e)},async restartSession(e,t){return WC(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await qC(e)},async tmuxAction(e,t){return zC(e,t)},async listTmuxSessions(){return y1()},async getTmuxStatus(){return v1()},async checkHealth(e){return VC(e)}}),HR={app:{name:"Termdock"},common:{cancel:"Cancel",close:"Close",save:"Save",reset:"Reset",loading:"Loading…",error:"Error",retry:"Retry",refresh:"Refresh",search:"Search",clear:"Clear",delete:"Delete",on:"On",off:"Off",back:"Back",copy:"Copy",decrease:"Decrease",increase:"Increase"},login:{prompt:"termdock login",placeholder:"Enter password",placeholderBlocked:({s:e})=>`Please wait ${e}s`,submit:"Sign in",invalidPassword:"Incorrect password",failed:"Login failed"},sidebar:{sessions:"Sessions",noSessions:"No open sessions yet.",noMatchingSessions:"No matching sessions.",toggleSearch:"Toggle search",settings:"Settings",filterSessions:"Filter sessions",clearSearch:"Clear search",sortRecent:"Recent activity first",sortRecentTitle:"Sort sessions by latest terminal output. Manual drag order is restored when off.",groupByFolder:"Group by folder",groupByFolderTitle:"Collapse sessions into groups by working directory. Mutually exclusive with drag sorting.",ungrouped:"Other",needsAttention:"Needs attention",closeSession:({name:e})=>`Close ${e}`,newShell:"Shell",newTmux:"Tmux",newTmuxDisabled:"tmux not available on server",confirmNewShell:"Create Shell?",confirmNewTmux:"Create Tmux?"},rightSidebar:{workspace:"Workspace",currentProject:"Project",browsingLocation:"Browsing",parentFolder:"Parent folder",backToProjectRoot:"Back to project",refreshFiles:"Refresh current folder",resizeFileTree:"Drag to resize file browser",pinCurrentFolder:"Pin current folder to this project",unpinCurrentFolder:"Unpin current folder",showHiddenFiles:"Show hidden files",hideHiddenFiles:"Hide hidden files",insertCurrentFolder:"Insert current folder reference",insertCurrentFolderShort:"Insert",pinnedFolders:"Pinned",unpinFolder:({name:e})=>`Unpin ${e}`,fileWatchUnavailable:({message:e})=>`File watcher unavailable: ${e}. Click to refresh manually.`,browsingOutsideProject:"Browsing outside current project",browsingOutsideProjectHint:"Git and Changes still use the current project. File references from here are inserted as external paths.",toggleSearch:"Toggle search",refreshGit:"Refresh Git status",close:"Close",filterChanges:"Filter changes or files",searchPlaceholderContent:"Search text in files…",searchModeName:"Name",searchModeContent:"Content",clearSearch:"Clear search",insertGitContext:"Insert current Git context into terminal",copyGitContext:"Copy Git context",insertChangeAuditPrompt:"Explain changes",insertChangeAuditPromptTitle:"Insert the change audit prompt into the current session",changeAuditShort:"Explain changes",changeAuditLoading:"Loading hunk explanations…",changeAuditLoaded:({count:e})=>`${e} hunk explanation${e===1?"":"s"} loaded`,changeAuditLoadedAt:({time:e})=>`Generated ${e}`,changeAuditRegenerate:"Regenerate",changeAuditRefreshStale:"Fill stale",changeAuditRefreshStaleTitle:"Insert a prompt to refresh stale hunk explanations",clearChangeAudit:"Clear",clearChangeAuditTitle:"Clear hunk explanations for the current repository",changeAuditClearFailed:({message:e})=>`Failed to clear hunk explanations: ${e}`,changeAuditScopeAll:"All repositories",changeAuditScopeLabel:"Explain scope",branchAuditTitle:"Branch explanation",branchAuditShort:"Explain branch changes",branchAuditBaseLabel:"Base branch",branchAuditBasePlaceholder:"Base branch, e.g. master",branchAuditBaseSearchPlaceholder:"Search base branch",branchAuditBaseEmpty:"No branch options. Type a branch name directly.",branchAuditGenerate:"Generate",branchAuditRegenerate:"Regenerate",branchAuditGenerateTitle:"Insert a prompt to explain this branch against the base branch",branchAuditViewDiff:"View diff",branchAuditViewDiffTitle:"View target branch changes against the base branch",branchAuditDiffLoading:"Loading branch diff...",branchAuditDiffEmpty:"No changes between this branch and the base branch.",branchAuditMissingBase:({repo:e})=>`${e} has no base branch set`,branchAuditRefreshDiff:"Refresh diff",branchAuditRefreshStale:"Fill stale",branchAuditRefreshStaleTitle:"Insert a prompt to refresh stale branch explanations",branchAuditClearTitle:"Clear current branch explanation",branchAuditClearFailed:({message:e})=>`Failed to clear branch explanation: ${e}`,branchAuditCommitCount:({count:e})=>`${e} commit${e===1?"":"s"}`,branchAuditFileCount:({count:e})=>`${e} file${e===1?"":"s"}`,branchAuditTruncated:"diff truncated",branchAuditCurrent:"Saved explanation",branchAuditStale:"Explanation is stale",branchAuditEmpty:"No branch explanation yet. Generate one to persist it here for later review.",branchAuditView:"View explanations",branchAuditSaved:({count:e})=>`${e} hunk explanation${e===1?"":"s"} saved`,branchAuditGeneratedAt:({time:e})=>`Generated ${e}`,insertPreset:({label:e})=>`Insert: ${e}`,tabChanges:"Changes",tabGit:"Git",tabFiles:"Files",tabPreview:"Preview",inserted:"Inserted",copied:"Copied",selectFilePrompt:"Select a file to preview its contents",backToFileList:"Back to file list",insertLineRef:({lineLabel:e})=>`Insert ${e}`,insertFileRef:"Insert",copyFileRef:"Copy file reference",downloadFile:"Download file",downloadFailed:"Download failed",uploadFile:"Upload file",uploadFiles:"Upload files",dropToUpload:"Drop files to upload",uploading:"Uploading…",uploadSuccess:({count:e})=>`${e} file${e===1?"":"s"} uploaded`,uploadFailed:"Upload failed",binaryPreviewHint:"Binary files cannot be previewed. Use the download button above to save it.",selectedLineHint:({lineLabel:e})=>`Selected ${e} · tap "Insert" below to add to terminal`,multiLineHint:"Multi-line select: tap start line, then end line",loadingImage:"Loading image…",imagePreviewHint:"Pinch or ⌘/Ctrl + scroll to zoom · double-tap to reset",imageLoadFailed:"Failed to load image preview",markdownPreview:"Preview",markdownSource:"Source",markdownPreviewHint:"Markdown preview · switch to Source to select lines",markdownOutline:"Markdown outline",markdownOutlineShort:"Outline",closeMarkdownOutline:"Close outline",changedFromPath:({path:e})=>`from ${e}`,selectedLineFooter:({lineLabel:e})=>`Selected ${e}`,clearSelection:"Clear",allChanges:"All changes",backToChangeList:"Back to list",allRepositories:"All repositories",allRepositoriesShort:"All",repositories:"Repositories",gitRepositorySectionTitle:"Repository",gitRepositoryLabel:"Repository",gitRepositoryPlaceholder:"Select repository",gitRepositorySearchPlaceholder:"Search repositories",gitRepositoryEmpty:"No available repositories",selectRepositoryForGitActions:"Select a repository before running Git actions",selectRepositoryForDiff:"Select a repository or file to view diff",repoChangedCount:({count:e})=>`${e} change${e===1?"":"s"}`,repoStagedCount:({count:e})=>`${e} staged`,noChanges:"No changes",noMatchingChanges:"No matching changes",loadingGitChanges:"Loading Git changes…",loadingGitChangesSlow:"Large repositories can take a few seconds.",refreshingGitChanges:"Refreshing Git changes…",gitChangesLoadFailed:"Unable to load Git changes",retryGitChanges:"Retry",insertThisFile:"Insert this file reference into terminal",viewDiff:"View diff",diffViewMode:"Change file display mode",diffViewModeList:"Flat list",diffViewModeTree:"Folder tree",diffViewModeAi:"AI walkthrough",changeWalkthroughEmpty:"No AI walkthrough yet. Generate explanations to show the overview, flow, and checks here.",gitInfo:"Git context",wrapLongLines:"Wrap long lines",wrapOn:"Wrapped",wrapOff:"Raw",horizontalScrollHint:"Swipe left/right to see the full diff",stageFile:"Stage",stageAll:"Stage all",unstageFile:"Unstage",stashFile:"Stash",stashAll:"Stash all",restoreFile:"Restore",gitQuickActions:"Git Actions",gitUnavailable:"Current directory is not a Git repository",branchSectionTitle:"Current branch",currentBranchLabel:"Branch",switchBranchPlaceholder:"Select branch",switchBranchSearchPlaceholder:"Search local branch",switchNoBranches:"No local branches",switchBranch:"Switch",noStagedChangesShort:"no staged",stagedCount:({count:e})=>`${e} staged`,stagedCountShort:({count:e})=>`${e} staged`,commitSectionTitle:"Commit",commitReadyHint:({count:e})=>`${e} file${e===1?"":"s"} ready`,commitMessagePlaceholder:"Commit message",commitChanges:"Commit",commitNeedsStaged:"Stage changes before committing",recentCommitsTitle:"Recent commits",recentCommitsSearchPlaceholder:"Search commit hash or message",recentCommitsLoadMore:"Load more commits",recentCommitsEmpty:"No commit history",pushSectionTitle:"Remote sync",pushRemoteLabel:"Remote",pushRemotePlaceholder:"origin",pushRemoteSearchPlaceholder:"Search remote",pushNoRemotes:"No remotes",pushBranchLabel:"Target",pushBranchPlaceholder:({branch:e})=>`${e}`,pushBranchSearchPlaceholder:"Search branch",pushNoBranches:"No branches",pushUpstreamBadge:"upstream",pushCurrentBranchBadge:"current",pushNoUpstream:"No upstream configured",pushUpToDate:"Up to date with remote",pushAheadCount:({count:e})=>`${e} commit${e===1?"":"s"} to push`,pushBehindCount:({count:e})=>`${e} commit${e===1?"":"s"} to pull`,pushDivergedCount:({ahead:e,behind:t})=>`${e} ahead / ${t} behind`,pullChanges:"Pull",pushChanges:"Push",gitActionRunning:"Running…",gitActionFailed:({message:e})=>`Git action failed: ${e}`,confirmRestoreTitle:"Discard changes?",confirmRestoreDescription:({path:e})=>`This will discard unstaged changes in ${e}. Termdock cannot recover them.`,confirmRestorePhrase:"discard changes",confirmRestorePlaceholder:"Type “discard changes” to confirm",confirmStashAllTitle:"Stash all changes?",confirmStashAllDescription:"This moves current working tree changes, including untracked files, into a stash.",confirmAction:"Confirm"},fileTree:{insertRef:"Insert",insertRefTitle:"Insert file reference into active terminal",openDirRoot:"Open",openDirRootTitle:"Use this folder as the current browsing root",openInFileBrowser:"Reveal in Finder",openInFileBrowserTitle:"Open this item in the system file browser",openInFileBrowserFailed:"Failed to open file browser",moreDirActions:"More folder actions",pinDir:"Pin",pinDirTitle:"Pin this folder to the current project",unpinDir:"Pinned",unpinDirTitle:"Unpin this folder",pinFileTitle:"Pin this file to the current project",unpinFileTitle:"Unpin this file",pinFile:"Pin",unpinFile:"Unpin",moreFileActions:"More file actions",noWorkingDir:"No working directory detected.",emptyDir:"Empty directory.",noMatchingFiles:"No matching files.",searching:"Searching files…",searchingWithCount:({count:e})=>`Searching… ${e} found`,searchResults:({count:e})=>`${e} results`,searchTruncatedHint:({count:e})=>`Fallback search scanned a large directory and stopped after ${e} matches. Install ripgrep or refine the query for complete results.`,searchStillRunning:"Search is still running. More results will appear automatically.",showingSearchResults:({shown:e,total:t})=>`Showing ${e} of ${t}`,loadMoreSearchResults:({shown:e,total:t})=>`Show more (${e}/${t})`,contentMatchesCount:({count:e})=>`${e} file${e===1?"":"s"} with matches`,moreMatches:({count:e})=>`+${e} more match${e===1?"":"es"}`,noContentMatches:"No matches found in file contents.",contentSearchNeedsRipgrep:"Content search requires ripgrep (rg). Install it on the server to search inside files.",truncatedHint:"Showing first 1000 entries. Use search or open a smaller folder for better performance.",dropToUploadHere:"Upload here"},diffViewer:{noFileChanges:"No changes in this file.",noUnstagedChanges:"No unstaged changes.",emptyHint:"Make some changes, or pull from a remote.",loading:"Loading diff…",insertAllDiff:"Insert current diff as context",insertFileDiff:"Insert this file's diff",insertHunkDiff:"Insert this hunk",insertHunkShort:"Insert",insertFileShort:"Insert",insertAllShort:"Insert all",auditExplanation:"Change meaning",auditStale:"Explanation stale",auditClear:"Clear explanation",auditGeneratedAt:({time:e})=>`Generated ${e}`,allDiffLabel:"all changes",allChangesLabel:"all changes",workingTree:"Working tree changes",allUnstaged:"All unstaged changes",binaryOrEmpty:"No textual changes to display.",noHunks:"No hunks",hunkOutline:"Hunks",expandHunkRail:"Show hunk list",collapseHunkRail:"Hide hunk list",prevHunk:"Previous hunk",nextHunk:"Next hunk",prevFile:"Previous",nextFile:"Next",expandFile:"Expand file",collapseFile:"Collapse file",expandAll:"Expand all",collapseAll:"Collapse all",collapseHunk:"Collapse hunk",useBracketKeysHint:"Press [ / ] to jump between hunks",unified:"Unified",unifiedMode:"Unified view",split:"Split",splitMode:"Side-by-side view",moreActions:"More actions",view:"View"},settings:{title:"Settings",font:"Font",render:"Render",theme:"Theme",darkTheme:"Dark",lightTheme:"Light",newTab:"New tab",debug:"Debug",noSleep:"No sleep",noSleepUnavailable:"No network — disabled",notifications:"Notify",notificationsTitle:"Notification settings",notificationsHint:"Notify when an AI task finishes while Termdock is hidden.",notificationsPageHint:"Choose which Termdock events can send system notifications. The master switch controls browser permission and delivery; event switches decide what should notify you.",notificationsMaster:"System notifications",notificationsMasterHint:"Allow Termdock to send notifications when it is hidden or running as an installed PWA.",notificationsPermission:"Permission",notificationsTest:"Send test",notificationsAlertStyle:"Alert style",notificationsAlertStyleHint:"Browsers and Android still decide the final heads-up behavior. Termdock can only request quiet/default/sticky notification options.",notificationsStyleNormal:"Default",notificationsStyleNormalHint:"Sound/vibration if allowed",notificationsStyleQuiet:"Quiet",notificationsStyleQuietHint:"Status tray, no sound",notificationsStylePersistent:"Sticky",notificationsStylePersistentHint:"Stay until dismissed",notificationsEvents:"Events",notificationsAiFinished:"AI task finished",notificationsAiFinishedHint:"Notify when an AI agent stops while Termdock is in the background.",notificationsFutureHint:"More notification types can be added here later without changing the top-level settings layout.",notificationsOffSummary:"System notifications disabled",notificationsAiOnSummary:"AI task finished enabled",notificationsNoEventsSummary:"No notification events enabled",notificationsDenied:"Browser notification permission is blocked. Enable it in site settings.",notificationsUnsupported:"Notifications require a secure context and service worker support.",notificationsTestBody:"Notifications are enabled. You will be notified when an AI task finishes in the background.",shell:"Shell",tmux:"Tmux",auto:"Auto",webgl:"WebGL",canvas:"Built-in",tmuxServer:"Tmux server",tmuxUnavailable:"unavailable",noTmuxSessions:"No tmux sessions on the server.",installTmuxHint:"Install tmux on the server to enable.",refresh:"Refresh",attached:"Attached",restorable:"Restorable",attach:"Attach",attaching:"Attaching…",destroy:"Destroy",sessions:({n:e})=>`${e} session${e===1?"":"s"}`,windows:({n:e})=>`${e} window${e===1?"":"s"}`,keyboardToolbar:"Keyboard toolbar",aiAgentDetection:"AI agent detection",signOut:"Sign out",language:"Language",programNamePlaceholder:"Program name (e.g. claude)",patternPlaceholder:"Regex pattern (e.g. Thinking|Generating)",statusPlaceholder:"Status",addProgram:"Add program",addPattern:"Add pattern",resetDefaults:"Reset defaults",invalidRegex:"Invalid regex",removeProgram:"Remove program",removeRule:"Remove rule",keepLabel:"keep",customColor:"Custom color",tabIndicator:"Tab indicator style",toolbarPresets:"Toolbar presets",detectionRules:"Detection rules",agentHooksHint:"With hooks installed, agents report their own status: working (green), waiting for you (amber), turn done (check) — and you get a notification the moment one needs your input. Hooks install globally but only fire inside termdock terminals.",agentHooksInstall:"Install",agentHooksInstalled:"Installed",agentHooksOutdated:"Outdated",agentHooksNotInstalled:"Not installed",agentHooksUninstall:"Uninstall",agentHooksReinstall:"Reinstall",agentHooksDevMode:"Dev mode: hooks point at TS sources and need a built install to fire",agentHooksTarget:"writes to",agentPlugins:"Agent Plugins",agentPluginAdd:"Add Plugin",agentPluginHint:"Define custom agents with their own hooks config. Paste a manifest.json below to register a new agent and optionally install hooks for it.",agentPluginCreate:"Create Plugin",agentPluginDelete:"Delete Plugin",mobileKeyboard:"Mobile keyboard",saving:"Saving…",rulesHint:"Configure regex patterns to detect what an AI tool is doing in a terminal tab. Each rule can choose its label, color, icon style and how long the indicator is kept after output quiets down. When it stops and you haven't viewed the tab yet, the tab keeps a yellow review hint.",programsHelp:"Supports multiple programs in one config. Separate with commas.",programLabelResolution:"Program label resolution",rawCommandMapping:"Raw command mapping",rawCommandMappingHint:"Rules below map the raw command line to the tab display label. User rules run before built-ins.",genericProgramNames:"Generic program names",genericProgramNamesHint:"Trigger ps-based deep detection (e.g. node, python)",wrapperScriptNames:"Wrapper script names",wrapperScriptNamesHint:"CLI wrappers that launch another tool (e.g. aiden, npx)",shellNamesConfig:"Shell names",shellNamesHint:"Filtered out from tab display (e.g. bash, zsh)",addTag:"+ add",customRules:"Custom rules",addRule:"Add rule",localAccess:"Local access",localAccessHint:"Use this LAN URL from your phone after trusting the local CA. Open Mobile setup on your phone to download the CA certificate.",resetAutoName:"Reset auto",onboardingUrl:"Mobile setup",httpsActive:"HTTPS active",httpsInactive:"HTTPS inactive",caMissing:"CA download unavailable"},toolbarPresets:{preview:"Preview",presets:"Presets",label:"Label",new:"New",reset:"Reset",presetLabelPlaceholder:"Preset label",deletePreset:({name:e})=>`Delete preset ${e}`,matchPrograms:"Match programs",typeEnterHint:"Type & Enter",programsPlaceholder:"vim, nvim, /^claude(-code)?$/i …",programsHelp:"Plain names match as case-insensitive substrings. Wrap in /…/flags for regex (tested against the lowercase program name).",altSlot:"Alt modifier slot",altSlotHint:"Reserve one preview slot for the Alt key.",desktopVisibility:"Show on desktop",desktopVisibilityHint:"Desktop shows only this preset’s custom actions, not the basic keyboard shortcuts.",rowLayout:"Row layout",rowLayoutHint:"Buttons per expanded row.",addRow:"Row",rowN:({n:e})=>`Row ${e}`,del:"Del",buttons:"Buttons",buttonsHint:"Tap to edit. Use ↑↓ to reorder.",addButton:"Add button",noCustomButtons:"No custom buttons yet. Add one to override the default toolbar.",moveUp:"Move up",moveDown:"Move down",removeRow:({n:e})=>`Remove row ${e}`,removeAction:({name:e})=>`Remove ${e}`,labelField:"Label",labelPlaceholder:"Label shown on the button",sequence:"Sequence",sequencePlaceholder:"e.g. /undo or \\t or /||undo",sequenceHint:"Double-tap sequence",doubleTap:"Double-tap sequence",doubleTapAdd:"+ Add",doubleTapPlaceholder:"e.g. /undo\\r or /||undo ||\\r",remove:"Remove",noSequence:"No sequence",preset:"Preset",overCapacityHint:"More buttons than slots. Extra rows will use the last row size."},agentRules:{ruleColors:{green:"Green",yellow:"Yellow",red:"Red",blue:"Blue",purple:"Purple",orange:"Orange",gray:"Gray"}},tab:{session:"Session",new:"New session",rename:"Rename",renameHint:"Change the tab display name",renamePlaceholder:"Leave empty to reset to default",copyCwd:"Copy cwd",copyCwdHint:"Copy the current working directory",resumeAgent:"Resume agent session",resumeAgentHint:"Resume the last conversation by its native session id",copied:"Copied",close:"Close session",closeHint:"Remove this tab from the list",longPressTip:"Tip: hold a tab still for a moment to open actions; hold and drag to reorder.",sessionsTitle:"Sessions",explorerTitle:"Explorer"},agent:{aiRunning:"AI running",needsReview:"Needs review",finishedReview:"AI finished — needs review",aiWaiting:"AI waiting",copyMode:"Copy mode",jumpToNext:"Jump to next session needing attention"},connection:{reconnecting:"Reconnecting…"},terminal:{input:"Terminal input",error:"Error",dropFilesToPastePaths:"Drop files to paste paths"},errorBoundary:{title:"Something went wrong",unexpected:"An unexpected error occurred",retry:"Try Again"},error:{type:{network:"Network error",session:"Session error",terminal:"Terminal error",auth:"Authentication error",validation:"Validation error",unknown:"Unknown error"},severity:{low:"Notice: ",medium:"Warning: ",high:"Error: ",critical:"Critical: "},suggestion:{networkCheck:"Check your network connection",networkRetry:"Try reconnecting",networkProxy:"Check proxy settings",networkWait:"Wait for the network to recover",sessionRecreate:"Recreate the session",sessionServer:"Check the server status",sessionCache:"Clear your browser cache",terminalRestart:"Restart the terminal",terminalConfig:"Check the terminal configuration",terminalClear:"Clear the terminal output",authRelogin:"Sign in again",authCredentials:"Check your credentials",authAdmin:"Contact the administrator",validationFormat:"Check the input format",validationParams:"Verify your parameters",validationDocs:"See the documentation",unknownReload:"Reload the page",unknownApp:"Restart the app",unknownSupport:"Contact support"}}},UR={app:{name:"Termdock"},common:{cancel:"取消",close:"关闭",save:"保存",reset:"重置",loading:"加载中…",error:"错误",retry:"重试",refresh:"刷新",search:"搜索",clear:"清除",delete:"删除",on:"开",off:"关",back:"返回",copy:"复制",decrease:"减少",increase:"增加"},login:{prompt:"termdock login",placeholder:"请输入密码",placeholderBlocked:({s:e})=>`请稍候 ${e}s`,submit:"登录",invalidPassword:"密码错误",failed:"登录失败"},sidebar:{sessions:"会话",noSessions:"暂无打开的会话。",noMatchingSessions:"没有匹配的会话。",toggleSearch:"切换搜索",settings:"设置",filterSessions:"过滤会话",clearSearch:"清除搜索",sortRecent:"最近活跃优先",sortRecentTitle:"按最近一次 Terminal 输出排序;关闭后恢复手动拖拽顺序。",groupByFolder:"按文件夹分组",groupByFolderTitle:"按工作目录把会话归组折叠;与拖拽排序互斥。",ungrouped:"其他",needsAttention:"待处理",closeSession:({name:e})=>`关闭 ${e}`,newShell:"Shell",newTmux:"Tmux",newTmuxDisabled:"服务端未安装 tmux",confirmNewShell:"创建 Shell?",confirmNewTmux:"创建 Tmux?"},rightSidebar:{workspace:"工作区",currentProject:"项目",browsingLocation:"浏览中",parentFolder:"上一级目录",backToProjectRoot:"回到当前项目",refreshFiles:"刷新当前目录",resizeFileTree:"拖动调整文件目录宽度",pinCurrentFolder:"固定当前目录到这个项目",unpinCurrentFolder:"取消固定当前目录",showHiddenFiles:"显示隐藏文件",hideHiddenFiles:"不显示隐藏文件",insertCurrentFolder:"引用当前目录",insertCurrentFolderShort:"引用",pinnedFolders:"固定",unpinFolder:({name:e})=>`取消固定 ${e}`,fileWatchUnavailable:({message:e})=>`文件监听不可用:${e}。可点击手动刷新。`,browsingOutsideProject:"正在浏览当前项目外目录",browsingOutsideProjectHint:"Git 和改动仍使用当前项目;这里引用的文件会按外部路径插入。",toggleSearch:"切换搜索",refreshGit:"刷新 Git 状态",close:"关闭",filterChanges:"过滤改动或文件",searchPlaceholderContent:"在文件内容中搜索…",searchModeName:"名称",searchModeContent:"内容",clearSearch:"清除搜索",insertGitContext:"把当前 Git 信息插入 Terminal",copyGitContext:"复制 Git 信息",insertChangeAuditPrompt:"解释当前改动",insertChangeAuditPromptTitle:"把更改审计提示词插入当前会话",changeAuditShort:"解释当前改动",changeAuditLoading:"正在加载 hunk 解释…",changeAuditLoaded:({count:e})=>`已加载 ${e} 条 hunk 解释`,changeAuditLoadedAt:({time:e})=>`最近生成 ${e}`,changeAuditRegenerate:"重新生成",changeAuditRefreshStale:"补充失效",changeAuditRefreshStaleTitle:"为已失效的 hunk 解释插入补充生成提示词",clearChangeAudit:"清理",clearChangeAuditTitle:"清理当前仓库的 hunk 解释",changeAuditClearFailed:({message:e})=>`清理 hunk 解释失败:${e}`,changeAuditScopeAll:"全部仓库",changeAuditScopeLabel:"解释范围",branchAuditTitle:"分支解释",branchAuditShort:"解释分支改动",branchAuditBaseLabel:"基线分支",branchAuditBasePlaceholder:"基线分支,例如 master",branchAuditBaseSearchPlaceholder:"搜索基线分支",branchAuditBaseEmpty:"没有可选分支,可直接输入分支名",branchAuditGenerate:"生成解释",branchAuditRegenerate:"重新生成",branchAuditGenerateTitle:"生成当前分支相对于基线分支的解释提示词",branchAuditViewDiff:"查看对比",branchAuditViewDiffTitle:"查看目标分支相对于基线分支的改动",branchAuditDiffLoading:"正在加载分支对比…",branchAuditDiffEmpty:"当前分支相对于基线分支暂无改动。",branchAuditMissingBase:({repo:e})=>`${e} 未设置基线分支`,branchAuditRefreshDiff:"刷新对比",branchAuditRefreshStale:"补充失效",branchAuditRefreshStaleTitle:"为已失效的分支解释插入补充生成提示词",branchAuditClearTitle:"清理当前分支解释",branchAuditClearFailed:({message:e})=>`清理分支解释失败:${e}`,branchAuditCommitCount:({count:e})=>`${e} 个提交`,branchAuditFileCount:({count:e})=>`${e} 个文件`,branchAuditTruncated:"diff 已截断",branchAuditCurrent:"已保存解释",branchAuditStale:"解释已失效",branchAuditEmpty:"暂无分支解释。生成后会持久化保存,可随时回来查看。",branchAuditView:"查看解释",branchAuditSaved:({count:e})=>`已保存 ${e} 条 hunk 解释`,branchAuditGeneratedAt:({time:e})=>`生成于 ${e}`,insertPreset:({label:e})=>`插入:${e}`,tabChanges:"改动",tabGit:"Git",tabFiles:"文件",tabPreview:"预览",inserted:"已插入",copied:"已复制",selectFilePrompt:"选择文件以预览内容",backToFileList:"返回文件列表",insertLineRef:({lineLabel:e})=>`引用${e}`,insertFileRef:"引用",copyFileRef:"复制文件引用",downloadFile:"下载文件",downloadFailed:"下载失败",uploadFile:"上传文件",uploadFiles:"上传文件",dropToUpload:"拖放文件以上传",uploading:"上传中…",uploadSuccess:({count:e})=>`已上传 ${e} 个文件`,uploadFailed:"上传失败",binaryPreviewHint:"二进制文件无法预览,请使用上方下载按钮保存到本地",selectedLineHint:({lineLabel:e})=>`已选 ${e} · 点下方「引用」按钮插入`,multiLineHint:"多行引用:先点起始行,再点结束行",loadingImage:"正在加载图片…",imagePreviewHint:"双指捏合或 ⌘/Ctrl + 滚动缩放 · 双击还原",imageLoadFailed:"图片预览加载失败",markdownPreview:"预览",markdownSource:"源码",markdownPreviewHint:"Markdown 预览 · 切到源码可选择行号",markdownOutline:"Markdown 目录",markdownOutlineShort:"目录",closeMarkdownOutline:"关闭目录",changedFromPath:({path:e})=>`来自 ${e}`,selectedLineFooter:({lineLabel:e})=>`已选 ${e}`,clearSelection:"清除",allChanges:"全部改动",backToChangeList:"返回目录",allRepositories:"全部仓库",allRepositoriesShort:"全部",repositories:"仓库",gitRepositorySectionTitle:"操作仓库",gitRepositoryLabel:"仓库",gitRepositoryPlaceholder:"选择仓库",gitRepositorySearchPlaceholder:"搜索仓库",gitRepositoryEmpty:"没有可操作的仓库",selectRepositoryForGitActions:"请选择一个仓库后再执行 Git 操作",selectRepositoryForDiff:"选择一个仓库或文件查看 diff",repoChangedCount:({count:e})=>`${e} 个改动`,repoStagedCount:({count:e})=>`${e} 已暂存`,noChanges:"没有改动",noMatchingChanges:"没有匹配的改动",loadingGitChanges:"正在加载 Git 改动…",loadingGitChangesSlow:"仓库较大时可能需要几秒。",refreshingGitChanges:"正在刷新 Git 改动…",gitChangesLoadFailed:"无法加载 Git 改动",retryGitChanges:"重试",insertThisFile:"把这个文件引用插入 Terminal",viewDiff:"查看 diff",diffViewMode:"改动文件展示方式",diffViewModeList:"平铺列表",diffViewModeTree:"目录结构",diffViewModeAi:"AI 导览",changeWalkthroughEmpty:"暂无 AI 导览。生成解释后会在这里展示总览、链路和验证点。",gitInfo:"Git 信息",wrapLongLines:"长行换行",wrapOn:"已换行",wrapOff:"原始",horizontalScrollHint:"左右滑动查看完整 diff",stageFile:"暂存",stageAll:"全部暂存",unstageFile:"取消暂存",stashFile:"贮藏",stashAll:"全部贮藏",restoreFile:"丢弃",gitQuickActions:"Git 操作",gitUnavailable:"当前目录不是 Git 仓库",branchSectionTitle:"当前分支",currentBranchLabel:"分支",switchBranchPlaceholder:"选择分支",switchBranchSearchPlaceholder:"搜索本地分支",switchNoBranches:"没有本地分支",switchBranch:"切换",noStagedChangesShort:"无暂存",stagedCount:({count:e})=>`已暂存 ${e}`,stagedCountShort:({count:e})=>`已暂存 ${e}`,commitSectionTitle:"提交",commitReadyHint:({count:e})=>`${e} 个文件已准备提交`,commitMessagePlaceholder:"提交信息",commitChanges:"提交",commitNeedsStaged:"请先暂存要提交的改动",recentCommitsTitle:"近期提交",recentCommitsSearchPlaceholder:"搜索提交 hash 或信息",recentCommitsLoadMore:"加载更多提交",recentCommitsEmpty:"暂无提交历史",pushSectionTitle:"同步远端",pushRemoteLabel:"Remote",pushRemotePlaceholder:"origin",pushRemoteSearchPlaceholder:"搜索 Remote",pushNoRemotes:"没有 Remote",pushBranchLabel:"目标分支",pushBranchPlaceholder:({branch:e})=>`${e}`,pushBranchSearchPlaceholder:"搜索分支",pushNoBranches:"没有分支",pushUpstreamBadge:"upstream",pushCurrentBranchBadge:"当前",pushNoUpstream:"当前分支未设置 upstream",pushUpToDate:"与远端同步",pushAheadCount:({count:e})=>`领先远端 ${e} 个提交`,pushBehindCount:({count:e})=>`落后远端 ${e} 个提交`,pushDivergedCount:({ahead:e,behind:t})=>`领先 ${e} / 落后 ${t} 个提交`,pullChanges:"拉取",pushChanges:"推送",gitActionRunning:"执行中…",gitActionFailed:({message:e})=>`Git 操作失败:${e}`,confirmRestoreTitle:"确认丢弃改动",confirmRestoreDescription:({path:e})=>`将丢弃 ${e} 的未暂存改动,此操作不可从 Termdock 恢复。`,confirmRestorePhrase:"丢弃改动",confirmRestorePlaceholder:"输入“丢弃改动”确认",confirmStashAllTitle:"确认贮藏全部改动",confirmStashAllDescription:"会把当前工作区改动(包含未跟踪文件)移入贮藏。",confirmAction:"确认"},fileTree:{insertRef:"引用",insertRefTitle:"Insert file reference into active terminal",openDirRoot:"进入",openDirRootTitle:"把这个目录作为当前浏览根目录",openInFileBrowser:"在 Finder 中显示",openInFileBrowserTitle:"在系统文件浏览器中打开这个项目",openInFileBrowserFailed:"打开文件浏览器失败",moreDirActions:"更多目录操作",pinDir:"固定",pinDirTitle:"固定这个目录到当前项目",unpinDir:"已固定",unpinDirTitle:"取消固定这个目录",pinFileTitle:"固定这个文件到当前项目",unpinFileTitle:"取消固定这个文件",pinFile:"固定",unpinFile:"已固定",moreFileActions:"更多文件操作",noWorkingDir:"未检测到工作目录。",emptyDir:"空目录。",noMatchingFiles:"没有匹配的文件。",searching:"正在搜索文件…",searchingWithCount:({count:e})=>`搜索中…已找到 ${e} 项`,searchResults:({count:e})=>`${e} 个结果`,searchTruncatedHint:({count:e})=>`降级搜索已扫描大量目录并在找到 ${e} 项后停止。安装 ripgrep 或输入更精确关键词可获得完整结果。`,searchStillRunning:"搜索仍在进行,更多结果会自动出现。",showingSearchResults:({shown:e,total:t})=>`正在展示 ${e}/${t}`,loadMoreSearchResults:({shown:e,total:t})=>`查看更多(${e}/${t})`,contentMatchesCount:({count:e})=>`${e} 个文件命中`,moreMatches:({count:e})=>`还有 ${e} 处匹配`,noContentMatches:"文件内容中没有匹配。",contentSearchNeedsRipgrep:"内容搜索需要 ripgrep(rg),请在服务端安装后再在文件内搜索。",truncatedHint:"仅展示前 1000 项。使用搜索或打开更小的文件夹以获得更好性能。",dropToUploadHere:"上传到这里"},diffViewer:{noFileChanges:"此文件无改动。",noUnstagedChanges:"没有未暂存的改动。",emptyHint:"做一些改动,或从远程拉取。",loading:"正在加载 diff…",insertAllDiff:"把当前 diff 内容作为上下文插入 Terminal",insertFileDiff:"引用这个文件的 diff",insertHunkDiff:"引用这段 diff hunk",insertHunkShort:"引用",insertFileShort:"引用",insertAllShort:"全部",auditExplanation:"更改意义",auditStale:"解释已失效",auditClear:"清除解释",auditGeneratedAt:({time:e})=>`生成于 ${e}`,allDiffLabel:"全部 diff",allChangesLabel:"全部改动",workingTree:"工作区改动",allUnstaged:"所有未暂存改动",binaryOrEmpty:"没有可显示的文本改动。",noHunks:"没有 hunk",hunkOutline:"Hunk 列表",expandHunkRail:"显示 hunk 列表",collapseHunkRail:"隐藏 hunk 列表",prevHunk:"上一个 hunk",nextHunk:"下一个 hunk",prevFile:"上一个",nextFile:"下一个",expandFile:"展开文件",collapseFile:"折叠文件",expandAll:"全部展开",collapseAll:"全部折叠",collapseHunk:"折叠 hunk",useBracketKeysHint:"按 [ / ] 在 hunk 之间跳转",unified:"统一",unifiedMode:"统一视图",split:"分屏",splitMode:"左右分屏视图",moreActions:"更多操作",view:"视图"},settings:{title:"设置",font:"字体",render:"渲染",theme:"主题",darkTheme:"深色",lightTheme:"浅色",newTab:"新标签",debug:"调试",noSleep:"常亮",noSleepUnavailable:"无网络 — 已禁用",notifications:"通知",notificationsTitle:"通知设置",notificationsHint:"Termdock 在后台时,AI 任务结束后发送系统通知。",notificationsPageHint:"选择哪些 Termdock 事件可以发送系统通知。总开关负责浏览器权限和投递,事件开关决定具体哪些内容提醒你。",notificationsMaster:"系统通知",notificationsMasterHint:"允许 Termdock 在隐藏或作为 PWA 安装运行时发送通知。",notificationsPermission:"权限",notificationsTest:"发送测试",notificationsAlertStyle:"提醒方式",notificationsAlertStyleHint:"最终是否横幅弹出仍由浏览器和 Android 系统决定。Termdock 只能请求静默、默认或持续显示等通知选项。",notificationsStyleNormal:"默认",notificationsStyleNormalHint:"允许时声音/震动",notificationsStyleQuiet:"静默",notificationsStyleQuietHint:"仅状态栏,无声音",notificationsStylePersistent:"持续",notificationsStylePersistentHint:"保留到手动关闭",notificationsEvents:"事件",notificationsAiFinished:"AI 任务结束",notificationsAiFinishedHint:"当 Termdock 在后台时,AI agent 停止后发送通知。",notificationsFutureHint:"后续可以在这里继续增加更多通知类型,不需要改变顶层设置布局。",notificationsOffSummary:"系统通知已关闭",notificationsAiOnSummary:"AI 任务结束通知已开启",notificationsNoEventsSummary:"暂无开启的通知事件",notificationsDenied:"浏览器通知权限已被阻止,请在站点设置中开启。",notificationsUnsupported:"通知需要安全上下文和 Service Worker 支持。",notificationsTestBody:"通知已开启。后台 AI 任务结束后会提醒你。",shell:"Shell",tmux:"Tmux",auto:"自动",webgl:"WebGL",canvas:"内置",tmuxServer:"Tmux 服务",tmuxUnavailable:"不可用",noTmuxSessions:"服务端没有 tmux 会话。",installTmuxHint:"请在服务端安装 tmux 后启用。",refresh:"刷新",attached:"已连接",restorable:"可恢复",attach:"连接",attaching:"连接中…",destroy:"销毁",sessions:({n:e})=>`${e} 个会话`,windows:({n:e})=>`${e} 个窗口`,keyboardToolbar:"键盘工具栏",aiAgentDetection:"AI 代理检测",signOut:"退出登录",language:"语言",programNamePlaceholder:"程序名(如 claude)",patternPlaceholder:"正则表达式(如 Thinking|Generating)",statusPlaceholder:"状态",addProgram:"添加程序",addPattern:"添加规则",resetDefaults:"恢复默认",invalidRegex:"无效的正则",removeProgram:"移除程序",removeRule:"移除规则",keepLabel:"保持",customColor:"自定义颜色",tabIndicator:"标签指示器样式",toolbarPresets:"工具栏预设",detectionRules:"检测规则",agentHooksHint:"安装 hooks 后,agent 会主动上报状态:回合进行中(绿)、等你授权/回答(黄)、回合完成(对勾),并在等待你输入时推送通知。hooks 全局安装但只在 termdock 的终端里生效。",agentHooksInstall:"安装",agentHooksInstalled:"已安装",agentHooksOutdated:"需更新",agentHooksNotInstalled:"未安装",agentHooksUninstall:"卸载",agentHooksReinstall:"重新安装",agentHooksDevMode:"开发模式:hooks 指向 TS 源码,需要构建后的版本才能生效",agentHooksTarget:"写入",agentPlugins:"Agent 插件",agentPluginAdd:"添加插件",agentPluginHint:"自定义 agent 的注册和 hooks 配置。粘贴 manifest.json 来注册新 agent,可选安装 hooks。",agentPluginCreate:"创建插件",agentPluginDelete:"删除插件",mobileKeyboard:"移动键盘",saving:"保存中…",rulesHint:"配置正则表达式来识别 AI 工具在终端标签中的状态。每条规则可独立设置标签、颜色、图标样式以及输出静默后指示器保留的时长。停止后若你未查看该标签,标签会保留一个黄色待查看提示。",programsHelp:"支持在一个配置中匹配多个程序,用英文逗号分隔。",programLabelResolution:"程序名识别",rawCommandMapping:"原始命令映射",rawCommandMappingHint:"以下规则将原始命令行映射为标签显示名。用户规则优先于内置规则。",genericProgramNames:"通用程序名",genericProgramNamesHint:"触发 ps 深度识别(如 node, python)",wrapperScriptNames:"包装脚本名",wrapperScriptNamesHint:"CLI 包装器,启动其他工具(如 aiden, npx)",shellNamesConfig:"Shell 名称",shellNamesHint:"从标签显示中过滤(如 bash, zsh)",addTag:"+ 添加",customRules:"自定义规则",addRule:"添加规则",localAccess:"本地访问",localAccessHint:"手机信任本地 CA 后,可通过这个局域网地址访问。请先在手机上打开「手机引导」地址下载 CA 证书。",resetAutoName:"恢复自动",onboardingUrl:"手机引导",httpsActive:"HTTPS 已启用",httpsInactive:"HTTPS 未启用",caMissing:"未配置 CA 下载"},toolbarPresets:{preview:"预览",presets:"预设",label:"标签",new:"新建",reset:"重置",presetLabelPlaceholder:"预设名称",deletePreset:({name:e})=>`删除预设 ${e}`,matchPrograms:"匹配程序",typeEnterHint:"输入后回车",programsPlaceholder:"vim, nvim, /^claude(-code)?$/i …",programsHelp:"纯字符串按大小写不敏感子串匹配。用 /…/flags 包裹则为正则(针对小写程序名测试)。",altSlot:"Alt 修饰键槽",altSlotHint:"在预览中保留一个 Alt 键槽位。",desktopVisibility:"桌面端显示",desktopVisibilityHint:"桌面端只显示该预设的自定义按钮,不显示基础快捷键。",rowLayout:"行布局",rowLayoutHint:"每行按钮数。",addRow:"行",rowN:({n:e})=>`第 ${e} 行`,del:"删",buttons:"按钮",buttonsHint:"点击编辑,使用 ↑↓ 排序。",addButton:"添加按钮",noCustomButtons:"暂无自定义按钮。添加一个来覆盖默认工具栏。",moveUp:"上移",moveDown:"下移",removeRow:({n:e})=>`移除第 ${e} 行`,removeAction:({name:e})=>`移除 ${e}`,labelField:"标签",labelPlaceholder:"按钮上显示的文本",sequence:"序列",sequencePlaceholder:"例如 /undo 或 \\t 或 /||undo",sequenceHint:"双击序列",doubleTap:"双击序列",doubleTapAdd:"+ 添加",doubleTapPlaceholder:"例如 /undo\\r 或 /||undo ||\\r",remove:"移除",noSequence:"无序列",preset:"预设",overCapacityHint:"按钮数超过槽位,多余按钮将使用最后一行的尺寸。"},agentRules:{ruleColors:{green:"绿",yellow:"黄",red:"红",blue:"蓝",purple:"紫",orange:"橙",gray:"灰"}},tab:{session:"会话",new:"新建会话",rename:"重命名",renameHint:"修改标签的显示名称",renamePlaceholder:"留空则恢复默认名称",copyCwd:"复制当前目录",copyCwdHint:"复制当前工作目录",resumeAgent:"恢复 Agent 会话",resumeAgentHint:"用原生 session id 恢复上次对话",copied:"已复制",close:"关闭会话",closeHint:"从列表移除该标签",longPressTip:"提示:按住标签不动约半秒打开操作菜单,按住并拖动可排序。",sessionsTitle:"会话",explorerTitle:"资源管理器"},agent:{aiRunning:"AI 运行中",needsReview:"需要查看",finishedReview:"AI 已完成 — 需要查看",aiWaiting:"AI 等待中",copyMode:"Copy 模式",jumpToNext:"跳到下一个待处理"},connection:{reconnecting:"正在重连…"},terminal:{input:"终端输入",error:"错误",dropFilesToPastePaths:"拖放文件以输入路径"},errorBoundary:{title:"出现了一些问题",unexpected:"发生意外错误",retry:"重试"},error:{type:{network:"网络连接错误",session:"会话错误",terminal:"终端错误",auth:"认证错误",validation:"验证错误",unknown:"未知错误"},severity:{low:"提示:",medium:"警告:",high:"错误:",critical:"严重错误:"},suggestion:{networkCheck:"检查网络连接",networkRetry:"尝试重新连接",networkProxy:"检查代理设置",networkWait:"等待网络恢复",sessionRecreate:"重新创建会话",sessionServer:"检查服务器状态",sessionCache:"清理浏览器缓存",terminalRestart:"重启终端",terminalConfig:"检查终端配置",terminalClear:"清除终端输出",authRelogin:"重新登录",authCredentials:"检查凭证",authAdmin:"联系管理员",validationFormat:"检查输入格式",validationParams:"验证参数",validationDocs:"参考文档",unknownReload:"刷新页面",unknownApp:"重启应用",unknownSupport:"联系技术支持"}}},GR=["en","zh"],Qd="en",B1="termdock:locale",kg={en:HR,zh:UR};function zR(e){return typeof e=="string"&&GR.includes(e)}function WR(){if(typeof window>"u")return Qd;try{const t=window.localStorage.getItem(B1);if(zR(t))return t}catch{}return(window.navigator?.language?.toLowerCase()??"").startsWith("zh")?"zh":Qd}const Ww=A.createContext(null);function zx(e,t){const r=t.split(".");let n=e;for(const s of r)if(n&&typeof n=="object"&&s in n)n=n[s];else return;return n}function Wx(e,t){return typeof e=="function"?e(t??{}):typeof e!="string"?String(e):t?e.replace(/\{(\w+)\}/g,(r,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):r):e}function VR({children:e}){const[t,r]=A.useState(()=>WR());A.useEffect(()=>{typeof window>"u"||fetch("/api/terminal/settings").then(u=>u.json()).then(u=>{if(u?.locale==="zh"||u?.locale==="en"){r(u.locale);try{window.localStorage.setItem(B1,u.locale)}catch{}}}).catch(()=>{})},[]),A.useEffect(()=>{if(!(typeof window>"u")){try{window.localStorage.setItem(B1,t)}catch{}fetch("/api/terminal/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:t})}).catch(()=>{}),document.documentElement.lang=t==="zh"?"zh-CN":"en"}},[t]);const n=A.useCallback(u=>{r(u)},[]),s=kg[t]??kg[Qd],i=A.useCallback((u,d)=>{const f=zx(s,u);if(f===void 0){const b=zx(kg[Qd],u);return b===void 0?u:Wx(b,d)}return Wx(f,d)},[s]),a=A.useMemo(()=>({locale:t,setLocale:n,t:i}),[t,n,i]);return c.jsx(Ww.Provider,{value:a,children:e})}function Qn(){const e=A.useContext(Ww);return e||{locale:Qd,setLocale:()=>{},t:t=>t}}function qR({error:e}){const{t}=Qn();return c.jsx("div",{className:"flex h-full items-center justify-center p-4",children:c.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[c.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:c.jsx("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.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"})})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("h3",{className:"font-medium text-foreground",children:t("errorBoundary.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e?.message||t("errorBoundary.unexpected")})]}),c.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:t("errorBoundary.retry")})]})})}let Vw=class extends P.Component{state={hasError:!1,error:null};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.error("Terminal error caught by boundary:",t,r)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:c.jsx(qR,{error:this.state.error}):this.props.children}};function P1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const yd=12;function YR(){return qw.map(e=>e.id)}const qw=[{id:"default",label:"Base",programs:[],includeAlt:!0,rowLayout:[3,3,3],actions:[],showOnDesktop:!1},{id:"opencode",label:"Code",programs:["opencode"],includeAlt:!1,rowLayout:[4],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:[4],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:"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:[3,3],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:[3,2],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 Fd(){return qw.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function G2(e){const t=Array.isArray(e)?e.map(r=>Math.min(20,Math.max(2,Math.floor(r)))).filter(r=>Number.isFinite(r)):[];return t.length>0?t:[3,3]}function Yw(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const z2=/^\/(.+)\/([gimsuy]*)$/;function Vx(e){return z2.test(e.trim())}function Jf(e){const t=e.trim().match(z2);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function Zw(e){if(typeof e!="string")return null;const t=e.trim();return t?z2.test(t)?Jf(t)?t:null:t.toLowerCase():null}function qx(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16))).replace(/\\r/g,"\r").replace(/\\n/g,`
|
|
71
|
+
shadow-lg transition-all duration-150 ease-out`,style:{opacity:Re?1:0,transform:Re?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:"Tab"}),c.jsx("div",{ref:rr,"aria-hidden":!0,className:"fixed left-1/2 top-6 z-chrome-hint pointer-events-none transition-opacity duration-150 ease-out",style:{opacity:be.visible?1:0,transform:be.visible?"translate(-50%, 0) scale(1)":"translate(-50%, -8px) scale(0.9)"},children:be.visible&&(()=>{const{activeDir:$}=be,V=z=>$===z;return c.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-xl bg-[var(--overlay-background)] backdrop-blur-sm shadow-lg px-1.5 py-1.5",children:[c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("up")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 19V5M7 11l5-5 5 5"})})}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("left")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),c.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg text-[rgb(var(--overlay-foreground-rgb)_/_0.18)]",children:c.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("circle",{cx:"12",cy:"12",r:"4"})})}),c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("right")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})})]}),c.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-lg transition-colors ${V("down")?"bg-[var(--overlay-control-bg)] text-[color:var(--overlay-foreground)]":"text-[rgb(var(--overlay-foreground-rgb)_/_0.34)]"}`,children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M12 5v14M19 12l-7 7-7-7"})})})]})})()})]})]})});Hw.displayName="TerminalViewport";const NR=Hw,DR={background:"#1C1B1A",foreground:"#CECDC3",cursor:"#CECDC3",cursorAccent:"#1C1B1A",selectionBackground:"#403E3C",selectionForeground:"#CECDC3",selectionInactiveBackground:"#403E3C50",black:"#6F6E69",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#CECDC3",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#FFFCF0"},BR={background:"#FFFCF0",foreground:"#100F0F",cursor:"#100F0F",cursorAccent:"#FFFCF0",selectionBackground:"#CECDC3",selectionForeground:"#100F0F",selectionInactiveBackground:"#CECDC350",black:"#100F0F",red:"#AF3029",green:"#66800B",yellow:"#AD8301",blue:"#205EA6",magenta:"#A02F6F",cyan:"#24837B",white:"#575653",brightBlack:"#6F6E69",brightRed:"#D14D41",brightGreen:"#879A39",brightYellow:"#D0A215",brightBlue:"#4385BE",brightMagenta:"#CE5D97",brightCyan:"#3AA99F",brightWhite:"#100F0F"};function PR(e){return e==="light"?BR:DR}const H2=new Set(["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"]);function Ol(e){if(!e)return null;if(e==="/")return"/";const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function Bf(e,t,r,n=H2,s=null,i=null){if(e.customName)return{primary:e.name,secondary:Ol(r)};if(s){const u=Ol(r),d=s===r||s===u;if(i!=="idle"&&!n.has(s)&&!d)return{primary:s,secondary:u}}if(t&&!n.has(t))return{primary:t,secondary:Ol(r)};const a=Ol(r);return a?{primary:a,secondary:null}:{primary:e.name,secondary:null}}function jR(e,t,r,n=H2,s=null,i=null){return Bf(e,t,r,n,s,i).primary}function U2(e,t,r){const n=[],s=new Map;for(const i of e){const a=t(i),u=a&&a.trim().length>0?a:"";let d=s.get(u);d||(d={key:u,label:u?Ol(u)??u:r,sessions:[]},s.set(u,d),n.push(d)),d.sessions.push(i)}return n.sort((i,a)=>(i.key===""?1:0)-(a.key===""?1:0))}function QR(e){return e&&e.trim().length>0?e:""}function Uw(e,t,r){const n=[...e],[s]=n.splice(t,1);return s?(n.splice(r,0,s),n.flatMap(i=>i.sessions.map(a=>a.id))):e.flatMap(i=>i.sessions.map(a=>a.id))}function Gw(e,t,r,n){return e.flatMap(s=>{if(s.key!==t)return s.sessions.map(u=>u.id);const i=s.sessions.map(u=>u.id),[a]=i.splice(r,1);return a===void 0?s.sessions.map(u=>u.id):(i.splice(n,0,a),i)})}function zw(e,t,r,n){if(!r)return{arranged:e,groups:[]};const s=U2(e,t,n);return{arranged:s.flatMap(a=>a.sessions),groups:s}}function FR(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}const OR=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},$R=()=>({async createSession(e){return FC(e)},connect(e,t,r){const n=OC(e,t.onEvent,t.onError,OR(r));return{close:()=>n()}},async sendInput(e,t){await $C(e,t)},async resize(e){await GC(e.sessionId,e.cols,e.rows,e.seq)},async close(e){await Q6(e)},async restartSession(e,t){return WC(e,{cols:t.cols,rows:t.rows,mode:t.mode,tmuxSessionName:t.tmuxSessionName})},async forceKill(e){await qC(e)},async tmuxAction(e,t){return zC(e,t)},async listTmuxSessions(){return y1()},async getTmuxStatus(){return v1()},async checkHealth(e){return VC(e)}}),HR={app:{name:"Termdock"},common:{cancel:"Cancel",close:"Close",save:"Save",reset:"Reset",loading:"Loading…",error:"Error",retry:"Retry",refresh:"Refresh",search:"Search",clear:"Clear",delete:"Delete",on:"On",off:"Off",back:"Back",copy:"Copy",decrease:"Decrease",increase:"Increase"},login:{prompt:"termdock login",placeholder:"Enter password",placeholderBlocked:({s:e})=>`Please wait ${e}s`,submit:"Sign in",invalidPassword:"Incorrect password",failed:"Login failed"},sidebar:{sessions:"Sessions",noSessions:"No open sessions yet.",noMatchingSessions:"No matching sessions.",toggleSearch:"Toggle search",settings:"Settings",filterSessions:"Filter sessions",clearSearch:"Clear search",sortRecent:"Recent activity first",sortRecentTitle:"Sort sessions by latest terminal output. Manual drag order is restored when off.",groupByFolder:"Group by folder",groupByFolderTitle:"Collapse sessions into groups by working directory. Mutually exclusive with drag sorting.",ungrouped:"Other",needsAttention:"Needs attention",closeSession:({name:e})=>`Close ${e}`,newShell:"Shell",newTmux:"Tmux",newTmuxDisabled:"tmux not available on server",confirmNewShell:"Create Shell?",confirmNewTmux:"Create Tmux?"},rightSidebar:{workspace:"Workspace",currentProject:"Project",browsingLocation:"Browsing",parentFolder:"Parent folder",backToProjectRoot:"Back to project",refreshFiles:"Refresh current folder",resizeFileTree:"Drag to resize file browser",pinCurrentFolder:"Pin current folder to this project",unpinCurrentFolder:"Unpin current folder",showHiddenFiles:"Show hidden files",hideHiddenFiles:"Hide hidden files",insertCurrentFolder:"Insert current folder reference",insertCurrentFolderShort:"Insert",pinnedFolders:"Pinned",unpinFolder:({name:e})=>`Unpin ${e}`,fileWatchUnavailable:({message:e})=>`File watcher unavailable: ${e}. Click to refresh manually.`,browsingOutsideProject:"Browsing outside current project",browsingOutsideProjectHint:"Git and Changes still use the current project. File references from here are inserted as external paths.",toggleSearch:"Toggle search",refreshGit:"Refresh Git status",close:"Close",filterChanges:"Filter changes or files",searchPlaceholderContent:"Search text in files…",searchModeName:"Name",searchModeContent:"Content",clearSearch:"Clear search",insertGitContext:"Insert current Git context into terminal",copyGitContext:"Copy Git context",insertChangeAuditPrompt:"Explain changes",insertChangeAuditPromptTitle:"Insert the change audit prompt into the current session",changeAuditShort:"Explain changes",changeAuditLoading:"Loading hunk explanations…",changeAuditLoaded:({count:e})=>`${e} hunk explanation${e===1?"":"s"} loaded`,changeAuditLoadedAt:({time:e})=>`Generated ${e}`,changeAuditRegenerate:"Regenerate",changeAuditRefreshStale:"Fill stale",changeAuditRefreshStaleTitle:"Insert a prompt to refresh stale hunk explanations",clearChangeAudit:"Clear",clearChangeAuditTitle:"Clear hunk explanations for the current repository",changeAuditClearFailed:({message:e})=>`Failed to clear hunk explanations: ${e}`,changeAuditScopeAll:"All repositories",changeAuditScopeLabel:"Explain scope",branchAuditTitle:"Branch explanation",branchAuditShort:"Explain branch changes",branchAuditBaseLabel:"Base branch",branchAuditBasePlaceholder:"Base branch, e.g. master",branchAuditBaseSearchPlaceholder:"Search base branch",branchAuditBaseEmpty:"No branch options. Type a branch name directly.",branchAuditGenerate:"Generate",branchAuditRegenerate:"Regenerate",branchAuditGenerateTitle:"Insert a prompt to explain this branch against the base branch",branchAuditViewDiff:"View diff",branchAuditViewDiffTitle:"View target branch changes against the base branch",branchAuditDiffLoading:"Loading branch diff...",branchAuditDiffEmpty:"No changes between this branch and the base branch.",branchAuditMissingBase:({repo:e})=>`${e} has no base branch set`,branchAuditRefreshDiff:"Refresh diff",branchAuditRefreshStale:"Fill stale",branchAuditRefreshStaleTitle:"Insert a prompt to refresh stale branch explanations",branchAuditClearTitle:"Clear current branch explanation",branchAuditClearFailed:({message:e})=>`Failed to clear branch explanation: ${e}`,branchAuditCommitCount:({count:e})=>`${e} commit${e===1?"":"s"}`,branchAuditFileCount:({count:e})=>`${e} file${e===1?"":"s"}`,branchAuditTruncated:"diff truncated",branchAuditCurrent:"Saved explanation",branchAuditStale:"Explanation is stale",branchAuditEmpty:"No branch explanation yet. Generate one to persist it here for later review.",branchAuditView:"View explanations",branchAuditSaved:({count:e})=>`${e} hunk explanation${e===1?"":"s"} saved`,branchAuditGeneratedAt:({time:e})=>`Generated ${e}`,insertPreset:({label:e})=>`Insert: ${e}`,tabChanges:"Changes",tabGit:"Git",tabFiles:"Files",tabPreview:"Preview",inserted:"Inserted",copied:"Copied",selectFilePrompt:"Select a file to preview its contents",backToFileList:"Back to file list",insertLineRef:({lineLabel:e})=>`Insert ${e}`,insertFileRef:"Insert",copyFileRef:"Copy file reference",downloadFile:"Download file",downloadFailed:"Download failed",uploadFile:"Upload file",uploadFiles:"Upload files",dropToUpload:"Drop files to upload",uploading:"Uploading…",uploadSuccess:({count:e})=>`${e} file${e===1?"":"s"} uploaded`,uploadFailed:"Upload failed",binaryPreviewHint:"Binary files cannot be previewed. Use the download button above to save it.",selectedLineHint:({lineLabel:e})=>`Selected ${e} · tap "Insert" below to add to terminal`,multiLineHint:"Multi-line select: tap start line, then end line",loadingImage:"Loading image…",imagePreviewHint:"Pinch or ⌘/Ctrl + scroll to zoom · double-tap to reset",imageLoadFailed:"Failed to load image preview",markdownPreview:"Preview",markdownSource:"Source",markdownPreviewHint:"Markdown preview · switch to Source to select lines",markdownOutline:"Markdown outline",markdownOutlineShort:"Outline",closeMarkdownOutline:"Close outline",changedFromPath:({path:e})=>`from ${e}`,selectedLineFooter:({lineLabel:e})=>`Selected ${e}`,clearSelection:"Clear",allChanges:"All changes",backToChangeList:"Back to list",allRepositories:"All repositories",allRepositoriesShort:"All",repositories:"Repositories",gitRepositorySectionTitle:"Repository",gitRepositoryLabel:"Repository",gitRepositoryPlaceholder:"Select repository",gitRepositorySearchPlaceholder:"Search repositories",gitRepositoryEmpty:"No available repositories",selectRepositoryForGitActions:"Select a repository before running Git actions",selectRepositoryForDiff:"Select a repository or file to view diff",repoChangedCount:({count:e})=>`${e} change${e===1?"":"s"}`,repoStagedCount:({count:e})=>`${e} staged`,noChanges:"No changes",noMatchingChanges:"No matching changes",loadingGitChanges:"Loading Git changes…",loadingGitChangesSlow:"Large repositories can take a few seconds.",refreshingGitChanges:"Refreshing Git changes…",gitChangesLoadFailed:"Unable to load Git changes",retryGitChanges:"Retry",insertThisFile:"Insert this file reference into terminal",viewDiff:"View diff",diffViewMode:"Change file display mode",diffViewModeList:"Flat list",diffViewModeTree:"Folder tree",diffViewModeAi:"AI walkthrough",changeWalkthroughEmpty:"No AI walkthrough yet. Generate explanations to show the overview, flow, and checks here.",gitInfo:"Git context",wrapLongLines:"Wrap long lines",wrapOn:"Wrapped",wrapOff:"Raw",horizontalScrollHint:"Swipe left/right to see the full diff",stageFile:"Stage",stageAll:"Stage all",unstageFile:"Unstage",stashFile:"Stash",stashAll:"Stash all",restoreFile:"Restore",gitQuickActions:"Git Actions",gitUnavailable:"Current directory is not a Git repository",branchSectionTitle:"Current branch",currentBranchLabel:"Branch",switchBranchPlaceholder:"Select branch",switchBranchSearchPlaceholder:"Search local branch",switchNoBranches:"No local branches",switchBranch:"Switch",noStagedChangesShort:"no staged",stagedCount:({count:e})=>`${e} staged`,stagedCountShort:({count:e})=>`${e} staged`,commitSectionTitle:"Commit",commitReadyHint:({count:e})=>`${e} file${e===1?"":"s"} ready`,commitMessagePlaceholder:"Commit message",commitChanges:"Commit",commitNeedsStaged:"Stage changes before committing",recentCommitsTitle:"Recent commits",recentCommitsSearchPlaceholder:"Search commit hash or message",recentCommitsLoadMore:"Load more commits",recentCommitsEmpty:"No commit history",pushSectionTitle:"Remote sync",pushRemoteLabel:"Remote",pushRemotePlaceholder:"origin",pushRemoteSearchPlaceholder:"Search remote",pushNoRemotes:"No remotes",pushBranchLabel:"Target",pushBranchPlaceholder:({branch:e})=>`${e}`,pushBranchSearchPlaceholder:"Search branch",pushNoBranches:"No branches",pushUpstreamBadge:"upstream",pushCurrentBranchBadge:"current",pushNoUpstream:"No upstream configured",pushUpToDate:"Up to date with remote",pushAheadCount:({count:e})=>`${e} commit${e===1?"":"s"} to push`,pushBehindCount:({count:e})=>`${e} commit${e===1?"":"s"} to pull`,pushDivergedCount:({ahead:e,behind:t})=>`${e} ahead / ${t} behind`,pullChanges:"Pull",pushChanges:"Push",gitActionRunning:"Running…",gitActionFailed:({message:e})=>`Git action failed: ${e}`,confirmRestoreTitle:"Discard changes?",confirmRestoreDescription:({path:e})=>`This will discard unstaged changes in ${e}. Termdock cannot recover them.`,confirmRestorePhrase:"discard changes",confirmRestorePlaceholder:"Type “discard changes” to confirm",confirmStashAllTitle:"Stash all changes?",confirmStashAllDescription:"This moves current working tree changes, including untracked files, into a stash.",confirmAction:"Confirm"},fileTree:{insertRef:"Insert",insertRefTitle:"Insert file reference into active terminal",openDirRoot:"Open",openDirRootTitle:"Use this folder as the current browsing root",openInFileBrowser:"Reveal in Finder",openInFileBrowserTitle:"Open this item in the system file browser",openInFileBrowserFailed:"Failed to open file browser",moreDirActions:"More folder actions",pinDir:"Pin",pinDirTitle:"Pin this folder to the current project",unpinDir:"Pinned",unpinDirTitle:"Unpin this folder",pinFileTitle:"Pin this file to the current project",unpinFileTitle:"Unpin this file",pinFile:"Pin",unpinFile:"Unpin",moreFileActions:"More file actions",noWorkingDir:"No working directory detected.",emptyDir:"Empty directory.",noMatchingFiles:"No matching files.",searching:"Searching files…",searchingWithCount:({count:e})=>`Searching… ${e} found`,searchResults:({count:e})=>`${e} results`,searchTruncatedHint:({count:e})=>`Fallback search scanned a large directory and stopped after ${e} matches. Install ripgrep or refine the query for complete results.`,searchStillRunning:"Search is still running. More results will appear automatically.",showingSearchResults:({shown:e,total:t})=>`Showing ${e} of ${t}`,loadMoreSearchResults:({shown:e,total:t})=>`Show more (${e}/${t})`,contentMatchesCount:({count:e})=>`${e} file${e===1?"":"s"} with matches`,moreMatches:({count:e})=>`+${e} more match${e===1?"":"es"}`,noContentMatches:"No matches found in file contents.",contentSearchNeedsRipgrep:"Content search requires ripgrep (rg). Install it on the server to search inside files.",truncatedHint:"Showing first 1000 entries. Use search or open a smaller folder for better performance.",dropToUploadHere:"Upload here"},diffViewer:{noFileChanges:"No changes in this file.",noUnstagedChanges:"No unstaged changes.",emptyHint:"Make some changes, or pull from a remote.",loading:"Loading diff…",insertAllDiff:"Insert current diff as context",insertFileDiff:"Insert this file's diff",insertHunkDiff:"Insert this hunk",insertHunkShort:"Insert",insertFileShort:"Insert",insertAllShort:"Insert all",auditExplanation:"Change meaning",auditStale:"Explanation stale",auditClear:"Clear explanation",auditGeneratedAt:({time:e})=>`Generated ${e}`,allDiffLabel:"all changes",allChangesLabel:"all changes",workingTree:"Working tree changes",allUnstaged:"All unstaged changes",binaryOrEmpty:"No textual changes to display.",noHunks:"No hunks",hunkOutline:"Hunks",expandHunkRail:"Show hunk list",collapseHunkRail:"Hide hunk list",prevHunk:"Previous hunk",nextHunk:"Next hunk",prevFile:"Previous",nextFile:"Next",expandFile:"Expand file",collapseFile:"Collapse file",expandAll:"Expand all",collapseAll:"Collapse all",collapseHunk:"Collapse hunk",useBracketKeysHint:"Press [ / ] to jump between hunks",unified:"Unified",unifiedMode:"Unified view",split:"Split",splitMode:"Side-by-side view",moreActions:"More actions",view:"View"},settings:{title:"Settings",font:"Font",render:"Render",theme:"Theme",darkTheme:"Dark",lightTheme:"Light",newTab:"New tab",debug:"Debug",noSleep:"No sleep",noSleepUnavailable:"No network — disabled",notifications:"Notify",notificationsTitle:"Notification settings",notificationsHint:"Notify when an AI task finishes while Termdock is hidden.",notificationsPageHint:"Choose which Termdock events can send system notifications. The master switch controls browser permission and delivery; event switches decide what should notify you.",notificationsMaster:"System notifications",notificationsMasterHint:"Allow Termdock to send notifications when it is hidden or running as an installed PWA.",notificationsPermission:"Permission",notificationsTest:"Send test",notificationsAlertStyle:"Alert style",notificationsAlertStyleHint:"Browsers and Android still decide the final heads-up behavior. Termdock can only request quiet/default/sticky notification options.",notificationsStyleNormal:"Default",notificationsStyleNormalHint:"Sound/vibration if allowed",notificationsStyleQuiet:"Quiet",notificationsStyleQuietHint:"Status tray, no sound",notificationsStylePersistent:"Sticky",notificationsStylePersistentHint:"Stay until dismissed",notificationsEvents:"Events",notificationsAiFinished:"AI task finished",notificationsAiFinishedHint:"Notify when an AI agent stops while Termdock is in the background.",notificationsFutureHint:"More notification types can be added here later without changing the top-level settings layout.",notificationsOffSummary:"System notifications disabled",notificationsAiOnSummary:"AI task finished enabled",notificationsNoEventsSummary:"No notification events enabled",notificationsDenied:"Browser notification permission is blocked. Enable it in site settings.",notificationsUnsupported:"Notifications require a secure context and service worker support.",notificationsTestBody:"Notifications are enabled. You will be notified when an AI task finishes in the background.",shell:"Shell",tmux:"Tmux",auto:"Auto",webgl:"WebGL",canvas:"Built-in",tmuxServer:"Tmux server",tmuxUnavailable:"unavailable",noTmuxSessions:"No tmux sessions on the server.",installTmuxHint:"Install tmux on the server to enable.",refresh:"Refresh",attached:"Attached",restorable:"Restorable",attach:"Attach",attaching:"Attaching…",destroy:"Destroy",sessions:({n:e})=>`${e} session${e===1?"":"s"}`,windows:({n:e})=>`${e} window${e===1?"":"s"}`,keyboardToolbar:"Keyboard toolbar",aiAgentDetection:"AI agent detection",signOut:"Sign out",language:"Language",programNamePlaceholder:"Program name (e.g. claude)",patternPlaceholder:"Regex pattern (e.g. Thinking|Generating)",statusPlaceholder:"Status",addProgram:"Add program",addPattern:"Add pattern",resetDefaults:"Reset defaults",invalidRegex:"Invalid regex",removeProgram:"Remove program",removeRule:"Remove rule",keepLabel:"keep",customColor:"Custom color",tabIndicator:"Tab indicator style",toolbarPresets:"Toolbar presets",detectionRules:"Detection rules",agentHooksHint:"With hooks installed, agents report their own status: working (green), waiting for you (amber), turn done (check) — and you get a notification the moment one needs your input. Hooks install globally but only fire inside termdock terminals.",agentHooksInstall:"Install",agentHooksInstalled:"Installed",agentHooksOutdated:"Outdated",agentHooksNotInstalled:"Not installed",agentHooksUninstall:"Uninstall",agentHooksReinstall:"Reinstall",agentHooksDevMode:"Dev mode: hooks point at TS sources and need a built install to fire",agentHooksTarget:"writes to",agentPlugins:"Agent Plugins",agentPluginAdd:"Add Plugin",agentPluginHint:"Define custom agents with their own hooks config. Paste a manifest.json below to register a new agent and optionally install hooks for it.",agentPluginCreate:"Create Plugin",agentPluginDelete:"Delete Plugin",mobileKeyboard:"Mobile keyboard",saving:"Saving…",rulesHint:"Configure regex patterns to detect what an AI tool is doing in a terminal tab. Each rule can choose its label, color, icon style and how long the indicator is kept after output quiets down. When it stops and you haven't viewed the tab yet, the tab keeps a yellow review hint.",programsHelp:"Supports multiple programs in one config. Separate with commas.",programLabelResolution:"Program label resolution",rawCommandMapping:"Raw command mapping",rawCommandMappingHint:"Rules below map the raw command line to the tab display label. User rules run before built-ins.",genericProgramNames:"Generic program names",genericProgramNamesHint:"Trigger ps-based deep detection (e.g. node, python)",wrapperScriptNames:"Wrapper script names",wrapperScriptNamesHint:"CLI wrappers that launch another tool (e.g. aiden, npx)",shellNamesConfig:"Shell names",shellNamesHint:"Filtered out from tab display (e.g. bash, zsh)",addTag:"+ add",customRules:"Custom rules",addRule:"Add rule",localAccess:"Local access",localAccessHint:"Use this LAN URL from your phone after trusting the local CA. Open Mobile setup on your phone to download the CA certificate.",resetAutoName:"Reset auto",onboardingUrl:"Mobile setup",httpsActive:"HTTPS active",httpsInactive:"HTTPS inactive",caMissing:"CA download unavailable"},toolbarPresets:{preview:"Preview",presets:"Presets",label:"Label",new:"New",reset:"Reset",presetLabelPlaceholder:"Preset label",deletePreset:({name:e})=>`Delete preset ${e}`,matchPrograms:"Match programs",typeEnterHint:"Type & Enter",programsPlaceholder:"vim, nvim, /^claude(-code)?$/i …",programsHelp:"Plain names match as case-insensitive substrings. Wrap in /…/flags for regex (tested against the lowercase program name).",altSlot:"Alt modifier slot",altSlotHint:"Reserve one preview slot for the Alt key.",desktopVisibility:"Show on desktop",desktopVisibilityHint:"Desktop shows only this preset’s custom actions, not the basic keyboard shortcuts.",rowLayout:"Row layout",rowLayoutHint:"Buttons per expanded row.",addRow:"Row",rowN:({n:e})=>`Row ${e}`,del:"Del",buttons:"Buttons",buttonsHint:"Tap to edit. Use ↑↓ to reorder.",addButton:"Add button",noCustomButtons:"No custom buttons yet. Add one to override the default toolbar.",moveUp:"Move up",moveDown:"Move down",removeRow:({n:e})=>`Remove row ${e}`,removeAction:({name:e})=>`Remove ${e}`,labelField:"Label",labelPlaceholder:"Label shown on the button",sequence:"Sequence",sequencePlaceholder:"e.g. /undo or \\t or /||undo",sequenceHint:"Double-tap sequence",doubleTap:"Double-tap sequence",doubleTapAdd:"+ Add",doubleTapPlaceholder:"e.g. /undo\\r or /||undo ||\\r",remove:"Remove",noSequence:"No sequence",preset:"Preset",overCapacityHint:"More buttons than slots. Extra rows will use the last row size."},agentRules:{ruleColors:{green:"Green",yellow:"Yellow",red:"Red",blue:"Blue",purple:"Purple",orange:"Orange",gray:"Gray"}},tab:{session:"Session",new:"New session",rename:"Rename",renameHint:"Change the tab display name",renamePlaceholder:"Leave empty to reset to default",copyCwd:"Copy cwd",copyCwdHint:"Copy the current working directory",resumeAgent:"Resume agent session",resumeAgentHint:"Resume the last conversation by its native session id",copied:"Copied",close:"Close session",closeHint:"Remove this tab from the list",longPressTip:"Tip: hold a tab still for a moment to open actions; hold and drag to reorder.",sessionsTitle:"Sessions",explorerTitle:"Explorer"},agent:{aiRunning:"AI running",needsReview:"Needs review",finishedReview:"AI finished — needs review",aiWaiting:"AI waiting",copyMode:"Copy mode",jumpToNext:"Jump to next session needing attention"},connection:{reconnecting:"Reconnecting…"},terminal:{input:"Terminal input",error:"Error",dropFilesToPastePaths:"Drop files to paste paths"},errorBoundary:{title:"Something went wrong",unexpected:"An unexpected error occurred",retry:"Try Again"},error:{type:{network:"Network error",session:"Session error",terminal:"Terminal error",auth:"Authentication error",validation:"Validation error",unknown:"Unknown error"},severity:{low:"Notice: ",medium:"Warning: ",high:"Error: ",critical:"Critical: "},suggestion:{networkCheck:"Check your network connection",networkRetry:"Try reconnecting",networkProxy:"Check proxy settings",networkWait:"Wait for the network to recover",sessionRecreate:"Recreate the session",sessionServer:"Check the server status",sessionCache:"Clear your browser cache",terminalRestart:"Restart the terminal",terminalConfig:"Check the terminal configuration",terminalClear:"Clear the terminal output",authRelogin:"Sign in again",authCredentials:"Check your credentials",authAdmin:"Contact the administrator",validationFormat:"Check the input format",validationParams:"Verify your parameters",validationDocs:"See the documentation",unknownReload:"Reload the page",unknownApp:"Restart the app",unknownSupport:"Contact support"}}},UR={app:{name:"Termdock"},common:{cancel:"取消",close:"关闭",save:"保存",reset:"重置",loading:"加载中…",error:"错误",retry:"重试",refresh:"刷新",search:"搜索",clear:"清除",delete:"删除",on:"开",off:"关",back:"返回",copy:"复制",decrease:"减少",increase:"增加"},login:{prompt:"termdock login",placeholder:"请输入密码",placeholderBlocked:({s:e})=>`请稍候 ${e}s`,submit:"登录",invalidPassword:"密码错误",failed:"登录失败"},sidebar:{sessions:"会话",noSessions:"暂无打开的会话。",noMatchingSessions:"没有匹配的会话。",toggleSearch:"切换搜索",settings:"设置",filterSessions:"过滤会话",clearSearch:"清除搜索",sortRecent:"最近活跃优先",sortRecentTitle:"按最近一次 Terminal 输出排序;关闭后恢复手动拖拽顺序。",groupByFolder:"按文件夹分组",groupByFolderTitle:"按工作目录把会话归组折叠;与拖拽排序互斥。",ungrouped:"其他",needsAttention:"待处理",closeSession:({name:e})=>`关闭 ${e}`,newShell:"Shell",newTmux:"Tmux",newTmuxDisabled:"服务端未安装 tmux",confirmNewShell:"创建 Shell?",confirmNewTmux:"创建 Tmux?"},rightSidebar:{workspace:"工作区",currentProject:"项目",browsingLocation:"浏览中",parentFolder:"上一级目录",backToProjectRoot:"回到当前项目",refreshFiles:"刷新当前目录",resizeFileTree:"拖动调整文件目录宽度",pinCurrentFolder:"固定当前目录到这个项目",unpinCurrentFolder:"取消固定当前目录",showHiddenFiles:"显示隐藏文件",hideHiddenFiles:"不显示隐藏文件",insertCurrentFolder:"引用当前目录",insertCurrentFolderShort:"引用",pinnedFolders:"固定",unpinFolder:({name:e})=>`取消固定 ${e}`,fileWatchUnavailable:({message:e})=>`文件监听不可用:${e}。可点击手动刷新。`,browsingOutsideProject:"正在浏览当前项目外目录",browsingOutsideProjectHint:"Git 和改动仍使用当前项目;这里引用的文件会按外部路径插入。",toggleSearch:"切换搜索",refreshGit:"刷新 Git 状态",close:"关闭",filterChanges:"过滤改动或文件",searchPlaceholderContent:"在文件内容中搜索…",searchModeName:"名称",searchModeContent:"内容",clearSearch:"清除搜索",insertGitContext:"把当前 Git 信息插入 Terminal",copyGitContext:"复制 Git 信息",insertChangeAuditPrompt:"解释当前改动",insertChangeAuditPromptTitle:"把更改审计提示词插入当前会话",changeAuditShort:"解释当前改动",changeAuditLoading:"正在加载 hunk 解释…",changeAuditLoaded:({count:e})=>`已加载 ${e} 条 hunk 解释`,changeAuditLoadedAt:({time:e})=>`最近生成 ${e}`,changeAuditRegenerate:"重新生成",changeAuditRefreshStale:"补充失效",changeAuditRefreshStaleTitle:"为已失效的 hunk 解释插入补充生成提示词",clearChangeAudit:"清理",clearChangeAuditTitle:"清理当前仓库的 hunk 解释",changeAuditClearFailed:({message:e})=>`清理 hunk 解释失败:${e}`,changeAuditScopeAll:"全部仓库",changeAuditScopeLabel:"解释范围",branchAuditTitle:"分支解释",branchAuditShort:"解释分支改动",branchAuditBaseLabel:"基线分支",branchAuditBasePlaceholder:"基线分支,例如 master",branchAuditBaseSearchPlaceholder:"搜索基线分支",branchAuditBaseEmpty:"没有可选分支,可直接输入分支名",branchAuditGenerate:"生成解释",branchAuditRegenerate:"重新生成",branchAuditGenerateTitle:"生成当前分支相对于基线分支的解释提示词",branchAuditViewDiff:"查看对比",branchAuditViewDiffTitle:"查看目标分支相对于基线分支的改动",branchAuditDiffLoading:"正在加载分支对比…",branchAuditDiffEmpty:"当前分支相对于基线分支暂无改动。",branchAuditMissingBase:({repo:e})=>`${e} 未设置基线分支`,branchAuditRefreshDiff:"刷新对比",branchAuditRefreshStale:"补充失效",branchAuditRefreshStaleTitle:"为已失效的分支解释插入补充生成提示词",branchAuditClearTitle:"清理当前分支解释",branchAuditClearFailed:({message:e})=>`清理分支解释失败:${e}`,branchAuditCommitCount:({count:e})=>`${e} 个提交`,branchAuditFileCount:({count:e})=>`${e} 个文件`,branchAuditTruncated:"diff 已截断",branchAuditCurrent:"已保存解释",branchAuditStale:"解释已失效",branchAuditEmpty:"暂无分支解释。生成后会持久化保存,可随时回来查看。",branchAuditView:"查看解释",branchAuditSaved:({count:e})=>`已保存 ${e} 条 hunk 解释`,branchAuditGeneratedAt:({time:e})=>`生成于 ${e}`,insertPreset:({label:e})=>`插入:${e}`,tabChanges:"改动",tabGit:"Git",tabFiles:"文件",tabPreview:"预览",inserted:"已插入",copied:"已复制",selectFilePrompt:"选择文件以预览内容",backToFileList:"返回文件列表",insertLineRef:({lineLabel:e})=>`引用${e}`,insertFileRef:"引用",copyFileRef:"复制文件引用",downloadFile:"下载文件",downloadFailed:"下载失败",uploadFile:"上传文件",uploadFiles:"上传文件",dropToUpload:"拖放文件以上传",uploading:"上传中…",uploadSuccess:({count:e})=>`已上传 ${e} 个文件`,uploadFailed:"上传失败",binaryPreviewHint:"二进制文件无法预览,请使用上方下载按钮保存到本地",selectedLineHint:({lineLabel:e})=>`已选 ${e} · 点下方「引用」按钮插入`,multiLineHint:"多行引用:先点起始行,再点结束行",loadingImage:"正在加载图片…",imagePreviewHint:"双指捏合或 ⌘/Ctrl + 滚动缩放 · 双击还原",imageLoadFailed:"图片预览加载失败",markdownPreview:"预览",markdownSource:"源码",markdownPreviewHint:"Markdown 预览 · 切到源码可选择行号",markdownOutline:"Markdown 目录",markdownOutlineShort:"目录",closeMarkdownOutline:"关闭目录",changedFromPath:({path:e})=>`来自 ${e}`,selectedLineFooter:({lineLabel:e})=>`已选 ${e}`,clearSelection:"清除",allChanges:"全部改动",backToChangeList:"返回目录",allRepositories:"全部仓库",allRepositoriesShort:"全部",repositories:"仓库",gitRepositorySectionTitle:"操作仓库",gitRepositoryLabel:"仓库",gitRepositoryPlaceholder:"选择仓库",gitRepositorySearchPlaceholder:"搜索仓库",gitRepositoryEmpty:"没有可操作的仓库",selectRepositoryForGitActions:"请选择一个仓库后再执行 Git 操作",selectRepositoryForDiff:"选择一个仓库或文件查看 diff",repoChangedCount:({count:e})=>`${e} 个改动`,repoStagedCount:({count:e})=>`${e} 已暂存`,noChanges:"没有改动",noMatchingChanges:"没有匹配的改动",loadingGitChanges:"正在加载 Git 改动…",loadingGitChangesSlow:"仓库较大时可能需要几秒。",refreshingGitChanges:"正在刷新 Git 改动…",gitChangesLoadFailed:"无法加载 Git 改动",retryGitChanges:"重试",insertThisFile:"把这个文件引用插入 Terminal",viewDiff:"查看 diff",diffViewMode:"改动文件展示方式",diffViewModeList:"平铺列表",diffViewModeTree:"目录结构",diffViewModeAi:"AI 导览",changeWalkthroughEmpty:"暂无 AI 导览。生成解释后会在这里展示总览、链路和验证点。",gitInfo:"Git 信息",wrapLongLines:"长行换行",wrapOn:"已换行",wrapOff:"原始",horizontalScrollHint:"左右滑动查看完整 diff",stageFile:"暂存",stageAll:"全部暂存",unstageFile:"取消暂存",stashFile:"贮藏",stashAll:"全部贮藏",restoreFile:"丢弃",gitQuickActions:"Git 操作",gitUnavailable:"当前目录不是 Git 仓库",branchSectionTitle:"当前分支",currentBranchLabel:"分支",switchBranchPlaceholder:"选择分支",switchBranchSearchPlaceholder:"搜索本地分支",switchNoBranches:"没有本地分支",switchBranch:"切换",noStagedChangesShort:"无暂存",stagedCount:({count:e})=>`已暂存 ${e}`,stagedCountShort:({count:e})=>`已暂存 ${e}`,commitSectionTitle:"提交",commitReadyHint:({count:e})=>`${e} 个文件已准备提交`,commitMessagePlaceholder:"提交信息",commitChanges:"提交",commitNeedsStaged:"请先暂存要提交的改动",recentCommitsTitle:"近期提交",recentCommitsSearchPlaceholder:"搜索提交 hash 或信息",recentCommitsLoadMore:"加载更多提交",recentCommitsEmpty:"暂无提交历史",pushSectionTitle:"同步远端",pushRemoteLabel:"Remote",pushRemotePlaceholder:"origin",pushRemoteSearchPlaceholder:"搜索 Remote",pushNoRemotes:"没有 Remote",pushBranchLabel:"目标分支",pushBranchPlaceholder:({branch:e})=>`${e}`,pushBranchSearchPlaceholder:"搜索分支",pushNoBranches:"没有分支",pushUpstreamBadge:"upstream",pushCurrentBranchBadge:"当前",pushNoUpstream:"当前分支未设置 upstream",pushUpToDate:"与远端同步",pushAheadCount:({count:e})=>`领先远端 ${e} 个提交`,pushBehindCount:({count:e})=>`落后远端 ${e} 个提交`,pushDivergedCount:({ahead:e,behind:t})=>`领先 ${e} / 落后 ${t} 个提交`,pullChanges:"拉取",pushChanges:"推送",gitActionRunning:"执行中…",gitActionFailed:({message:e})=>`Git 操作失败:${e}`,confirmRestoreTitle:"确认丢弃改动",confirmRestoreDescription:({path:e})=>`将丢弃 ${e} 的未暂存改动,此操作不可从 Termdock 恢复。`,confirmRestorePhrase:"丢弃改动",confirmRestorePlaceholder:"输入“丢弃改动”确认",confirmStashAllTitle:"确认贮藏全部改动",confirmStashAllDescription:"会把当前工作区改动(包含未跟踪文件)移入贮藏。",confirmAction:"确认"},fileTree:{insertRef:"引用",insertRefTitle:"Insert file reference into active terminal",openDirRoot:"进入",openDirRootTitle:"把这个目录作为当前浏览根目录",openInFileBrowser:"在 Finder 中显示",openInFileBrowserTitle:"在系统文件浏览器中打开这个项目",openInFileBrowserFailed:"打开文件浏览器失败",moreDirActions:"更多目录操作",pinDir:"固定",pinDirTitle:"固定这个目录到当前项目",unpinDir:"已固定",unpinDirTitle:"取消固定这个目录",pinFileTitle:"固定这个文件到当前项目",unpinFileTitle:"取消固定这个文件",pinFile:"固定",unpinFile:"已固定",moreFileActions:"更多文件操作",noWorkingDir:"未检测到工作目录。",emptyDir:"空目录。",noMatchingFiles:"没有匹配的文件。",searching:"正在搜索文件…",searchingWithCount:({count:e})=>`搜索中…已找到 ${e} 项`,searchResults:({count:e})=>`${e} 个结果`,searchTruncatedHint:({count:e})=>`降级搜索已扫描大量目录并在找到 ${e} 项后停止。安装 ripgrep 或输入更精确关键词可获得完整结果。`,searchStillRunning:"搜索仍在进行,更多结果会自动出现。",showingSearchResults:({shown:e,total:t})=>`正在展示 ${e}/${t}`,loadMoreSearchResults:({shown:e,total:t})=>`查看更多(${e}/${t})`,contentMatchesCount:({count:e})=>`${e} 个文件命中`,moreMatches:({count:e})=>`还有 ${e} 处匹配`,noContentMatches:"文件内容中没有匹配。",contentSearchNeedsRipgrep:"内容搜索需要 ripgrep(rg),请在服务端安装后再在文件内搜索。",truncatedHint:"仅展示前 1000 项。使用搜索或打开更小的文件夹以获得更好性能。",dropToUploadHere:"上传到这里"},diffViewer:{noFileChanges:"此文件无改动。",noUnstagedChanges:"没有未暂存的改动。",emptyHint:"做一些改动,或从远程拉取。",loading:"正在加载 diff…",insertAllDiff:"把当前 diff 内容作为上下文插入 Terminal",insertFileDiff:"引用这个文件的 diff",insertHunkDiff:"引用这段 diff hunk",insertHunkShort:"引用",insertFileShort:"引用",insertAllShort:"全部",auditExplanation:"更改意义",auditStale:"解释已失效",auditClear:"清除解释",auditGeneratedAt:({time:e})=>`生成于 ${e}`,allDiffLabel:"全部 diff",allChangesLabel:"全部改动",workingTree:"工作区改动",allUnstaged:"所有未暂存改动",binaryOrEmpty:"没有可显示的文本改动。",noHunks:"没有 hunk",hunkOutline:"Hunk 列表",expandHunkRail:"显示 hunk 列表",collapseHunkRail:"隐藏 hunk 列表",prevHunk:"上一个 hunk",nextHunk:"下一个 hunk",prevFile:"上一个",nextFile:"下一个",expandFile:"展开文件",collapseFile:"折叠文件",expandAll:"全部展开",collapseAll:"全部折叠",collapseHunk:"折叠 hunk",useBracketKeysHint:"按 [ / ] 在 hunk 之间跳转",unified:"统一",unifiedMode:"统一视图",split:"分屏",splitMode:"左右分屏视图",moreActions:"更多操作",view:"视图"},settings:{title:"设置",font:"字体",render:"渲染",theme:"主题",darkTheme:"深色",lightTheme:"浅色",newTab:"新标签",debug:"调试",noSleep:"常亮",noSleepUnavailable:"无网络 — 已禁用",notifications:"通知",notificationsTitle:"通知设置",notificationsHint:"Termdock 在后台时,AI 任务结束后发送系统通知。",notificationsPageHint:"选择哪些 Termdock 事件可以发送系统通知。总开关负责浏览器权限和投递,事件开关决定具体哪些内容提醒你。",notificationsMaster:"系统通知",notificationsMasterHint:"允许 Termdock 在隐藏或作为 PWA 安装运行时发送通知。",notificationsPermission:"权限",notificationsTest:"发送测试",notificationsAlertStyle:"提醒方式",notificationsAlertStyleHint:"最终是否横幅弹出仍由浏览器和 Android 系统决定。Termdock 只能请求静默、默认或持续显示等通知选项。",notificationsStyleNormal:"默认",notificationsStyleNormalHint:"允许时声音/震动",notificationsStyleQuiet:"静默",notificationsStyleQuietHint:"仅状态栏,无声音",notificationsStylePersistent:"持续",notificationsStylePersistentHint:"保留到手动关闭",notificationsEvents:"事件",notificationsAiFinished:"AI 任务结束",notificationsAiFinishedHint:"当 Termdock 在后台时,AI agent 停止后发送通知。",notificationsFutureHint:"后续可以在这里继续增加更多通知类型,不需要改变顶层设置布局。",notificationsOffSummary:"系统通知已关闭",notificationsAiOnSummary:"AI 任务结束通知已开启",notificationsNoEventsSummary:"暂无开启的通知事件",notificationsDenied:"浏览器通知权限已被阻止,请在站点设置中开启。",notificationsUnsupported:"通知需要安全上下文和 Service Worker 支持。",notificationsTestBody:"通知已开启。后台 AI 任务结束后会提醒你。",shell:"Shell",tmux:"Tmux",auto:"自动",webgl:"WebGL",canvas:"内置",tmuxServer:"Tmux 服务",tmuxUnavailable:"不可用",noTmuxSessions:"服务端没有 tmux 会话。",installTmuxHint:"请在服务端安装 tmux 后启用。",refresh:"刷新",attached:"已连接",restorable:"可恢复",attach:"连接",attaching:"连接中…",destroy:"销毁",sessions:({n:e})=>`${e} 个会话`,windows:({n:e})=>`${e} 个窗口`,keyboardToolbar:"键盘工具栏",aiAgentDetection:"AI 代理检测",signOut:"退出登录",language:"语言",programNamePlaceholder:"程序名(如 claude)",patternPlaceholder:"正则表达式(如 Thinking|Generating)",statusPlaceholder:"状态",addProgram:"添加程序",addPattern:"添加规则",resetDefaults:"恢复默认",invalidRegex:"无效的正则",removeProgram:"移除程序",removeRule:"移除规则",keepLabel:"保持",customColor:"自定义颜色",tabIndicator:"标签指示器样式",toolbarPresets:"工具栏预设",detectionRules:"检测规则",agentHooksHint:"安装 hooks 后,agent 会主动上报状态:回合进行中(绿)、等你授权/回答(黄)、回合完成(对勾),并在等待你输入时推送通知。hooks 全局安装但只在 termdock 的终端里生效。",agentHooksInstall:"安装",agentHooksInstalled:"已安装",agentHooksOutdated:"需更新",agentHooksNotInstalled:"未安装",agentHooksUninstall:"卸载",agentHooksReinstall:"重新安装",agentHooksDevMode:"开发模式:hooks 指向 TS 源码,需要构建后的版本才能生效",agentHooksTarget:"写入",agentPlugins:"Agent 插件",agentPluginAdd:"添加插件",agentPluginHint:"自定义 agent 的注册和 hooks 配置。粘贴 manifest.json 来注册新 agent,可选安装 hooks。",agentPluginCreate:"创建插件",agentPluginDelete:"删除插件",mobileKeyboard:"移动键盘",saving:"保存中…",rulesHint:"配置正则表达式来识别 AI 工具在终端标签中的状态。每条规则可独立设置标签、颜色、图标样式以及输出静默后指示器保留的时长。停止后若你未查看该标签,标签会保留一个黄色待查看提示。",programsHelp:"支持在一个配置中匹配多个程序,用英文逗号分隔。",programLabelResolution:"程序名识别",rawCommandMapping:"原始命令映射",rawCommandMappingHint:"以下规则将原始命令行映射为标签显示名。用户规则优先于内置规则。",genericProgramNames:"通用程序名",genericProgramNamesHint:"触发 ps 深度识别(如 node, python)",wrapperScriptNames:"包装脚本名",wrapperScriptNamesHint:"CLI 包装器,启动其他工具(如 aiden, npx)",shellNamesConfig:"Shell 名称",shellNamesHint:"从标签显示中过滤(如 bash, zsh)",addTag:"+ 添加",customRules:"自定义规则",addRule:"添加规则",localAccess:"本地访问",localAccessHint:"手机信任本地 CA 后,可通过这个局域网地址访问。请先在手机上打开「手机引导」地址下载 CA 证书。",resetAutoName:"恢复自动",onboardingUrl:"手机引导",httpsActive:"HTTPS 已启用",httpsInactive:"HTTPS 未启用",caMissing:"未配置 CA 下载"},toolbarPresets:{preview:"预览",presets:"预设",label:"标签",new:"新建",reset:"重置",presetLabelPlaceholder:"预设名称",deletePreset:({name:e})=>`删除预设 ${e}`,matchPrograms:"匹配程序",typeEnterHint:"输入后回车",programsPlaceholder:"vim, nvim, /^claude(-code)?$/i …",programsHelp:"纯字符串按大小写不敏感子串匹配。用 /…/flags 包裹则为正则(针对小写程序名测试)。",altSlot:"Alt 修饰键槽",altSlotHint:"在预览中保留一个 Alt 键槽位。",desktopVisibility:"桌面端显示",desktopVisibilityHint:"桌面端只显示该预设的自定义按钮,不显示基础快捷键。",rowLayout:"行布局",rowLayoutHint:"每行按钮数。",addRow:"行",rowN:({n:e})=>`第 ${e} 行`,del:"删",buttons:"按钮",buttonsHint:"点击编辑,使用 ↑↓ 排序。",addButton:"添加按钮",noCustomButtons:"暂无自定义按钮。添加一个来覆盖默认工具栏。",moveUp:"上移",moveDown:"下移",removeRow:({n:e})=>`移除第 ${e} 行`,removeAction:({name:e})=>`移除 ${e}`,labelField:"标签",labelPlaceholder:"按钮上显示的文本",sequence:"序列",sequencePlaceholder:"例如 /undo 或 \\t 或 /||undo",sequenceHint:"双击序列",doubleTap:"双击序列",doubleTapAdd:"+ 添加",doubleTapPlaceholder:"例如 /undo\\r 或 /||undo ||\\r",remove:"移除",noSequence:"无序列",preset:"预设",overCapacityHint:"按钮数超过槽位,多余按钮将使用最后一行的尺寸。"},agentRules:{ruleColors:{green:"绿",yellow:"黄",red:"红",blue:"蓝",purple:"紫",orange:"橙",gray:"灰"}},tab:{session:"会话",new:"新建会话",rename:"重命名",renameHint:"修改标签的显示名称",renamePlaceholder:"留空则恢复默认名称",copyCwd:"复制当前目录",copyCwdHint:"复制当前工作目录",resumeAgent:"恢复 Agent 会话",resumeAgentHint:"用原生 session id 恢复上次对话",copied:"已复制",close:"关闭会话",closeHint:"从列表移除该标签",longPressTip:"提示:按住标签不动约半秒打开操作菜单,按住并拖动可排序。",sessionsTitle:"会话",explorerTitle:"资源管理器"},agent:{aiRunning:"AI 运行中",needsReview:"需要查看",finishedReview:"AI 已完成 — 需要查看",aiWaiting:"AI 等待中",copyMode:"Copy 模式",jumpToNext:"跳到下一个待处理"},connection:{reconnecting:"正在重连…"},terminal:{input:"终端输入",error:"错误",dropFilesToPastePaths:"拖放文件以输入路径"},errorBoundary:{title:"出现了一些问题",unexpected:"发生意外错误",retry:"重试"},error:{type:{network:"网络连接错误",session:"会话错误",terminal:"终端错误",auth:"认证错误",validation:"验证错误",unknown:"未知错误"},severity:{low:"提示:",medium:"警告:",high:"错误:",critical:"严重错误:"},suggestion:{networkCheck:"检查网络连接",networkRetry:"尝试重新连接",networkProxy:"检查代理设置",networkWait:"等待网络恢复",sessionRecreate:"重新创建会话",sessionServer:"检查服务器状态",sessionCache:"清理浏览器缓存",terminalRestart:"重启终端",terminalConfig:"检查终端配置",terminalClear:"清除终端输出",authRelogin:"重新登录",authCredentials:"检查凭证",authAdmin:"联系管理员",validationFormat:"检查输入格式",validationParams:"验证参数",validationDocs:"参考文档",unknownReload:"刷新页面",unknownApp:"重启应用",unknownSupport:"联系技术支持"}}},GR=["en","zh"],Qd="en",B1="termdock:locale",kg={en:HR,zh:UR};function zR(e){return typeof e=="string"&&GR.includes(e)}function WR(){if(typeof window>"u")return Qd;try{const t=window.localStorage.getItem(B1);if(zR(t))return t}catch{}return(window.navigator?.language?.toLowerCase()??"").startsWith("zh")?"zh":Qd}const Ww=A.createContext(null);function zx(e,t){const r=t.split(".");let n=e;for(const s of r)if(n&&typeof n=="object"&&s in n)n=n[s];else return;return n}function Wx(e,t){return typeof e=="function"?e(t??{}):typeof e!="string"?String(e):t?e.replace(/\{(\w+)\}/g,(r,n)=>Object.prototype.hasOwnProperty.call(t,n)?String(t[n]):r):e}function VR({children:e}){const[t,r]=A.useState(()=>WR());A.useEffect(()=>{typeof window>"u"||fetch("/api/terminal/settings").then(u=>u.json()).then(u=>{if(u?.locale==="zh"||u?.locale==="en"){r(u.locale);try{window.localStorage.setItem(B1,u.locale)}catch{}}}).catch(()=>{})},[]),A.useEffect(()=>{if(!(typeof window>"u")){try{window.localStorage.setItem(B1,t)}catch{}(async()=>{try{const d=document.cookie.split("; ").find(b=>b.startsWith("XSRF-TOKEN=")),f=d?decodeURIComponent(d.split("=")[1]):"";await fetch("/api/terminal/settings",{method:"PUT",headers:{"Content-Type":"application/json",...f?{"X-XSRF-TOKEN":f}:{}},body:JSON.stringify({locale:t})})}catch{}})(),document.documentElement.lang=t==="zh"?"zh-CN":"en"}},[t]);const n=A.useCallback(u=>{r(u)},[]),s=kg[t]??kg[Qd],i=A.useCallback((u,d)=>{const f=zx(s,u);if(f===void 0){const b=zx(kg[Qd],u);return b===void 0?u:Wx(b,d)}return Wx(f,d)},[s]),a=A.useMemo(()=>({locale:t,setLocale:n,t:i}),[t,n,i]);return c.jsx(Ww.Provider,{value:a,children:e})}function Qn(){const e=A.useContext(Ww);return e||{locale:Qd,setLocale:()=>{},t:t=>t}}function qR({error:e}){const{t}=Qn();return c.jsx("div",{className:"flex h-full items-center justify-center p-4",children:c.jsxs("div",{className:"flex flex-col items-center gap-3 text-center max-w-md",children:[c.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:c.jsx("svg",{className:"w-6 h-6 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.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"})})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("h3",{className:"font-medium text-foreground",children:t("errorBoundary.title")}),c.jsx("p",{className:"text-sm text-muted-foreground",children:e?.message||t("errorBoundary.unexpected")})]}),c.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"mt-2 px-5 py-2.5 bg-primary text-primary-foreground text-sm font-medium rounded-full hover:bg-primary/90 active:scale-[0.97] transition-all shadow-sm",children:t("errorBoundary.retry")})]})})}let Vw=class extends P.Component{state={hasError:!1,error:null};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){console.error("Terminal error caught by boundary:",t,r)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:c.jsx(qR,{error:this.state.error}):this.props.children}};function P1(e,t){return e.label.trim().length>0?e.label:`Key ${t+1}`}const yd=12;function YR(){return qw.map(e=>e.id)}const qw=[{id:"default",label:"Base",programs:[],includeAlt:!0,rowLayout:[3,3,3],actions:[],showOnDesktop:!1},{id:"opencode",label:"Code",programs:["opencode"],includeAlt:!1,rowLayout:[4],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:[4],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:"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:[3,3],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:[3,2],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 Fd(){return qw.map(e=>({...e,programs:[...e.programs],includeAlt:e.includeAlt,rowLayout:[...e.rowLayout],actions:e.actions.map(t=>({...t})),showOnDesktop:e.showOnDesktop}))}function G2(e){const t=Array.isArray(e)?e.map(r=>Math.min(20,Math.max(2,Math.floor(r)))).filter(r=>Number.isFinite(r)):[];return t.length>0?t:[3,3]}function Yw(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.length>0?t:null}const z2=/^\/(.+)\/([gimsuy]*)$/;function Vx(e){return z2.test(e.trim())}function Jf(e){const t=e.trim().match(z2);if(!t)return null;try{return new RegExp(t[1]??"",t[2]??"")}catch{return null}}function Zw(e){if(typeof e!="string")return null;const t=e.trim();return t?z2.test(t)?Jf(t)?t:null:t.toLowerCase():null}function qx(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16))).replace(/\\r/g,"\r").replace(/\\n/g,`
|
|
72
72
|
`).replace(/\\t/g," ")}const Yx="||",ZR=120;function KR(e){return e.includes(Yx)?e.split(Yx).filter(t=>t.length>0):[e]}function Qu(e){const t=new Set,r=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}`,u=t.has(a)?`${a}-${i+1}`:a;return t.add(u),{id:u,label:typeof s.label=="string"&&s.label.trim().length>0?s.label.trim():"Preset",programs:Array.isArray(s.programs)?s.programs.map(d=>Zw(d)).filter(d=>!!d):[],includeAlt:typeof s.includeAlt=="boolean"?!!s.includeAlt:!1,rowLayout:G2(s.rowLayout),showOnDesktop:typeof s.showOnDesktop=="boolean"?!!s.showOnDesktop:!1,actions:Array.isArray(s.actions)?s.actions.map((d,f)=>{const b={id:typeof d.id=="string"&&d.id.trim().length>0?d.id:`${u}-action-${f+1}`,label:typeof d.label=="string"?d.label:`Key ${f+1}`,sequence:typeof d.sequence=="string"?d.sequence:""};return typeof d.doubleTapSequence=="string"&&(b.doubleTapSequence=d.doubleTapSequence),b}):[]}}).filter(s=>s.id!=="auto"),n=Fd()[0];return n&&!r.some(s=>s.id==="default")&&r.unshift(n),r}function XR(e,t){const r=Yw(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const s of n.programs){const i=Jf(s);if(i){if(i.test(r))return n.id}else if(r.includes(s))return n.id}return"default"}function Zx(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??Fd()[0]}function JR(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function eN(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function Kw(e,t){const r=G2(t),n=[];let s=0,i=0;for(;s<e.length;){const a=r[Math.min(i,r.length-1)]??3;n.push({columns:a,items:e.slice(s,s+a)}),s+=a,i+=1}return n}const Xw=28,Jw=({mode:e,presetLabel:t,title:r,ariaLabel:n,disabled:s,onPointerDown:i,buttonRef:a})=>c.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:r,"aria-label":n??r,children:e==="auto"?c.jsx(zk,{size:14}):(t.charAt(0)||"?").toUpperCase()}),tN={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},Kx=8;function rN(e,t){return tN[e]??null}const nN=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:s,disabled:i,defaultShowExtended:a=!1,presetLabel:u,presetModeLabel:d,presetMode:f,presetOptions:b,includeAlt:g,presetRowLayout:y,extraActions:v,onKeyPress:w,onTextPress:T,onPastePress:C,longPressMode:E="arrows",copyFeedback:N="idle",onLongPressModeToggle:D,onModifierToggle:R,onPresetSelect:_,onExpandedChange:M})=>{const[Q,H]=P.useState(a),[G,U]=P.useState(!1),W=P.useRef(null),J=r==="desktop-actions",ee=J||Q,[ae,Se]=P.useState(!1),[Le,_e]=P.useState(null),se=i||!e||!t,ie=i||!e,fe=P.useRef(null),Qe=P.useRef(null),de=P.useRef(0),Fe=P.useCallback($e=>{if(se)return;const lt=$e.target;if(!(lt instanceof HTMLElement))return;const $t=lt.closest("button"),Ht=$t?.hasAttribute("data-mobile-copy-button")===!0;$t&&!Ht?($e.preventDefault(),jl(Kx)):$t&&jl(Kx)},[se]),rt=P.useCallback($e=>{$e.preventDefault()},[]),ht=P.useCallback($e=>{const lt=$e.target;se||lt instanceof HTMLElement&<.closest("button")&<.blur()},[se]);P.useEffect(()=>{H(a)},[a]),P.useEffect(()=>{J||M?.(Q)},[J,M,Q]),P.useEffect(()=>{se&&(Qe.current!==null&&(window.clearTimeout(Qe.current.timer),Qe.current=null),Se(!1),_e(null))},[se]),P.useEffect(()=>{e||(Se(!1),_e(null))},[e]),P.useEffect(()=>{if(!ae)return;const $e=()=>{const lt=fe.current?.getBoundingClientRect();lt&&_e({left:Math.max(8,lt.left),top:Math.max(8,lt.top-8)})};return $e(),window.addEventListener("resize",$e),window.addEventListener("scroll",$e,!0),()=>{window.removeEventListener("resize",$e),window.removeEventListener("scroll",$e,!0)}},[ae]);const Ee=P.useCallback(($e,lt)=>{se||($e.preventDefault(),w(lt))},[w,se]),ce=P.useCallback(($e,lt)=>{se||($e.preventDefault(),R(lt))},[R,se]),je=P.useCallback($e=>{se||($e.preventDefault(),H(lt=>{const $t=!lt;return $t&&(U(!0),W.current!==null&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{U(!1),W.current=null},350)),$t}))},[se]),De=P.useCallback(()=>{const $e=typeof performance<"u"?performance.now():Date.now();$e-de.current<350||(de.current=$e,C?.())},[C]),ke=P.useCallback($e=>{se||($e.stopPropagation(),$e.pointerType!=="touch"&&($e.preventDefault(),De()))},[se,De]),ge=P.useCallback($e=>{se||($e.preventDefault(),$e.stopPropagation(),De())},[se,De]),Me=P.useCallback($e=>{se||$e.stopPropagation()},[se]),ct=250,Ae=P.useCallback(()=>{Qe.current!==null&&(window.clearTimeout(Qe.current.timer),Qe.current=null)},[]);P.useEffect(()=>()=>{Ae(),W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[Ae]);const Ve=P.useCallback(($e,lt)=>{if(se)return;if($e.preventDefault(),!lt.doubleTapSequence){T(lt.sequence);return}const $t=Qe.current;if($t!==null&&$t.actionId===lt.id){window.clearTimeout($t.timer),Qe.current=null,T(lt.doubleTapSequence);return}Ae();const Ht=window.setTimeout(()=>{Qe.current=null,T(lt.sequence)},ct);Qe.current={actionId:lt.id,timer:Ht}},[Ae,T,se]),We=P.useCallback($e=>{se||($e.preventDefault(),$e.stopPropagation(),D?.())},[D,se]),he=P.useCallback($e=>{se||$e.stopPropagation()},[se]),Be=P.useCallback($e=>{if(se)return;$e.preventDefault();const lt=$e.currentTarget.getBoundingClientRect();_e({left:Math.max(8,lt.left),top:Math.max(8,lt.top-8)}),Se($t=>!$t)},[se]),Ce=P.useCallback(($e,lt)=>{se||($e.preventDefault(),Se(!1),_e(null),_(lt))},[_,se]),nt=v.length>0,kt=P.useMemo(()=>{const $e=[{id:"preset",kind:"preset"}];return!J&&g&&$e.push({id:"alt",kind:"alt"}),nt?$e.concat(v.map(lt=>({id:lt.id,kind:"text",action:lt}))):J?$e:$e.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,nt,g,J]),vt=P.useMemo(()=>Kw(kt,y),[kt,y]),wt=`${J?"space-y-1":"mt-1 space-y-1"}${G?" pointer-events-none":""}`,Xe=ae&&Le?o0.createPortal(c.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:Le.left,top:Le.top},children:c.jsx("div",{className:"grid gap-1",children:b.map($e=>c.jsx("button",{type:"button",onPointerDown:lt=>Ce(lt,$e.id),tabIndex:-1,disabled:ie,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${$e.id===f?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:$e.label},$e.id))})}),document.body):null;return c.jsxs(c.Fragment,{children:[Xe,c.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?J?"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:Fe,onPointerDownCapture:Fe,onContextMenuCapture:rt,onFocusCapture:ht,children:c.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!J&&c.jsxs("div",{className:"grid grid-cols-10 gap-1",children:[c.jsx("button",{type:"button",onPointerDown:$e=>Ee($e,"esc"),tabIndex:-1,disabled:ie,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"}),c.jsx("button",{type:"button",onPointerDown:$e=>ce($e,"ctrl"),tabIndex:-1,disabled:ie,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${s==="ctrl"?"ring-2 ring-accent":""}`,children:c.jsx("span",{className:"font-medium",children:s==="ctrl"?"Ctrl*":"Ctrl"})}),c.jsx("button",{type:"button",onPointerDown:$e=>Ee($e,"ctrl-c"),tabIndex:-1,disabled:ie,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"}),c.jsx("button",{type:"button",onPointerDown:$e=>Ee($e,"ctrl-w"),tabIndex:-1,disabled:ie,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-W"}),c.jsx("button",{type:"button",onPointerDown:$e=>Ee($e,"ctrl-u"),tabIndex:-1,disabled:ie,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"}),c.jsx("button",{type:"button",onPointerDown:()=>T("/"),tabIndex:-1,disabled:ie,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.jsx("button",{type:"button",onPointerDown:$e=>Ee($e,"enter"),tabIndex:-1,disabled:ie,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:c.jsx(DL,{size:16})}),c.jsx("button",{type:"button","data-mobile-copy-button":"true",onPointerDown:he,onTouchStart:he,onClick:We,tabIndex:-1,disabled:ie,title:N==="copied"?"Copied":N==="failed"?"Copy failed":E==="copy"?"Long press selects text":"Long press sends arrows","aria-label":E==="copy"?"Switch long press to arrow keys":"Switch long press to copy selection",className:`h-7 w-full rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${N==="copied"?"bg-primary/15 text-primary":N==="failed"?"bg-destructive/15 text-destructive":E==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:N==="copied"?c.jsx(rw,{size:15}):N==="failed"?c.jsx(Ks,{size:15}):E==="copy"?c.jsx(LL,{size:15}):c.jsx(xk,{size:15})}),c.jsx("button",{type:"button","data-mobile-copy-button":"true",onPointerDown:ke,onPointerUp:Me,onTouchStart:Me,onTouchEnd:Me,onClick:ge,tabIndex:-1,disabled:ie,title:"Paste","aria-label":"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:c.jsx(CL,{size:15})}),c.jsx("button",{type:"button",onPointerDown:je,tabIndex:-1,disabled:ie,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:Q?c.jsx(vL,{size:16}):c.jsx(Vl,{size:16})})]}),ee&&c.jsx("div",{className:wt,children:vt.map(($e,lt)=>{const $t=$e.items[0]?.kind==="preset",Ht=Math.max(2,$e.columns),St=$t?`${Xw}px repeat(${Math.max(1,Ht-1)}, minmax(0, 1fr))`:`repeat(${Ht}, minmax(0, 1fr))`;return c.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:St},children:$e.items.map(ut=>ut.kind==="preset"?c.jsx(Jw,{buttonRef:ut.id==="preset"?fe:void 0,mode:f,presetLabel:u,title:d,disabled:ie,onPointerDown:Be},ut.id):ut.kind==="alt"?c.jsx("button",{type:"button",onPointerDown:Oe=>ce(Oe,"alt"),tabIndex:-1,disabled:ie,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="alt"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${s==="alt"?"ring-2 ring-accent":""}`,children:c.jsx("span",{className:"font-medium",children:s==="alt"?"Alt*":"Alt"})},ut.id):ut.kind==="text"?c.jsxs("button",{type:"button",onPointerDown:Oe=>Ve(Oe,ut.action),tabIndex:-1,disabled:ie,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:[ut.action.label,ut.action.doubleTapSequence&&c.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},ut.id):c.jsx("button",{type:"button",onPointerDown:Oe=>Ee(Oe,ut.keyName),tabIndex:-1,disabled:ie,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:ut.keyName==="ctrl-d"?"Ctrl-D":ut.keyName==="home"?"Home":"End"},ut.id))},`row-${lt}`)})})]})})]})},sN=({isMobile:e,isInputFocused:t,isIOS:r,isConnecting:n,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 c.jsxs("div",{className:"px-3 py-2 bg-surface text-foreground text-xs border-b border-border/15",children:[c.jsx("div",{className:"font-bold mb-2",children:"Debug Info"}),c.jsxs("div",{className:"grid grid-cols-2 gap-1 font-mono",children:[c.jsxs("div",{children:["isMobile: ",c.jsx("span",{className:e?"text-accent":"text-destructive",children:String(e)})]}),c.jsxs("div",{children:["touchPoints: ",navigator.maxTouchPoints]}),c.jsxs("div",{children:["innerWidth: ",window.innerWidth]}),c.jsxs("div",{children:["innerHeight: ",window.innerHeight]}),c.jsxs("div",{children:["viewportH:"," ",window.visualViewport?Math.round(window.visualViewport.height):"N/A"]}),c.jsxs("div",{children:["inputFocused: ",String(t)]}),c.jsxs("div",{children:["keyboard~: ",a,"px"]}),c.jsxs("div",{children:["connecting:"," ",c.jsx("span",{className:n?"text-muted-foreground":"text-accent",children:String(n)})]}),c.jsxs("div",{children:["sessionId:"," ",c.jsx("span",{className:i?"text-accent":"text-destructive",children:i?"✓":"✗"})]}),c.jsxs("div",{children:["error:"," ",c.jsx("span",{className:s?"text-destructive":"text-accent",children:s?"Yes":"No"})]}),c.jsxs("div",{children:["isIOS:"," ",c.jsx("span",{className:r?"text-muted-foreground":"text-accent",children:String(r)})]})]}),c.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:c.jsx("div",{children:"Tip: Tap the status bar 3 times to toggle debug panel"})})]})},iN=/^Reconnecting/i,oN=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:s})=>{const{t:i}=Qn(),a=!!e&&!t&&iN.test(e);return n&&!e||a?c.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:c.jsx("span",{className:"text-[11px] text-muted-foreground/60 animate-pulse tracking-wide",children:e||i("connection.reconnecting")})}):e?c.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2",children:c.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-destructive/70",children:[c.jsx("span",{children:e}),t&&c.jsx("button",{type:"button",onClick:s,disabled:r,className:"text-[11px] text-destructive/90 hover:text-destructive underline underline-offset-2 transition-colors disabled:opacity-40",children:i("common.retry")})]})}):null},aN=120,lN=80,cN=400;function Xx(){if(typeof window>"u")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 r=Number.parseFloat(document.documentElement.style.getPropertyValue("--app-base-vh")||"0")||window.innerHeight,n=Number.parseFloat(document.documentElement.style.getPropertyValue("--safe-bottom-inset")||"0")||0,s=t.height+t.offsetTop;return Math.max(0,Math.round(r-s-n))}function uN(e){const{enabled:t,openThresholdPx:r=aN,closeThresholdPx:n=lN,settleDelayMs:s=cN}=e,i=P.useMemo(()=>Dc("keyboard"),[]),a=P.useRef(!1),u=P.useRef(null),d=P.useRef(0),[f,b]=P.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return P.useEffect(()=>{if(typeof window>"u"||!t){a.current=!1,u.current!==null&&(clearTimeout(u.current),u.current=null),b(M=>!M.isOpen&&!M.isSettled&&M.keyboardHeight===0?M:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let g=null;const y=()=>{g=null;const M=Xx();let Q=a.current;if(M>=r?Q=!0:M<=n&&(Q=!1),a.current=Q,Q){const H=Math.abs(M-d.current);d.current=M,H>10&&(u.current!==null&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null,b(G=>G.isSettled?G:{...G,isSettled:!0})},s))}else u.current!==null&&(clearTimeout(u.current),u.current=null);b(H=>{const G=Q?H.isSettled:!1;return H.isOpen===Q&&H.keyboardHeight===M&&H.isSettled===G?H:(i("sync",{keyboardHeight:M,isOpen:Q,isSettled:G,visualViewport:window.visualViewport?{width:Math.round(window.visualViewport.width),height:Math.round(window.visualViewport.height),offsetTop:Math.round(window.visualViewport.offsetTop)}:null}),{isOpen:Q,isSettled:G,keyboardHeight:M})})},v=(M="event")=>{(M.includes("visibilitychange")||M.includes("pageshow"))&&i("schedule",{source:M}),g===null&&(g=window.requestAnimationFrame(y))};v("mount");const w=()=>v("resize"),T=()=>v("orientationchange"),C=()=>v("visualViewport.resize"),E=()=>v("visualViewport.scroll"),N=()=>v("viewport-keyboard-change");window.addEventListener("resize",w),window.addEventListener("orientationchange",T),window.visualViewport?.addEventListener("resize",C),window.visualViewport?.addEventListener("scroll",E),document.addEventListener("termdock:viewport-keyboard-change",N);const D=M=>{i("resume",{source:M,keyboardHeight:Xx(),hidden:document.hidden}),v(`${M}:now`),window.setTimeout(()=>v(`${M}:50ms`),50),window.setTimeout(()=>v(`${M}:200ms`),200)},R=()=>{document.hidden||D("visibilitychange")},_=()=>D("pageshow");return document.addEventListener("visibilitychange",R),window.addEventListener("pageshow",_),()=>{window.removeEventListener("resize",w),window.removeEventListener("orientationchange",T),window.visualViewport?.removeEventListener("resize",C),window.visualViewport?.removeEventListener("scroll",E),document.removeEventListener("termdock:viewport-keyboard-change",N),document.removeEventListener("visibilitychange",R),window.removeEventListener("pageshow",_),g!==null&&window.cancelAnimationFrame(g),u.current!==null&&(clearTimeout(u.current),u.current=null)}},[i,t,r,n,s]),f}const dN=320,Jx="termdock:mobile-keyboard-expanded",ey="termdock:mobile-keyboard-preset-mode",ty="termdock:mobile-long-press-mode",hN={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},fN=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=$2(),colorTheme:s="dark",toolbarPresets:i=[],isActive:a=!0,focusRequestToken:u=0,resumeRequestToken:d=0,resumeRequestReason:f="visibility",onKeyboardVisibilityChange:b,showDebug:g,onStatusChange:y})=>{const[v,w]=P.useState(n.fontSize),T=P.useMemo(()=>$R(),[]),C=P.useMemo(()=>Dc("session"),[]),E=P.useMemo(()=>Dc("keyboard"),[]);P.useEffect(()=>{w(n.fontSize)},[n.fontSize]);const N=P.useMemo(()=>({...n,fontSize:v}),[n,v]),[D]=P.useState(e||pC()),[R,_]=P.useState(!1),[M,Q]=P.useState(!1),[H,G]=P.useState(!1),[U,W]=P.useState(!1),[J,ee]=P.useState(()=>typeof document>"u"?!0:!document.hidden),[ae,Se]=P.useState(()=>typeof document>"u"?!0:document.hasFocus()),[Le,_e]=P.useState(!1),{isOpen:se,keyboardHeight:ie}=uN({enabled:R&&a}),[fe,Qe]=P.useState(null),[de,Fe]=P.useState(null),[rt,ht]=P.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(Jx)==="true"),[Ee,ce]=P.useState(()=>{if(typeof window>"u")return"auto";const ve=window.localStorage.getItem(ey);return ve&&ve.length>0?ve:"auto"}),[je,De]=P.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(ty)==="copy"?"copy":"arrows"),[ke,ge]=P.useState("idle"),Me=Pn(),ct=Me.sessions,Ae=Me.setTerminalSession,Ve=Me.setConnecting,We=Me.appendToBuffer,he=Me.clearTerminalSession,Be=Me.removeTerminalSession,Ce=Me.clearBuffer,nt=Me.setSessionActiveProgram,kt=Me.setSessionCwd,vt=Me.setSessionCopyMode,wt=Me.setSessionAgentStatus,Xe=Me.setSessionShellTitle,$e=Me.setSessionPromptState,lt=P.useMemo(()=>{if(D)return ct.get(D)},[ct,D]),$t=P.useMemo(()=>`wt-${D.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[D]),Ht=lt?.terminalSessionId??null,St=lt?.mode??"shell",ut=lt?.activeProgram??null,Oe=P.useMemo(()=>Qu(i),[i]),It=St==="tmux",it=lt?.bufferChunks??[],Re=lt?.isConnecting??!1,ne=Ht,be=t??lt?.mode??"shell",Te=be==="tmux"?r??lt?.tmuxSessionName??null:null,[ue,ot]=P.useState(null),[xt,Rt]=P.useState(!1),[at,Ye]=P.useState(!1),[st,mt]=P.useState(0),[Ze,rr]=P.useState(null),Tt=g!==void 0?g:!1,yr=P.useRef(null),cn=P.useRef(null),Vt=P.useRef(null),le=P.useRef(null),Yt=P.useRef(null),et=P.useRef(!1),Ct=P.useRef(null),Fn=P.useRef([]),On=P.useRef(0),lr=P.useRef(!1),Bt=P.useRef(null),nn=P.useRef(null),qn=P.useRef(null),ri=P.useRef(0),Hr=P.useRef(null),Rr=P.useRef(0),un=P.useRef(a),_n=P.useRef(R),Sr=P.useRef(null),sn=P.useRef(null),Dr=P.useRef(null),on=P.useRef(null),Yn=P.useCallback(()=>{Dr.current=null;const ve=sn.current;sn.current=null,ve&&Xe(ve.sessionId,ve.title)},[Xe]),ts=P.useCallback((ve,Je)=>{if(sn.current={sessionId:ve,title:Je},Dr.current===null){if(typeof window>"u"){Yn();return}Dr.current=window.requestAnimationFrame(Yn)}},[Yn]),Fs=P.useCallback(()=>{Dr.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(Dr.current),Dr.current=null,sn.current=null},[]),ks=P.useCallback(async()=>{const ve=be;return(await O6({preferredFrontendSessionId:D,mode:ve,tmuxSessionName:ve==="tmux"?Te||$t:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[be,Te,$t,D]);P.useEffect(()=>{un.current=a},[a]);const ni=P.useRef(!1);P.useEffect(()=>{if(!a){Yt.current?.blur(),ni.current=!1;return}if(ni.current)return;ni.current=!0;let ve=0,Je=0;ve=requestAnimationFrame(()=>{Je=requestAnimationFrame(()=>{Yt.current?.requestRefresh("page-flip")})});const ft=window.setTimeout(()=>{Yt.current?.requestRefresh("page-flip")},360);return()=>{cancelAnimationFrame(ve),cancelAnimationFrame(Je),window.clearTimeout(ft)}},[a,ne]),P.useEffect(()=>{_n.current=R},[R]);const dn=P.useCallback(()=>{un.current&&Yt.current?.focus()},[]),Cr=P.useCallback(ve=>{typeof window>"u"||typeof document>"u"||!un.current||_n.current||document.hidden||(Sr.current!==null&&window.clearTimeout(Sr.current),Sr.current=window.setTimeout(()=>{if(Sr.current=null,!un.current||_n.current||document.hidden)return;const Je=document.activeElement,ft=Je?.getAttribute("data-terminal-input-anchor")==="true";if((Je instanceof HTMLInputElement||Je instanceof HTMLTextAreaElement||Je instanceof HTMLSelectElement||Je?.isContentEditable===!0)&&!ft){E("desktop resume focus skipped: editable active",{reason:ve});return}E("desktop resume focus",{reason:ve}),Yt.current?.focus()},50))},[E]);P.useEffect(()=>()=>{Sr.current!==null&&typeof window<"u"&&window.clearTimeout(Sr.current),Sr.current=null,on.current!==null&&typeof window<"u"&&window.clearTimeout(on.current),on.current=null},[]);const cr=P.useCallback(()=>{Fr.current=!1,mt(ve=>ve+1)},[]),Kr=P.useCallback(ve=>{const Je=Vt.current;if(Je&&HC(Je)){C("[Terminal] resume probe sent",{reason:ve,backendSessionId:Je,active:un.current});return}C("[Terminal] resume probe missing connection, restarting ensureSession",{reason:ve,backendSessionId:Je,active:un.current}),cr()},[C,cr]),Br=P.useCallback((ve,Je)=>{const ft=Vt.current;ft&&Ct.current!==ve&&(Ct.current=ve,_b(ft,ve,Je),C("[Terminal] flow-control state sent",{backendSessionId:ft,paused:ve,reason:Je}))},[C]),Qr=P.useCallback((ve,Je)=>{const ft=Vt.current;ft&&Hr.current!==ve&&(Hr.current=ve,UC(ft,ve,Je),C("[Terminal] focus state sent",{backendSessionId:ft,focused:ve,reason:Je}))},[C]),Os=FR({isActive:a,viewportFocused:U,documentVisible:J,windowFocused:ae,streamReady:Le});P.useEffect(()=>{Qr(Os,"logical-focus-change")},[Os,Qr,ne]),P.useEffect(()=>{const ve=Je=>{const Pe=Je.detail;typeof Pe=="number"&&Pe>=8&&Pe<=32&&w(Pe)};return document.addEventListener("termfontchange",ve),()=>document.removeEventListener("termfontchange",ve)},[]),P.useEffect(()=>{const ve=()=>{const Et=!document.hidden;ee(Et),Et&&a&&Cr("visibility")},Je=Et=>{a&&Cr(Et.persisted?"bfcache":"pageshow")},ft=()=>{Se(!0),Cr("window-focus")},Pe=()=>Se(!1);return document.addEventListener("visibilitychange",ve),window.addEventListener("pageshow",Je),window.addEventListener("focus",ft),window.addEventListener("blur",Pe),()=>{document.removeEventListener("visibilitychange",ve),window.removeEventListener("pageshow",Je),window.removeEventListener("focus",ft),window.removeEventListener("blur",Pe)}},[a,Cr]),P.useEffect(()=>{d&&(Yt.current?.requestRefresh(f),Kr("global-resume"))},[d,f,Kr]);const dr=P.useRef(0);P.useEffect(()=>{if(Le){dr.current=0;return}if(!xt||dr.current>=8)return;const Je=dr.current,ft=Math.min(2e3*Math.pow(2,Je),3e4),Pe=setTimeout(()=>{dr.current+=1,C("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:dr.current,backendSessionId:Vt.current}),ot("Reconnecting..."),Rt(!1),cr()},ft);return()=>clearTimeout(Pe)},[xt,Le,st,C,cr]),P.useEffect(()=>{if(typeof window>"u"){Q(!1);return}const ve=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;Q(ve)},[]),P.useEffect(()=>{(!a||!R)&&G(!1),a||W(!1)},[a,R]),P.useEffect(()=>{Vt.current=ne,Hr.current=null,Ct.current=null},[ne]),P.useEffect(()=>{It||(lr.current=!1,Bt.current=null,nn.current&&(clearTimeout(nn.current),nn.current=null))},[It]),P.useEffect(()=>{ne&&Yt.current?.requestRefresh("session-key-change",{force:!0})},[ne]),P.useEffect(()=>{const ve=a&&R&&se;E("visibility signal",{sessionId:D,isActive:a,isMobile:R,isInputFocused:H,isViewportKeyboardOpen:se,viewportKeyboardHeight:ie,visible:ve}),b?.(D,ve)},[b,D,a,R,se,ie,E]),P.useEffect(()=>{a&&u&&u!==ri.current&&(ri.current=u,dn())},[u,dn,a]),P.useEffect(()=>{le.current=D},[D]),P.useEffect(()=>{!R&&(fe!==null||de!==null)&&(Qe(null),Fe(null),qn.current=null)},[R,fe,de]),P.useEffect(()=>{!ne&&(fe!==null||de!==null)&&(Qe(null),Fe(null),qn.current=null)},[ne,fe,de]),P.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Jx,rt?"true":"false")},[rt]),P.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(ey,Ee)},[Ee]),P.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(ty,je)},[je]),P.useEffect(()=>{const ve=()=>{if(typeof window>"u")return!1;const ft=navigator.maxTouchPoints>0||"ontouchstart"in window,Pe=window.innerWidth<768;return ft&&Pe};_(ve());const Je=()=>{_(ve())};return window.addEventListener("resize",Je),()=>window.removeEventListener("resize",Je)},[]);const gr=P.useCallback(()=>{Rr.current+=1,Yn(),Fs();const ve=yr.current;yr.current=null,cn.current=null,_e(!1),Yt.current?.setSessionReady(!1);const Je=Vt.current;Je&&_b(Je,!1,"stream-disconnect"),et.current=!1,Ct.current=null,Fn.current=[],ve?.()},[Fs,Yn]),Es=P.useCallback(ve=>{if(cn.current===ve){C(`[startStream] Skipping - already connected to ${ve}`);return}C(`[startStream] Starting stream for frontendSessionId=${D} backendSessionId=${ve}`),gr();const Je=Rr.current+1;Rr.current=Je;const ft=T.connect(ve,{onEvent:Pe=>{if(Rr.current!==Je)return;const Et=D;if(Et)switch(Pe.type){case"connected":{(Pe.runtime||Pe.ptyBackend)&&C(`[Terminal] connected frontendSessionId=${Et} backendSessionId=${Vt.current} runtime=${Pe.runtime??"unknown"} pty=${Pe.ptyBackend??"unknown"} cwd=${Pe.cwd??"unknown"}`),Ve(Et,!1),ot(null),Rt(!1),_e(!0),Yt.current?.setSessionReady(!0),Ct.current=null,Br(et.current,"stream-connected"),Pe.tuiProgress!==void 0&&Pn.getState().setSessionTuiProgress(Et,Pe.tuiProgress??null),Pe.shellTitle!==void 0&&Pn.getState().setSessionShellTitle(Et,Pe.shellTitle??null),Pe.promptState!==void 0&&Pe.promptState!==null&&Pn.getState().setSessionPromptState(Et,Pe.promptState);const Mt=Pn.getState().getTerminalSession(Et);if(Mt?.terminalSessionId&&Pe.mode&&Pn.getState().setTerminalSession(Et,{sessionId:Mt.terminalSessionId,cols:80,rows:24,mode:Pe.mode,tmuxSessionName:Pe.tmuxSessionName??null,cwd:Pe.cwd??null}),Pe.activeProgram!==void 0&&nt(Et,Pe.activeProgram??null,Pe.activeProgramSource??null,Pe.activeProgramRaw??null),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Yt.current?.requestRefresh("connected",{force:!0,resizeDebounceMs:0})})}),typeof window<"u"&&un.current&&_n.current&&(window.setTimeout(()=>{Yt.current?.requestRefresh("connected",{force:!0,resizeDebounceMs:0})},120),window.setTimeout(()=>{Yt.current?.requestRefresh("connected",{force:!0,resizeDebounceMs:0})},360)),Pe.mode!=="tmux"&&(rr(null),vt(Et,!1)),C("[Terminal] Connected event received:",{frontendSessionId:Et,backendSessionId:Vt.current,storeHasState:!!Mt,storeTerminalId:Mt?.terminalSessionId,hasHistoryInStore:!!Mt?.history?.length,historyLength:Mt?.history?.length??0}),Mt?.history&&Mt.history.length>0){C(`[Terminal] Restoring ${Mt.history.length} history chunks to frontend session ${Et}`);const Ar=Mt.history.reduce((Gr,zr)=>Gr+zr.length,0),vn=Math.max(300,Math.min(2e3,Math.ceil(Ar/200)));On.current=Date.now()+vn,Mt.history.forEach(Gr=>{We(Et,Gr,{markActivity:!1})}),Pn.getState().setSessionHistory(Et,[]),C(`[Terminal] History restoration complete for ${Et}`)}else C(`[Terminal] No history to restore for ${Et}`);const br=Pe.replayChunks;if(br&&br.length>0){Pe.replayOutOfWindow?(C(`[Terminal] Replay out-of-window, clearing buffer before replay (${br.length} chunks)`),Ce(Et),Yt.current?.clear()):C(`[Terminal] Replay incremental: ${br.length} chunks`);const Ar=br.reduce((Gr,zr)=>Gr+zr.length,0),vn=Math.max(200,Math.min(1500,Math.ceil(Ar/200)));On.current=Math.max(On.current,Date.now()+vn);for(const Gr of br)We(Et,Gr)}break}case"reconnecting":{const Mt=Pe.attempt??0,br=Pe.maxAttempts??3;ot(`Reconnecting (${Mt}/${br})...`),Rt(!1);break}case"data":{Pe.data&&(et.current?Fn.current.push(Pe.data):We(Et,Pe.data));break}case"tmux-layout":{rr(Pe.layout??null),Pe.layout&&vt(Et,Pe.layout.inCopyMode);break}case"active-program":{nt(Et,Pe.activeProgram??null,Pe.activeProgramSource??null,Pe.activeProgramRaw??null);break}case"cwd":{kt(Et,Pe.cwd??null);break}case"agent-status":{wt(Et,{agentStatus:Pe.agentStatus??null,agentIndicator:Pe.agentIndicator??null,agent:Pe.agent??null,agentMessage:Pe.agentMessage??null,agentNativeSessionId:Pe.agentNativeSessionId??null,agentRich:Pe.agentRich===!0,agentActivity:Pe.agentActivity??0,agentCwd:Pe.agentCwd??null,reviewed:Pe.reviewed??null});break}case"git-status":{Pn.getState().setSessionGitStatus(Et,Pe.gitStatus??null);break}case"focus-mode":{C("[Terminal] focus tracking mode",{backendSessionId:Vt.current,requested:Pe.focusTrackingRequested===!0});break}case"pty-size":{typeof Pe.cols=="number"&&typeof Pe.rows=="number"&&Yt.current?.notifyServerSize(Pe.cols,Pe.rows,Pe.source);break}case"shell-title":{ts(Et,Pe.title??null);break}case"prompt-state":{$e(Et,Pe.state??"idle",Pe.exitCode??null);break}case"tui-progress":{Pn.getState().setSessionTuiProgress(Et,Pe.tuiProgress??null);break}case"exit":{const Mt=typeof Pe.exitCode=="number"?Pe.exitCode:null,br=typeof Pe.signal=="number"?Pe.signal:null;We(Et,`\r
|
|
73
73
|
[Process exited${Mt!==null?` with code ${Mt}`:""}${br!==null?` (signal ${br})`:""}]\r
|
|
74
74
|
`),he(Et),Ve(Et,!1),ot("Terminal session ended"),_e(!1),Rt(!1),rr(null),vt(Et,!1),gr();break}}},onError:(Pe,Et)=>{if(Rr.current!==Je)return;const Mt=D;if(!Mt)return;const br=Et?`Connection failed: ${Pe.message}`:Pe.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${Et}):`,br),Pe.message==="Session not found on server"&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:Vt.current,frontendSessionId:Mt,isActive:a,isMobile:R,fatal:Et,stack:new Error().stack}),ot(br),Rt(!!Et),Et&&(Ve(Mt,!1),gr(),Pe.message==="Session not found on server"&&(C("[onError] Session lost, auto-recreating"),ot("Reconnecting..."),Rt(!1),he(Mt),Ce(Mt),Vt.current=null,Fr.current=!1,setTimeout(()=>{Fr.current=!1,mt(Ar=>Ar+1)},200)))}},hN);yr.current=()=>{ft.close(),Rr.current===Je&&(cn.current=null)},cn.current=ve},[We,Ce,he,C,gr,Br,ts,Ve,nt,wt,vt,kt,$e,T,D]),Fr=P.useRef(!1),hn=P.useRef(0);P.useEffect(()=>()=>{hn.current+=1,Fr.current=!1,gr()},[gr]);const $n=P.useRef(be),ta=P.useRef(Te);P.useEffect(()=>{const ve=$n.current,Je=ta.current;$n.current=be,ta.current=Te,le.current===D&&(ve===be&&Je===Te||(Fr.current=!1,gr(),mt(ft=>ft+1)))},[be,Te,gr,D]),P.useEffect(()=>{if(le.current!==D&&(C(`[useEffect] sessionId changed from ${le.current} to ${D}, allowing reinitialization`),Fr.current=!1),Fr.current&&le.current===D){C(`[useEffect] Already initialized for sessionId=${D}, skipping`);return}C(`[useEffect] Running ensureSession for sessionId=${D}, hasInitialized=${Fr.current}`),Fr.current=!0;const ve=++hn.current;return(async()=>{if(C(`[ensureSession] Starting for sessionId=${D}, runId=${ve}`),!le.current||le.current!==D){C(`[ensureSession] SessionId mismatch or stale run (current=${le.current}, target=${D}), skipping`);return}if(ve!==hn.current){C(`[ensureSession] Stale run detected (runId=${ve}, currentRunId=${hn.current}), skipping`);return}const ft=Pn.getState(),Pe=ft.getTerminalSession(D),Et=Pe?.mode??be;C("[ensureSession] Current state from store:",{terminalSessionId:Pe?.terminalSessionId,mode:Pe?.mode,tmuxSessionName:Pe?.tmuxSessionName,isConnecting:Pe?.isConnecting});let Mt=Pe?.terminalSessionId??null,br=!Mt;if(Mt&&Et!==be?(C(`[ensureSession] Store mode mismatch for ${Mt}: current=${Et} desired=${be}, will create new session`),br=!0,ft.clearTerminalSession(D),Mt=null):Mt&&be==="tmux"&&Te&&Pe?.tmuxSessionName!==Te&&(C(`[ensureSession] Store tmux name mismatch for ${Mt}: current=${Pe?.tmuxSessionName} desired=${Te}, will create new session`),br=!0,ft.clearTerminalSession(D),Mt=null),Mt&&T.checkHealth){C(`[ensureSession] Checking health of existing session ${Mt}`);try{const Ar=await T.checkHealth(Mt);if(C("[ensureSession] Health check result:",Ar),!Ar.healthy)C(`[ensureSession] Session ${Mt} is NOT healthy (healthy=${Ar.healthy}), will create new session`),C("[ensureSession] Health check details:",Ar),br=!0,Ar.mode&&Pe?.terminalSessionId&&ft.setTerminalSession(D,{sessionId:Pe.terminalSessionId,cols:80,rows:24,mode:Ar.mode,tmuxSessionName:Ar.tmuxSessionName??null}),ft.clearTerminalSession(D),C("[ensureSession] Cleared unhealthy session from store");else{C(`[ensureSession] Session ${Mt} is healthy, reusing it, cwd=${Ar.cwd}, clients=${Ar.clients}, lastActivity=${Date.now()-(Ar.lastActivity||0)}ms ago`),Ar.mode&&Pe?.terminalSessionId&&ft.setTerminalSession(D,{sessionId:Pe.terminalSessionId,cols:80,rows:24,mode:Ar.mode,tmuxSessionName:Ar.tmuxSessionName??null}),C(`[ensureSession] Setting terminalIdRef to ${Mt} and starting stream`),Vt.current=Mt,Es(Mt),C(`[ensureSession] Successfully reused healthy session ${Mt}, returning early`);return}}catch(Ar){C(`[ensureSession] Failed to check health of session ${Mt}:`,Ar),C("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(C(`[ensureSession] Decision: shouldCreateNewSession=${br}, terminalId=${Mt}`),br){C(`[ensureSession] Creating new session, shouldCreateNewSession=${br}, runId=${ve}`),ot(null),Rt(!1),ft.setConnecting(D,!0);const vn=Pn.getState().getTerminalSession(D),zr=(vn?.mode??be)===be&&(be!=="tmux"||!Te||vn?.tmuxSessionName===Te);if(vn?.terminalSessionId&&zr)C(`[ensureSession] Race condition avoided: another instance already created session ${vn.terminalSessionId}`),ft.setConnecting(D,!1),Mt=vn.terminalSessionId,br=!1;else try{const ss=await ks();if(C(`[ensureSession] Opened managed backend session ${ss.sessionId}`),ve!==hn.current){C(`[ensureSession] Stale run after session creation (runId=${ve}, currentRunId=${hn.current}), leaving ${ss.sessionId} for sibling`);return}ft.setTerminalSession(D,ss),C(`[ensureSession] Updated store with new session ${ss.sessionId}`),Mt=ss.sessionId}catch(ss){if(ve!==hn.current){C("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(ss instanceof B6&&ss.code==="STALE_SESSION_RESTORE_REJECTED"){C("[ensureSession] Dropping stale persisted session:",{sessionId:D,error:ss.message}),ft.clearTerminalSession(D),window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:D,closeMode:"detach"}}));return}ot(ss instanceof Error?ss.message:"Failed to start terminal session"),Rt(!0),ft.setConnecting(D,!1);return}}if(ve!==hn.current){C(`[ensureSession] Stale run before starting stream (runId=${ve}, currentRunId=${hn.current}), skipping`);return}if(!Mt){C(`[ensureSession] No terminalId, terminalId=${Mt}`);return}C(`[ensureSession] Starting stream for session ${Mt}`),Vt.current=Mt,Es(Mt),C(`[ensureSession] ensureSession completed for sessionId=${D}, terminalId=${Mt}`)})(),()=>{C(`[useEffect] Cleanup for sessionId=${D}, runId=${ve}`)}},[D,st,Es,gr,T,C,be,Te,$t]);const vr=P.useCallback(async()=>{if(D&&!at){Ye(!0),ot(null),Rt(!1),gr();try{T.forceKill&&await T.forceKill({sessionId:D})}catch{}Be(D),Ce(D),Yt.current?.clear(),await new Promise(ve=>setTimeout(ve,100));try{Ve(D,!0);const ve=await ks();Ae(D,ve),Vt.current=ve.sessionId,Es(ve.sessionId)}catch(ve){ot(ve instanceof Error?ve.message:"Failed to create terminal"),Rt(!0),Ve(D,!1)}finally{Ye(!1)}}},[D,at,gr,T,Be,Ce,Ve,Ae,Es,ks]),Xr=P.useCallback((ve,Je)=>{if(!un.current||!ve)return;const ft=/^(\x1b\[<[0-9]+;[0-9]+;[0-9]+[mM])+$/.test(ve),Pe=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(ve);if(It&&Pe&&(lr.current=!0),Date.now()<On.current)return;let Et=ve,Mt=Je?.consumeModifier??!1;if(!Je?.skipModifierTransform&&fe&&ve.length>0){const vn=ve[0];if(vn.length===1&&/[a-zA-Z]/.test(vn)){const Gr=vn.toUpperCase();fe==="ctrl"?(Et=String.fromCharCode(Gr.charCodeAt(0)&31),Mt=!0):fe==="alt"&&(Et=`\x1B${ve}`,Mt=!0)}Mt||(fe==="alt"&&(Et=`\x1B${ve}`),Mt=!0)}const br=Vt.current;if(!br)return;(async()=>{try{if(It&&!ft&&lr.current&&T.tmuxAction){lr.current=!1;try{await T.tmuxAction(br,{action:"copy-mode",enabled:!1})}catch{}}await T.sendInput(br,Et),Me.clearAgentNeedsReview(D)}catch(vn){ot(vn instanceof Error?vn.message:"Failed to send input")}})(),Mt&&(de||Qe(null),dn())},[fe,dn,It,de,T]);P.useEffect(()=>{const ve=Je=>{if(!un.current)return;const ft=Je,Pe=ft.detail?.text;Pe&&(Yt.current?.sendSequence(Pe),ft.detail?.focus!==!1&&dn())};return window.addEventListener("termdock-insert-reference",ve),()=>window.removeEventListener("termdock-insert-reference",ve)},[dn]);const Jr=P.useCallback((ve,Je)=>{const ft=Vt.current;if(!ft){E("xterm resize push skipped: no terminalId",{cols:ve,rows:Je});return}E("xterm resize push",{cols:ve,rows:Je}),T.resize({sessionId:ft,cols:ve,rows:Je}).catch(Pe=>{Pe&&/session not found/i.test(String(Pe.message||Pe))&&console.warn("[Terminal] resize 404 session not found",{sessionId:ft,cols:ve,rows:Je,stack:new Error().stack})})},[T,E]),Pr=P.useCallback(async ve=>{const Je=Vt.current;if(!(!Je||!T.tmuxAction))try{const ft=await T.tmuxAction(Je,ve);ft.layout&&(rr(ft.layout),ve.action==="switch-session"&&(Ae(D,{sessionId:Je,cols:80,rows:24,mode:"tmux",tmuxSessionName:ft.layout.sessionName}),Lf(D,{tmuxSessionName:ft.layout.sessionName}).catch(Pe=>{console.warn("[Terminal] failed to update inventory after tmux switch",Pe)})))}catch(ft){ot(ft instanceof Error?ft.message:"Failed to execute tmux action")}},[D,Ae,T]);P.useEffect(()=>{if(!Ze||!ne)return;const Je=Ze.windows.find(ft=>ft.id===Ze.activeWindowId)?.panes.find(ft=>ft.id===Ze.activePaneId);Je&&Yt.current?.requestRefresh("tmux-layout",{candidateSize:{cols:Je.width,rows:Je.height},skipScrollToBottom:!0,dedupeKey:`${ne}:${Ze.sessionId}:${Je.id}:${Je.width}x${Je.height}`})},[Ze,ne]);const fn=P.useCallback((ve,Je=5)=>{const ft=Math.max(1,Math.min(Math.floor(Je)||1,40));lr.current=!0;const Pe=Bt.current;if(Pe&&Pe.direction===ve){Pe.lines+=ft;return}Pe&&Pr({action:"scroll",direction:Pe.direction,lines:Pe.lines}).finally(()=>{dn()}),Bt.current={direction:ve,lines:ft},nn.current&&clearTimeout(nn.current),nn.current=setTimeout(()=>{const Et=Bt.current;Et&&(Bt.current=null,Pr({action:"scroll",direction:Et.direction,lines:Et.lines}).finally(()=>{dn()}))},0)},[dn,Pr]),co=P.useCallback(ve=>{const Je=Date.now(),ft=qn.current,Pe=ft!==null&&ft.modifier===ve&&Je-ft.timestamp<=dN;if(qn.current={modifier:ve,timestamp:Je},de===ve){Fe(null),Qe(null);return}if(Pe){Fe(ve),Qe(ve);return}de!==null&&de!==ve&&Fe(null),Qe(Et=>Et===ve?null:ve)},[de]),uo=P.useCallback(ve=>{if(W(ve&&un.current),E("input focus changed",{focused:ve,isActive:un.current,isMobile:_n.current}),!_n.current||!un.current){G(!1);return}G(Je=>Je===ve?Je:ve)},[E]),Ur=P.useCallback(ve=>{if(et.current=ve,Br(ve,"viewport-watermark"),!ve&&Fn.current.length>0){const Je=D;if(Je){const ft=Fn.current;Fn.current=[];for(const Pe of ft)We(Je,Pe)}}},[We,Br,D]),_r=P.useCallback(ve=>{un.current&&Yt.current?.ensureSizeMatches(ve)},[]),Hn=P.useRef(null);P.useEffect(()=>{if(!a)return;const ve=Hn.current;if(!ve)return;const Je=()=>_r("pointerdown"),ft=()=>_r("keydown"),Pe=()=>_r("touchstart"),Et=()=>_r("wheel");return ve.addEventListener("pointerdown",Je),ve.addEventListener("keydown",ft),ve.addEventListener("touchstart",Pe,{passive:!0}),ve.addEventListener("wheel",Et,{passive:!0}),()=>{ve.removeEventListener("pointerdown",Je),ve.removeEventListener("keydown",ft),ve.removeEventListener("touchstart",Pe),ve.removeEventListener("wheel",Et)}},[a,_r]);const Mo=P.useCallback(ve=>{Yt.current=ve},[]),si=P.useCallback(ve=>{const Je=rN(ve);if(!Je)return;const ft=fe!==null;Yt.current?.sendSequence(Je,{consumeModifier:ft})},[fe]),Ai=P.useCallback(ve=>{const Je=KR(ve);if(Je.length===0)return;const ft=fe!==null;Yt.current?.sendSequence(qx(Je[0]),{consumeModifier:ft});for(let Pe=1;Pe<Je.length;Pe+=1){const Et=Je[Pe];window.setTimeout(()=>{Yt.current?.sendSequence(qx(Et))},ZR*Pe)}},[fe]),ms=P.useCallback(()=>{Yt.current?.pasteClipboardText()},[]),rs=Re||ue!==null,yn=P.useRef(ut);rs||(yn.current=ut);const Is=rs?yn.current:ut,ii=P.useMemo(()=>XR(Is,Oe),[Is,Oe]),oi=P.useMemo(()=>Zx(Oe,Ee),[Ee,Oe]),Sn=!R&&Ee!=="auto"&&oi.showOnDesktop!==!0?"auto":Ee,ho=Sn==="auto"?ii:Sn,ai=P.useMemo(()=>Zx(Oe,ho),[ho,Oe]),Mn=P.useMemo(()=>ai.actions.filter(ve=>ve.sequence.trim().length>0).map((ve,Je)=>({...ve,label:P1(ve,Je)})),[ai.actions]),Ti=P.useMemo(()=>Yw(ut),[ut]),Ei=ai.label,nr=P.useMemo(()=>Sn!=="auto"?`Manual preset: ${ai.label}`:Ti?`Auto preset · ${ai.label} (${Ti})`:"Auto preset",[Ti,Sn,ai.label]),Ii=P.useCallback(ve=>{ce(ve)},[]),li=P.useCallback(()=>{De(ve=>ve==="copy"?"arrows":"copy"),ge("idle")},[]),us=P.useCallback(()=>{typeof window>"u"||(on.current!==null&&window.clearTimeout(on.current),on.current=window.setTimeout(()=>{on.current=null,ge("idle")},1200))},[]),Lr=P.useCallback(ve=>{on.current!==null&&typeof window<"u"&&(window.clearTimeout(on.current),on.current=null),ge(ve?"copied":"failed"),us()},[us]),Ms=P.useCallback(ve=>{ht(ve)},[]),Zi=P.useMemo(()=>R?JR(Oe):eN(Oe),[R,Oe]),en=P.useMemo(()=>PR(s),[s]),pn=P.useMemo(()=>`terminal::${D}`,[D]);P.useEffect(()=>{y?.({isConnecting:Re,isRestarting:at,hasError:!!ue,sessionId:ne})},[Re,at,ue,ne,y]);const Ln=!ne||Re||at,Si=P.useCallback((ve,Je)=>{if(Ln)return;const ft=Math.max(1,Math.min(Math.floor(Je)||1,40));fn(ve,ft)},[fn,Ln]);P.useEffect(()=>{if(!a||!R)return;Yt.current?.requestRefresh("resize",{resizeDebounceMs:0,skipScrollToBottom:!se,force:!0})},[a,R,se,ie,D]),P.useEffect(()=>{if(!a||!R)return;const ve=Je=>{const ft=Je.detail;Yt.current?.requestRefresh("resize",{resizeDebounceMs:0,skipScrollToBottom:ft?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",ve),()=>{document.removeEventListener("termdock:viewport-keyboard-change",ve)}},[a,R,D]);const ns=R||ai.showOnDesktop===!0,Ki=a,ds=R?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,gs=R?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0;return c.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:ds,children:[Tt&&c.jsx(sN,{isMobile:R,isInputFocused:H,isIOS:M,isConnecting:Re,connectionError:ue,terminalSessionId:ne}),c.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:en.background,...gs},children:[c.jsx("div",{ref:Hn,className:"h-full w-full box-border",children:c.jsx(Vw,{fallback:c.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:c.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:c.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"})})}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Terminal component failed to load"})]})}),children:c.jsx(NR,{ref:Mo,sessionKey:pn,chunks:it,onInput:Xr,onResize:Jr,onFlowControl:Ur,onTmuxScroll:It?Si:void 0,tmuxScrollSensitivity:.38,onDoubleTap:R?()=>{Yt.current?.sendSequence(" ")}:void 0,onInputFocusChange:uo,onMobileLongPressCopyResult:Lr,terminalSettings:N,theme:en,enableTouchScroll:R,mobileLongPressMode:je,autoFocus:!R},pn)})}),c.jsx(oN,{connectionError:ue,isFatalError:xt,isRestarting:at,isConnecting:Re,onHardRestart:vr})]}),c.jsx(nN,{visible:ns,interactive:Ki,presentation:R?"mobile":"desktop-actions",activeModifier:fe,lockedModifier:de,disabled:Ln,defaultShowExtended:rt,presetLabel:Ei,presetModeLabel:nr,presetMode:Sn,presetOptions:Zi,includeAlt:ai.includeAlt,presetRowLayout:ai.rowLayout,extraActions:Mn,onKeyPress:si,onTextPress:Ai,onPastePress:R?ms:void 0,longPressMode:je,copyFeedback:ke,onLongPressModeToggle:li,onModifierToggle:co,onPresetSelect:Ii,onExpandedChange:Ms})]})},pN=1e3,mN=2e4,gN=9e4,bN=5e3,Yr={ws:null,listeners:new Set,reconnectAttempt:0,reconnectTimer:null,idleCloseTimer:null,closing:!1};let tf=0,Gu=null;function xN(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/control/ws`}function e4(){Yr.idleCloseTimer&&(clearTimeout(Yr.idleCloseTimer),Yr.idleCloseTimer=null)}function yN(){e4(),!(Yr.ws&&Yr.ws.readyState===WebSocket.OPEN)&&(Yr.idleCloseTimer=setTimeout(()=>{Yr.idleCloseTimer=null,Yr.listeners.size===0&&vN()},bN))}function vN(){if(Yr.ws){try{Yr.ws.close()}catch{}Yr.ws=null}Gu&&(clearInterval(Gu),Gu=null)}function ry(){if(Yr.reconnectTimer)return;const e=Math.min(pN*Math.pow(2,Yr.reconnectAttempt),mN);Yr.reconnectAttempt+=1,Yr.reconnectTimer=setTimeout(()=>{Yr.reconnectTimer=null,t4()},e)}function t4(){const e=xN();if(!e||Yr.ws&&Yr.ws.readyState===WebSocket.OPEN)return;let t;try{t=new WebSocket(e)}catch{ry();return}Yr.ws=t,t.onopen=()=>{Yr.reconnectAttempt=0,tf=Date.now(),Gu||(Gu=setInterval(()=>{if(!(!Yr.ws||Yr.ws.readyState!==WebSocket.OPEN)&&tf>0&&Date.now()-tf>gN)try{Yr.ws.close()}catch{}},3e4),Gu.unref?.())},t.onmessage=r=>{tf=Date.now();let n=null;try{n=JSON.parse(r.data)}catch{return}if(!n)return;if(n.type==="config-updated"){if(n.key!=="toolbar-presets"&&n.key!=="agent-rules"&&n.key!=="program-detection")return;const i={type:"config-updated",key:n.key,updatedAt:typeof n.updatedAt=="number"?n.updatedAt:void 0};for(const a of Yr.listeners)try{a(i)}catch(u){console.error("[clientStateSync] listener threw:",u)}return}if(n.type!=="client-state"||!n.state)return;const s={type:"client-state",clientState:{sessions:Array.isArray(n.state.sessions)?n.state.sessions:[],updatedAt:typeof n.state.updatedAt=="number"?n.state.updatedAt:Date.now()},inventory:n.inventory,seq:typeof n.seq=="number"?n.seq:void 0};for(const i of Yr.listeners)try{i(s)}catch(a){console.error("[clientStateSync] listener threw:",a)}},t.onclose=()=>{Yr.ws===t&&(Yr.ws=null),Yr.listeners.size>0&&ry()},t.onerror=()=>{}}function r4(e){return Yr.listeners.add(e),e4(),Yr.ws||t4(),()=>{Yr.listeners.delete(e),Yr.listeners.size===0&&yN()}}const Eg="termdock-sessions",j1="termdock-active-session",W2="termdock-sessions-cache";function ny(){try{const e=localStorage.getItem(j1);return e&&e.trim().length>0?e:null}catch{return null}}function Su(e){try{e?localStorage.setItem(j1,e):localStorage.removeItem(j1)}catch{}}function wN(){if(typeof window>"u")return null;try{const e=localStorage.getItem(W2);if(!e)return null;const t=JSON.parse(e);return Array.isArray(t)?t.filter(r=>typeof r=="object"&&r!==null&&typeof r.sessionId=="string"&&typeof r.name=="string"):null}catch{return null}}function mc(e){if(!(typeof window>"u"))try{localStorage.setItem(W2,JSON.stringify(e))}catch{}}function sy(){if(!(typeof window>"u"))try{localStorage.removeItem(W2)}catch{}}function n4(e){return e.map(t=>({...t,mode:t.mode==="tmux"?"tmux":"shell",tmuxSessionName:t.tmuxSessionName??null,customName:t.customName===!0}))}function iy(e){return n4(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,r)=>({...t,activeProgram:e[r]?.activeProgram??null,cwd:e[r]?.cwd??null}))}function oy(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 ay(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function AN(){const e=A.useRef(wN()).current,t=A.useRef(ny()).current,[r,n]=A.useState(e??[]),[s,i]=A.useState(null),[a,u]=A.useState(e&&e.length>0?ay(e,t):t),[d,f]=A.useState(e===null),b=A.useRef(!1),g=A.useRef(null),y=A.useRef(e===null),v=A.useRef(0);A.useEffect(()=>{y.current=d},[d]),A.useEffect(()=>{g.current=a},[a]);const w=A.useCallback(J=>{const ee=ay(J,g.current??ny());return u(ae=>ae===ee?ae:ee),Su(ee),g.current=ee,ee},[]),T=A.useCallback((J,ee)=>{n(ae=>oy(ae)===oy(J)?ae:J),mc(J),ee?.reconcileActive&&w(J)},[w]),C=A.useCallback((J,ee)=>{i(J),T(iy(J.clientSessions),ee)},[T]),E=A.useCallback(()=>typeof window>"u"?[]:localStorage.getItem(Eg)?(localStorage.removeItem(Eg),sy(),Su(null),n([]),u(null),console.info("[session-persist] discarded legacy local session cache"),[]):[],[]),N=A.useCallback(async()=>{if(typeof window>"u")return[];try{const J=await ZC();C(J,{reconcileActive:!0});const ee=iy(J.clientSessions);return ee.length>0?ee:E()}catch(J){console.error("Failed to restore sessions from server:",J);try{return E()}catch(ee){console.error("Failed to discard legacy local sessions:",ee)}}finally{f(!1)}return[]},[C,E]),D=A.useCallback(async J=>{const ee=await O6(J);return C(ee.inventory),u(ee.session.sessionId),Su(ee.session.sessionId),ee},[C]),R=A.useCallback(async J=>{n(ee=>{const ae=ee.filter(Le=>Le.sessionId!==J),Se=g.current===J?ae[0]?.sessionId??null:g.current;return u(Se),Su(Se),mc(ae),ae});try{await XC(J)}catch(ee){console.error("Failed to remove session from inventory:",ee)}},[]),_=A.useCallback(J=>{const ee=Date.now();n(ae=>{const Se=ae.map(Le=>Le.sessionId===J?{...Le,lastActivity:ee}:Le);return mc(Se),Se})},[]),M=A.useCallback(J=>{u(J),Su(J)},[]),Q=A.useCallback(async(J,ee)=>{const ae=ee.trim();if(ae){n(Se=>{const Le=Se.map(_e=>_e.sessionId===J?{..._e,name:ae,customName:!0}:_e);return mc(Le),Le});try{const Se=await Lf(J,{name:ae,customName:!0});C(Se)}catch(Se){console.error("Failed to rename session in inventory:",Se)}}},[C]),H=A.useCallback(async J=>{n(ee=>{const ae=ee.map(Se=>Se.sessionId===J?{...Se,customName:!1}:Se);return mc(ae),ae});try{const ee=await Lf(J,{customName:!1});C(ee)}catch(ee){console.error("Failed to reset session name in inventory:",ee)}},[C]),G=A.useCallback(async J=>{n(ee=>{const ae=new Map(ee.map(ie=>[ie.sessionId,ie])),Se=J.map(ie=>ae.get(ie)).filter(ie=>ie!==void 0),Le=new Set(J),_e=ee.filter(ie=>!Le.has(ie.sessionId)),se=[...Se,..._e];return mc(se),se});try{const ee=await KC(J);C(ee)}catch(ee){console.error("Failed to reorder sessions in inventory:",ee)}},[C]),U=A.useCallback(async()=>{n([]),i(null),u(null),Su(null),sy(),typeof window<"u"&&localStorage.removeItem(Eg);try{await JC()}catch(J){console.error("Failed to clear session inventory:",J)}},[]),W=A.useCallback(async(J,ee)=>{n(ae=>{const Se=ae.map(Le=>Le.sessionId===J?{...Le,backendSessionId:ee}:Le);return mc(Se),Se});try{const ae=await Lf(J,{backendSessionId:ee});C(ae)}catch(ae){console.error("Failed to update session backend in inventory:",ae)}},[C]);return A.useEffect(()=>{b.current||(b.current=!0,N())},[N]),A.useEffect(()=>r4(ee=>{if(ee.type!=="client-state"||y.current)return;const ae=typeof ee.seq=="number"?ee.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(ee.inventory){C(ee.inventory,{reconcileActive:!0});return}const Se=n4(ee.clientState.sessions||[]);T(Se,{reconcileActive:!0})}),[C,T]),{sessions:r,inventory:s,activeSessionId:a,isLoading:d,openSession:D,removeSession:R,updateSessionActivity:_,setActiveSession:M,updateSessionBackendId:W,renameSession:Q,resetSessionCustomName:H,reorderSessions:G,clearAllSessions:U,restoreSessions:N}}function Zr(e,t){if(typeof window>"u")return null;try{const r=window.localStorage.getItem(e);if(r===null||r==="")return null;const n=JSON.parse(r);return t(n)?n:null}catch{return null}}function ir(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}const kd=new Map,Ed=new Map,Pf=new Map;function Od(e,t,r){if(typeof window>"u")return;const n=Date.now(),s=Pf.get(e)??0,i=n-s;if(i>=r){Pf.set(e,n),ir(e,t);return}if(Ed.set(e,t),kd.has(e))return;const a=r-i,u=setTimeout(()=>{kd.delete(e);const d=Ed.get(e);Ed.delete(e),Pf.set(e,Date.now()),d!==void 0&&ir(e,d)},a);kd.set(e,u)}function vd(e){const t=kd.get(e);t&&(clearTimeout(t),kd.delete(e));const r=Ed.get(e);r!==void 0&&(Ed.delete(e),Pf.set(e,Date.now()),ir(e,r))}function TN(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}const s4="termdock:right-sidebar:tabs-by-root:v1",i4="termdock:right-sidebar:explorer-roots:v1",o4="termdock:right-sidebar:pinned-explorer-roots:v1",a4="termdock:right-sidebar:selected-files:v1",l4="termdock:right-sidebar:show-hidden-files:v1",Q1="termdock-sidebar-group-by-folder",c4="termdock-sidebar-collapsed-folder-groups",u4="termdock-left-sidebar-pinned",d4="termdock-left-sidebar-width";function SN(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(u4)==="1"}catch{return!1}}function ly(e){if(!(typeof window>"u"))try{window.localStorage.setItem(u4,e?"1":"0")}catch{}}function CN(){if(typeof window>"u")return 300;try{const e=window.localStorage.getItem(d4);if(!e)return 300;const t=parseInt(e,10);return Number.isFinite(t)&&t>=200&&t<=500?t:300}catch{return 300}}function _N(e){if(!(typeof window>"u"))try{window.localStorage.setItem(d4,String(e))}catch{}}function LN(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Q1);return e===null?!0:e==="1"}catch{return!0}}function cy(e){if(!(typeof window>"u"))try{e?window.localStorage.setItem(Q1,"1"):window.localStorage.setItem(Q1,"0")}catch{}}function kN(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(c4);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(r=>typeof r=="string")):new Set}catch{return new Set}}function EN(e){if(!(typeof window>"u"))try{window.localStorage.setItem(c4,JSON.stringify([...e]))}catch{}}function IN(e){return e==="git"||e==="files"||e==="diff"||e==="file"}function MN(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(IN)}function h4(){return Zr(s4,MN)??{}}function RN(e,t){e&&ir(s4,{...h4(),[e]:t})}function NN(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>typeof t=="string")}function DN(){return Zr(i4,NN)??{}}function uy(e){ir(i4,e)}function BN(e){return e!==null&&typeof e=="object"&&typeof e.path=="string"&&(e.kind==="file"||e.kind==="directory")}function PN(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>Array.isArray(t)&&t.every(r=>typeof r=="string"||BN(r)))}function jN(e){const t=new Set,r=[];for(const n of e){const s=typeof n=="string"?{path:n,kind:"directory"}:n;!s.path||t.has(s.path)||(t.add(s.path),r.push(s))}return r}function QN(){const e=Zr(o4,PN)??{},t={};for(const[r,n]of Object.entries(e))t[r]=jN(n);return t}function dy(e){ir(o4,e)}function FN(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.values(e).every(t=>typeof t=="string")}function f4(){return Zr(a4,FN)??{}}function hy(e,t){if(!e)return;const r={...f4()};t?r[e]=t:delete r[e],ir(a4,r)}function ON(e){return typeof e=="boolean"}function $N(){return Zr(l4,ON)??!1}function HN(e){const t=e.replace(/\/+$/,"")||"/";return t==="/"?"/":t.slice(0,t.lastIndexOf("/"))||"/"}function od(e,t){const r=e.replace(/\/+$/,"")||"/";return t===r||t.startsWith(`${r}/`)}function UN(e){return[...e].sort((t,r)=>t.type==="directory"&&r.type!=="directory"?-1:t.type!=="directory"&&r.type==="directory"?1:t.name.localeCompare(r.name))}function GN(e){return e.entry?{name:e.entry.name,path:e.entry.path,type:e.entry.type,isSymlink:e.entry.isSymlink,expanded:!1,loaded:!1,children:e.entry.type==="directory"?[]:void 0}:null}const dt=D6(e=>({leftOpen:!1,rightOpen:!1,leftPinned:SN(),leftSidebarWidth:CN(),rightTab:"files",rightSearchOpen:!1,rootPath:null,explorerRoot:null,explorerRootCache:DN(),pinnedExplorerRootsCache:QN(),expandedPaths:new Set,selectedFilePath:null,directoryCache:new Map,showHiddenFiles:$N(),groupByFolder:LN(),collapsedGroups:kN(),changedFiles:new Map,fileChangeVersions:new Map,gitBundleLoading:!1,gitBundleSlow:!1,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 r=!t.leftPinned;return ly(r),{leftPinned:r,leftOpen:!0}}),setLeftPinned:t=>e(()=>(ly(t),{leftPinned:t})),setLeftSidebarWidth:t=>e(r=>{const n=Math.min(Math.max(t,200),500);return r.leftSidebarWidth===n?r:(_N(n),{leftSidebarWidth:n})}),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(r=>(RN(r.rootPath,t),{rightTab:t})),openRightSearch:()=>e({rightSearchOpen:!0}),closeRightSearch:()=>e({rightSearchOpen:!1}),setRightSearchOpen:t=>e({rightSearchOpen:t}),setRootPath:t=>e(r=>{if(r.rootPath===t)return r;const n=new Map(r.projectStateCache);r.rootPath&&n.set(r.rootPath,{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});const s=t?n.get(t):void 0,i=t?h4()[t]:void 0,a=t?r.explorerRootCache[t]:void 0,u=t?f4()[t]:void 0;return{rootPath:t,rightTab:s?.rightTab??i??"files",explorerRoot:s?.explorerRoot??a??t,expandedPaths:s?new Set(s.expandedPaths):new Set,selectedFilePath:s?.selectedFilePath??u??null,directoryCache:s?new Map(s.directoryCache):new Map,changedFiles:s?new Map(s.changedFiles):new Map,gitBundleLoading:!1,gitBundleSlow:!1,gitBundleError:s?.gitBundleError??null,gitBundleLastLoadedAt:s?.gitBundleLastLoadedAt??null,gitBundleCacheInfo:s?.gitBundleCacheInfo??null,projectStateCache:n}}),setExplorerRoot:t=>e(r=>{if(r.explorerRoot===t)return r;const n={...r.explorerRootCache};return r.rootPath&&t&&(n[r.rootPath]=t,uy(n)),{explorerRoot:t,explorerRootCache:n}}),resetExplorerToProject:()=>e(t=>{if(t.explorerRoot===t.rootPath)return t;const r={...t.explorerRootCache};return t.rootPath&&(r[t.rootPath]=t.rootPath,uy(r)),{explorerRoot:t.rootPath,explorerRootCache:r}}),pinExplorerRoot:(t,r="directory")=>e(n=>{if(!n.rootPath||!t)return n;const s=n.pinnedExplorerRootsCache[n.rootPath]??[];if(s.some(a=>a.path===t))return n;const i={...n.pinnedExplorerRootsCache,[n.rootPath]:[{path:t,kind:r},...s].slice(0,12)};return dy(i),{pinnedExplorerRootsCache:i}}),unpinExplorerRoot:t=>e(r=>{if(!r.rootPath||!t)return r;const n=r.pinnedExplorerRootsCache[r.rootPath]??[];if(!n.some(a=>a.path===t))return r;const s=n.filter(a=>a.path!==t),i={...r.pinnedExplorerRootsCache};return s.length>0?i[r.rootPath]=s:delete i[r.rootPath],dy(i),{pinnedExplorerRootsCache:i}}),toggleExpanded:t=>e(r=>{const n=new Set(r.expandedPaths);return n.has(t)?n.delete(t):n.add(t),{expandedPaths:n}}),selectFile:t=>e(r=>(hy(r.rootPath,t),{selectedFilePath:t})),toggleShowHiddenFiles:()=>e(t=>{const r=!t.showHiddenFiles;ir(l4,r);const n=new Map(t.projectStateCache);for(const[s,i]of n)n.set(s,{...i,directoryCache:new Map});return{showHiddenFiles:r,directoryCache:new Map,projectStateCache:n}}),toggleGroupByFolder:()=>e(t=>{const r=!t.groupByFolder;return cy(r),{groupByFolder:r}}),setGroupByFolder:t=>e(r=>r.groupByFolder===t?r:(cy(t),{groupByFolder:t})),toggleGroupCollapsed:t=>e(r=>{const n=new Set(r.collapsedGroups);return n.has(t)?n.delete(t):n.add(t),EN(n),{collapsedGroups:n}}),setDirectoryCache:(t,r)=>e(n=>{const s=new Map(n.directoryCache);return s.set(t,r),{directoryCache:s}}),invalidateDirectoryCache:(t,r=!1)=>e(n=>{const s=new Map(n.directoryCache);for(const i of s.keys())(i===t||r&&od(t,i))&&s.delete(i);return{directoryCache:s}}),applyFileWatchEvents:t=>e(r=>{if(t.length===0)return r;const n=new Map(r.directoryCache),s=new Map(r.fileChangeVersions);let i=r.selectedFilePath,a=!1,u=!1;const d=f=>{s.set(f,(s.get(f)??0)+1),u=!0};for(const f of t){if(f.type==="rescan-required"){for(const T of n.keys())od(f.path,T)&&(n.delete(T),a=!0);i&&od(f.path,i)&&d(i);continue}const b=HN(f.path),g=n.get(b);if(f.type==="deleted"){if(d(f.path),i&&od(f.path,i)&&(i=null,hy(r.rootPath,null)),g){const T=g.filter(C=>C.path!==f.path);T.length!==g.length&&(n.set(b,T),a=!0)}for(const T of n.keys())od(f.path,T)&&(n.delete(T),a=!0);continue}d(f.path);const y=GN(f);if(!y||!g)continue;const v=g.find(T=>T.path===y.path),w=UN(v?g.map(T=>T.path===y.path?{...T,...y,children:T.children}:T):[...g,y]);n.set(b,w),a=!0}return!a&&!u?r:{directoryCache:a?n:r.directoryCache,selectedFilePath:i,fileChangeVersions:u?s:r.fileChangeVersions}}),setChangedFiles:t=>e({changedFiles:t}),setGitBundleLoading:t=>e({gitBundleLoading:t}),setGitBundleSlow:t=>e({gitBundleSlow:t}),setGitBundleError:t=>e({gitBundleError:t}),markGitBundleLoaded:(t=null)=>e({gitBundleLastLoadedAt:Date.now(),gitBundleCacheInfo:t,gitBundleLoading:!1,gitBundleSlow:!1})})),F1=320,p4=1,zN=F1+120;function fy(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function rf(e,t){const r=ep(e,t);if(r===null)return;const n=e.wrapperEl;fy(e),n&&(n.style.transitionDuration="0ms");try{const s=e;s.setTransition?.(0),s.setTranslate?.(r),fy(e),n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}catch{n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}}function O1(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 ep(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function WN(e,t){const r=O1(e),n=ep(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=p4}function VN(e){const t=[],r=new Map,n=new Map,s=new Map;for(const i of e){const a=r.get(i.id)??[];if(a.push(i.id),r.set(i.id,a),i.sessionId){const u=n.get(i.sessionId)??[];u.push(i.id),n.set(i.sessionId,u)}if(i.mode==="tmux"&&i.tmuxSessionName){const u=s.get(i.tmuxSessionName)??[];u.push(i.id),s.set(i.tmuxSessionName,u)}}for(const[i,a]of r)a.length>1&&t.push({kind:"frontend",key:i,sessionIds:a});for(const[i,a]of n)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 m4(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function g4(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 qN(e,t){const r=m4(e),n=r.findIndex(s=>s.id===t.id);if(n>=0){const s=[...r];return s[n]=t,s}return[...r,t]}function py(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const s=r.get(n.sessionId);return{...g4(n),history:s?.history}})}function YN(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function my(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 gy(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function ZN(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t)if(e.get(r)!==n)return!1;return!0}function KN(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const r=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`wt-${r}${n}`}const XN=({terminalSettings:e=$2(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:s=!0,defaultSessionMode:i="shell",defaultTmuxSessionName:a="",onStatusChange:u,onSessionDataUpdate:d})=>{const f=A.useMemo(()=>Dc("session"),[]),b=A.useMemo(()=>Dc("terminal"),[]),[g,y]=A.useState([]),[v,w]=A.useState(null),[T,C]=A.useState(!0),[E,N]=A.useState({token:0,reason:"visibility"}),D=A.useRef(!1),R=A.useRef(null),_=A.useRef({}),[M,Q]=A.useState(null),H=A.useRef(s),G=A.useRef(!1),U=A.useRef(null),W=A.useRef(null),J=A.useRef(!1),ee=A.useRef(null),ae=A.useRef([]),Se=A.useRef(0),Le=A.useRef(null),_e=A.useRef(!1),se=A.useRef(!0),ie=A.useRef(null),fe=A.useRef("");A.useEffect(()=>{if(typeof window>"u")return;const ne=()=>{const be=navigator.maxTouchPoints>0||"ontouchstart"in window,Te=window.innerWidth<768;J.current=be&&Te};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[]);const{sessions:Qe,activeSessionId:de,isLoading:Fe,openSession:rt,setActiveSession:ht,removeSession:Ee,renameSession:ce,resetSessionCustomName:je,reorderSessions:De}=AN(),ke=dt(ne=>ne.groupByFolder),ge=dt(ne=>ne.leftOpen||ne.rightOpen),[Me,ct]=A.useState(()=>gy(Pn.getState().sessions));A.useEffect(()=>Pn.subscribe(ne=>{const be=gy(ne.sessions);ct(Te=>ZN(Te,be)?Te:be)}),[]);const{arranged:Ae}=A.useMemo(()=>zw(g,ne=>Me.get(ne.id)??null,ke,""),[g,Me,ke]),Ve=A.useRef(Ae);Ve.current=Ae,ee.current=v,ae.current=g,Le.current=de,_e.current=Fe,se.current=T,H.current=s;const We=A.useCallback((ne=R.current)=>{const be=Se.current,Te=typeof window<"u"?window.visualViewport:null,ue=ne?O1(ne):null,ot=ne?ep(ne,be):null;return{sessionsLength:ae.current.length,sessionIds:ae.current.map(xt=>xt.id),activeSessionId:ee.current,activeSessionIndex:be,persistedActiveId:Le.current,isLoading:_e.current,isRestoring:se.current,activeIndex:ne?.activeIndex??null,previousIndex:ne?.previousIndex??null,animating:ne?.animating??null,allowTouchMove:ne?.allowTouchMove??null,width:ne?.width??null,translate:ue,targetTranslate:ot,translateDelta:ue!==null&&ot!==null?ue-ot:null,snapGridLength:ne?.snapGrid?.length??null,targetSnap:ne?.snapGrid?.[be]??null,visualViewport:Te?{width:Math.round(Te.width),height:Math.round(Te.height),offsetTop:Math.round(Te.offsetTop)}:null}},[]),he=A.useCallback((ne,be)=>{f(ne,{...We(),...be})},[f,We]);A.useEffect(()=>{Fe||T||v!==de&&ht(v)},[v,Fe,T,de,ht]);const Be=A.useMemo(()=>{if(Ae.length===0||!v)return 0;const ne=Ae.findIndex(be=>be.id===v);return ne>=0?ne:0},[Ae,v]);Se.current=Be;const Ce=A.useCallback(()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),nt=A.useCallback(ne=>{Ce(),U.current=setTimeout(()=>{U.current=null,G.current=!1,he("[swiper:touch-guard-clear]",{reason:ne})},zN)},[Ce,he]),kt=A.useCallback((ne,be={})=>{const Te=R.current,ue=Se.current,ot=ae.current;if(!Te||ot.length===0||ue<0||ue>=ot.length)return;if(G.current){he("[swiper:sync-skip-touch]",{reason:ne});return}if(Te.animating){he("[swiper:sync-skip-animating]",{reason:ne});return}const xt=O1(Te),Rt=ep(Te,ue),at=xt!==null&&Rt!==null&&Math.abs(xt-Rt)<=p4,Ye=Te.activeIndex===ue;if(he("[swiper:sync-check]",{reason:ne,activeIndexAligned:Ye,translateAligned:at,immediate:be.immediate===!0}),!(Ye&&at)){if(Ye){rf(Te,ue),he("[swiper:sync-forced-active]",{reason:ne,translateAligned:at,immediate:be.immediate===!0});return}be.immediate?(rf(Te,ue),Te.slideTo(ue,0,!1),rf(Te,ue)):Te.slideTo(ue,F1,!1),he("[swiper:sync-applied]",{reason:ne,activeIndexAligned:Ye,translateAligned:at,immediate:be.immediate===!0})}},[he]);A.useEffect(()=>{const ne=be=>{const Te=be;R.current&&(R.current.allowTouchMove=!Te.detail.locked),he("[swiper:gesture-lock]",{locked:Te.detail.locked})};return document.addEventListener("termdock:gesture-lock",ne),()=>document.removeEventListener("termdock:gesture-lock",ne)},[he]),A.useEffect(()=>{if(g.length===0){v!==null&&w(null);return}if(!v){w(g[0].id);return}g.some(be=>be.id===v)||w(g[0].id)},[g,v]);const vt=A.useCallback((ne,be)=>{_.current[ne]=be},[]),wt=A.useCallback(ne=>{const be=Ve.current[ne.activeIndex]?.id;if(he("[swiper:slide-change]",{nextSessionId:be??null,instanceActiveIndex:ne.activeIndex}),!be||be===v)return;const Te=!!v&&_.current[v]===!0,ue=H.current&&(!J.current||Te);if(W.current=be,w(be),ue){Q({sessionId:be,token:Date.now()});return}Q(null)},[g,v,he]);A.useEffect(()=>{if(W.current===v){he("[swiper:sync-skip-swiper-driven]",{activeSessionId:v}),W.current=null;return}kt("active-session-index",{immediate:!0})},[v,Be,g.length,kt,he]),A.useEffect(()=>{const ne=R.current;if(!ne)return;const be=Ae.length>1&&!ge;ne.allowTouchMove!==be&&(ne.allowTouchMove=be,he("[swiper:allow-touch-sync]",{nextAllow:be,sidebarOverlayOpen:ge}))},[Ae.length,he,ge]);const Xe=A.useCallback(ne=>{const be=R.current;if(!be)return;const Te=be.el;if(he("[swiper:layout-before]",{reason:ne,scrollLeft:Te?.scrollLeft??null}),Te&&(Te.scrollLeft=0),be.updateSize(),be.updateSlides(),be.updateProgress(),be.updateSlidesClasses(),Te&&(Te.scrollLeft=0),he("[swiper:layout-after]",{reason:ne,scrollLeft:Te?.scrollLeft??null}),G.current||be.animating){he("[swiper:layout-skip-sync-motion]",{reason:ne});return}kt(`layout:${ne}`,{immediate:!0}),requestAnimationFrame(()=>{const ue=R.current;ue&&(G.current||ue.animating||rf(ue,Se.current))})},[he,kt]);A.useEffect(()=>()=>Ce(),[Ce]);const $e=Ae.map(ne=>ne.id).join("\0");A.useEffect(()=>{requestAnimationFrame(()=>Xe("group-change"))},[ke,$e,Xe]),A.useEffect(()=>{const ne=()=>{requestAnimationFrame(()=>Xe("viewport-change"))};return window.addEventListener("resize",ne),window.visualViewport?.addEventListener("resize",ne),window.visualViewport?.addEventListener("scroll",ne),ne(),()=>{window.removeEventListener("resize",ne),window.visualViewport?.removeEventListener("resize",ne),window.visualViewport?.removeEventListener("scroll",ne)}},[Xe]),A.useEffect(()=>{if(typeof document>"u")return;let ne=null;const be=xt=>{if(xt!=="online"&&document.hidden)return;const Rt=xt==="bfcache"||xt==="online"?xt:"visibility";N(at=>({token:at.token+1,reason:Rt})),requestAnimationFrame(()=>Xe(`resume:${xt}:raf`)),ne&&clearTimeout(ne),ne=setTimeout(()=>{ne=null,Xe(`resume:${xt}:settled`)},320)},Te=()=>{document.hidden||be("visibility")},ue=xt=>{be(xt.persisted?"bfcache":"pageshow")},ot=()=>be("online");return document.addEventListener("visibilitychange",Te),window.addEventListener("pageshow",ue),window.addEventListener("online",ot),()=>{document.removeEventListener("visibilitychange",Te),window.removeEventListener("pageshow",ue),window.removeEventListener("online",ot),ne&&clearTimeout(ne)}},[Xe]),A.useEffect(()=>{const ne=VN(g),be=JSON.stringify(ne);ne.length>0&&be!==fe.current?(fe.current=be,console.warn("[session-invariant] duplicate mapping detected",ne)):ne.length===0&&fe.current&&(fe.current=""),d?.({sessions:g.map(Te=>({id:Te.id,name:Te.name,customName:Te.customName,mode:Te.mode,tmuxSessionName:Te.tmuxSessionName})),activeSessionId:v})},[g,v,d]),A.useEffect(()=>{if(Fe||D.current)return;D.current=!0;const ne=YN(Qe,de),be=m4(Qe.map(g4));if(f("[Session] Restoring",be.length,"persisted sessions (one-shot)"),he("[swiper:restore-start]",{persistedSessionIds:Qe.map(ue=>ue.sessionId),nextActiveSessionId:ne}),be.length>0){const ue=Pn.getState();be.forEach(ot=>{ot.sessionId&&ue.setTerminalSession(ot.id,{sessionId:ot.sessionId,cols:80,rows:24,mode:ot.mode,tmuxSessionName:ot.tmuxSessionName,history:ot.history})}),Qe.forEach(ot=>{ot.activeProgram!=null&&ue.setSessionActiveProgram(ot.sessionId,ot.activeProgram),ot.cwd!=null&&ue.setSessionCwd(ot.sessionId,ot.cwd)}),y(be),w(ne||be[0]?.id||null),he("[swiper:restore-complete]",{restoredSessionIds:be.map(ot=>ot.id),nextActiveSessionId:ne||be[0]?.id||null})}(async()=>(be.length===0&&await ie.current?.({createIfEmpty:!0}),C(!1),requestAnimationFrame(()=>kt("restore-finished",{immediate:!0}))))()},[Fe,Qe,de,f,he,kt]);const lt=A.useRef([]),$t=A.useRef(!1);ee.current=v,A.useEffect(()=>{if(T)return;const ne=lt.current,be=Qe;if(!$t.current){y(Ye=>py(Ye,be)),lt.current=be,$t.current=!0;return}const Te=new Set(ne.map(Ye=>Ye.sessionId)),ue=new Set(be.map(Ye=>Ye.sessionId)),ot=new Map(ne.map(Ye=>[Ye.sessionId,Ye.name]));lt.current=be,y(Ye=>{const st=py(Ye,be);return(!ee.current||!st.some(mt=>mt.id===ee.current))&&w(st[0]?.id??null),st});const xt=be.filter(Ye=>!Te.has(Ye.sessionId)),Rt=[...Te].filter(Ye=>!ue.has(Ye)),at=be.filter(Ye=>Te.has(Ye.sessionId)&&ot.get(Ye.sessionId)!==Ye.name);(xt.length>0||Rt.length>0||at.length>0)&&f("[Session] Synced persisted sessions:",{newSessionIds:xt.map(Ye=>Ye.sessionId),removedSessionIds:Rt,renamedSessionIds:at.map(Ye=>Ye.sessionId),currentSessionIds:be.map(Ye=>Ye.sessionId)});for(const Ye of be){if(!Ye.backendSessionId)continue;Pn.getState().setTerminalSession(Ye.sessionId,{sessionId:Ye.backendSessionId,cols:80,rows:24,mode:Ye.mode,tmuxSessionName:Ye.tmuxSessionName})}},[Qe,T,f]);const Ht=A.useCallback(async ne=>{try{const be=ne?.mode==="tmux"||ne?.mode==="shell"?ne.mode:i,Te=(ne?.tmuxSessionName||"").trim(),ue=a.trim(),ot=be==="tmux"?Te||ue||KN():null,xt=typeof ne?.cwd=="string"?ne.cwd:null,Rt=v?Pn.getState().sessions.get(v)?.cwd??null:null,at=typeof xt=="string"&&xt.trim().length>0?xt:typeof Rt=="string"&&Rt.trim().length>0?Rt:void 0,Ye=await rt({mode:be,tmuxSessionName:ot,cwd:at,termType:"xterm-256color",createIfEmpty:ne?.createIfEmpty===!0}),st=Ye.session,mt=Ye.terminalSession,Ze={id:st.sessionId,name:st.name,customName:st.customName===!0,sessionId:mt.sessionId,mode:mt.mode??st.mode,tmuxSessionName:mt.tmuxSessionName??st.tmuxSessionName};y(Tt=>qN(Tt,Ze)),w(Ze.id),Pn.getState().setTerminalSession(Ze.id,{sessionId:mt.sessionId,cols:80,rows:24,mode:Ze.mode,tmuxSessionName:Ze.tmuxSessionName,activeProgram:mt.activeProgram,activeProgramRaw:mt.activeProgramRaw,activeProgramSource:mt.activeProgramSource,cwd:mt.cwd}),f("[Session] Inventory opened session:",{frontendSessionId:Ze.id,backendSessionId:mt.sessionId,reused:Ye.reused,mode:Ze.mode,tmuxSessionName:Ze.tmuxSessionName})}catch(be){console.error("[Session] Failed to create new session:",be)}},[i,a,v,rt,f]);ie.current=Ht;const St=A.useCallback(ne=>{g.find(Te=>Te.id===ne)&&(w(ne),H.current&&!J.current&&Q({sessionId:ne,token:Date.now()}),f("[Session] Switched to session:",ne))},[g,f]),ut=A.useCallback((ne,be)=>{be.trim()&&(y(Te=>Te.map(ue=>ue.id===ne?{...ue,name:be.trim(),customName:!0}:ue)),ce(ne,be.trim()))},[ce]),Oe=A.useCallback(ne=>{y(be=>be.map(Te=>Te.id===ne?{...Te,customName:!1}:Te)),je(ne)},[je]),It=A.useCallback(ne=>{y(be=>{const Te=new Map(be.map(Rt=>[Rt.id,Rt])),ue=ne.map(Rt=>Te.get(Rt)).filter(Rt=>Rt!==void 0),ot=new Set(ne),xt=be.filter(Rt=>!ot.has(Rt.id));return[...ue,...xt]}),De(ne),f("[Session] Reordered sessions:",ne),requestAnimationFrame(()=>{R.current?.update()})},[De,f]),it=A.useCallback(async ne=>{const be=typeof ne=="string"?ne:ne.sessionId,Te=typeof ne=="string"?"auto":ne.closeMode??"auto",ue=g.find(ot=>ot.id===be);if(ue){try{Te==="destroy"&&ue.mode==="tmux"&&ue.tmuxSessionName?(await F6(ue.tmuxSessionName),f("[Session] Destroyed tmux session:",{frontendSessionId:ue.id,tmuxSessionName:ue.tmuxSessionName})):ue.sessionId&&(await Q6(ue.sessionId),f("[Session] Closed backend terminal:",ue.sessionId))}catch(ot){console.error("[Session] Failed to close backend terminal:",ot);return}y(ot=>{const xt=ot.filter(at=>at.id!==be),Rt=xt.length>0?xt[0].id:null;return w(Rt),xt}),Ee(be),delete _.current[be],f("[Session] Closed session:",{sessionId:be,closeMode:Te})}},[g,Ee,f]),Re=A.useCallback(ne=>{if(!ne)return;const be=g.filter(Te=>Te.sessionId===ne);if(be.length!==0){be.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:ne,frontendSessionIds:be.map(Te=>Te.id)}),y(Te=>{const ue=Te.filter(ot=>ot.sessionId!==ne);return ue.length!==Te.length&&!ue.some(xt=>xt.id===v)&&w(ue.length>0?ue[0].id:null),ue});for(const Te of be)Ee(Te.id),delete _.current[Te.id];f("[Session] Backend gone, dropped local session(s):",be.map(Te=>Te.id))}},[g,v,Ee,f]);return A.useEffect(()=>{const ne=st=>{Ht(st.detail)},be=st=>{St(st.detail)},Te=()=>{const st=ee.current;!st||J.current||Q({sessionId:st,token:Date.now()})},ue=st=>{const Ze=st.detail?.direction;if(Ze!=="prev"&&Ze!=="next")return;const rr=Ve.current;if(rr.length<=1)return;const Tt=ee.current,yr=Tt?rr.findIndex(et=>et.id===Tt):-1,le=((yr>=0?yr:0)+(Ze==="next"?1:-1)+rr.length)%rr.length,Yt=rr[le]?.id;Yt&&Yt!==Tt&&St(Yt)},ot=st=>{it(st.detail)},xt=st=>{Re(st.detail)},Rt=st=>{const mt=st;!mt.detail?.sessionId||!mt.detail?.name||ut(mt.detail.sessionId,mt.detail.name)},at=st=>{const mt=st;mt.detail?.sessionId&&Oe(mt.detail.sessionId)},Ye=st=>{const mt=st;mt.detail?.sessionIds&&It(mt.detail.sessionIds)};return window.addEventListener("new-terminal-session",ne),window.addEventListener("switch-terminal-session",be),window.addEventListener("focus-active-terminal-session",Te),window.addEventListener("cycle-terminal-session",ue),window.addEventListener("close-terminal-session",ot),window.addEventListener("close-terminal-session-by-backend",xt),window.addEventListener("rename-terminal-session",Rt),window.addEventListener("reset-terminal-session-name",at),window.addEventListener("reorder-terminal-session",Ye),()=>{window.removeEventListener("new-terminal-session",ne),window.removeEventListener("switch-terminal-session",be),window.removeEventListener("focus-active-terminal-session",Te),window.removeEventListener("cycle-terminal-session",ue),window.removeEventListener("close-terminal-session",ot),window.removeEventListener("close-terminal-session-by-backend",xt),window.removeEventListener("rename-terminal-session",Rt),window.removeEventListener("reset-terminal-session-name",at),window.removeEventListener("reorder-terminal-session",Ye)}},[Ht,St,it,Re,ut,Oe,It]),c.jsx("div",{className:"h-full flex flex-col",children:c.jsx("div",{className:"flex-1 overflow-hidden",children:c.jsx(sh,{onSwiper:ne=>{R.current=ne,ne.allowTouchMove=Ae.length>1&&!ge,he("[swiper:on-swiper]",{allowTouchMove:ne.allowTouchMove}),requestAnimationFrame(()=>Xe("on-swiper"))},onSlideChange:wt,onTouchStart:(ne,be)=>{const Te=my(be),ue=Te==="touch"||Te==="pen"||Te==="unknown";b("[swipe:touch-start]",{pointerType:Te,allowed:ue}),he("[swiper:touch-start]",{pointerType:Te,allowed:ue}),ue&&(Ce(),G.current=!0)},onTouchEnd:(ne,be)=>{const Te=my(be),ue=Te==="touch"||Te==="pen"||Te==="unknown";b("[swipe:touch-end]",{pointerType:Te,allowed:ue}),he("[swiper:touch-end]",{pointerType:Te,allowed:ue}),ue&&nt("touch-end")},onTransitionEnd:()=>{const ne=R.current;if(G.current&&ne&&!WN(ne,Se.current)){he("[swiper:transition-end-deferred]");return}Ce(),G.current=!1,he("[swiper:transition-end]")},initialSlide:Math.max(0,Be),speed:F1,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:Ae.map(ne=>{const be=ne.id===v;return c.jsx(Ic,{className:"h-full",children:c.jsx(fN,{sessionId:ne.id,mode:ne.mode,tmuxSessionName:ne.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:be,focusRequestToken:M?.sessionId===ne.id?M.token:0,resumeRequestToken:E.token,resumeRequestReason:E.reason,onKeyboardVisibilityChange:vt,showDebug:n,onStatusChange:be?u:void 0})},ne.id)})})})})};function Wi(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 JN=typeof Symbol=="function"&&Symbol.observable||"@@observable",by=JN,xy=()=>Math.random().toString(36).substring(7).split("").join("."),eD={INIT:`@@redux/INIT${xy()}`,REPLACE:`@@redux/REPLACE${xy()}`},yy=eD;function tD(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 b4(e,t,r){if(typeof e!="function")throw new Error(Wi(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Wi(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Wi(1));return r(b4)(e,t)}let n=e,s=t,i=new Map,a=i,u=0,d=!1;function f(){a===i&&(a=new Map,i.forEach((C,E)=>{a.set(E,C)}))}function b(){if(d)throw new Error(Wi(3));return s}function g(C){if(typeof C!="function")throw new Error(Wi(4));if(d)throw new Error(Wi(5));let E=!0;f();const N=u++;return a.set(N,C),function(){if(E){if(d)throw new Error(Wi(6));E=!1,f(),a.delete(N),i=null}}}function y(C){if(!tD(C))throw new Error(Wi(7));if(typeof C.type>"u")throw new Error(Wi(8));if(typeof C.type!="string")throw new Error(Wi(17));if(d)throw new Error(Wi(9));try{d=!0,s=n(s,C)}finally{d=!1}return(i=a).forEach(N=>{N()}),C}function v(C){if(typeof C!="function")throw new Error(Wi(10));n=C,y({type:yy.REPLACE})}function w(){const C=g;return{subscribe(E){if(typeof E!="object"||E===null)throw new Error(Wi(11));function N(){const R=E;R.next&&R.next(b())}return N(),{unsubscribe:C(N)}},[by](){return this}}}return y({type:yy.INIT}),{dispatch:y,subscribe:g,getState:b,replaceReducer:v,[by]:w}}function vy(e,t){return function(...r){return t(e.apply(this,r))}}function wy(e,t){if(typeof e=="function")return vy(e,t);if(typeof e!="object"||e===null)throw new Error(Wi(16));const r={};for(const n in e){const s=e[n];typeof s=="function"&&(r[n]=vy(s,t))}return r}function x4(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function rD(...e){return t=>(r,n)=>{const s=t(r,n);let i=()=>{throw new Error(Wi(15))};const a={getState:s.getState,dispatch:(d,...f)=>i(d,...f)},u=e.map(d=>d(a));return i=x4(...u)(s.dispatch),{...s,dispatch:i}}}var Ig={exports:{}},Mg={};var Ay;function nD(){if(Ay)return Mg;Ay=1;var e=_p();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,u=e.useDebugValue;return Mg.useSyncExternalStoreWithSelector=function(d,f,b,g,y){var v=s(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=a(function(){function C(_){if(!E){if(E=!0,N=_,_=g(_),y!==void 0&&w.hasValue){var M=w.value;if(y(M,_))return D=M}return D=_}if(M=D,r(N,_))return M;var Q=g(_);return y!==void 0&&y(M,Q)?(N=_,M):(N=_,D=Q)}var E=!1,N,D,R=b===void 0?null:b;return[function(){return C(f())},R===null?void 0:function(){return C(R())}]},[f,b,g,y]);var T=n(d,v[0],v[1]);return i(function(){w.hasValue=!0,w.value=T},[T]),u(T),T},Mg}var Ty;function sD(){return Ty||(Ty=1,Ig.exports=nD()),Ig.exports}sD();var iD=A.version.startsWith("19"),oD=Symbol.for(iD?"react.transitional.element":"react.element"),aD=Symbol.for("react.portal"),lD=Symbol.for("react.fragment"),cD=Symbol.for("react.strict_mode"),uD=Symbol.for("react.profiler"),dD=Symbol.for("react.consumer"),hD=Symbol.for("react.context"),y4=Symbol.for("react.forward_ref"),fD=Symbol.for("react.suspense"),pD=Symbol.for("react.suspense_list"),V2=Symbol.for("react.memo"),mD=Symbol.for("react.lazy"),gD=y4,bD=V2;function xD(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case oD:switch(e=e.type,e){case lD:case uD:case cD:case fD:case pD:return e;default:switch(e=e&&e.$$typeof,e){case hD:case y4:case mD:case V2:return e;case dD:return e;default:return t}}case aD:return t}}}function yD(e){return xD(e)===V2}function vD(e,t,r,n,{areStatesEqual:s,areOwnPropsEqual:i,areStatePropsEqual:a}){let u=!1,d,f,b,g,y;function v(N,D){return d=N,f=D,b=e(d,f),g=t(n,f),y=r(b,g,f),u=!0,y}function w(){return b=e(d,f),t.dependsOnOwnProps&&(g=t(n,f)),y=r(b,g,f),y}function T(){return e.dependsOnOwnProps&&(b=e(d,f)),t.dependsOnOwnProps&&(g=t(n,f)),y=r(b,g,f),y}function C(){const N=e(d,f),D=!a(N,b);return b=N,D&&(y=r(b,g,f)),y}function E(N,D){const R=!i(D,f),_=!s(N,d,D,f);return d=N,f=D,R&&_?w():R?T():_?C():y}return function(D,R){return u?E(D,R):v(D,R)}}function wD(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...s}){const i=t(e,s),a=r(e,s),u=n(e,s);return vD(i,a,u,e,s)}function AD(e,t){const r={};for(const n in e){const s=e[n];typeof s=="function"&&(r[n]=(...i)=>t(s(...i)))}return r}function $1(e){return function(r){const n=e(r);function s(){return n}return s.dependsOnOwnProps=!1,s}}function Sy(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function v4(e,t){return function(n,{displayName:s}){const i=function(u,d){return i.dependsOnOwnProps?i.mapToProps(u,d):i.mapToProps(u,void 0)};return i.dependsOnOwnProps=!0,i.mapToProps=function(u,d){i.mapToProps=e,i.dependsOnOwnProps=Sy(e);let f=i(u,d);return typeof f=="function"&&(i.mapToProps=f,i.dependsOnOwnProps=Sy(f),f=i(u,d)),f},i}}function q2(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function TD(e){return e&&typeof e=="object"?$1(t=>AD(e,t)):e?typeof e=="function"?v4(e):q2(e,"mapDispatchToProps"):$1(t=>({dispatch:t}))}function SD(e){return e?typeof e=="function"?v4(e):q2(e,"mapStateToProps"):$1(()=>({}))}function CD(e,t,r){return{...r,...e,...t}}function _D(e){return function(r,{displayName:n,areMergedPropsEqual:s}){let i=!1,a;return function(d,f,b){const g=e(d,f,b);return i?s(g,a)||(a=g):(i=!0,a=g),a}}}function LD(e){return e?typeof e=="function"?_D(e):q2(e,"mergeProps"):()=>CD}function kD(e){e()}function ED(){let e=null,t=null;return{clear(){e=null,t=null},notify(){kD(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const s=t={callback:r,next:null,prev:t};return s.prev?s.prev.next=s:e=s,function(){!n||e===null||(n=!1,s.next?s.next.prev=s.prev:t=s.prev,s.prev?s.prev.next=s.next:e=s.next)}}}}var Cy={notify(){},get:()=>[]};function w4(e,t){let r,n=Cy,s=0,i=!1;function a(T){b();const C=n.subscribe(T);let E=!1;return()=>{E||(E=!0,C(),g())}}function u(){n.notify()}function d(){w.onStateChange&&w.onStateChange()}function f(){return i}function b(){s++,r||(r=t?t.addNestedSub(d):e.subscribe(d),n=ED())}function g(){s--,r&&s===0&&(r(),r=void 0,n.clear(),n=Cy)}function y(){i||(i=!0,b())}function v(){i&&(i=!1,g())}const w={addNestedSub:a,notifyNestedSubs:u,handleChangeWrapper:d,isSubscribed:f,trySubscribe:y,tryUnsubscribe:v,getListeners:()=>n};return w}var ID=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MD=ID(),RD=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ND=RD(),DD=()=>MD||ND?A.useLayoutEffect:A.useEffect,tp=DD();function _y(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Rg(e,t){if(_y(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(t,r[s])||!_y(e[r[s]],t[r[s]]))return!1;return!0}var BD={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},PD={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},jD={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},A4={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},QD={[gD]:jD,[bD]:A4};function Ly(e){return yD(e)?A4:QD[e.$$typeof]||BD}var FD=Object.defineProperty,OD=Object.getOwnPropertyNames,ky=Object.getOwnPropertySymbols,$D=Object.getOwnPropertyDescriptor,HD=Object.getPrototypeOf,Ey=Object.prototype;function H1(e,t){if(typeof t!="string"){if(Ey){const i=HD(t);i&&i!==Ey&&H1(e,i)}let r=OD(t);ky&&(r=r.concat(ky(t)));const n=Ly(e),s=Ly(t);for(let i=0;i<r.length;++i){const a=r[i];if(!PD[a]&&!(s&&s[a])&&!(n&&n[a])){const u=$D(t,a);try{FD(e,a,u)}catch{}}}}return e}var UD=Symbol.for("react-redux-context"),GD=typeof globalThis<"u"?globalThis:{};function zD(){if(!A.createContext)return{};const e=GD[UD]??=new Map;let t=e.get(A.createContext);return t||(t=A.createContext(null),e.set(A.createContext,t)),t}var T4=zD(),WD=[null,null];function VD(e,t,r){tp(()=>e(...t),r)}function qD(e,t,r,n,s,i){e.current=n,r.current=!1,s.current&&(s.current=null,i())}function YD(e,t,r,n,s,i,a,u,d,f,b){if(!e)return()=>{};let g=!1,y=null;const v=()=>{if(g||!u.current)return;const T=t.getState();let C,E;try{C=n(T,s.current)}catch(N){E=N,y=N}E||(y=null),C===i.current?a.current||f():(i.current=C,d.current=C,a.current=!0,b())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(g=!0,r.tryUnsubscribe(),r.onStateChange=null,y)throw y}}function ZD(e,t){return e===t}function KD(e,t,r,{pure:n,areStatesEqual:s=ZD,areOwnPropsEqual:i=Rg,areStatePropsEqual:a=Rg,areMergedPropsEqual:u=Rg,forwardRef:d=!1,context:f=T4}={}){const b=f,g=SD(e),y=TD(t),v=LD(r),w=!!e;return C=>{const E=C.displayName||C.name||"Component",N=`Connect(${E})`,D={shouldHandleStateChanges:w,displayName:N,wrappedComponentName:E,WrappedComponent:C,initMapStateToProps:g,initMapDispatchToProps:y,initMergeProps:v,areStatesEqual:s,areStatePropsEqual:a,areOwnPropsEqual:i,areMergedPropsEqual:u};function R(Q){const[H,G,U]=A.useMemo(()=>{const{reactReduxForwardedRef:Me,...ct}=Q;return[Q.context,Me,ct]},[Q]),W=A.useMemo(()=>{let Me=b;return H?.Consumer,Me},[H,b]),J=A.useContext(W),ee=!!Q.store&&!!Q.store.getState&&!!Q.store.dispatch,ae=!!J&&!!J.store,Se=ee?Q.store:J.store,Le=ae?J.getServerState:Se.getState,_e=A.useMemo(()=>wD(Se.dispatch,D),[Se]),[se,ie]=A.useMemo(()=>{if(!w)return WD;const Me=w4(Se,ee?void 0:J.subscription),ct=Me.notifyNestedSubs.bind(Me);return[Me,ct]},[Se,ee,J]),fe=A.useMemo(()=>ee?J:{...J,subscription:se},[ee,J,se]),Qe=A.useRef(void 0),de=A.useRef(U),Fe=A.useRef(void 0),rt=A.useRef(!1),ht=A.useRef(!1),Ee=A.useRef(void 0);tp(()=>(ht.current=!0,()=>{ht.current=!1}),[]);const ce=A.useMemo(()=>()=>Fe.current&&U===de.current?Fe.current:_e(Se.getState(),U),[Se,U]),je=A.useMemo(()=>ct=>se?YD(w,Se,se,_e,de,Qe,rt,ht,Fe,ie,ct):()=>{},[se]);VD(qD,[de,Qe,rt,U,Fe,ie]);let De;try{De=A.useSyncExternalStore(je,ce,Le?()=>_e(Le(),U):ce)}catch(Me){throw Ee.current&&(Me.message+=`
|
|
@@ -163,7 +163,7 @@ ${M.desc}`:""}`,"aria-pressed":v===M.key,onPointerEnter:()=>y(M.key),onPointerLe
|
|
|
163
163
|
`),blockKey:`${t}-code-${C}`},`${t}-code-${C}`):["math","latex","tex"].includes(T.toLowerCase())?c.jsx(th,{tex:v.join(`
|
|
164
164
|
`),display:!0},`${t}-code-${C}`):c.jsx(nh,{code:v.join(`
|
|
165
165
|
`),lang:T,blockKey:`${t}-code-${C}`},`${t}-code-${C}`));continue}if(Ap(i)){const v=[],w=s;for(;s<e.length&&(Ap(e[s])||!e[s].trim());)v.push(e[s].trim()?b9(e[s]):""),s+=1;n.push(c.jsx(nh,{code:v.join(`
|
|
166
|
-
`).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${w}`},`${t}-indented-code-${w}`));continue}const f=a.match(/^(#{1,6})\s+(.+)$/);if(f){const w=`h${Math.min(6,f[1].length+1)}`,T=l9(f[2]),C=y2(T,r);n.push(c.jsx(w,{id:C,className:"scroll-mt-16 font-semibold text-foreground",children:Xs(T,`${t}-heading-${s}`,!0,r)},`${t}-heading-${s}`)),s+=1;continue}if(s+1<e.length&&i.includes("|")&&Sp(e[s+1])){const v=rh(i),w=x9(e[s+1]),T=[],C=s;for(s+=2;s<e.length&&e[s].includes("|")&&e[s].trim();)T.push(rh(e[s])),s+=1;n.push(c.jsx("div",{className:K8,"data-markdown-table-scroll":!0,children:c.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[c.jsx("thead",{className:"bg-surface-2 text-foreground",children:c.jsx("tr",{children:v.map((E,N)=>c.jsx("th",{className:`${Y8} ${Tp(w[N]??null)}`,children:c.jsx("div",{className:vp,children:Xs(E,`${t}-th-${C}-${N}`,!0,r)})},`h-${N}`))})}),c.jsx("tbody",{children:T.map((E,N)=>c.jsx("tr",{className:"border-t border-border/10",children:v.map((D,R)=>c.jsx("td",{className:`${Z8} ${Tp(w[R]??null)}`,children:c.jsx("div",{className:vp,children:Xs(E[R]??"",`${t}-td-${C}-${N}-${R}`,!0,r)})},`c-${R}`))},`r-${N}`))})]})},`${t}-table-${C}`));continue}const b=j5(i);if(b){const v=b.ordered,w=P5(i),T=b.start,C=s,E=y9(e,s,w,v,!1);s=E.nextIndex;const N=v?"ol":"ul";n.push(c.jsx(N,{start:v?T:void 0,className:`${v?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Q5(E.items,C,r)},`${t}-list-${C}`));continue}const g=[i.trimStart()],y=s;for(s+=1;s<e.length&&e[s].trim()&&!x2(e[s])&&!(s+1<e.length&&e[s].includes("|")&&Sp(e[s+1]));)g.push(e[s].trimStart()),s+=1;n.push(c.jsx("p",{children:Dd(g,`${t}-p-${y}`,r)},`${t}-p-${y}`))}return n}let yf=null,F3=!1;const vf=16,v9=192;function BW(){return yf||(yf=qd(()=>import("./mermaid.core-
|
|
166
|
+
`).replace(/\n+$/,""),lang:"",blockKey:`${t}-indented-code-${w}`},`${t}-indented-code-${w}`));continue}const f=a.match(/^(#{1,6})\s+(.+)$/);if(f){const w=`h${Math.min(6,f[1].length+1)}`,T=l9(f[2]),C=y2(T,r);n.push(c.jsx(w,{id:C,className:"scroll-mt-16 font-semibold text-foreground",children:Xs(T,`${t}-heading-${s}`,!0,r)},`${t}-heading-${s}`)),s+=1;continue}if(s+1<e.length&&i.includes("|")&&Sp(e[s+1])){const v=rh(i),w=x9(e[s+1]),T=[],C=s;for(s+=2;s<e.length&&e[s].includes("|")&&e[s].trim();)T.push(rh(e[s])),s+=1;n.push(c.jsx("div",{className:K8,"data-markdown-table-scroll":!0,children:c.jsxs("table",{className:"w-max min-w-full max-w-none table-auto border-collapse text-left text-[11px] sm:text-xs",children:[c.jsx("thead",{className:"bg-surface-2 text-foreground",children:c.jsx("tr",{children:v.map((E,N)=>c.jsx("th",{className:`${Y8} ${Tp(w[N]??null)}`,children:c.jsx("div",{className:vp,children:Xs(E,`${t}-th-${C}-${N}`,!0,r)})},`h-${N}`))})}),c.jsx("tbody",{children:T.map((E,N)=>c.jsx("tr",{className:"border-t border-border/10",children:v.map((D,R)=>c.jsx("td",{className:`${Z8} ${Tp(w[R]??null)}`,children:c.jsx("div",{className:vp,children:Xs(E[R]??"",`${t}-td-${C}-${N}-${R}`,!0,r)})},`c-${R}`))},`r-${N}`))})]})},`${t}-table-${C}`));continue}const b=j5(i);if(b){const v=b.ordered,w=P5(i),T=b.start,C=s,E=y9(e,s,w,v,!1);s=E.nextIndex;const N=v?"ol":"ul";n.push(c.jsx(N,{start:v?T:void 0,className:`${v?"list-decimal":"list-disc"} space-y-0.5 pl-4 marker:text-muted-foreground/70`,children:Q5(E.items,C,r)},`${t}-list-${C}`));continue}const g=[i.trimStart()],y=s;for(s+=1;s<e.length&&e[s].trim()&&!x2(e[s])&&!(s+1<e.length&&e[s].includes("|")&&Sp(e[s+1]));)g.push(e[s].trimStart()),s+=1;n.push(c.jsx("p",{children:Dd(g,`${t}-p-${y}`,r)},`${t}-p-${y}`))}return n}let yf=null,F3=!1;const vf=16,v9=192;function BW(){return yf||(yf=qd(()=>import("./mermaid.core-DQW1U4Sy.js").then(e=>e.aJ),__vite__mapDeps([3,1,4])).then(e=>e.default??e).catch(e=>{throw yf=null,e})),yf}function PW(e){F3||(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"}),F3=!0)}function jW(e){const t=e.match(/\sviewBox=(["'])([^"']+)\1/i);if(!t)return e;const[,,r]=t,n=r.trim().split(/[\s,]+/).map(Number),[,,s,i]=n;if(!Number.isFinite(s)||!Number.isFinite(i)||s<=0||i<=0)return e;const a=Math.max(v9,Math.ceil(s)),u=Math.ceil(a/s*i);return e.replace(/<svg\b([^>]*)>/i,(d,f)=>`<svg${f.replace(/\s(?:width|height)=(["']).*?\1/gi,"").replace(/\sstyle=(["']).*?\1/gi,"")} width="${a}" height="${u}">`)}function QW(e){const t=e?.querySelector("svg");if(!t)return;let r;try{r=t.getBBox()}catch{return}if(!Number.isFinite(r.width)||!Number.isFinite(r.height)||r.width<=0||r.height<=0)return;const n=r.x-vf,s=r.y-vf,i=r.width+vf*2,a=r.height+vf*2,u=Math.max(v9,Math.ceil(i)),d=Math.ceil(u/i*a);t.setAttribute("viewBox",`${n} ${s} ${i} ${a}`),t.setAttribute("width",String(u)),t.setAttribute("height",String(d)),t.removeAttribute("style")}function FW(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t)return null;const r=t.replace(/^language-/,"");return P8(`code.${r}`)??r}function w9({code:e,blockKey:t}){const[r,n]=A.useState(null),[s,i]=A.useState(!1),a=A.useRef(null),u=A.useContext(o9);A.useEffect(()=>{let f=!1;return n(null),i(!1),BW().then(async b=>{PW(b);const g=`termdock-md-mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}`,{svg:y}=await b.render(g,e);f||n(jW(y))}).catch(()=>{f||i(!0)}),()=>{f=!0}},[t,e]),A.useLayoutEffect(()=>{r&&QW(a.current)},[r]);const d=A.useCallback(()=>{const f=a.current?.querySelector("svg")?.outerHTML??r;f&&u?.(f)},[u,r]);return s?c.jsx(nh,{code:e,lang:"mermaid",blockKey:`${t}-fallback`}):c.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[c.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"}),c.jsx("div",{className:"bg-surface p-3",children:r?c.jsx("button",{type:"button",className:"block max-w-full rounded text-left focus:outline-none focus:ring-2 focus:ring-ring/45",title:"Open Mermaid diagram",onClick:f=>{f.stopPropagation(),d()},children:c.jsx("span",{ref:a,role:"img","aria-label":"Mermaid diagram",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}})}):c.jsx("div",{className:"py-6 text-center text-xs text-muted-foreground",children:"Rendering diagram..."})})]})}function nh({code:e,lang:t,blockKey:r}){const n=FW(t),[s,i]=A.useState(null);return A.useEffect(()=>{if(!n||!j8(e)){i(null);return}let a=!1;return Q8().then(u=>{if(a||!u.registered(n)){a||i(null);return}try{i(F8(u.highlight(e,n),`md-code-${r}`))}catch{a||i(null)}}).catch(()=>{a||i(null)}),()=>{a=!0}},[r,e,n]),c.jsxs("div",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface shadow-sm",children:[t&&c.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}),c.jsx("pre",{className:`${B5} termdock-code overflow-auto p-3 text-[11px] leading-relaxed text-foreground`,children:c.jsx("code",{children:s??(e||" ")})})]})}function OW(e,t,r,n){e=gW(e);const s=fW(e),i=mW(e),a=[],u={markdownFilePath:t,rootPath:r,referenceDefinitions:s,footnoteDefinitions:pW(e),headingSlugCounts:new Map,images:a,onImageOpen:n},d=[];let f=0;for(;f<e.length;){const g=e[f],y=g.trim();if(wp(g)||i.has(f)){f+=1;continue}if(!y){f+=1;continue}if(/^<details>\s*$/i.test(y)){const D=f;let R="Details";const _=[];for(f+=1;f<e.length&&!/^<\/details>\s*$/i.test(e[f].trim());){const M=e[f].trim().match(/^<summary>(.*?)<\/summary>\s*$/i);M?R=M[1].trim()||R:_.push(e[f].trimStart()),f+=1}f<e.length&&(f+=1),d.push({key:`details-${D}`,startLine:D+1,endLine:f,content:c.jsxs("details",{className:"overflow-hidden rounded-lg border border-border/20 bg-surface px-3 py-2 text-muted-foreground",children:[c.jsx("summary",{className:"cursor-pointer text-sm font-semibold text-foreground",children:Xs(R,`details-${D}-summary`,!0,u)}),_.length>0&&c.jsx("div",{className:"mt-2 text-sm leading-6",children:Dd(_,`details-${D}`,u)})]})});continue}const v=g9(g);if(v){const D=[g],R=f;for(f+=1;f<e.length&&!v.selfContained&&!new RegExp(`</${v.tag}>`,"i").test(e[f]);)D.push(e[f]),f+=1;f<e.length&&!v.selfContained&&(D.push(e[f]),f+=1),d.push({key:`html-${R}`,startLine:R+1,endLine:f,content:c.jsx(m9,{html:D.join(`
|
|
167
167
|
`)})});continue}const w=y.match(/^(```|~~~)\s*(.*)$/);if(w){const D=[],R=w[1],_=w[2]?.trim(),M=f;for(f+=1;f<e.length&&!e[f].trim().startsWith(R);)D.push(e[f]),f+=1;f<e.length&&(f+=1),d.push({key:`code-${M}`,startLine:M+1,endLine:f,content:_.toLowerCase()==="mermaid"?c.jsx(w9,{code:D.join(`
|
|
168
168
|
`),blockKey:`code-${M}`}):["math","latex","tex"].includes(_.toLowerCase())?c.jsx(th,{tex:D.join(`
|
|
169
169
|
`),display:!0}):c.jsx(nh,{code:D.join(`
|
|
@@ -405,4 +405,4 @@ ${Te}
|
|
|
405
405
|
config.retry = 2;
|
|
406
406
|
return config;
|
|
407
407
|
}`}};function u6(){if(typeof window>"u")return"kotlin";const t=new URLSearchParams(window.location.search).get("fixture");return t&&t in T2?t:"kotlin"}function d6(){return typeof window>"u"?"unified":new URLSearchParams(window.location.search).get("view")==="split"?"split":"unified"}function h6(){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 f6(){return typeof window>"u"?!0:new URLSearchParams(window.location.search).get("wrap")!=="off"}function qV(){const[e,t]=A.useState(()=>u6()),[r,n]=A.useState(()=>d6()),[s,i]=A.useState(()=>h6()),[a,u]=A.useState(()=>f6()),d=T2[e],f=A.useMemo(()=>Object.entries(T2),[]);return A.useEffect(()=>{if(typeof window>"u")return;let b=window.location.search;const g=()=>{window.location.search!==b&&(b=window.location.search,t(u6()),n(d6()),i(h6()),u(f6()))};window.addEventListener("popstate",g),window.addEventListener("pageshow",g),window.addEventListener("focus",g);const y=window.setInterval(g,250);return()=>{window.removeEventListener("popstate",g),window.removeEventListener("pageshow",g),window.removeEventListener("focus",g),window.clearInterval(y)}},[]),c.jsx("div",{className:"min-h-screen bg-background-subtle text-foreground","data-diff-lab":!0,"data-diff-lab-fixture":e,"data-diff-lab-view":r,"data-diff-lab-inline":s,"data-diff-lab-wrap":a?"on":"off",children:c.jsxs("div",{className:"mx-auto flex min-h-screen max-w-[1180px] flex-col px-4 py-4",children:[c.jsxs("header",{className:"mb-3 flex flex-wrap items-center justify-between gap-3 border-b border-border/20 pb-3",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-semibold",children:"Diff Lab"}),c.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."})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("select",{value:e,onChange:b=>t(b.target.value),className:"h-8 rounded-md border border-border/30 bg-surface px-2 text-xs text-foreground outline-none",children:f.map(([b,g])=>c.jsx("option",{value:b,children:g.label},b))}),c.jsxs("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:[c.jsx("button",{type:"button",onClick:()=>n("unified"),className:`rounded-full px-3 text-xs font-semibold ${r==="unified"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Unified"}),c.jsx("button",{type:"button",onClick:()=>n("split"),className:`rounded-full px-3 text-xs font-semibold ${r==="split"?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:"Split"})]}),c.jsx("div",{className:"inline-flex h-8 overflow-hidden rounded-full bg-surface-2 p-0.5",children:["none","words","chars"].map(b=>c.jsx("button",{type:"button",onClick:()=>i(b),className:`rounded-full px-3 text-xs font-semibold ${s===b?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:b},b))}),c.jsxs("button",{type:"button",onClick:()=>u(b=>!b),className:`h-8 rounded-full px-3 text-xs font-semibold ${a?"bg-primary/15 text-primary":"bg-surface-2 text-muted-foreground"}`,children:["Wrap ",a?"on":"off"]})]})]}),c.jsx("main",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border/20 bg-surface",children:c.jsx(N8,{filePath:d.path,repoRoot:"/tmp/termdock-diff-lab",changedFile:{path:d.path,absolutePath:`/tmp/termdock-diff-lab/${d.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:d.diff,oldSourceOverride:d.oldSource,active:!0,wrap:a,showScrollHint:!a,viewType:r,inlineMode:s})})]})})}const N9=40,S2="/tmp/termdock-diff-review-lab";function p6(e,t){const r=[`diff --git a/${e} b/${e}`,`--- a/${e}`,`+++ b/${e}`,`@@ -1,${t} +1,${t} @@`];for(let n=0;n<t;n+=1)n%5===0&&r.push(`-const removed_${n} = ${n};`),n%3===0&&r.push(`+const added_${n} = ${n} * 2;`),r.push(` context line ${n} in ${e}`);return r.join(`
|
|
408
|
-
`)}function YV(e,t){return Array.from({length:N9},(r,n)=>{const s=6+n*7%60,i=`src/module${String(n).padStart(2,"0")}/File${n}.ts`,a=`${S2}/${i}`,u=p6(i,s),d=p6(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:S2,displayName:`File${n}.ts`,displayDir:`src/module${String(n).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(n)?u:d,auditRecords:[]}})}function ZV(){const e=A.useMemo(()=>{if(typeof window>"u")return 0;const T=new URLSearchParams(window.location.search).get("delay"),C=T===null?0:Number.parseInt(T,10);return Number.isInteger(C)&&C>0?C:0},[]),t=e>0,[r,n]=A.useState(()=>new Set);A.useEffect(()=>{if(!t)return;const T=Array.from({length:N9},(C,E)=>window.setTimeout(()=>{n(N=>{const D=new Set(N);return D.add(E),D})},e+E*20));return()=>T.forEach(C=>window.clearTimeout(C))},[t,e]);const s=A.useMemo(()=>YV(r,t),[r,t]),i=A.useMemo(()=>[{key:"mock-repo",root:S2,label:"diff-review-lab",files:s.map(T=>({key:T.key,path:T.path,absolutePath:T.absolutePath,displayName:T.displayName,displayDir:T.displayDir,status:T.status}))}],[s]),a=A.useMemo(()=>{if(typeof window>"u")return null;const T=new URLSearchParams(window.location.search).get("select");if(T===null)return null;const C=Number.parseInt(T,10);return Number.isInteger(C)&&C>=0&&C<s.length?C:null},[s.length]),[u,d]=A.useState(()=>a!==null?s[a].key:null),[f,b]=A.useState("list"),[g,y]=A.useState(new Set),[v,w]=A.useState(a!==null?1:0);return c.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[c.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: ",c.jsx("span",{"data-lab-selected":!0,children:u??"none"})," · slide ",v]}),c.jsx("div",{className:"min-h-0 flex-1",children:c.jsx(Nd,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:u,mode:f,onModeChange:T=>{T!=="ai"&&b(T)},collapsedDirectoryKeys:g,onToggleDirectory:T=>y(C=>{const E=new Set(C);return E.has(T)?E.delete(T):E.add(T),E}),onSelectFile:T=>d(T.key),onMobileSlideChange:w,renderLeading:()=>null,renderStreamBadge:T=>c.jsx("span",{className:"text-[10px] text-muted-foreground",children:T}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const KV=6e4,m1="termdock:build-id:v1";let m6=!1;function g6(){m6||(m6=!0,window.setTimeout(()=>{window.location.reload()},80))}function C2(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function XV(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function JV(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&C2(e)})})}function eq(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="
|
|
408
|
+
`)}function YV(e,t){return Array.from({length:N9},(r,n)=>{const s=6+n*7%60,i=`src/module${String(n).padStart(2,"0")}/File${n}.ts`,a=`${S2}/${i}`,u=p6(i,s),d=p6(i,1);return{key:a,path:i,absolutePath:a,status:"modified",repoRoot:S2,displayName:`File${n}.ts`,displayDir:`src/module${String(n).padStart(2,"0")} · ${s} lines`,diffOverride:!t||e.has(n)?u:d,auditRecords:[]}})}function ZV(){const e=A.useMemo(()=>{if(typeof window>"u")return 0;const T=new URLSearchParams(window.location.search).get("delay"),C=T===null?0:Number.parseInt(T,10);return Number.isInteger(C)&&C>0?C:0},[]),t=e>0,[r,n]=A.useState(()=>new Set);A.useEffect(()=>{if(!t)return;const T=Array.from({length:N9},(C,E)=>window.setTimeout(()=>{n(N=>{const D=new Set(N);return D.add(E),D})},e+E*20));return()=>T.forEach(C=>window.clearTimeout(C))},[t,e]);const s=A.useMemo(()=>YV(r,t),[r,t]),i=A.useMemo(()=>[{key:"mock-repo",root:S2,label:"diff-review-lab",files:s.map(T=>({key:T.key,path:T.path,absolutePath:T.absolutePath,displayName:T.displayName,displayDir:T.displayDir,status:T.status}))}],[s]),a=A.useMemo(()=>{if(typeof window>"u")return null;const T=new URLSearchParams(window.location.search).get("select");if(T===null)return null;const C=Number.parseInt(T,10);return Number.isInteger(C)&&C>=0&&C<s.length?C:null},[s.length]),[u,d]=A.useState(()=>a!==null?s[a].key:null),[f,b]=A.useState("list"),[g,y]=A.useState(new Set),[v,w]=A.useState(a!==null?1:0);return c.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground","data-diff-review-lab":!0,children:[c.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: ",c.jsx("span",{"data-lab-selected":!0,children:u??"none"})," · slide ",v]}),c.jsx("div",{className:"min-h-0 flex-1",children:c.jsx(Nd,{mobile:!0,backLabel:"Back",files:s,groups:i,selectedKey:u,mode:f,onModeChange:T=>{T!=="ai"&&b(T)},collapsedDirectoryKeys:g,onToggleDirectory:T=>y(C=>{const E=new Set(C);return E.has(T)?E.delete(T):E.add(T),E}),onSelectFile:T=>d(T.key),onMobileSlideChange:w,renderLeading:()=>null,renderStreamBadge:T=>c.jsx("span",{className:"text-[10px] text-muted-foreground",children:T}),wrap:!0,showScrollHint:!1,activePane:!0})})]})}const KV=6e4,m1="termdock:build-id:v1";let m6=!1;function g6(){m6||(m6=!0,window.setTimeout(()=>{window.location.reload()},80))}function C2(e){e.waiting?.postMessage({type:"SKIP_WAITING"})}async function XV(){if(typeof caches>"u")return;const e=await caches.keys();await Promise.all(e.map(t=>caches.delete(t)))}function JV(e){e.addEventListener("updatefound",()=>{const t=e.installing;t&&t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&C2(e)})})}function eq(){if(typeof window>"u"||!("serviceWorker"in navigator))return;const e="1785215418688",t=window.localStorage.getItem(m1);if(t&&t!==e){XV().finally(()=>{window.localStorage.setItem(m1,e),g6()});return}t!==e&&window.localStorage.setItem(m1,e);let r=null;navigator.serviceWorker.addEventListener("controllerchange",g6),window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).then(n=>{JV(n),C2(n);const s=()=>{document.visibilityState==="visible"&&n.update().then(()=>C2(n)).catch(()=>{})};s(),r=window.setInterval(s,KV),document.addEventListener("visibilitychange",s)}).catch(()=>{})}),window.addEventListener("beforeunload",()=>{r!==null&&window.clearInterval(r)})}vF();eq();try{const e=JSON.parse(window.localStorage.getItem("termdock-color-theme")||"null");(e==="dark"||e==="light")&&(document.documentElement.dataset.theme=e,M7(e))}catch{}function tq(){const{t:e}=Qn(),[t,r]=A.useState(null),[n,s]=A.useState(null),i=A.useCallback(async()=>{try{const a=await s_();r(a),s(null)}catch(a){s(a instanceof Error?a.message:"Failed to query auth status")}},[]);return A.useEffect(()=>{i()},[i]),A.useEffect(()=>{const a=()=>{r(u=>u&&{...u,authenticated:!1})};return window.addEventListener(Yf,a),()=>window.removeEventListener(Yf,a)},[]),t===null?c.jsx("div",{className:"flex w-screen items-center justify-center bg-background text-muted-foreground",style:{height:"var(--app-vh, 100vh)"},children:n?`${e("common.error")}: ${n}`:e("common.loading")}):t.enabled&&!t.authenticated?c.jsx(WV,{onLoginSuccess:i}):c.jsx(GV,{})}NT.createRoot(document.getElementById("root")).render(c.jsx(P.StrictMode,{children:c.jsx(VR,{children:c.jsx(Vw,{children:(()=>{const e=new URLSearchParams(window.location.search);return e.get("dag-playground")==="1"?c.jsx(VV,{}):e.get("diff-review-lab")==="1"?c.jsx(ZV,{}):e.get("diff-lab")==="1"?c.jsx(qV,{}):c.jsx(tq,{})})()})})}));export{qd as _,pC as v};
|