pi-web-ui 0.72.0 → 0.74.0

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.
@@ -1,335 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-SG88Uj0n.js","assets/markdown-Cpo0pNcR.js","assets/xterm-B96xOxS9.js","assets/react-CtudoG1_.js","assets/TerminalPanel-DOrYoP_4.css"])))=>i.map(i=>d[i]);
2
- import{R as Ft,a as l,j as s,f as Fo,b as ia,p as xa,c as ya,n as Na,h as rn,s as ws,o as Ln,z as Di,d as Ho,e as Uo,g as qt,v as qo,i as Pi,k as ka,M as $o,l as Wo,m as Oi}from"./markdown-Cpo0pNcR.js";import{r as Mi}from"./react-CtudoG1_.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var Rs={},Ca;function Ko(){if(Ca)return Rs;Ca=1;var e=Mi();return Rs.createRoot=e.createRoot,Rs.hydrateRoot=e.hydrateRoot,Rs}var Yo=Ko();const Go="modulepreload",Vo=function(e){return"/"+e},va={},zo=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),u=d?.nonce||d?.getAttribute("nonce");o=c(n.map(f=>{if(f=Vo(f),f in va)return;va[f]=!0;const g=f.endsWith(".css"),b=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const x=document.createElement("link");if(x.rel=g?"stylesheet":Go,g||(x.as="script"),x.crossOrigin="",x.href=f,u&&x.setAttribute("nonce",u),document.head.appendChild(x),g)return new Promise((N,S)=>{x.addEventListener("load",N),x.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};var Bi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_a=Ft.createContext&&Ft.createContext(Bi),Qo=["attr","size","title"];function Xo(e,t){if(e==null)return{};var n,a,o=Jo(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Jo(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Ws(){return Ws=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ws.apply(null,arguments)}function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function Ks(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sa(Object(n),!0).forEach(function(a){Zo(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function Zo(e,t,n){return(t=el(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function el(e){var t=tl(e,"string");return typeof t=="symbol"?t:t+""}function tl(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Fi(e){return e&&e.map((t,n)=>Ft.createElement(t.tag,Ks({key:n},t.attr),Fi(t.child)))}function fe(e){return t=>Ft.createElement(sl,Ws({attr:Ks({},e.attr)},t),Fi(e.child))}function sl(e){var t=n=>{var a=e.attr,o=e.size,i=e.title,c=Xo(e,Qo),d=o||n.size||"1em",u;return n.className&&(u=n.className),e.className&&(u=(u?u+" ":"")+e.className),Ft.createElement("svg",Ws({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,c,{className:u,style:Ks(Ks({color:e.color||n.color},n.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&Ft.createElement("title",null,i),e.children)};return _a!==void 0?Ft.createElement(_a.Consumer,null,n=>t(n)):t(Bi)}function nl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(e)}function al(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"11",y1:"8",x2:"11",y2:"14"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(e)}function Ms(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"},child:[]}]})(e)}function Je(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"18",y1:"6",x2:"6",y2:"18"},child:[]},{tag:"line",attr:{x1:"6",y1:"6",x2:"18",y2:"18"},child:[]}]})(e)}function Hi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(e)}function Aa(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"},child:[]},{tag:"circle",attr:{cx:"9",cy:"7",r:"4"},child:[]},{tag:"path",attr:{d:"M23 21v-2a4 4 0 0 0-3-3.87"},child:[]},{tag:"path",attr:{d:"M16 3.13a4 4 0 0 1 0 7.75"},child:[]}]})(e)}function Ui(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"17 8 12 3 7 8"},child:[]},{tag:"line",attr:{x1:"12",y1:"3",x2:"12",y2:"15"},child:[]}]})(e)}function il(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 9.9-1"},child:[]}]})(e)}function et(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"3 6 5 6 21 6"},child:[]},{tag:"path",attr:{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",y1:"11",x2:"10",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",y1:"11",x2:"14",y2:"17"},child:[]}]})(e)}function Xt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"4 17 10 11 4 5"},child:[]},{tag:"line",attr:{x1:"12",y1:"19",x2:"20",y2:"19"},child:[]}]})(e)}function wa(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"6"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"2"},child:[]}]})(e)}function Ia(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(e)}function rl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"5"},child:[]},{tag:"line",attr:{x1:"12",y1:"1",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"23"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"},child:[]},{tag:"line",attr:{x1:"1",y1:"12",x2:"3",y2:"12"},child:[]},{tag:"line",attr:{x1:"21",y1:"12",x2:"23",y2:"12"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"},child:[]}]})(e)}function Ys(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]}]})(e)}function ol(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",y1:"21",x2:"4",y2:"14"},child:[]},{tag:"line",attr:{x1:"4",y1:"10",x2:"4",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"20",y1:"21",x2:"20",y2:"16"},child:[]},{tag:"line",attr:{x1:"20",y1:"12",x2:"20",y2:"3"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"7",y2:"14"},child:[]},{tag:"line",attr:{x1:"9",y1:"8",x2:"15",y2:"8"},child:[]},{tag:"line",attr:{x1:"17",y1:"16",x2:"23",y2:"16"},child:[]}]})(e)}function Gs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}function Vs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"22",y1:"2",x2:"11",y2:"13"},child:[]},{tag:"polygon",attr:{points:"22 2 15 22 11 13 2 9 22 2"},child:[]}]})(e)}function zs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]}]})(e)}function ll(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},child:[]},{tag:"polyline",attr:{points:"17 21 17 13 7 13 7 21"},child:[]},{tag:"polyline",attr:{points:"7 3 7 8 15 8"},child:[]}]})(e)}function qi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"1 4 1 10 7 10"},child:[]},{tag:"path",attr:{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"},child:[]}]})(e)}function Lt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"polyline",attr:{points:"1 20 1 14 7 14"},child:[]},{tag:"path",attr:{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"},child:[]}]})(e)}function ct(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(e)}function xf(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"5 3 19 12 5 21 5 3"},child:[]}]})(e)}function cl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"},child:[]}]})(e)}function fn(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"16.5",y1:"9.4",x2:"7.5",y2:"4.21"},child:[]},{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(e)}function ul(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"19",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"5",cy:"12",r:"1"},child:[]}]})(e)}function dl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(e)}function pl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"},child:[]}]})(e)}function Jt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(e)}function ml(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"3",y1:"12",x2:"21",y2:"12"},child:[]},{tag:"line",attr:{x1:"3",y1:"6",x2:"21",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"18",x2:"21",y2:"18"},child:[]}]})(e)}function hl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"},child:[]}]})(e)}function fl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"15 3 21 3 21 9"},child:[]},{tag:"polyline",attr:{points:"9 21 3 21 3 15"},child:[]},{tag:"line",attr:{x1:"21",y1:"3",x2:"14",y2:"10"},child:[]},{tag:"line",attr:{x1:"3",y1:"21",x2:"10",y2:"14"},child:[]}]})(e)}function gl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 10 0v4"},child:[]}]})(e)}function bl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"2",x2:"12",y2:"6"},child:[]},{tag:"line",attr:{x1:"12",y1:"18",x2:"12",y2:"22"},child:[]},{tag:"line",attr:{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"},child:[]},{tag:"line",attr:{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"6",y2:"12"},child:[]},{tag:"line",attr:{x1:"18",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"line",attr:{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"},child:[]},{tag:"line",attr:{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"},child:[]}]})(e)}function Rn(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"},child:[]},{tag:"path",attr:{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},child:[]}]})(e)}function Qs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"12 2 2 7 12 12 22 7 12 2"},child:[]},{tag:"polyline",attr:{points:"2 17 12 22 22 17"},child:[]},{tag:"polyline",attr:{points:"2 12 12 17 22 12"},child:[]}]})(e)}function El(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(e)}function Tl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"circle",attr:{cx:"8.5",cy:"8.5",r:"1.5"},child:[]},{tag:"polyline",attr:{points:"21 15 16 10 5 21"},child:[]}]})(e)}function ja(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"path",attr:{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"},child:[]},{tag:"line",attr:{x1:"12",y1:"17",x2:"12.01",y2:"17"},child:[]}]})(e)}function xl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"14",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"3",y:"14",width:"7",height:"7"},child:[]}]})(e)}function $i(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"path",attr:{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"},child:[]}]})(e)}function La(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"},child:[]}]})(e)}function Bs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"6",y1:"3",x2:"6",y2:"15"},child:[]},{tag:"circle",attr:{cx:"18",cy:"6",r:"3"},child:[]},{tag:"circle",attr:{cx:"6",cy:"18",r:"3"},child:[]},{tag:"path",attr:{d:"M18 9a9 9 0 0 1-9 9"},child:[]}]})(e)}function Rt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},child:[]}]})(e)}function yl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"},child:[]},{tag:"polyline",attr:{points:"13 2 13 9 20 9"},child:[]}]})(e)}function Wi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},child:[]},{tag:"polyline",attr:{points:"14 2 14 8 20 8"},child:[]},{tag:"line",attr:{x1:"16",y1:"13",x2:"8",y2:"13"},child:[]},{tag:"line",attr:{x1:"16",y1:"17",x2:"8",y2:"17"},child:[]},{tag:"polyline",attr:{points:"10 9 9 9 8 9"},child:[]}]})(e)}function Dn(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]}]})(e)}function zt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 20h9"},child:[]},{tag:"path",attr:{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"},child:[]}]})(e)}function Xs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"},child:[]}]})(e)}function Ht(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"7 10 12 15 17 10"},child:[]},{tag:"line",attr:{x1:"12",y1:"15",x2:"12",y2:"3"},child:[]}]})(e)}function vs(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"4",y:"4",width:"16",height:"16",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{x:"9",y:"9",width:"6",height:"6"},child:[]},{tag:"line",attr:{x1:"9",y1:"1",x2:"9",y2:"4"},child:[]},{tag:"line",attr:{x1:"15",y1:"1",x2:"15",y2:"4"},child:[]},{tag:"line",attr:{x1:"9",y1:"20",x2:"9",y2:"23"},child:[]},{tag:"line",attr:{x1:"15",y1:"20",x2:"15",y2:"23"},child:[]},{tag:"line",attr:{x1:"20",y1:"9",x2:"23",y2:"9"},child:[]},{tag:"line",attr:{x1:"20",y1:"14",x2:"23",y2:"14"},child:[]},{tag:"line",attr:{x1:"1",y1:"9",x2:"4",y2:"9"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"4",y2:"14"},child:[]}]})(e)}function Nl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 10 4 15 9 20"},child:[]},{tag:"path",attr:{d:"M20 4v7a4 4 0 0 1-4 4H4"},child:[]}]})(e)}function kt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},child:[]}]})(e)}function kl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(e)}function Pn(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(e)}function Ra(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"},child:[]},{tag:"rect",attr:{x:"8",y:"2",width:"8",height:"4",rx:"1",ry:"1"},child:[]}]})(e)}function Ki(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"13 17 18 12 13 7"},child:[]},{tag:"polyline",attr:{points:"6 17 11 12 6 7"},child:[]}]})(e)}function Yi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"11 17 6 12 11 7"},child:[]},{tag:"polyline",attr:{points:"18 17 13 12 18 7"},child:[]}]})(e)}function on(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"18 15 12 9 6 15"},child:[]}]})(e)}function $t(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 18 15 12 9 6"},child:[]}]})(e)}function Pt(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"6 9 12 15 18 9"},child:[]}]})(e)}function Et(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"20 6 9 17 4 12"},child:[]}]})(e)}function ts(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"},child:[]},{tag:"polyline",attr:{points:"22 4 12 14.01 9 11.01"},child:[]}]})(e)}function gn(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(e)}function Cl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"},child:[]},{tag:"path",attr:{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"},child:[]}]})(e)}function vl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"},child:[]},{tag:"path",attr:{d:"M13.73 21a2 2 0 0 1-3.46 0"},child:[]}]})(e)}function Gi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"19",x2:"12",y2:"5"},child:[]},{tag:"polyline",attr:{points:"5 12 12 5 19 12"},child:[]}]})(e)}function Vi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"polyline",attr:{points:"19 12 12 19 5 12"},child:[]}]})(e)}function zi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"21 8 21 21 3 21 3 8"},child:[]},{tag:"rect",attr:{x:"1",y:"3",width:"22",height:"5"},child:[]},{tag:"line",attr:{x1:"10",y1:"12",x2:"14",y2:"12"},child:[]}]})(e)}function _l(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},child:[]},{tag:"line",attr:{x1:"12",y1:"9",x2:"12",y2:"13"},child:[]},{tag:"line",attr:{x1:"12",y1:"17",x2:"12.01",y2:"17"},child:[]}]})(e)}function Sl(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12.01",y2:"16"},child:[]}]})(e)}function Al(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function Ct(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=new Uint8Array(16);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function wt({trigger:e,open:t,onOpenChange:n,children:a,align:o="right",fit:i=!1,direction:c="down",menuClassName:d,menuRef:u,menuStyle:f}){const g=l.useRef(null);return l.useEffect(()=>{if(!t)return;const b=N=>{g.current&&!g.current.contains(N.target)&&n(!1)},x=N=>{N.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[t,n]),s.jsxs("div",{className:`dropdown ${o} ${i?"fit":""} ${c==="up"?"dd-up":""}`,ref:g,children:[s.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!t),"aria-expanded":t,children:[e,s.jsx(Pt,{className:`dd-caret ${t?"up":""}`})]}),t&&s.jsx("div",{className:`dd-menu ${d??""}`,ref:u,style:f,children:a})]})}function nt({active:e,disabled:t=!1,title:n,onClick:a,children:o}){return s.jsx("button",{type:"button",className:`dd-item ${e?"active":""}`,disabled:t,title:n,onClick:a,children:o})}let bn=null;function wl(e){if(e===void 0){const n=globalThis.document;if(n&&typeof n.baseURI=="string"&&n.baseURI)try{e=new URL(n.baseURI).pathname}catch{}if(e===void 0)return"/"}if(!e||e==="/")return"/";let t=e.replace(/index\.html$/i,"");return t.endsWith("/")||(t+="/"),t}function Qi(){return bn===null&&(bn=wl()),bn}function Il(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function it(e){return Il(e,Qi())}const Xi="pi-web-ui:token";function jl(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(Xi,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function Ll(){try{return localStorage.getItem(Xi)??""}catch{return""}}function Dt(e){const t=Ll();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const Rl=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function On(e,t,n,a=Rl){const o=(e??"").trim();if(o)return o;for(const c of t??[]){const d=String(c??"").trim().toLowerCase().replace(/_/g,"-");if(!d)continue;if(a.includes(d))return d;const u=d.split("-")[0];if(u&&a.includes(u))return u}const i=(n??"").trim().toLowerCase();return i&&a.includes(i)?i:"en"}const Mn="pi-web-ui:lang",Dl={docTitle:"pi-web-ui — pi 编码智能体",cancel:"取消",ok:"确定",save:"保存",close:"关闭",widgetExpand:"点击放大查看完整输出",collapsePanel:"收起面板",expandPanel:"展开面板",dragToResize:"拖拽调整宽度 · 双击复位",loading:"加载中…",connected:"已连接",connecting:"连接中…",reconnecting:"重连中…",language:"语言",langZh:"中文",langEn:"English",langIt:"Italiano",langJa:"日语",langKo:"韩语",langFr:"法语",langDe:"德语",langEs:"西班牙语",langRu:"俄语",langPt:"葡萄牙语",githubRepo:"GitHub 仓库(xing-shuyin/pi-web-ui)",copy:"复制",viewSwitch:"视图切换",chat:"对话",terminal:"终端",selectModel:"选择模型",availableModels:"可用模型",allProviders:"全部",providers:"服务商",noModels:"暂无可用模型(请先配置 API 密钥)",reasoning:"推理",vision:"识图",refreshModels:"刷新模型列表(保留手填,合并新增)",manageModels:"⚙ 管理模型(新增 / 修改)",manageModelsTitle:"管理模型",thinkingLevel:"思考强度",thinking:"思考",thinkingChip:"思考:{level}",sound:"声音",theme:"主题",themeDefault:"深色(默认)",newChat:"新对话",more:"更多",newChatTip:"新建对话(每个浏览器独立保存会话)","thinking.off":"关闭","thinking.minimal":"极简","thinking.low":"低","thinking.medium":"中","thinking.high":"高","thinking.xhigh":"极高","thinking.max":"最大",thinkingUnsupported:"当前模型不支持该级别,已按模型能力就近生效",context:"上下文",contextUsage:"上下文用量",cumulativeCost:"累计成本",sessionMessages:"会话消息数",messages:"消息",pluginStatus:"插件状态",engineBadge:"引擎",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",cwdGoUp:"上级目录",cwdPickCurrent:"选择当前目录",cwdChoose:"选择",cwdEnter:"进入",cwdEmpty:"(空目录)",cwdNewFolder:"新建文件夹",cwdNewName:"文件夹名称",cwdCreate:"创建",cwdCancel:"取消",cacheHit:"缓存命中",cacheHitTip:"缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)",tps:"t/s",rateTip:"实时生成速率(估算)",folderRef:"文件夹引用:{path}",refOnly:"仅引用:{path}",attachContent:"附加内容:{path}",attachLines:"附加选中行:{path}(第 {start}-{end} 行)",attachImage:"图片:{name}",attachFile:"文件:{name}",removeAttachment:"移除附件",attachHint:"将随下一条消息发送",uploadFile:"添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)",dropHereToAttach:"松开以添加文件",imageNotSupported:"当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)",imageLoadFailed:"图片读取失败:{name}",fileLoadFailed:"文件读取失败:{name}",fileTooLarge:"文件过大已跳过(>{size}MB):{name}",foldersNotSupported:"不支持直接拖入文件夹,请展开后选择文件",placeholderStreaming:"智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送",placeholderIdle:"给 pi 发送消息 — Enter 发送,/ 查看命令",placeholderConnecting:"正在连接服务器…",stopAgent:"停止智能体",stop:"停止",bgTasks:"后台任务",bgTasksTip:"AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留",bgTasksEmpty:"暂无后台任务",bgTasksDesc:"AI 运行中启动并仍在监听的进程(按监听端口检测)",bgTaskPort:"端口",bgTaskPid:"PID",bgTaskSince:"启动",bgTaskStop:"停止",bgTaskStopAll:"全部关闭",bgTaskRefresh:"刷新",bgTaskJustNow:"刚刚",bgTaskMinutes:"{n} 分钟前",bgTaskHours:"{n} 小时前",bgTaskDays:"{n} 天前",stopBash:"停止",stopBashTip:"停止正在运行的 bash 命令(对话继续)",supplement:"排队",supplementTip:"加入队列:AI 回答完全结束后才发送(不打断)",queueSteerTag:"插队",queueFollowTag:"排队",queueRemoveTip:"移除此排队消息",sendTip:"发送(Enter)",quickPhrases:"快捷短语",quickPhrasesDesc:"输入框上方的一排常用短语按钮,点击即发送(会带上当前已选的文件附件,不清空输入框草稿)",quickPhrasesEnabled:"启用快捷短语",quickPhrasesOffHint:"已关闭:输入框上方不再显示快捷短语按钮(已配置的短语保留,可随时重新启用)",quickPhrasesPlaceholder:"输入常用短语…(Enter 添加)",quickPhrasesAdd:"添加",quickPhrasesEmpty:"还没有快捷短语,在下面添加第一条",quickPhrasesTip:"点击发送:{text}",quickPhrasesMoveUp:"上移",quickPhrasesMoveDown:"下移",quickPhrasesDelete:"删除该短语",quickPhrasesEdit:"编辑该短语",quickPhrasesEditPh:"修改短语…(Enter 保存,Esc 取消)",quickPhrasesReset:"恢复默认短语",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",recentProjects:"最近项目",runningConversations:"运行的对话",subagentBadge:"子代理",convErrorBadge:"子代理运行报错:{error}",subagentTitle:"子代理 · {title}",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",renameSession:"重命名该对话",renameSessionPlaceholder:"输入新名称…",renameSessionConfirm:"重命名",dismissConversation:"从运行列表移出(历史记录保留)",dismissConversationConfirm:"确认移出",collapseSection:"折叠",expandSection:"展开",emptyChat:"空对话",editReask:"编辑重问",editReaskTip:"修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)",reaskFromHere:"从此处重新提问",editPlaceholder:"修改问题内容…",editHint:"⌘/Ctrl+Enter 提交 · Esc 取消",editAttachmentHint:"原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消",expandMsg:"展开",collapseMsg:"收起",toolCalls:"工具调用",bashRuns:"终端运行",images:"图片",update:"更新",updateTip:"检查并更新 pi-web-ui",currentVersion:"当前版本",latestVersion:"最新版本",checkingUpdate:"检查中…",checkUpdate:"检查更新",upToDate:"已是最新版本",updateAvailable:"发现新版本 v{version}",updateJustPublished:"v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查",updateNow:"在终端中更新",updateTabTitle:"更新 pi-web-ui",updateTerminalHint:"点击后会在可见终端中运行 npm i -g pi-web-ui@latest;完成后重启服务生效(pi-web-ui server restart)。",updatesAllTitle:"全部组件更新",updatesAllBadge:"{n} 个更新",updatesAllUpToDate:"全部组件均为最新",kindWebUi:"Web 界面",kindPiCore:"核心",kindPackage:"组件",updatesAllRefresh:"重新检查全部",updateCheckFailed:"检查失败",updateBtn:"更新",updateAllBtn:"全部更新",updatePkgTabTitle:"更新 {name}",updateAllTabTitle:"更新全部组件",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",copyName:"复制名称",copyPath:"复制路径",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
3
- `,uploadToFolder:"上传文件到此文件夹",uploadToCurrentDir:"上传文件到当前目录",openAsProject:"以项目打开",protocolMismatch:"页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。",selectLinesHint:"点击选择行;拖拽或 Shift+点击选择范围",enableWrap:"开启自动换行",disableWrap:"关闭自动换行",selectedRange:"已选 {n} 行(第 {start}-{end} 行)",fileLines:"{n} 行",selectAll:"全选",clearSelection:"清除",addToChat:"添加到对话",addedToChat:"已添加",previewTruncated:"⚠ 文件过大,仅预览前 512KB",previewLinesTruncated:"… 文件行数过多,仅显示前 {n} 行",binaryFile:"🔣 二进制文件,已显示前 4KB 十六进制",binaryHexTruncated:"(文件更大,可下载完整文件)",previewNotSupported:"该类型文件不支持预览(仅图片 / 视频 / 文本)",emptyFile:"(空文件)",editFile:"编辑文件",exitEditFile:"退出编辑",saveFile:"保存文件",discardFileChanges:"放弃未保存的修改?",fileSaved:"已保存",fileEditTruncated:"文件过大,预览不完整,无法编辑",showMarkdownSource:"显示 Markdown 原文",showMarkdownPreview:"显示 Markdown 预览",fullscreen:"全屏",exitFullscreen:"退出全屏",zoomIn:"放大字号",zoomOut:"缩小字号",resetZoom:"重置缩放",pluginRequest:"插件请求",modelQuestion:"模型提问",modelQuestionCustom:"补充回答(可选)",modelQuestionSubmit:"提交回答",next:"下一步",previous:"上一步",questionStep:"第 {cur} / {total} 题",optionPreview:"选项预览",noOptions:"(无选项)",inputPlaceholder:"输入内容",questionTimeout:"⏳ 剩余 {s} 秒,超时将自动取消",questionTimeoutExpired:"提问已超时,正在恢复对话…",modelNoVision:"当前模型 {name} 不支持图片,请切换到 DeepSeek V4 Flash Vision (exp)",dshSkillsNote:"DSH 引擎使用运行时内置技能(dsh-skill),暂不支持在设置面板启停",dshExtensionsNote:"DSH 引擎无 pi 扩展体系,能力由运行时内置(MCP/subagent/goal/plan/skill 等)",dshReviewPromptNote:"DSH 无独立审查会话:此指令将随目标轮次附加到系统提示词,供模型在目标轮次中遵守",dshVisionHiddenNote:"DSH 引擎直接支持图片输入(仅 DeepSeek V4 Flash Vision (exp) 模型),无需视觉桥转写",dshNoReviewModel:"DSH 无独立审查模型:目标由模型自判定完成/受阻,轮次上限即自动迭代次数",soundHeader:"声音提示",enableSound:"启用声音",preview:"试听",volume:"音量",notifyHeader:"桌面通知",notifyEnable:"启用桌面通知(PWA)",notifyEnableDesc:"会话完成或需要你输入时,即使切到其他应用也会提醒(需授权,仅页面前台无焦点时触发)。",notifyDenied:"通知权限已被拒绝 —— 请在浏览器/系统设置里为本站点开启通知。",notifyUnsupported:"此浏览器不支持通知。",notifyDoneTitle:"任务完成",notifyDoneBody:"会话已完成,等待你的输入。",notifyQuestionTitle:"需要你回答",notifyQuestionBody:"pi 正在等你回答一个问题。",notifyErrorTitle:"出错了",notifyErrorBody:"一个会话报告了错误。","sound.question":"问卷弹出","sound.question.desc":"ask_user_question 出现时","sound.done":"回复结束","sound.done.desc":"智能体完成一轮回答时","sound.start":"回复开始","sound.start.desc":"智能体开始新一轮时","sound.error":"出错","sound.error.desc":"出现错误提示时",setupTitle:"未检测到 pi agent 配置",setupDesc:"pi-web-ui 需要 pi 的配置目录(~/.pi/agent)和至少一个 API 密钥才能运行智能体。pi 内置了 openai、anthropic、deepseek 等服务商——选一个填密钥即可,全程无需打开终端。",installFailed:"✖ pi agent 安装失败:",retryInstall:"重试安装",skip:"跳过",installDone:"✅ pi agent CLI 已安装。选择服务商并填入 API 密钥即可开始对话:",cliReadyHint:"✅ 本地已检测到 pi agent,选择服务商并填入 API 密钥即可开始对话:",provider:"服务商",configured:"已配置",providerKeyReady:"该服务商已配置密钥,可直接使用或更换新密钥。",apiKey:"API 密钥",saving:"保存中…",saveAndStart:"保存并开始使用",recheck:"重新检测",installing:"正在安装 pi agent CLI…",autoInstall:"自动安装 pi agent",attachment:"附件",plugin:"插件",unknown:"未知",thinkingWait:"正在思考",exitCode:"退出码 {code}",cancelled:"已取消",truncated:"… 内容过长,当前视图已截断",outputTruncated:"… 输出过长,当前视图已截断",refOnlyShort:"仅引用",folderRefShort:"文件夹 · 仅引用",inlineLines:"内联 · {n} 行",inlineLinesRange:"行 {start}-{end}",image:"🖼 图片",bridgedVision:"👁 已转写",bridgedVisionDetail:"图片已由视觉桥转写(当前模型不支持识图)",folderNotExpanded:"文件夹,未展开内容 —— 智能体会按需浏览目录",fileNotExpanded:"文件较大({size}),未展开内容 —— 智能体会按需读取","role.user":"你","role.assistant":"pi","role.tool":"工具","role.bash":"终端","role.branch":"分支摘要","role.compaction":"上下文已压缩",directory:"目录",waitingResponse:"正在等待模型响应…",retryingApi:"大模型 API 出错,正在自动重试({attempt}/{max}):{error}",retryingApiSoon:"大模型 API 出错,正在自动重试:{error}",modelRetryAttempts:"模型报错自动重试次数",modelRetryHint:"大模型 API 调用出错时自动重试的次数。次数用完后本轮停止并标红,可点「重试」手动再试;设为 0 则失败即停。修改即时生效,无需重载。",retryNow:"重试",retryLastTip:"手动重试上次失败的模型请求",compactingContext:"正在压缩上下文,摘要生成中…",compactingReasonManual:"手动触发",compactingReasonThreshold:"上下文达到阈值,自动触发",compactingReasonOverflow:"上下文溢出,自动触发",compactionFrom:"从 {tokens} tokens 压缩",compactionKeptHint:"此前历史已折叠为该摘要,上下文中仅保留最近消息",backToBottom:"回到底部",questionNavTitle:"问题列表",searchPlaceholder:"在对话中搜索…",searchNoResults:"无结果",searchModels:"搜索模型…",noModelMatches:"无匹配模型",modelUsedCount:"已用 {n} 次",searchGlobal:"搜索",searchGlobalTip:"全局搜索:对话 / 项目 / 文件(Ctrl+K)",gsPlaceholder:"搜索项目、历史对话、工作区文件…",gsHint:"输入关键词:搜索历史对话全文(含 AI 回复)、最近项目与当前项目的文件名",gsSessions:"对话",gsProjects:"项目",gsFiles:"文件",gsNoResults:"无匹配结果",gsSearching:"正在搜索…",gsTruncated:"匹配过多,仅显示部分结果",gsCurrentProject:"当前",gsOpenPreview:"打开文件预览",gsNavigate:"选择",gsOpen:"打开",gsCloseHint:"关闭",bgTaskCommand:"命令行",searchPrev:"上一个(Shift+Enter)",searchNext:"下一个(Enter)",searchClose:"关闭(Esc)",questionNavTip:"本对话的全部问题,悬浮展开,点击跳转","tpl.title":"提示词模板","tpl.hint":"点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板","tpl.clickCard":"点击填入输入框","tpl.editTpl":"编辑 / 删除模板","tpl.openPicker":"提示词模板(常用提示词,随时取用)","tpl.pickerTitle":"提示词模板","tpl.pickerHint":"点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板","tpl.add":"新建模板","tpl.addDesc":"把常用工作流存成模板","tpl.reset":"恢复默认模板","tpl.resetConfirm":"确认恢复默认?","tpl.builtin":"内置","tpl.custom":"自定义","tpl.newTitle":"新建提示词模板","tpl.editTitle":"编辑提示词模板","tpl.fieldIcon":"图标","tpl.fieldTitle":"标题","tpl.fieldTitlePh":"卡片上显示的短标题","tpl.fieldDesc":"说明","tpl.fieldDescPh":"一句话说明,显示在卡片上","tpl.fieldPrompt":"提示词","tpl.fieldPromptPh":"完整提示词 —— 发送给智能体的内容","tpl.required":"标题和提示词不能为空","tpl.save":"保存修改","tpl.fill":"填入输入框","tpl.fillTip":"填入输入框,可再编辑后发送","tpl.sendNow":"直接发送","tpl.sendTip":"立即作为新对话发送","tpl.delete":"删除","tpl.deleteTip":"删除这个自定义模板","tpl.remove":"移出模板库","tpl.removeTip":"把内置模板移出模板库,可在底部「恢复默认模板」找回","tpl.restore":"恢复默认","tpl.restoreTip":"撤掉你的修改,恢复内置默认","tpl.sk.setup":"仓库初始化","tpl.sk.setup.desc":"让仓库了解它的构建与约定","tpl.sk.setup.prompt":`请先扫描这个仓库,建立「其他工作流都能用」的基础上下文,输出一份简明报告:
4
-
5
- 1. 项目类型、技术栈与目录结构
6
- 2. 构建 / 测试 / 运行 / 格式化的具体命令
7
- 3. 代码约定与命名规范
8
- 4. 任务 / issue 的存放位置与格式
9
- 5. 目前已知的坑或遗留问题
10
-
11
- 先只报告,不修改任何文件。`,"tpl.sk.ask":"技能导航","tpl.sk.ask.desc":"告诉我该用哪个流程","tpl.sk.ask.prompt":"我先描述当前要解决的情况,你先判断最适合的工作流(需求澄清 / 拆解计划 / 测试驱动 / 排错 / 架构 / 审查 / 交接等),说明为什么推荐它、会怎么做,等我确认后按它执行。","tpl.sk.grilldocs":"需求拷问·落档","tpl.sk.grilldocs.desc":"边盘问需求边记录决策","tpl.sk.grilldocs.prompt":"动手前,请用拷问的方式向我盘问这个计划(一次一个问题),直到达成共识。同时把过程中的关键术语和已定决策记录下来(例如写入 CONTEXT.md 或 ADR 文件),让后续所有工作都基于同一套「共享语言」。每个问题先给出你的推荐答案。","tpl.sk.tospec":"转规格说明","tpl.sk.tospec.desc":"把讨论结果整理成规格书","tpl.sk.tospec.prompt":`请把我们在对话中已经达成的共识,整理成一份结构化的规格说明书:
12
-
13
- 1. 背景与目标
14
- 2. 明确的目标与非目标
15
- 3. 用户与使用场景
16
- 4. 边界条件与失败场景
17
- 5. 验收标准(怎样算完成)
18
- 6. 接口 / 数据结构概要
19
-
20
- 先输出规格让我评审,确认后再继续。`,"tpl.sk.totickets":"拆工单","tpl.sk.totickets.desc":"把规格拆成可构建的小任务","tpl.sk.totickets.prompt":`请把这份规格说明拆成一组小工单,供逐个构建:
21
-
22
- 1. 每个工单足够小、可独立验收
23
- 2. 标注依赖顺序(哪些必须先做)
24
- 3. 每个工单含:做什么、验收标准、涉及文件
25
- 4. 识别出可并行的工单
26
-
27
- 先输出工单列表,我确认顺序后再执行。`,"tpl.sk.implement":"规格落地","tpl.sk.implement.desc":"按规格测试优先实现","tpl.sk.implement.prompt":`请按这份规格说明实现,测试优先:
28
-
29
- 1. 先为每个工单写会失败的测试(覆盖正常、边界、错误分支)
30
- 2. 用最小实现让测试通过
31
- 3. 重构并保持测试通过
32
- 4. 逐工单推进,每完成一个简要汇报
33
-
34
- 最后对照验收标准逐条确认。`,"tpl.sk.codeview":"代码审查","tpl.sk.codeview.desc":"对照规格与标准审查 diff","tpl.sk.codeview.prompt":`请审查最近改动的 diff:
35
-
36
- 1. 对照规格说明,实现是否完全覆盖、有无偏差
37
- 2. 正确性:边界、空值、并发与时序
38
- 3. 安全:输入校验、注入、敏感信息
39
- 4. 性能与可读性:是否遵循项目约定
40
- 5. 测试:关键路径是否有覆盖
41
-
42
- 按严重程度分级列出问题,每条给出具体修改建议。`,"tpl.sk.wayfinder":"大任务地图","tpl.sk.wayfinder.desc":"把大工程画成决策地图","tpl.sk.wayfinder.prompt":`这是一个大型任务。请先把它画成一张「决策地图」:
43
-
44
- 1. 拆出所有需要做出的决策点及其依赖关系
45
- 2. 为每个决策点列出选项、权衡与你的推荐
46
- 3. 标注哪些可以并行推进、哪些必须串行
47
- 4. 输出一份路径规划,我逐项确认后再动手。`,"tpl.sk.prototype":"快速原型","tpl.sk.prototype.desc":"用一次性代码验证设计假设","tpl.sk.prototype.prompt":`请针对这个设计问题写一个最小原型来验证假设:
48
-
49
- 1. 只验证关键假设,不做完整实现
50
- 2. 用最简单的方式(可硬编码、可牺牲边界情况)
51
- 3. 运行并告诉我结论:假设成立吗?有哪些权衡?
52
- 4. 验证完的原型可以删除,或等确认后再正式实现。`,"tpl.sk.research":"有据调研","tpl.sk.research.desc":"读一手来源给出带引用的答案","tpl.sk.research.prompt":`请调研这个问题,优先读一手来源(官方文档 / 源码 / 规范):
53
-
54
- 1. 给出带来源链接的答案
55
- 2. 明确区分:事实、合理推断、仍不确定
56
- 3. 列出主要选项及其权衡
57
- 4. 避免用二手内容拼凑,找不到就直接说没找到。`,"tpl.sk.arch":"架构体检","tpl.sk.arch.desc":"找出值得重构的模块(报告)","tpl.sk.arch.prompt":`对整个代码库做一次架构体检:
58
-
59
- 1. 找出「深模块被破坏」的迹象:过长的函数与类、明显的重复、命名混乱、隐藏的耦合
60
- 2. 按严重程度与影响范围分级,输出一份可视化改进报告
61
- 3. 对每一项给出最小可行的重构方案与理由
62
- 4. 先报告再动手,重构前确认范围。`,"tpl.sk.debug":"系统化排错","tpl.sk.debug.desc":"从可复现的失败开始诊断","tpl.sk.debug.prompt":`请系统化诊断这个 bug:
63
-
64
- 1. 先复现,给出可复现的步骤或输入(没有就先造最小复现)
65
- 2. 二分或排除法缩小范围到具体模块
66
- 3. 提出假设,用日志 / 断言 / 最小样例验证,不凭感觉改
67
- 4. 定位根因后解释,再做最小修复
68
- 5. 补回归测试防止复发。`,"tpl.sk.merge":"解决合并冲突","tpl.sk.merge.desc":"逐个 hunk 完成合并/变基","tpl.sk.merge.prompt":`请帮我解决这个合并 / 变基冲突:
69
-
70
- 1. 逐个冲突 hunk 处理,先读懂双方各自的意图
71
- 2. 选择或合并出保留正确语义的代码,不盲目取一边
72
- 3. 处理完运行测试与构建确认没问题
73
- 4. 最后总结每处冲突的取舍原因。`,"tpl.sk.triage":"工单分流","tpl.sk.triage.desc":"把原始 issue 整理成可领取的工作","tpl.sk.triage.prompt":`请把这些原始 issue / 反馈整理成可执行的工作项:
74
-
75
- 1. 去重、合并相关的条目
76
- 2. 分类(bug / 功能 / 改进 / 问题)
77
- 3. 按影响与紧急度标优先级
78
- 4. 每个工作项补上:复现信息或期望、验收标准
79
-
80
- 输出整理后的清单。`,"tpl.sk.wizard":"设置向导","tpl.sk.wizard.desc":"生成引导人类完成设置的脚本","tpl.sk.wizard.prompt":`请为一个需要手动操作的设置流程生成一个引导向导(脚本或文档):
81
-
82
- 1. 一步步引导,每步说明为什么
83
- 2. 每步带校验,输错给出可操作的提示
84
- 3. 支持撤销 / 回退到上一步
85
- 4. 结束时做一次自检并给出验证方法。`,"tpl.sk.grillme":"需求拷问","tpl.sk.grillme.desc":"动手前盘问对齐想法","tpl.sk.grillme.prompt":`开始之前,请不遗余力地盘问我这个想法的每一个方面,直到我们达成共识(一次只问一个问题,每个问题先给推荐答案):
86
-
87
- 1. 目标与非目标
88
- 2. 用户与场景
89
- 3. 边界与失败模式
90
- 4. 约束与依赖
91
- 5. 验收标准
92
-
93
- 达成共识后再给实现计划,等确认再写代码。`,"tpl.sk.handoff":"交接","tpl.sk.handoff.desc":"把长会话写成交接文档","tpl.sk.handoff.prompt":`请把当前会话整理成一份交接文档,让另一个 agent / 同事能无缝继续:
94
-
95
- 1. 背景与目标
96
- 2. 已完成的工作与关键决策(附原因)
97
- 3. 未完成项与下一步
98
- 4. 已知风险与待确认问题
99
- 5. 如何验证当前状态(命令等)
100
-
101
- 输出为结构化文档。`,"tpl.sk.questionnaire":"转问卷","tpl.sk.questionnaire.desc":"把开放问题变成可填问卷","tpl.sk.questionnaire.prompt":`请把需要别人提供的信息整理成一份可填写的问卷:
102
-
103
- 1. 每个问题说明背景和用途
104
- 2. 标注必填 / 选填
105
- 3. 给出示例答案降低理解成本
106
- 4. 分组排序,先简单后复杂
107
-
108
- 输出一份文档,对方可以照着填。`,"tpl.sk.teach":"持续学习","tpl.sk.teach.desc":"跨多次会话循序渐进学习","tpl.sk.teach.prompt":`请按循序渐进的方式教我:
109
-
110
- 1. 先定学习路径和目标
111
- 2. 一次只讲一小节,讲完给个小练习
112
- 3. 基于上一节的内容递进,主动提问确认理解
113
- 4. 每节结束总结要点
114
-
115
- 适合跨多次会话推进。`,"tpl.sk.ww":"说人话","tpl.sk.ww.desc":"用大白话重讲刚才的解释","tpl.sk.ww.prompt":`请把刚才的解释用最简单的语言重新讲一遍:
116
-
117
- 1. 避免术语,必须用时先给一句话定义
118
- 2. 用类比或具体例子说明
119
- 3. 明确指出哪部分仍是猜测 / 不确定
120
- 4. 用最短的话说完核心意思。`,"tpl.sk.wfa":"写给 agent 的文档","tpl.sk.wfa.desc":"按 agent 易读的原则写文档","tpl.sk.wfa.prompt":`请按「写给 agent 阅读」的原则写这份文档 / 说明:
121
-
122
- 1. 目标与使用场景写在最前
123
- 2. 指令具体、可验证,避免歧义和空话
124
- 3. 给正反例帮助理解
125
- 4. 结构化:标题、步骤、清单
126
- 5. 标注哪些是硬性要求、哪些是可选。`,"tpl.sk.codesign":"深模块设计","tpl.sk.codesign.desc":"用深模块原则审查与设计","tpl.sk.codesign.prompt":`请用「深模块」设计原则审查 / 设计:
127
-
128
- 1. 识别模块对外暴露的接口是否比内部实现更简单
129
- 2. 找出把复杂度泄漏到外部的模块
130
- 3. 给出每个模块的职责边界与改进方案
131
- 4. 平衡内聚与复用,避免过度抽象
132
-
133
- 输出审查结论与重构建议。`,"tpl.sk.domain":"领域建模","tpl.sk.domain.desc":"打磨项目用词并写下来","tpl.sk.domain.prompt":`请帮我梳理这个项目的领域语言:
134
-
135
- 1. 找出核心术语及当前叫法
136
- 2. 识别同词异义 / 异词同义造成的混乱
137
- 3. 统一推荐用词,写进术语表
138
- 4. 说明每个术语的边界(不是什么)
139
-
140
- 输出一份领域术语表。`,"tpl.sk.grilling":"拷问流程","tpl.sk.grilling.desc":"用拷问压测一个计划","tpl.sk.grilling.prompt":`请对下面这个计划做压力测试(拷问):
141
-
142
- 1. 逐项检查假设:如果它是错的会怎样?
143
- 2. 找漏洞:边界、失败模式、依赖、时序
144
- 3. 质疑决策:为什么这样?有没有更简单的路?
145
- 4. 每次只提出一个最尖锐的问题,等我回答
146
-
147
- 直到这个计划经得起推敲。`,"tpl.sk.tdd":"测试驱动","tpl.sk.tdd.desc":"红-绿-重构的规则","tpl.sk.tdd.prompt":`请用 TDD(红-绿-重构)完成:
148
-
149
- 1. 先写会失败的测试,覆盖正常路径、边界与错误分支
150
- 2. 用最小实现让测试通过
151
- 3. 重构并保持测试通过
152
-
153
- 避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:"出错",done:"完成",running:"执行中…",toolQueued:"排队中",copyArgs:"复制参数",copyMessage:"复制消息",copied:"已复制",errorOutput:"错误输出",output:"输出",waitingOutput:"等待输出…",toolDoneWaitingModel:"已结束 · 等模型",waitingModel:"等待模型响应…",thinkingNow:"思考中",thinkingPreview:"思考:{preview}",commands:"命令",newCommand:"新建命令",newTerminal:"新建终端",name:"名称",command:"命令",cwdHint:"(${pwd} = 当前工作目录)",noCommands:"还没有命令,点 + 添加一个",clickToRun:"点击运行",edit:"编辑",delete:"删除",confirmQ:"确认?",builtinTerminal:"内置终端",termEmptySub:"点击左侧命令运行,或点右侧 + 新建终端",noTerminal:"暂无终端",exited:"(已退出{code})",exitBanner:"[进程已退出,退出码 {code}]",closeTerminal:"关闭终端",renameTerminal:"重命名终端",rerun:"重新读取 .pi/commands.json",terminalTitle:"终端 {n}",aiBashGroup:"终端接管 bash",exampleName:"例如:启动开发服务器",exampleCommand:"例如:npm run dev",scmTab:"Git",scmTitle:"源代码管理",scmRefreshTip:"重新查询 Git 状态与差异",scmCurrentBranch:"当前分支",scmUpstreamGone:"上游已删除",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"分离 HEAD",scmSelectBranch:"选择分支…",scmRemoteBranches:"远程分支",scmStageTip:"暂存 {path}",scmUnstageTip:"取消暂存 {path}",scmSwitch:"切换",scmSwitchBranch:"切换分支",scmSwitchBranchTip:"在终端中执行 git checkout {branch}",scmPush:"推送",scmPushTip:"在终端中执行 git push",scmPull:"拉取",scmPullTip:"在终端中执行 git pull",scmCommit:"提交",scmCommitTip:'在终端中执行 git commit -m "…"(仅提交已暂存的更改)',scmCommitAll:"全部提交",scmCommitAllTip:'在终端中执行 git add -A && git commit -m "…"(暂存全部更改含未跟踪并提交)',scmCommitPlaceholder:"输入提交信息…",scmChanges:"更改",scmHistory:"提交树",scmCommitDetail:"提交详情",scmSelectCommitHint:"点击左侧提交查看详情",scmNoHistory:"暂无提交记录",scmNoChanges:"工作区干净,没有更改",scmNotGitRepo:"当前目录不是 Git 仓库",scmLoading:"查询中…",scmConnecting:"等待连接…",scmDiff:"差异",scmSelectFileHint:"点击左侧文件查看差异",scmNoDiff:"(无差异)",scmStaged:"已暂存",scmUnstaged:"未暂存",scmStagedUnstaged:"已暂存 + 未暂存",scmUntracked:"未跟踪",scmUntrackedNote:"未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含",scmQueryFailed:"Git 查询失败:{error}",scmQueryFailedShort:"查询失败",pluginCommandFallback:"插件命令",scmTooManyFailures:"Git 查询连续失败,请点击刷新重试",scmRunsInTerminal:"提交 / 切换分支 / 推送 / 拉取在终端中执行",scmViewTerminal:"去终端",editProvider:"编辑服务商",builtinProviders:"内置服务商",hintKeyOnly:"只需填入 API 密钥",configuredBadge:"✓ 已配置",keyReady:"密钥已就绪",replaceKey:"更换密钥",replaceKeyTitle:"替换已保存的密钥",clearKey:"清空",clearKeyTitle:"清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)",clearKeyConfirm:"清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。",cloneProvider:"添加密钥",cloning:"添加中",cloneProviderTitle:"为该供应商添加第二把密钥(自动复制 baseUrl 与模型列表,可改名后保存)",pasteKey:"粘贴 API 密钥…",savingKey:"保存中",saveKey:"保存密钥",addKey:"添加密钥",addKeyPlaceholder:"粘贴密钥值…",keyNamePh:"名称(可留空,如 备用)",providerIdPlaceholder:"供应商 ID",baseUrlExamplePh:"baseUrl 链接,如 https://api.opencode.ai/zen/v1 或 http://127.0.0.1:4096",saveAllBatch:"一键保存全部({n})",netDisconnected:"网络连接已断开,请重连后重试",advancedEdit:"高级编辑",batchCreateProviders:"批量创建供应商({n}个接口)",secondKeyTitle:"为 {api} · {baseUrl} · {n} 个模型添加第二把密钥,只需指定新供应商名字和密钥即可。",noBaseUrlShort:"(无 baseUrl)",providerNameLabel:"供应商名字",providerNameHint:"(新 ID,如 opencode-2)",apiKeyLabel:"API 密钥",secondKeyPlaceholder:"sk-… 第二把 key",batchDesc:"该供应商含多种接口({apis}),已按接口拆分为 {n} 个自定义供应商,分别保存后才能让所有模型(如 muse-spark)都可用。统一填入第二把 API 密钥后一键保存。",batchKeyLabel:"统一 API 密钥(将应用到全部 {n} 个供应商)",modelsCountShort:"{n} 个模型:",noKeyYet:"尚无密钥,添加一把即可用",activateKey:"设为当前",removeKey:"移除",removeKeyConfirm:"确定移除该密钥?移除后需重新配置才能使用。",customProviders:"自定义服务商",customDesc:"用于 Ollama / vLLM / 兼容 OpenAI 的代理等,写入 pi 的 models.json,保存后热重载、立即生效。",noCustomProviders:"还没有自定义服务商",modelsCount:"{n} 个模型",addProvider:"新增服务商",providerId:"服务商 ID",providerIdHint:"(必填,如 ollama / my-proxy)",displayName:"显示名",displayNamePh:"我的代理",apiType:"API 类型",baseUrlHint:"(OpenAI 兼容端点)",apiKeyHint:"sk-…(可留空,用 auth.json 的密钥)",authHeader:"自动添加 Authorization 请求头",modelsTitle:"模型",modelIdReq:"模型 ID(必填)",text:"文本",textImage:"文本+图片",contextWindow:"上下文",maxOutput:"最大输出",removeModel:"移除模型",addModel:"添加模型",deleteProviderConfirm:"删除服务商 {id} 及其 {n} 个模型?",fetchModels:"自动获取模型列表",fetchModelsHint:"从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)",fetchingModels:"获取中…",fetchModelsOk:"已获取 {n} 个模型",fetchModelsEmpty:"接口未返回任何模型",fetchModelsErr:"获取失败:{msg}",fetchModelsNeedBaseUrl:"请先填写 baseUrl 再获取",goalBarTitle:"目标",goalBarPlaceholder:"设定一个目标,agent 完成后自动审查…",goalBarSet:"开始",goalBarClear:"取消",goalBarLocked:"锁定:应用到后续所有回合",goalBarUnlocked:"仅本回合(改完自动清除)",goalBarReviewModel:"审查模型",goalBarUseMainModel:"使用主模型",goalBarMaxRounds:"最大轮数",goalBarMaxRoundsTip:"最大审查重改轮数;0 或不填 = 不限(持续改到通过)",goalBarUnlimitedShort:"不限",goalBarReviewing:"审查中…",goalBarRound:"第 {n} 轮",goalBarActive:"目标生效中",goalBarPassed:"已通过",goalBarFailed:"未通过",goalBarStatusPending:"等待生成…",goalWizardBtn:"AI 提炼",goalWizardTip:"让 AI 通过问卷调研细化需求,收敛为目标",goalWizardRunning:"目标调研中",goalWizardAnswer:"回答",goalWizardCard:"目标调研",settings:"设置",settingsTitle:"设置",settingsDesc:"修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。",settingsSystemPrompt:"系统提示词",settingsPromptHistory:"输入历史",settingsPromptHistoryDesc:"用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)",promptHistoryMax:"最大条数",promptHistoryMaxHint:"超过上限时最旧的自动丢弃,可设 1–500",promptHistoryCharLimit:"限制单条字数",promptHistoryCharLimitHint:"开启后超长输入截断后保存,避免大段粘贴占满存储",promptHistoryCharLimitPlaceholder:"最大字数(100–20000)",promptHistoryClear:"清空历史",promptHistoryClearConfirm:"确认清空?",promptHistoryCleared:"已清空输入历史",promptHistoryCount:"当前 {n} 条",promptHistoryEmpty:"暂无历史记录,上/下键暂无可循环内容",settingsPromptMode:"模式",promptModeAppend:"追加",promptModeReplace:"替换",promptAppendHint:"追加模式:自定义内容拼接到默认系统提示词末尾(推荐,保留默认行为约束)。",promptReplaceHint:"替换模式:只替换内置模板的「灵魂提示词」(人物设定段,如 “You are an expert coding assistant…”);工具列表、Guidelines、文档指引、项目上下文、技能段等自动拼装段仍由系统每次重新生成,不会被替换。切换后输入框显示原本的灵魂提示词,可直接修改;留空则使用内置默认。",promptPlaceholder:"输入自定义系统提示词…(失焦后自动应用)",promptComposeHint:"模板里的 {{token}} 在每次对话时展开为对应「来源」的提示词;未覆盖的来源用自动内容(工具列表/项目上下文/技能等永远用最新数据生成)。",promptComposeDesc:"组合模板:{{token}} 自由排序/删改/穿插自己的话;空 = 默认模板。下面每个来源可单独覆盖(留空 = 自动内容),也可逐块恢复默认。",promptTemplateLabel:"组合模板",promptSourcesLabel:"各来源(可单独覆盖)",promptInsertTokens:"插入段落:",promptResetAll:"恢复默认模板并清空所有覆盖",promptResetSource:"恢复默认",promptAutoBadge:"自动",promptOverridePlaceholder:"输入覆盖内容(留空 = 用自动内容)…",promptSourceDefaultEmpty:"(该来源当前无自动内容)",promptReadonlyBadge:"系统自动生成(只读)",promptReadonlyLockedBadge:"自定义覆盖(只读·锁定)",promptReadonlyLockedHint:"该来源由系统自动生成,只读;此覆盖不会被设置面板编辑,服务端仍按原样生效。",promptReadonlyTitle:"系统自动生成的来源,仅只读展示,不可编辑",promptSourceDefaultEditHint:"该来源当前的默认(自动)内容 —— 点击可直接输入覆盖文字",promptSourceExpand:"展开全文",promptSourceCollapse:"收起",promptSourceRefLabel:"默认(自动)内容(可对照 / 复制)",promptSourceSeedButton:"填入默认内容,只改一小部分",promptSourceSeedTip:"把该来源当前的默认内容复制进覆盖框:只想改一小部分时直接改这里。填入后此来源内容固定,不再随每次对话自动重新生成。",promptTok_soul:"灵魂提示词",promptTok_soul_desc:"agent 人物设定(无 SYSTEM.md 时内置默认)",promptTok_tools:"工具列表",promptTok_tools_desc:"Available tools(各工具说明,每次自动生成)",promptTok_guidelines:"行为准则",promptTok_guidelines_desc:"Guidelines:各工具引导 + 通用规则",promptTok_pi_docs:"Pi 文档指引",promptTok_pi_docs_desc:"指向 pi 包文档的提示段",promptTok_append:"追加段",promptTok_append_desc:"APPEND_SYSTEM.md 内容;覆盖 = 自定义追加文字",promptTok_persona:"Windows 约束",promptTok_persona_desc:"Windows persona(仅 win32;超时/PTY/GBK 注意事项)",promptTok_terminal:"终端工具引导",promptTok_terminal_desc:"持久终端使用引导(「终端工具」开时注入)",promptTok_markers:"标记工具引导",promptTok_markers_desc:"内置标记工具使用说明(markers 开时注入)",promptTok_context:"项目上下文",promptTok_context_desc:"<project_context>:AGENTS.md/CLAUDE.md 收集结果",promptTok_skills:"技能段",promptTok_skills_desc:"<available_skills>:可用技能清单",promptTok_cwd:"工作目录行",promptTok_cwd_desc:"Current working directory 行",settingsViewPrompt:"查看当前完整提示词",settingsViewPromptHint:"当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。",settingsViewPromptEmpty:"会话尚未就绪,暂无系统提示词。",settingsViewToolsSchema:"工具 schema",settingsViewToolsSchemaHint:"发给模型的 function-calling 工具定义(name / description / parameters),与系统提示词正文拼成完整初始上下文,只读。",settingsViewToolsSchemaEmpty:"会话尚未就绪,暂无工具 schema。",settingsSkills:"技能",settingsReview:"目标审查",settingsReviewDesc:"为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。",settingsReviewSkills:"审查可用技能",reviewPromptPlaceholder:"输入审查自定义提示词…(失焦后自动应用)",reviewPromptHint:"这些内容会追加到审查任务中;审查仍会强制要求输出 pass/fail JSON。技能开关仅对审查生效。",goalModeEnabled:"启用目标模式",goalModeEnabledDesc:"目标条 / 目标调研向导 / 审查循环的总开关(默认开)。关闭后目标条隐藏,无法设置目标、启动调研或触发审查。",goalModeOffHint:"目标模式已关闭:目标条已隐藏,已有的目标将不再触发审查。",settingsVisionBridge:"视觉桥",settingsVisionBridgeDesc:"当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答",visionBridgeEnabled:"启用视觉桥",visionBridgeModel:"转写模型",visionBridgeAuto:"自动选择(按顺序)",visionBridgeNoModels:"未找到已配置的视觉模型:在模型配置里添加任意支持图片的模型(如 qwen-vl、GLM-4V、Gemini)即可自动启用",visionBridgeOffHint:"已关闭:图片将原样发送,纯文本模型可能看不到图片内容",visionBridgeCurrent:"当前转写模型:{model}",visionBridgePromptMode:"转写提示词",settingsMarkers:"标记工具",settingsMarkersDesc:"让 AI 用 [[todo:...]] / [[notify:...]] / [[conv:rename:...]] 内联标记在正文里改状态,无需工具往返。全局关闭则全部停用;分组开关可细粒度控制。",markersEnabled:"启用标记工具(全局)",markersEnabledDesc:"关闭后 AI 不再收到任何标记引导,解析也跳过(所有标记原文原样保留,不执行)。",markersOffHint:"已全局关闭:所有标记停用,AI 不会写标记,也不会触发任务/重命名等副作用。",markerGroupTodo:"任务标记 todo",markerGroupNotify:"提醒标记 notify",markerGroupRename:"重命名标记 conv/rename",markerRenameTip:"[[conv:rename:新标题]] 重命名当前对话(标题 ≤80 字;在回复第一条消息末尾根据情况重命名)",settingsTerminalTools:"终端工具",terminalToolsEnabled:"启用持久终端工具",settingsTerminalToolsDesc:"让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具",terminalToolsOffHint:"已关闭:AI 无法使用 terminal_* 工具,也不会收到相关使用引导",settingsEditTools:"编辑工具",editSoftEnabled:"启用编辑工具 edit_soft",editSoftEnabledDesc:"让 AI 用一个独立、不严格要求缩进的编辑工具:当你的 oldText 与文件缩进/空白不一致(如 JS/JSON)时可避免因缩进差异导致编辑失败。命中后按你给出的 newText 原样写入(缩进即最终缩进)。",editSoftOffHint:"已关闭:AI 无法使用 edit_soft 工具,也不会收到相关使用引导",settingsQuestionnaire:"问卷提问",questionnaireEnabled:"允许模型向我提问(问卷)",questionnaireEnabledDesc:"开启默认值:模型可用 ask_user_question 弹出可回复的问卷/提问对话框(含选项、多选、自定义输入)。关闭后模型将不再弹出问卷,调用也会直接返回已禁用。",questionnaireOffHint:"已关闭:模型不能再向你弹出问卷/提问对话框",settingsMessageDisplay:"对话",thinkingWrap:"完整显示思考",thinkingWrapDesc:"开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本",toolsWrap:"完整显示工具",toolsWrapDesc:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",wideChat:"宽屏聊天列",wideChatDesc:"开启:中央列铺满宽度(超宽屏有用);关闭:保持 860px 上限",projectTitle:"标题显示项目名",projectTitleDesc:"开启:浏览器标签页标题为「项目目录名 — pi-web-ui」,切项目即时更新(多标签页开多个项目时好区分);关闭:固定显示应用名",terminalBashTakeover:"终端接管 bash",terminalBashTakeoverDesc:"此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)",terminalBashIdleMs:"静默转后台阈值(毫秒)",terminalBashIdleMsDesc:"持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)",visionBridgePromptPlaceholder:"输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)",visionBridgePromptAppendHint:"追加模式:自定义内容拼接到内置转写提示词末尾(推荐,保留默认的逐字转写约束)。",visionBridgePromptReplaceHint:"替换模式:完全用自定义内容替换内置转写提示词。切换后输入框会显示内置默认提示词,可直接修改;不改动失焦则仍使用默认。",uninstallExt:"卸载",uninstallConfirm:"确认卸载?",uninstallConfirmHint:"再次点击确认,将在终端执行 pi remove",uninstallHint:"通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表",uninstallTitle:"卸载",pluginUpdate:"更新",pluginUpdateHint:"从安装来源重新拉取并覆盖安装(保留 config.json 配置),完成后自动重载插件列表",pluginMarket:"插件市场",updatesManaged:"本实例由部署方管理:更新与插件安装不在此进行",pluginCatalogAdd:"添加插件",pluginCatalogAddHint:"把第三方插件填进可安装列表(owner/repo 或完整 GitHub 地址)",pluginCatalogSource:"来源 owner/repo 或 owner/repo/子目录(必填)",pluginCatalogId:"id(可选,默认取仓库/子目录名)",pluginCatalogName:"名称(可选)",pluginCatalogIcon:"图标 emoji(可选)",pluginCatalogDesc:"简介(可选)",pluginCatalogAddSubmit:"添加到列表",noPluginCatalog:"列表为空 —— 点「添加插件」把第三方插件填进列表",pluginInstalled:"已安装",pluginCatalogCustom:"自定义",pluginInstall:"安装",pluginInstallHint:"从来源直接安装到界面插件(在可见终端执行)",pluginCatalogRemoveHint:"从列表移除这条自定义插件",pluginUninstallHint:"在可见终端执行 pi-web-ui uninstall 卸载此插件(再次点击确认),完成后自动刷新列表",settingsExtensions:"插件",settingsUiPlugins:"界面插件",noUiPlugins:"未安装界面组件(<dataDir>/plugins/)",dshPatches:"DSH 用户补丁",dshPatchesDesc:"启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。",dshPatchesRescan:"重扫",dshPatchesRescanHint:"重新扫描补丁目录并重启 DSH 运行时使新补丁生效",dshPatchesEmpty:"未放置补丁文件",dshPatchesPath:"补丁目录:",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",settingsPresets:"预设",settingsSubagentTemplates:"子代理模板",settingsSubagentTemplatesDesc:"配置子代理预设(角色系统提示词 + 技能/扩展白名单 + 可选模型)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。",noSubagentTemplates:"还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单 + 可选模型),也可以不传 template 按默认配置运行。",subagentTemplateNew:"新建模板",subagentTemplateEdit:"编辑",subagentTemplateClosed:"已停用",tplDefaultBadge:"默认",subagentTemplateOffHint:"关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择",subagentTemplateEnable:"启用",subagentTemplateDisable:"停用",subagentDefaultModelLabel:"子代理默认模型",subagentFollowMain:"跟随主对话当前模型",subagentDefaultModelHint:"所有子代理的兜底模型(模板里指定的模型和 subagent_spawn 的 model 参数优先级更高);不改主对话模型。",subagentNoModels:"暂无可用的模型(需要先配置服务商 API Key)——子代理将跟随主对话模型。",tplNamePlaceholder:"模板名(AI 用 subagent_spawn 的 template 参数引用)…",tplDescriptionPlaceholder:"简介(AI 据此判断适用场景)…",tplDescriptionEnPlaceholder:"英文简介(英文 UI 时 AI 看这个,留空则用中文简介)…",tplPromptModeLabel:"系统提示词模式",tplModelLabel:"模型(空 = 跟随主对话)",tplSystemPromptLabel:"系统提示词",tplSystemPromptPlaceholder:"模板角色系统提示词…(append 模式可留空)",tplSystemPromptEnPlaceholder:"英文系统提示词…(英文 UI 时生效,留空则用中文)",tplWhitelistHint:"白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置",tplSkillsLabel:"技能白名单",tplExtensionsLabel:"扩展白名单",tplSave:"保存模板",tplCancel:"取消编辑",tplDelete:"删除模板",tplInherit:"跟随主会话",settingsEnabled:"已启用",settingsDisabled:"已禁用",presetNamePlaceholder:"预设名称…",saveAsPreset:"保存为预设",applyPreset:"应用",deletePreset:"删除预设",noSkills:"暂无技能",noExtensions:"暂无插件",noPresets:"暂无预设(先调整上面的设置,再保存为预设组合)",loadingSession:"正在加载会话…",connectingServer:"正在连接 pi-web-ui 服务器…",localePacks:"语言包",localeGetMore:"获取更多语言",localeInstalled:"已安装",localeInstall:"下载",localeRemove:"移除",localeDownloading:"下载中…",localeRemoving:"移除中…",localeInstallFailed:"下载失败:{error}",localeListFailed:"获取语言包列表失败:{error}",localeRemoveHint:"移除后随时可重新下载",wallpaperTitle:"聊天背景图",wallpaperDesc:"给整个窗口加一张背景图(左右面板、顶栏、底栏也会透出):主题自带的图会自动生效,在此填地址则优先用你的;用压暗与模糊保证文字清晰。",wallpaperUrlPh:"图片地址(https://…,留空关闭)",wallpaperDim:"压暗",wallpaperBlur:"模糊",wallpaperClear:"清除",wallpaperUpload:"上传图片",wallpaperUploadFailed:"图片读取失败或过大,请换一张试试"},Pl={docTitle:"pi-web-ui — pi coding agent",cancel:"Cancel",ok:"OK",save:"Save",close:"Close",widgetExpand:"Click to view full output",collapsePanel:"Collapse panel",expandPanel:"Expand panel",dragToResize:"Drag to resize · double-click to reset",loading:"Loading…",connected:"Connected",connecting:"Connecting…",reconnecting:"Reconnecting…",language:"Language",langZh:"中文",langEn:"English",langIt:"Italiano",langJa:"日本語",langKo:"한국어",langFr:"Français",langDe:"Deutsch",langEs:"Español",langRu:"Русский",langPt:"Português",githubRepo:"GitHub repository (xing-shuyin/pi-web-ui)",copy:"Copy",viewSwitch:"Switch view",chat:"Chat",terminal:"Terminal",selectModel:"Select model",availableModels:"Available models",allProviders:"All",providers:"Providers",noModels:"No models available (configure an API key first)",reasoning:"reasoning",vision:"vision",refreshModels:"Refresh model list (keeps manual rows, merges new ones)",manageModels:"⚙ Manage models (add / edit)",manageModelsTitle:"Manage models",thinkingLevel:"Thinking level",thinking:"Thinking",thinkingChip:"Thinking: {level}",sound:"Sound",theme:"Theme",themeDefault:"Dark (default)",newChat:"New chat",more:"More",newChatTip:"New chat (sessions are saved per browser)","thinking.off":"Off","thinking.minimal":"Minimal","thinking.low":"Low","thinking.medium":"Medium","thinking.high":"High","thinking.xhigh":"Extra high","thinking.max":"Max",thinkingUnsupported:"Not supported by this model — snapped to the nearest supported level",context:"Context",contextUsage:"Context usage",cumulativeCost:"Cumulative cost",sessionMessages:"Session messages",messages:"messages",pluginStatus:"Plugin status",engineBadge:"Engine",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",cwdGoUp:"Up one level",cwdPickCurrent:"Select this folder",cwdChoose:"Select",cwdEnter:"Enter",cwdEmpty:"(empty)",cwdNewFolder:"New folder",cwdNewName:"Folder name",cwdCreate:"Create",cwdCancel:"Cancel",cacheHit:"Cache hit",cacheHitTip:"read {read} · write {write} · miss {miss} (of {input} input tokens)",tps:"t/s",rateTip:"Live generation rate (estimated)",folderRef:"Folder reference: {path}",refOnly:"Reference only: {path}",attachContent:"Attached content: {path}",attachLines:"Attached selected lines: {path} (lines {start}-{end})",attachImage:"Image: {name}",attachFile:"File: {name}",removeAttachment:"Remove attachment",attachHint:"Will be sent with the next message",uploadFile:"Add files (images / text / any file — or drag in / paste a screenshot)",dropHereToAttach:"Release to attach file",imageNotSupported:"The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)",imageLoadFailed:"Couldn't read image: {name}",fileLoadFailed:"Couldn't read file: {name}",fileTooLarge:"File too large, skipped (> {size}MB): {name}",foldersNotSupported:"Folders can't be dropped directly — expand and pick files instead",placeholderStreaming:"The agent is working… press Enter to steer, or click Queue to send after the reply finishes",placeholderIdle:"Message pi — Enter to send, / for commands",placeholderConnecting:"Connecting to server…",stopAgent:"Stop agent",stop:"Stop",bgTasks:"Background tasks",bgTasksTip:"Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation",bgTasksEmpty:"No background tasks",bgTasksDesc:"Processes the AI started that are still listening (detected by port)",bgTaskPort:"Port",bgTaskPid:"PID",bgTaskSince:"Started",bgTaskStop:"Stop",bgTaskStopAll:"Stop all",bgTaskRefresh:"Refresh",bgTaskJustNow:"just now",bgTaskMinutes:"{n} min ago",bgTaskHours:"{n} hr ago",bgTaskDays:"{n} days ago",stopBash:"Stop",stopBashTip:"Stop the running bash command (conversation continues)",supplement:"Queue",supplementTip:"Add to queue: sent only after the whole run finishes (no interruption)",queueSteerTag:"Steer",queueFollowTag:"Queued",queueRemoveTip:"Remove this queued message",sendTip:"Send (Enter)",quickPhrases:"Quick phrases",quickPhrasesDesc:"A row of frequently-used phrase buttons above the input box — click to send (current file attachments are included, the input draft is kept)",quickPhrasesEnabled:"Enable quick phrases",quickPhrasesOffHint:"Off: the phrase buttons above the input box are hidden (saved phrases are kept and can be re-enabled anytime)",quickPhrasesPlaceholder:"Type a frequently-used phrase… (Enter to add)",quickPhrasesAdd:"Add",quickPhrasesEmpty:"No quick phrases yet — add your first one below",quickPhrasesTip:"Click to send: {text}",quickPhrasesMoveUp:"Move up",quickPhrasesMoveDown:"Move down",quickPhrasesDelete:"Delete this phrase",quickPhrasesEdit:"Edit this phrase",quickPhrasesEditPh:"Edit phrase… (Enter to save, Esc to cancel)",quickPhrasesReset:"Reset to defaults",slashCommands:"Commands",slashMenuHint:"↑↓ select · Enter/Tab complete",slashHelpTitle:"pi commands",slashHelpHint:"Type / anytime to open the command list",slashLoading:"Loading commands… (available once connected)",slashBuiltin:"Builtin",slashExtension:"Extension",slashPrompt:"Template",slashSkill:"Skill",slashPlugin:"Plugin",slashCopied:"Copied the last assistant reply",slashCopyFailed:"Copy failed — please copy manually",slashCopyEmpty:"No assistant reply to copy yet",recentProjects:"Recent projects",runningConversations:"Running chats",subagentBadge:"Subagent",convErrorBadge:"Subagent failed: {error}",subagentTitle:"Subagent · {title}",historySessions:"History",openHistory:"History",openFiles:"Files",streaming:"Streaming…",noHistory:"No previous chats",current:"Current",messageCount:"{n} messages",tuiTip:"Chat in the pi terminal (TUI)",deleteProject:"Remove from recent projects",deleteProjectConfirm:"Confirm remove",deleteSession:"Delete this chat transcript permanently",deleteSessionConfirm:"Confirm delete",renameSession:"Rename this chat",renameSessionPlaceholder:"Type a new name…",renameSessionConfirm:"Rename",dismissConversation:"Dismiss from running (keep in history)",dismissConversationConfirm:"Confirm dismiss",collapseSection:"Collapse",expandSection:"Expand",emptyChat:"Empty chat",editReask:"Edit & re-ask",editReaskTip:"Edit this question and re-ask from here (forks a new conversation; the original is kept)",reaskFromHere:"Re-ask from here",editPlaceholder:"Edit the question…",editHint:"⌘/Ctrl+Enter to submit · Esc to cancel",editAttachmentHint:"Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel",expandMsg:"Expand",collapseMsg:"Collapse",toolCalls:"tool calls",bashRuns:"bash runs",images:"images",update:"Update",updateTip:"Check & update pi-web-ui",currentVersion:"Current version",latestVersion:"Latest version",checkingUpdate:"Checking…",checkUpdate:"Check for updates",upToDate:"You're up to date",updateAvailable:"New version v{version} available",updateJustPublished:"v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment",updateNow:"Update in terminal",updateTabTitle:"Update pi-web-ui",updateTerminalHint:"Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).",updatesAllTitle:"Component updates",updatesAllBadge:"{n} updates",updatesAllUpToDate:"All components up to date",kindWebUi:"Web UI",kindPiCore:"Core",kindPackage:"Package",updatesAllRefresh:"Re-check all",updateCheckFailed:"Check failed",updateBtn:"Update",updateAllBtn:"Update all",updatePkgTabTitle:"Update {name}",updateAllTabTitle:"Update all components",computer:"This PC",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",previewFile:"Preview",downloadFile:"Download file",copyName:"Copy name",copyPath:"Copy path",downloadFailed:"Download failed: {error}",fileNotFoundShort:"File not found",pluginMountFailed:"Plugin {name} failed to mount",liveOutputOmitted:`…[{n} chars omitted above]…
154
- `,uploadToFolder:"Upload files to this folder",uploadToCurrentDir:"Upload files to current directory",openAsProject:"Open as project",protocolMismatch:"Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.",selectLinesHint:"Click a line to select; drag or Shift+click for a range",enableWrap:"Enable line wrap",disableWrap:"Disable line wrap",selectedRange:"Selected {n} lines (lines {start}-{end})",fileLines:"{n} lines",selectAll:"Select all",clearSelection:"Clear",addToChat:"Add to chat",addedToChat:"Added",previewTruncated:"⚠ File too large — previewing the first 512KB",previewLinesTruncated:"… too many lines — showing the first {n}",binaryFile:"🔣 Binary file — first 4KB shown as hex",binaryHexTruncated:" (file larger — download for the full file)",previewNotSupported:"This file type can't be previewed (only images / videos / text)",emptyFile:"(empty file)",editFile:"Edit file",exitEditFile:"Exit editing",saveFile:"Save file",discardFileChanges:"Discard unsaved changes?",fileSaved:"Saved",fileEditTruncated:"The preview is incomplete, so this file can't be edited",showMarkdownSource:"Show Markdown source",showMarkdownPreview:"Show Markdown preview",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",zoomIn:"Increase font size",zoomOut:"Decrease font size",resetZoom:"Reset zoom",pluginRequest:"Plugin request",modelQuestion:"Model question",modelQuestionCustom:"Custom answer (optional)",modelQuestionSubmit:"Submit answer",next:"Next",previous:"Previous",questionStep:"Q {cur} / {total}",optionPreview:"Option preview",questionTimeout:"⏳ {s}s left — auto-cancels on timeout",questionTimeoutExpired:"Question timed out, resuming conversation…",modelNoVision:"Current model {name} doesn't support images — switch to DeepSeek V4 Flash Vision (exp)",dshSkillsNote:"DSH uses runtime-built-in skills (dsh-skill); toggling is not supported in settings yet",dshExtensionsNote:"DSH has no pi extension system; capabilities are runtime-built-in (MCP/subagent/goal/plan/skill…)",dshReviewPromptNote:"DSH has no separate reviewer: this text is appended to the system prompt for goal rounds",dshVisionHiddenNote:"DSH supports real image input (DeepSeek V4 Flash Vision (exp) only) — no vision bridge needed",dshNoReviewModel:"DSH has no separate reviewer model — the model self-certifies goal completion; max rounds = auto-iteration count",noOptions:"(no options)",inputPlaceholder:"Enter content",soundHeader:"Sound notifications",enableSound:"Enable sound",preview:"Preview",volume:"Volume",notifyHeader:"Desktop notifications",notifyEnable:"Enable desktop notifications",notifyEnableDesc:"Ping you when a session finishes or needs your input, even while you're in another app. Requires permission; only fires when this page is not focused.",notifyDenied:"Notification permission was blocked — enable notifications for this site in your browser / system settings.",notifyUnsupported:"Notifications are not supported by this browser.",notifyDoneTitle:"Task finished",notifyDoneBody:"The session finished and is ready for your input.",notifyQuestionTitle:"Needs your input",notifyQuestionBody:"pi is waiting for your answer to a question.",notifyErrorTitle:"Something went wrong",notifyErrorBody:"A session reported an error.","sound.question":"Question popup","sound.question.desc":"When ask_user_question appears","sound.done":"Reply finished","sound.done.desc":"When the agent finishes a turn","sound.start":"Reply started","sound.start.desc":"When the agent starts a new turn","sound.error":"Error","sound.error.desc":"When an error notice appears",setupTitle:"pi agent config not detected",setupDesc:"pi-web-ui needs pi's config directory (~/.pi/agent) and at least one API key to run the agent. pi has built-in providers such as openai, anthropic, and deepseek — just pick one and enter a key, no terminal needed.",installFailed:"✖ pi agent installation failed:",retryInstall:"Retry install",skip:"Skip",installDone:"✅ pi agent CLI installed. Pick a provider and enter an API key to start chatting:",cliReadyHint:"✅ pi agent CLI already installed locally. Pick a provider and enter an API key to start chatting:",provider:"Provider",configured:"configured",providerKeyReady:"This provider already has a key — use it or replace it.",apiKey:"API key",saving:"Saving…",saveAndStart:"Save and start using",recheck:"Recheck",installing:"Installing pi agent CLI…",autoInstall:"Auto-install pi agent",attachment:"Attachment",plugin:"plugin",unknown:"unknown",thinkingWait:"Thinking",exitCode:"Exit code {code}",cancelled:"Cancelled",truncated:"… content too long, truncated in this view",outputTruncated:"… output too long, truncated in this view",refOnlyShort:"Reference only",folderRefShort:"Folder · reference only",inlineLines:"Inline · {n} lines",inlineLinesRange:"Lines {start}-{end}",image:"🖼 Image",bridgedVision:"👁 Transcribed",bridgedVisionDetail:"Image transcribed by the vision bridge (current model can't see images)",folderNotExpanded:"Folder — content not expanded, the agent will browse it as needed",fileNotExpanded:"Large file ({size}) — content not expanded, the agent will read it as needed","role.user":"You","role.assistant":"pi","role.tool":"Tool","role.bash":"Terminal","role.branch":"Branch summary","role.compaction":"Context compacted",directory:"Directory",waitingResponse:"Waiting for model response…",retryingApi:"Model API error, auto-retrying ({attempt}/{max}): {error}",retryingApiSoon:"Model API error, auto-retrying: {error}",modelRetryAttempts:"Auto-retry attempts on model errors",modelRetryHint:"How many times a failed model API call is retried automatically. When the budget runs out the turn stops with a red error and you can retry manually; 0 stops at the first failure. Applies immediately, no reload needed.",retryNow:"Retry",retryLastTip:"Manually retry the last failed model request",compactingContext:"Compacting context, generating summary…",compactingReasonManual:"Triggered manually",compactingReasonThreshold:"Auto-triggered by context threshold",compactingReasonOverflow:"Auto-triggered by context overflow",compactionFrom:"Compacted from {tokens} tokens",compactionKeptHint:"Earlier history is folded into this summary; only recent messages stay in context",backToBottom:"Back to bottom",questionNavTitle:"Questions",searchPlaceholder:"Search in conversation…",searchNoResults:"No results",searchModels:"Filter models…",noModelMatches:"No matching models",modelUsedCount:"used {n}×",searchGlobal:"Search",searchGlobalTip:"Global search: sessions / projects / files (Ctrl+K)",gsPlaceholder:"Search projects, past conversations, workspace files…",gsHint:"Type to search full conversation text (AI replies included), recent projects and file names in the current workspace at once",gsSessions:"Conversations",gsProjects:"Projects",gsFiles:"Files",gsNoResults:"No matches",gsSearching:"Searching…",gsTruncated:"Too many matches — showing a subset",gsCurrentProject:"current",gsOpenPreview:"Open file preview",gsNavigate:"select",gsOpen:"open",gsCloseHint:"close",bgTaskCommand:"Command",searchPrev:"Previous (Shift+Enter)",searchNext:"Next (Enter)",searchClose:"Close (Esc)",questionNavTip:"All questions in this conversation — hover to expand, click to jump","tpl.title":"Prompt templates","tpl.hint":"Click a card to fill the input; ✏️ to edit or delete; add your own too","tpl.clickCard":"Click to fill the input","tpl.editTpl":"Edit / delete template","tpl.openPicker":"Prompt templates (reusable prompts, anytime)","tpl.pickerTitle":"Prompt templates","tpl.pickerHint":"Click a card to fill the input; ✏️ to edit or delete; add your own too","tpl.add":"New template","tpl.addDesc":"Save a workflow you use often","tpl.reset":"Restore defaults","tpl.resetConfirm":"Restore defaults?","tpl.builtin":"Built-in","tpl.custom":"Custom","tpl.newTitle":"New prompt template","tpl.editTitle":"Edit prompt template","tpl.fieldIcon":"Icon","tpl.fieldTitle":"Title","tpl.fieldTitlePh":"Short title shown on the card","tpl.fieldDesc":"Description","tpl.fieldDescPh":"One-liner shown on the card","tpl.fieldPrompt":"Prompt","tpl.fieldPromptPh":"The full prompt sent to the agent","tpl.required":"Title and prompt are required","tpl.save":"Save","tpl.fill":"Fill input","tpl.fillTip":"Fill the input so you can tweak it before sending","tpl.sendNow":"Send now","tpl.sendTip":"Send immediately as a new conversation","tpl.delete":"Delete","tpl.deleteTip":"Delete this custom template","tpl.remove":"Remove from library","tpl.removeTip":"Remove this built-in template; restore later via “Restore defaults”","tpl.restore":"Restore default","tpl.restoreTip":"Discard your edits and restore the built-in default","tpl.sk.setup":"Repo setup","tpl.sk.setup.desc":"Give the repo a baseline that other workflows can use","tpl.sk.setup.prompt":`Scan this repository and build the baseline context other workflows rely on, then report concisely:
155
-
156
- 1. Project type, tech stack and directory layout
157
- 2. Concrete commands for build / test / run / format
158
- 3. Code conventions and naming rules
159
- 4. Where tasks / issues live and their format
160
- 5. Known pitfalls or leftover issues
161
-
162
- Report only — do not modify any files.`,"tpl.sk.ask":"Skill navigator","tpl.sk.ask.desc":"Tell me which workflow to use","tpl.sk.ask.prompt":"I'll describe the situation I'm in; you decide the best workflow (clarify requirements / plan & execute / TDD / debugging / architecture / review / handoff, etc.), explain why you recommend it and how you'd run it, then execute it after I confirm.","tpl.sk.grilldocs":"Grill & record","tpl.sk.grilldocs.desc":"Interview the plan and record decisions","tpl.sk.grilldocs.prompt":"Before starting, grill me about this plan (one question at a time) until we reach shared understanding. Record key terms and settled decisions as you go (e.g. into CONTEXT.md or an ADR file) so all later work shares one vocabulary. Give your recommended answer with each question.","tpl.sk.tospec":"To spec","tpl.sk.tospec.desc":"Turn the agreed discussion into a written spec","tpl.sk.tospec.prompt":`Turn the consensus we reached into a structured specification:
163
-
164
- 1. Background and goals
165
- 2. Explicit goals and non-goals
166
- 3. Users and usage scenarios
167
- 4. Edge cases and failure modes
168
- 5. Acceptance criteria (what counts as done)
169
- 6. Interface / data-shape overview
170
-
171
- Output the spec for my review first, then continue only after I confirm.`,"tpl.sk.totickets":"To tickets","tpl.sk.totickets.desc":"Split the spec into small buildable tickets","tpl.sk.totickets.prompt":`Split this spec into a set of small tickets an agent can build one by one:
172
-
173
- 1. Each ticket small enough to be independently accepted
174
- 2. Annotate dependency order (what must come first)
175
- 3. Each ticket has: what to do, acceptance criteria, files involved
176
- 4. Flag which tickets can run in parallel
177
-
178
- Output the ticket list; I'll confirm the order before you execute.`,"tpl.sk.implement":"Implement spec","tpl.sk.implement.desc":"Build the finished spec, test-first","tpl.sk.implement.prompt":`Implement per this spec, test-first:
179
-
180
- 1. Write failing tests for each ticket first (happy path, edges, error branches)
181
- 2. Make them pass with the minimal implementation
182
- 3. Refactor while keeping tests green
183
- 4. Proceed ticket by ticket, reporting briefly after each
184
-
185
- Finally check every acceptance criterion explicitly.`,"tpl.sk.codeview":"Code review","tpl.sk.codeview.desc":"Review the diff against the spec and your standards","tpl.sk.codeview.prompt":`Review the recently changed diff:
186
-
187
- 1. Against the spec: is the implementation complete and faithful?
188
- 2. Correctness: edges, nulls, concurrency and timing
189
- 3. Security: input validation, injection, sensitive data
190
- 4. Performance & readability: does it follow project conventions?
191
- 5. Tests: are critical paths covered?
192
-
193
- List issues by severity, each with a concrete suggestion.`,"tpl.sk.wayfinder":"Wayfinder","tpl.sk.wayfinder.desc":"Chart a large effort as a map of decisions","tpl.sk.wayfinder.prompt":`This is a large task. First chart it as a decision map:
194
-
195
- 1. List every decision point and its dependencies
196
- 2. For each decision give options, trade-offs and your recommendation
197
- 3. Mark what can run in parallel vs. what must be sequential
198
- 4. Output a path plan; I'll confirm each item before you start.`,"tpl.sk.prototype":"Prototype","tpl.sk.prototype.desc":"Answer a design question with throwaway code","tpl.sk.prototype.prompt":`Write a minimal prototype to validate the design assumption:
199
-
200
- 1. Validate only the key assumption, not the full implementation
201
- 2. Use the simplest means (hard-coding and skipped edge cases are fine)
202
- 3. Run it and tell me the verdict: does the assumption hold? trade-offs?
203
- 4. The prototype can be deleted, or made production-ready only after I confirm.`,"tpl.sk.research":"Research","tpl.sk.research.desc":"Get a cited answer from primary sources","tpl.sk.research.prompt":`Research this question, preferring primary sources (official docs / source / specs):
204
-
205
- 1. Give an answer with source links
206
- 2. Distinguish facts, reasonable inference, and what's still uncertain
207
- 3. List the main options and their trade-offs
208
- 4. Don't stitch together secondary content; say so if you can't find it.`,"tpl.sk.arch":"Architecture review","tpl.sk.arch.desc":"Find the modules worth refactoring (report)","tpl.sk.arch.prompt":`Do an architecture review of the whole codebase:
209
-
210
- 1. Find signs of broken deep modules: oversized functions/classes, duplication, poor naming, hidden coupling
211
- 2. Prioritize improvements by severity and blast radius; produce a visual report
212
- 3. For each item give the minimal viable refactor with rationale
213
- 4. Report before changing anything; confirm scope before refactoring.`,"tpl.sk.debug":"Diagnose bugs","tpl.sk.debug.desc":"Diagnose from a repro that fails","tpl.sk.debug.prompt":`Diagnose this bug systematically:
214
-
215
- 1. Reproduce it first (build a minimal repro if none exists)
216
- 2. Narrow to a specific module via bisection or elimination
217
- 3. Form hypotheses and verify with logs / assertions / a minimal sample — no guessing
218
- 4. Once the root cause is found, explain it, then make the minimal fix
219
- 5. Add a regression test to prevent recurrence.`,"tpl.sk.merge":"Resolve merge conflicts","tpl.sk.merge.desc":"Finish a merge or rebase conflict hunk by hunk","tpl.sk.merge.prompt":`Help me resolve this merge / rebase conflict:
220
-
221
- 1. Handle each conflict hunk, reading both sides' intent first
222
- 2. Choose or merge to keep correct semantics — don't blindly pick one side
223
- 3. Run tests and build afterwards to confirm
224
- 4. Finally summarize the rationale for each resolution.`,"tpl.sk.triage":"Triage","tpl.sk.triage.desc":"Sort raw issues into work someone can pick up","tpl.sk.triage.prompt":`Turn these raw issues / feedback into actionable work items:
225
-
226
- 1. Deduplicate and merge related entries
227
- 2. Categorize (bug / feature / improvement / question)
228
- 3. Prioritize by impact and urgency
229
- 4. For each item add: repro info or expectation, acceptance criteria
230
-
231
- Output the cleaned list.`,"tpl.sk.wizard":"Setup wizard","tpl.sk.wizard.desc":"Generate a script that walks a human through setup","tpl.sk.wizard.prompt":`Create a guided wizard (script or doc) for a manual setup flow:
232
-
233
- 1. Guide step by step, explaining why at each step
234
- 2. Validate each step; on wrong input give actionable hints
235
- 3. Support undo / going back a step
236
- 4. End with a self-check and how to verify.`,"tpl.sk.grillme":"Grill me","tpl.sk.grillme.desc":"Align on an idea before committing","tpl.sk.grillme.prompt":`Before starting, interview me relentlessly about every aspect of this idea until we reach shared understanding (one question at a time, each with your recommended answer):
237
-
238
- 1. Goals and non-goals
239
- 2. Users and scenarios
240
- 3. Edge cases and failure modes
241
- 4. Constraints and dependencies
242
- 5. Acceptance criteria
243
-
244
- Then give an implementation plan and wait for my confirmation before writing code.`,"tpl.sk.handoff":"Handoff","tpl.sk.handoff.desc":"Write up a long session so another agent can continue","tpl.sk.handoff.prompt":`Turn this session into a handoff doc so another agent / teammate can continue seamlessly:
245
-
246
- 1. Background and goals
247
- 2. Work done and key decisions (with reasons)
248
- 3. Outstanding items and next steps
249
- 4. Known risks and open questions
250
- 5. How to verify current state (commands, etc.)
251
-
252
- Output as a structured document.`,"tpl.sk.questionnaire":"To questionnaire","tpl.sk.questionnaire.desc":"Turn open questions into a doc someone fills in","tpl.sk.questionnaire.prompt":`Turn the info you need from someone into a fillable questionnaire:
253
-
254
- 1. Explain the background and purpose of each question
255
- 2. Mark required / optional
256
- 3. Give example answers to lower friction
257
- 4. Group and order: easy first, hard later
258
-
259
- Output a doc they can fill in directly.`,"tpl.sk.teach":"Teach","tpl.sk.teach.desc":"Learn a topic across sessions that build on each other","tpl.sk.teach.prompt":`Teach me this topic incrementally:
260
-
261
- 1. First set a learning path and goal
262
- 2. Teach one small section at a time, then a quick exercise
263
- 3. Build on the previous section and ask questions to confirm understanding
264
- 4. Summarize key points at the end of each section
265
-
266
- Works well across multiple sessions.`,"tpl.sk.ww":"Wait, what?","tpl.sk.ww.desc":"Say the last explanation again in plain English","tpl.sk.ww.prompt":`Re-explain what you just said in the simplest terms:
267
-
268
- 1. Avoid jargon; define any term you must use in one sentence
269
- 2. Use an analogy or concrete example
270
- 3. Be clear about what is still guesswork / uncertain
271
- 4. Keep the core point as short as possible.`,"tpl.sk.wfa":"Writing for agents","tpl.sk.wfa.desc":"Write docs that follow agent-friendly principles","tpl.sk.wfa.prompt":`Write this doc / explanation following “written for agents to read” principles:
272
-
273
- 1. Put the goal and usage up front
274
- 2. Make instructions concrete and verifiable — no vagueness
275
- 3. Give positive and negative examples
276
- 4. Structure with headings, steps and checklists
277
- 5. Mark what's required vs. optional.`,"tpl.sk.codesign":"Deep-module design","tpl.sk.codesign.desc":"Review & design with deep-module principles","tpl.sk.codesign.prompt":`Review / design using the “deep module” principle:
278
-
279
- 1. Check whether each module's public interface is simpler than its implementation
280
- 2. Find modules that leak complexity outward
281
- 3. Give responsibility boundaries and improvement plans
282
- 4. Balance cohesion and reuse without over-abstracting
283
-
284
- Output the review conclusions and refactor suggestions.`,"tpl.sk.domain":"Domain modeling","tpl.sk.domain.desc":"Sharpen the words a project uses and write them down","tpl.sk.domain.prompt":`Help me clean up this project's domain language:
285
-
286
- 1. Find the core terms and their current spellings
287
- 2. Spot confusion from same-word-different-meaning / different-word-same-meaning
288
- 3. Recommend one canonical term each, into a glossary
289
- 4. State each term's boundary (what it is not)
290
-
291
- Output a domain glossary.`,"tpl.sk.grilling":"Grilling","tpl.sk.grilling.desc":"Stress-test a plan with an interview","tpl.sk.grilling.prompt":`Stress-test this plan with an interview:
292
-
293
- 1. Check each assumption: what if it's wrong?
294
- 2. Hunt for holes: edges, failure modes, dependencies, timing
295
- 3. Challenge decisions: why this way? is there a simpler path?
296
- 4. Ask one sharp question at a time and wait for my answer
297
-
298
- Keep going until the plan holds up.`,"tpl.sk.tdd":"Test-driven","tpl.sk.tdd.desc":"The rules of the red-green-refactor loop","tpl.sk.tdd.prompt":`Implement using TDD (red-green-refactor):
299
-
300
- 1. First write failing tests covering the happy path, edge cases and error branches
301
- 2. Make them pass with the minimal implementation
302
- 3. Refactor while keeping tests green
303
-
304
- Avoid three test anti-patterns: tests coupled to the implementation, tautological assertions (always true), and horizontal slicing (surface only). Report after each step and run the tests.`,error:"Error",done:"Done",running:"Running…",toolQueued:"Queued",copyArgs:"Copy args",copyMessage:"Copy message",copied:"Copied",errorOutput:"Error output",output:"Output",waitingOutput:"Waiting for output…",toolDoneWaitingModel:"Done · waiting on model",waitingModel:"Waiting for model response…",thinkingNow:"Thinking",thinkingPreview:"Thinking: {preview}",commands:"Commands",newCommand:"New command",newTerminal:"New terminal",name:"Name",command:"Command",cwdHint:"(${pwd} = current working directory)",noCommands:"No commands yet — click + to add one",clickToRun:"Click to run",edit:"Edit",delete:"Delete",confirmQ:"Confirm?",builtinTerminal:"Built-in terminal",termEmptySub:"Click a command on the left to run it, or + on the right for a new terminal",noTerminal:"No terminals",exited:"(exited{code})",exitBanner:"[Process exited with code {code}]",closeTerminal:"Close terminal",renameTerminal:"Rename terminal",rerun:"Reload .pi/commands.json",terminalTitle:"Terminal {n}",aiBashGroup:"Terminal-backed bash",exampleName:"e.g. start dev server",exampleCommand:"e.g. npm run dev",scmTab:"Git",scmTitle:"Source Control",scmRefreshTip:"Re-query git status & diff",scmCurrentBranch:"Current branch",scmUpstreamGone:"Upstream deleted",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"Detached HEAD",scmSelectBranch:"Select branch…",scmRemoteBranches:"Remote branches",scmStageTip:"Stage {path}",scmUnstageTip:"Unstage {path}",scmSwitch:"Switch",scmSwitchBranch:"Switch branch",scmSwitchBranchTip:"Runs git checkout {branch} in the terminal",scmPush:"Push",scmPushTip:"Runs git push in the terminal",scmPull:"Pull",scmPullTip:"Runs git pull in the terminal",scmCommit:"Commit",scmCommitTip:'Runs git commit -m "…" in the terminal (commits staged changes only)',scmCommitAll:"Commit All",scmCommitAllTip:'Runs git add -A && git commit -m "…" in the terminal (stages all changes incl. untracked and commits)',scmCommitPlaceholder:"Type a commit message…",scmChanges:"Changes",scmHistory:"Commit tree",scmCommitDetail:"Commit details",scmSelectCommitHint:"Click a commit on the left to view its details",scmNoHistory:"No commits yet",scmNoChanges:"Working tree clean — no changes",scmNotGitRepo:"Current directory is not a Git repository",scmLoading:"Querying…",scmConnecting:"Waiting for connection…",scmDiff:"Diff",scmSelectFileHint:"Click a file on the left to view its diff",scmNoDiff:"(no diff)",scmStaged:"Staged",scmUnstaged:"Unstaged",scmStagedUnstaged:"Staged + unstaged",scmUntracked:"Untracked",scmUntrackedNote:"Untracked file — stage it with + to include (or use Commit All)",scmQueryFailed:"Git query failed: {error}",scmQueryFailedShort:"Query failed",pluginCommandFallback:"Plugin command",scmTooManyFailures:"Git queries keep failing — click refresh to retry",scmRunsInTerminal:"Commit / branch switch / push / pull run in the terminal",scmViewTerminal:"Open terminal",editProvider:"Edit provider",builtinProviders:"Built-in providers",hintKeyOnly:"Just enter an API key",configuredBadge:"✓ Configured",keyReady:"Key ready",replaceKey:"Replace key",replaceKeyTitle:"Replace the saved key",clearKey:"Clear",clearKeyTitle:"Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)",clearKeyConfirm:"Clear the stored key for {id}? Its models will leave the list until you configure it again.",cloneProvider:"Add key",cloning:"Adding",cloneProviderTitle:"Add a second API key for this provider (baseUrl and model list are copied automatically)",pasteKey:"Paste API key…",savingKey:"Saving",saveKey:"Save key",addKey:"Add key",addKeyPlaceholder:"Paste the key value…",keyNamePh:"Name (optional, e.g. backup)",providerIdPlaceholder:"Provider ID",baseUrlExamplePh:"baseUrl, e.g. https://api.opencode.ai/zen/v1 or http://127.0.0.1:4096",saveAllBatch:"Save all ({n})",netDisconnected:"Network disconnected — reconnect and retry",advancedEdit:"Advanced edit",batchCreateProviders:"Batch-create providers ({n} APIs)",secondKeyTitle:"Add a second key for {api} · {baseUrl} · {n} models — just name the new provider and enter the key.",noBaseUrlShort:"(no baseUrl)",providerNameLabel:"Provider name",providerNameHint:"(new ID, e.g. opencode-2)",apiKeyLabel:"API key",secondKeyPlaceholder:"sk-… second key",batchDesc:"This provider has multiple APIs ({apis}); it was split into {n} custom providers. Save each so all models (e.g. muse-spark) work. Enter one shared second key to save all at once.",batchKeyLabel:"Shared API key (applies to all {n} providers)",modelsCountShort:"{n} models: ",noKeyYet:"No key yet — add one to use this provider",activateKey:"Set active",removeKey:"Remove",removeKeyConfirm:"Remove this key? It must be re-configured to be used again.",customProviders:"Custom providers",customDesc:"For Ollama / vLLM / OpenAI-compatible proxies, etc. Written to pi's models.json — hot-reloaded immediately.",noCustomProviders:"No custom providers yet",modelsCount:"{n} models",addProvider:"Add provider",providerId:"Provider ID",providerIdHint:"(required, e.g. ollama / my-proxy)",displayName:"Display name",displayNamePh:"My proxy",apiType:"API type",baseUrlHint:"(OpenAI-compatible endpoint)",apiKeyHint:"sk-… (optional — uses the auth.json key)",authHeader:"Auto-add Authorization header",modelsTitle:"Models",modelIdReq:"Model ID (required)",text:"Text",textImage:"Text+image",contextWindow:"Context",maxOutput:"Max output",removeModel:"Remove model",addModel:"Add model",deleteProviderConfirm:"Delete provider {id} and its {n} models?",fetchModels:"Fetch model list",fetchModelsHint:"Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)",fetchingModels:"Fetching…",fetchModelsOk:"Fetched {n} models",fetchModelsEmpty:"The endpoint returned no models",fetchModelsErr:"Fetch failed: {msg}",fetchModelsNeedBaseUrl:"Enter a baseUrl first",goalBarTitle:"Goal",goalBarPlaceholder:"Set a goal; the agent's output is auto-reviewed…",goalBarSet:"Start",goalBarClear:"Cancel",goalBarLocked:"Locked: applies to every later turn",goalBarUnlocked:"This turn only (cleared afterwards)",goalBarReviewModel:"Review model",goalBarUseMainModel:"Use the main model",goalBarMaxRounds:"Max rounds",goalBarMaxRoundsTip:"Max review-revision rounds; 0 or empty = unlimited (keep revising until it passes)",goalBarUnlimitedShort:"Unlimited",goalBarReviewing:"Reviewing…",goalBarRound:"Round {n}",goalBarActive:"Goal active",goalBarPassed:"Passed",goalBarFailed:"Failed",goalBarStatusPending:"Waiting to generate…",goalWizardBtn:"AI Scrape",goalWizardTip:"Let AI refine the requirement into a goal via a Q&A survey",goalWizardRunning:"Scoping the goal",goalWizardAnswer:"Answer",goalWizardCard:"Goal survey",settings:"Settings",settingsTitle:"Settings",settingsDesc:"Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).",settingsSystemPrompt:"System prompt",settingsPromptHistory:"Input history",settingsPromptHistoryDesc:"Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)",promptHistoryMax:"Max entries",promptHistoryMaxHint:"Oldest entries are dropped when exceeded (1–500)",promptHistoryCharLimit:"Limit characters per entry",promptHistoryCharLimitHint:"When enabled, overlong prompts are truncated before saving",promptHistoryCharLimitPlaceholder:"Max chars (100–20000)",promptHistoryClear:"Clear history",promptHistoryClearConfirm:"Confirm clear?",promptHistoryCleared:"Input history cleared",promptHistoryCount:"{n} entries",promptHistoryEmpty:"No history yet — ↑/↓ has nothing to cycle",settingsPromptMode:"Mode",promptModeAppend:"Append",promptModeReplace:"Replace",promptAppendHint:"Append mode: your text is appended to the end of the default system prompt (recommended — keeps the default behavior constraints).",promptReplaceHint:`Replace mode: only the built-in template's persona (soul) paragraph is replaced (e.g. "You are an expert coding assistant…"). The tools list, guidelines, docs pointers, project context and skills are auto-assembled on every run and are never replaced. After switching, the editor shows the built-in soul paragraph; leaving it empty keeps the built-in default.`,promptPlaceholder:"Type a custom system prompt… (applied on blur)",promptComposeHint:"Each {{token}} in the template expands to that source's prompt on every run; non-overridden sources use auto content (tools list / project context / skills are always regenerated from the latest data).",promptComposeDesc:"Compose: reorder / drop / annotate {{token}} blocks freely; empty = the default template. Each source below can be overridden individually (leave empty = auto content) and reset back to default.",promptTemplateLabel:"Compose template",promptSourcesLabel:"Sources (override individually)",promptInsertTokens:"Insert block: ",promptResetAll:"Restore default template and clear all overrides",promptResetSource:"Restore default",promptAutoBadge:"auto",promptOverridePlaceholder:"Override text (leave empty = auto content)…",promptSourceDefaultEmpty:"(no auto content for this source right now)",promptReadonlyBadge:"System-generated (read-only)",promptReadonlyLockedBadge:"Custom override (read-only/locked)",promptReadonlyLockedHint:"This source is system-generated and read-only; the override won't be edited here, but the server still applies it as-is.",promptReadonlyTitle:"System-generated source — read-only display, not editable",promptSourceDefaultEditHint:"This source's current default (auto) content — click to type an override",promptSourceExpand:"Show more",promptSourceCollapse:"Show less",promptSourceRefLabel:"Default (auto) content — for reference / copying",promptSourceSeedButton:"Load default text to tweak",promptSourceSeedTip:"Copies this source's current default text into the override box so you can tweak just a part. Once filled, this source stays fixed and is no longer auto-regenerated each run.",promptTok_soul:"Soul / persona",promptTok_soul_desc:"the agent persona (built-in default unless a SYSTEM.md exists)",promptTok_tools:"Tools list",promptTok_tools_desc:"Available tools with snippets, regenerated each run",promptTok_guidelines:"Guidelines",promptTok_guidelines_desc:"per-tool guidance + generic rules",promptTok_pi_docs:"Pi docs pointer",promptTok_pi_docs_desc:"the block pointing at the pi package docs",promptTok_append:"Append block",promptTok_append_desc:"APPEND_SYSTEM.md content; override = custom appended text",promptTok_persona:"Windows persona",promptTok_persona_desc:"win32-only safety rules (timeout / PTY / GBK)",promptTok_terminal:"Terminal guidance",promptTok_terminal_desc:"persistent-terminal usage guide (injected when terminal tools are on)",promptTok_markers:"Markers guidance",promptTok_markers_desc:"built-in marker tools usage (injected when markers are on)",promptTok_context:"Project context",promptTok_context_desc:"<project_context>: AGENTS.md / CLAUDE.md collection",promptTok_skills:"Skills",promptTok_skills_desc:"<available_skills> list of usable skills",promptTok_cwd:"Working dir line",promptTok_cwd_desc:"the Current working directory line",settingsViewPrompt:"View the current full prompt",settingsViewPromptHint:"The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.",settingsViewPromptEmpty:"Session not ready yet — no system prompt available.",settingsViewToolsSchema:"Tools schema",settingsViewToolsSchemaHint:"The function-calling tool definitions sent to the model (name / description / parameters), combining with the system prompt text to form the full initial context. Read-only.",settingsViewToolsSchemaEmpty:"Session not ready yet — no tools schema available.",settingsSkills:"Skills",settingsReview:"Goal review",settingsReviewDesc:"Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.",settingsReviewSkills:"Skills available to review",reviewPromptPlaceholder:"Type custom review instructions… (applied on blur)",reviewPromptHint:"These instructions are added to the review task; pass/fail JSON output is still enforced. Skill toggles apply only to review.",goalModeEnabled:"Enable goal mode",goalModeEnabledDesc:"Master switch for the goal bar, the goal wizard and the review loop (on by default). When off, the goal bar is hidden and you cannot set a goal, run the wizard, or trigger reviews.",goalModeOffHint:"Goal mode is off: the goal bar is hidden and existing goals no longer trigger reviews.",settingsVisionBridge:"Vision bridge",settingsVisionBridgeDesc:"When the current model can't see images, send them to a configured vision model and transcribe into text evidence first",visionBridgeEnabled:"Enable vision bridge",visionBridgeModel:"Transcription model",visionBridgeAuto:"Auto (in order)",visionBridgeNoModels:"No configured vision model found: add any image-capable model (e.g. qwen-vl, GLM-4V, Gemini) in Model config to enable automatically",visionBridgeOffHint:"Disabled: images are sent as-is, a text-only model may not see them",visionBridgeCurrent:"Current transcription model: {model}",visionBridgePromptMode:"Transcription prompt",settingsMarkers:"Markers",settingsMarkersDesc:"Let the AI write [[todo:...]] / [[notify:...]] / [[conv:rename:...]] inline markers in replies to update state without a tool round-trip. Global off disables all; per-marker toggles give fine control.",markersEnabled:"Markers enabled (global)",markersEnabledDesc:"Off = no marker guidance injected and no parsing; markers stay as plain text.",markersOffHint:"Globally off: all markers disabled — the AI won't write markers and no side effects fire.",markerGroupTodo:"todo — tasks",markerGroupNotify:"notify — non-blocking hints",markerGroupRename:"conv/rename — rename chat",markerRenameTip:"[[conv:rename:Title]] renames the current conversation (≤80 chars; rename at the end of the first reply)",settingsTerminalTools:"Terminal tools",terminalToolsEnabled:"Enable persistent terminal tools",settingsTerminalToolsDesc:"Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool",terminalToolsOffHint:"Disabled: the AI has no terminal_* tools and receives no usage guidance",settingsEditTools:"Edit tools",editSoftEnabled:"Enable edit_soft tool",editSoftEnabledDesc:"Let the AI use a separate indentation-insensitive edit tool: avoids edit failures when your oldText spacing differs from the file (e.g. JS/JSON). On a match, newText is written verbatim as you provide it (its indentation is final).",editSoftOffHint:"Disabled: the AI has no edit_soft tool and receives no usage guidance",settingsQuestionnaire:"Questionnaire",questionnaireEnabled:"Allow the model to ask me questions",questionnaireEnabledDesc:"On by default: the model may use ask_user_question to pop up an answerable question dialog (options, multi-select, custom input). Off: the model no longer pops up questionnaires; a call also returns disabled immediately.",questionnaireOffHint:"Disabled: the model can no longer pop up question dialogs",settingsMessageDisplay:"Conversation",thinkingWrap:"Show full thinking",thinkingWrapDesc:"On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming",toolsWrap:"Show full tools",toolsWrapDesc:"On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand",wideChat:"Wide chat column",wideChatDesc:"On: the center column fills the width (useful on ultrawide monitors); Off: keep the 860px cap",projectTitle:"Show project name in title",projectTitleDesc:"On: the browser tab title becomes “<project folder> — pi-web-ui” and updates when you switch projects (handy with several tabs open); Off: always show the app name",terminalBashTakeover:"Terminal-backed bash",terminalBashTakeoverDesc:"This switch decides whether bash is overridden to a terminal version: OFF = native SDK bash (process spawn, no terminal); ON = runs in a visible terminal, where the persist parameter decides (on top of the switch) one-shot (false — process exits when the command finishes, output retained) vs persistent (true — shell state retained across calls, silent commands move to the background and notify the AI)",terminalBashIdleMs:"Silence-to-background threshold (ms)",terminalBashIdleMsDesc:"In persistent-terminal mode, when a command produces no output for this long, stop blocking and let it keep running in the background; the AI is notified when it finishes. 0 = always wait until completion (default 15000)",visionBridgePromptPlaceholder:"Type a custom transcription prompt… (empty = built-in default, applied on blur)",visionBridgePromptAppendHint:"Append mode: custom text is appended after the built-in transcription prompt (recommended — keeps the verbatim-transcription contract).",visionBridgePromptReplaceHint:"Replace mode: custom text replaces the built-in transcription prompt entirely. After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",uninstallExt:"Uninstall",uninstallConfirm:"Confirm?",uninstallConfirmHint:"Click again to confirm — runs pi remove in the terminal",uninstallHint:"Runs pi remove in a visible terminal, then refreshes the list automatically",uninstallTitle:"Uninstall",pluginUpdate:"Update",pluginUpdateHint:"Re-installs from the recorded source (--force, keeps config.json), then refreshes the plugin list automatically",pluginMarket:"Plugin marketplace",updatesManaged:"Managed instance: updates and plugin installs are handled by whoever deploys it",pluginCatalogAdd:"Add plugin",pluginCatalogAddHint:"Drop a third-party plugin into the installable list (owner/repo or full GitHub URL)",pluginCatalogSource:"Source owner/repo or owner/repo/subdir (required)",pluginCatalogId:"id (optional, defaults to repo/subdir name)",pluginCatalogName:"Name (optional)",pluginCatalogIcon:"Icon emoji (optional)",pluginCatalogDesc:"Description (optional)",pluginCatalogAddSubmit:"Add to list",noPluginCatalog:'List is empty — click "Add plugin" to drop a third-party plugin in',pluginInstalled:"Installed",pluginCatalogCustom:"custom",pluginInstall:"Install",pluginInstallHint:"Install straight from the source into UI plugins (runs in a visible terminal)",pluginCatalogRemoveHint:"Remove this custom plugin from the list",pluginUninstallHint:"Runs pi-web-ui uninstall in a visible terminal (click again to confirm), then refreshes the list automatically",settingsExtensions:"Extensions",settingsUiPlugins:"UI plugins",noUiPlugins:"No UI plugins installed (<dataDir>/plugins/)",dshPatches:"DSH user patches",dshPatchesDesc:"Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.",dshPatchesRescan:"Rescan",dshPatchesRescanHint:"Re-scan the patch directory and restart the DSH runtime so new patches take effect",dshPatchesEmpty:"No patch files yet",dshPatchesPath:"Patch directory: ",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",settingsPresets:"Presets",settingsSubagentTemplates:"Subagent templates",settingsSubagentTemplatesDesc:"Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.",noSubagentTemplates:"No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model), or spawn without a template param for default config.",subagentTemplateNew:"New template",subagentTemplateEdit:"Edit",subagentTemplateClosed:"Disabled",tplDefaultBadge:"Built-in",subagentDefaultModelLabel:"Default subagent model",subagentFollowMain:"Follow the main conversation's current model",subagentDefaultModelHint:"Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.",subagentNoModels:"No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.",subagentTemplateOffHint:"Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them",subagentTemplateEnable:"Enable",subagentTemplateDisable:"Disable",tplNamePlaceholder:"Template name (referenced by AI via subagent_spawn's template param)…",tplDescriptionPlaceholder:"Description (AI uses it to judge when to pick this template)…",tplDescriptionEnPlaceholder:"English description (shown to AI under English UI; falls back to the description above)…",tplPromptModeLabel:"System prompt mode",tplModelLabel:"Model (empty = follow main conversation)",tplSystemPromptLabel:"System prompt",tplSystemPromptPlaceholder:"Template role system prompt… (may be empty in append mode)",tplSystemPromptEnPlaceholder:"English system prompt… (used under English UI; falls back to the prompt above)",tplWhitelistHint:"Whitelist: checked = the subagent only gets these; none checked = follow the main session settings",tplSkillsLabel:"Skills whitelist",tplExtensionsLabel:"Extensions whitelist",tplSave:"Save template",tplCancel:"Cancel edit",tplDelete:"Delete template",tplInherit:"Follow main session",settingsEnabled:"Enabled",settingsDisabled:"Disabled",presetNamePlaceholder:"Preset name…",saveAsPreset:"Save as preset",applyPreset:"Apply",deletePreset:"Delete preset",noSkills:"No skills",noExtensions:"No extensions",noPresets:"No presets yet (tune the settings above, then save them as a preset)",loadingSession:"Loading session…",connectingServer:"Connecting to pi-web-ui server…",localePacks:"Language packs",localeGetMore:"Get more languages",localeInstalled:"Installed",localeInstall:"Download",localeRemove:"Remove",localeDownloading:"Downloading…",localeRemoving:"Removing…",localeInstallFailed:"Download failed: {error}",localeListFailed:"Couldn't load language packs: {error}",localeRemoveHint:"You can re-download it anytime",wallpaperTitle:"Chat wallpaper",wallpaperDesc:"Show a full-window background image (side panels, top and bottom bars included): a theme-provided image applies automatically, a URL here takes precedence; use dim and blur to keep text readable.",wallpaperUrlPh:"Image URL (https://…, empty = off)",wallpaperDim:"Dim",wallpaperBlur:"Blur",wallpaperClear:"Clear",wallpaperUpload:"Upload image",wallpaperUploadFailed:"Couldn't read the image (or it's too big) — try another one"},Ol=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],fs={};function Ml(e){return!e||typeof e.code!="string"||!e.code||e.code==="zh"||e.code==="en"||!e.strings||typeof e.strings!="object"?!1:(fs[e.code]=e,!0)}function Bl(e){delete fs[e]}function Fl(e){return e==="zh"?"中文":e.toUpperCase()}function Hl(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function Da(e){const t=await fetch(Dt(it(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const Ji=l.createContext(null);function Zi(){try{return localStorage.getItem(Mn)}catch{return null}}function Ul(){return On(Zi(),typeof navigator<"u"?navigator.languages:[],null)}function ql({children:e}){const[t,n]=l.useState(Ul),[a,o]=l.useState(0),i=l.useRef(t);i.current=t;const c=l.useCallback(b=>{n(b);try{localStorage.setItem(Mn,b)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:b}))}catch{}},[]),d=l.useCallback(async()=>{let b,x=null;try{const N=await Da("/api/locales");b=N.packs??[],x=N.defaultLocale??null}catch{return null}return await Promise.all(b.filter(N=>N.installed).map(async N=>{try{const S=await Da(`/api/locales/${N.code}`);Ml({code:S.code||N.code,nativeName:S.nativeName||N.nativeName,strings:S.strings})}catch{}})),o(N=>N+1),x},[]);l.useEffect(()=>{d().then(b=>{if(!Zi()?.trim()){const N=On(null,typeof navigator<"u"?navigator.languages:[],b);N!==i.current&&(i.current=N,n(N))}const x=i.current;if(x!=="zh"&&x!=="en"&&!fs[x]){const N=On(null,typeof navigator<"u"?navigator.languages:[],b,["zh","en"]);i.current=N,n(N);try{localStorage.setItem(Mn,N)}catch{}}})},[d]);const u=l.useMemo(()=>[...Ol,...Object.values(fs).map(b=>({code:b.code,nativeName:b.nativeName}))],[a]),f=l.useCallback((b,x)=>{let N=fs[t]?.strings[b]??(t==="zh"?Dl[b]:Pl[b]);if(x)for(const[S,M]of Object.entries(x))N=N.replaceAll(`{${S}}`,String(M));return N},[t,a]);l.useEffect(()=>{document.documentElement.lang=Hl(t)},[t]);const g=l.useMemo(()=>({locale:t,setLocale:c,t:f,packs:u,reloadPacks:d}),[t,c,f,u,d]);return s.jsx(Ji.Provider,{value:g,children:e})}function Ot(){const e=l.useContext(Ji);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function Ae(){return Ot().t}const $l=[{kind:"question",labelKey:"sound.question",descKey:"sound.question.desc"},{kind:"done",labelKey:"sound.done",descKey:"sound.done.desc"},{kind:"start",labelKey:"sound.start",descKey:"sound.start.desc"},{kind:"error",labelKey:"sound.error",descKey:"sound.error.desc"}];function Pa({settings:e,onChange:t,onPreview:n}){const a=Ae(),o=i=>t({...e,...i});return s.jsxs("div",{className:"sound-menu",children:[s.jsx("div",{className:"dd-header",children:a("soundHeader")}),s.jsxs("label",{className:"sound-row sound-master",children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Hi,{className:"sound-icon"}),s.jsx("span",{children:a("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:i=>o({enabled:i.target.checked})})]}),$l.map(({kind:i,labelKey:c,descKey:d})=>s.jsxs("label",{className:`sound-row ${e.enabled?"":"disabled"}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx("span",{className:"sound-name",children:a(c)}),s.jsx("span",{className:"sound-desc",children:a(d)})]}),s.jsxs("span",{className:"sound-right",children:[s.jsx("button",{type:"button",className:"sound-preview",title:a("preview"),disabled:!e.enabled,onClick:u=>{u.preventDefault(),n(i)},children:a("preview")}),s.jsx("input",{type:"checkbox",checked:e[i],disabled:!e.enabled,onChange:u=>o({[i]:u.target.checked})})]})]},i)),s.jsxs("div",{className:`sound-volume ${e.enabled?"":"disabled"}`,children:[s.jsx("span",{className:"sound-name",children:a("volume")}),s.jsx("input",{type:"range",min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:i=>o({volume:Number(i.target.value)})}),s.jsxs("span",{className:"sound-vol-num",children:[e.volume,"%"]})]})]})}const er="pi-web-notify",En={enabled:!1};function tr(){try{const e=localStorage.getItem(er);if(!e)return{...En};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:En.enabled}}catch{return{...En}}}function Oa(e){try{localStorage.setItem(er,JSON.stringify(e))}catch{}}function _s(){return typeof window<"u"&&"Notification"in window}function Wl(){return _s()?Notification.permission:"denied"}async function Kl(){if(!_s())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}async function Tn(e,t){if(!_s()||document.hasFocus()||!tr().enabled||Notification.permission!=="granted")return;const n={body:t,icon:it("/icons/icon-192.png"),badge:it("/icons/icon-192.png"),tag:"pi-web-ui"};try{const a=await navigator.serviceWorker?.getRegistration();a&&typeof a.showNotification=="function"?a.showNotification(e,n):new Notification(e,n)}catch{}}function Ma(){const e=Ae(),[t,n]=l.useState(tr),[a,o]=l.useState(()=>_s()?Wl():"denied"),i=async c=>{const d={...t,enabled:c};if(n(d),Oa(d),c){const u=await Kl();if(o(u),u!=="granted"){const f={...d,enabled:!1};n(f),Oa(f)}}};return s.jsxs("div",{className:"sound-menu",style:{borderTop:"1px solid var(--border-color, rgba(255,255,255,.08))",marginTop:6,paddingTop:6},children:[s.jsx("div",{className:"dd-header",children:e("notifyHeader")}),s.jsxs("label",{className:"sound-row sound-master",children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(vl,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>i(c.target.checked)})]}),s.jsx("div",{className:"sound-desc",style:{padding:"2px 8px 4px",opacity:.7,fontSize:"0.82em"},children:e("notifyEnableDesc")}),!_s()&&s.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:e("notifyUnsupported")}),a==="denied"&&s.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:e("notifyDenied")})]})}function Yl({onClose:e}){const t=Ae(),{locale:n,setLocale:a,reloadPacks:o}=Ot(),[i,c]=l.useState(null),[d,u]=l.useState(""),[f,g]=l.useState("");async function b(){try{const S=await fetch(Dt(it("/api/locales")));if(!S.ok)throw new Error(`HTTP ${S.status}`);const M=await S.json();c(M.packs??[]),u("")}catch(S){u(t("localeListFailed",{error:S instanceof Error?S.message:String(S)}))}}l.useEffect(()=>{b()},[]);async function x(S){g(S),u("");try{const M=await fetch(Dt(it(`/api/locales/${S}/install`)),{method:"POST"});if(!M.ok){let G=`HTTP ${M.status}`;try{G=(await M.json()).error??G}catch{}throw new Error(G)}await o(),await b()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{g("")}}async function N(S){g(S),u("");try{const M=await fetch(Dt(it(`/api/locales/${S}`)),{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`);Bl(S),n===S&&a("zh"),await o(),await b()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{g("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx($i,{})," ",t("localePacks")]}),s.jsx("button",{type:"button",className:"btn",title:t("close"),onClick:e,children:s.jsx(Je,{})})]}),d&&s.jsx("div",{className:"bg-task-empty",children:d}),i===null&&!d?s.jsx("div",{className:"bg-task-empty",children:t("loading")}):s.jsx("ul",{className:"bg-task-list",children:(i??[]).map(S=>{const M=f===S.code;return s.jsxs("li",{className:"bg-task-item",children:[s.jsxs("div",{className:"bg-task-info",children:[s.jsxs("div",{className:"bg-task-line1",children:[s.jsx("span",{className:"bg-task-port",children:S.nativeName}),S.installed&&S.version&&s.jsxs("span",{className:"bg-task-name",children:["v",S.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:S.code}),S.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),S.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:M,title:t("localeRemove"),onClick:()=>void N(S.code),children:[s.jsx(et,{}),s.jsx("span",{children:t(M?"localeRemoving":"localeRemove")})]}):s.jsxs("button",{type:"button",className:"btn",disabled:M,title:t("localeInstall"),onClick:()=>void x(S.code),children:[s.jsx(Ht,{}),s.jsx("span",{children:t(M?"localeDownloading":"localeInstall")})]})]},S.code)})}),s.jsx("div",{className:"bg-task-foot",children:s.jsxs("button",{type:"button",className:"btn",title:t("bgTaskRefresh"),onClick:()=>void b(),children:[s.jsx(Lt,{}),s.jsx("span",{children:t("bgTaskRefresh")})]})})]})})}function Gl({chat:e,send:t,terminal:n,view:a,plugins:o,onViewChange:i,onOpenPanel:c,onOpenSettings:d,onOpenBgTasks:u,onOpenGlobalSearch:f,sound:g,onSoundChange:b,onSoundPreview:x,themes:N,theme:S,onThemeChange:M}){const{locale:G,setLocale:K,t:y,packs:R}=Ot(),[U,H]=l.useState(!1),[V,se]=l.useState(!1),[X,A]=l.useState(!1),[J,k]=l.useState(!1),[le,Y]=l.useState(!1),[me,he]=l.useState(!1),I=e.ready?y("connected"):e.status==="closed"?y("reconnecting"):y("connecting"),j=e.ready?"ok":"busy",D=()=>{if(!e.ready)return;const T=y("updateTabTitle"),ce={name:T,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},F=e.terminals.find(ie=>ie.title===T);F?(n.restart(F.id),t({type:"run_command",terminalId:F.id,conversationId:F.conversationId,command:ce,cols:80,rows:24})):n.create({id:Ct(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:T,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:ce}),k(!1),Y(!1),i("terminal")},re=(T,ce)=>{if(!e.ready||T.length===0)return;const F={name:ce,command:Al(T),cwd:"${pwd}"},ie=e.terminals.find(oe=>oe.title===ce);ie?(n.restart(ie.id),t({type:"run_command",terminalId:ie.id,conversationId:ie.conversationId,command:F,cols:80,rows:24})):n.create({id:Ct(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:ce,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:F}),k(!1),Y(!1),i("terminal")},te=T=>!e.tabs||T==="chat"||e.tabs.includes(T),ge=e.updatesAll??[],C=ge.filter(T=>!T.upToDate&&!T.error).length,Q=ge.filter(T=>!T.upToDate&&!T.error&&T.kind!=="webui"),P=()=>s.jsxs("div",{className:"dd-updates-all",children:[s.jsx("div",{className:"dd-header",children:y("updatesAllTitle")}),e.updatesAll===null?s.jsx("div",{className:"dd-note",children:y("checkingUpdate")}):ge.length===0?s.jsx("div",{className:"dd-note",children:y("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:ge.map(T=>s.jsxs("li",{className:`dd-all-item${T.error?" err":T.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:T.name,children:T.name}),s.jsx("span",{className:"dd-all-kind",children:T.kind==="webui"?y("kindWebUi"):T.kind==="pi-core"?y("kindPiCore"):y("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:T.error?y("updateCheckFailed"):T.upToDate?`v${T.current}`:s.jsxs(s.Fragment,{children:["v",T.current," → v",T.latest]})}),T.kind!=="webui"&&!T.upToDate&&!T.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>re([T],y("updatePkgTabTitle",{name:T.name})),children:y("updateBtn")})]},`${T.kind}:${T.name}`))}),s.jsxs("div",{className:"dd-actions",children:[Q.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>re(Q,y("updateAllTabTitle")),children:y("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:Q.length>0?{flex:1}:void 0,onClick:()=>t({type:"check_updates_all",force:!0}),children:y("updatesAllRefresh")})]})]}),$=()=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"dd-update",children:[s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:y("currentVersion")}),s.jsxs("b",{children:["v",e.update?.current??"…"]})]}),s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:y("latestVersion")}),s.jsx("b",{children:e.update===null?y("checkingUpdate"):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:y("checkingUpdate")})]}),e.update&&e.update.upToDate&&s.jsx("div",{className:"dd-note ok",children:y("upToDate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note warn",children:y("updateAvailable",{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<30*6e4&&s.jsx("div",{className:"dd-note warn",children:y("updateJustPublished",{version:e.update.latest??""})}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note",children:y("updateTerminalHint")})]}),s.jsxs("div",{className:"dd-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"check_update"}),children:e.update===null?y("checkingUpdate"):y("checkUpdate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("button",{type:"button",className:"dd-refresh accent",onClick:D,children:y("updateNow")})]})]});return s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("button",{type:"button",className:"panel-toggle",title:y("openHistory"),onClick:()=>c("left"),children:s.jsx(ml,{})}),s.jsx("span",{className:"brand-logo",children:"π"}),s.jsx("span",{className:"brand-name",children:"pi-web-ui"}),s.jsx("span",{className:`conn-dot ${j}`,title:I}),s.jsx("span",{className:"conn-label",children:I})]}),s.jsxs("div",{className:"topbar-actions",children:[s.jsxs("div",{className:"view-switch",role:"tablist","aria-label":y("viewSwitch"),children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="chat",className:a==="chat"?"active":"",onClick:()=>i("chat"),children:[s.jsx(Jt,{}),s.jsx("span",{children:y("chat")})]}),te("terminal")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="terminal",className:a==="terminal"?"active":"",onClick:()=>i("terminal"),children:[s.jsx(Xt,{}),s.jsx("span",{children:y("terminal")})]}),te("git")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="git",className:a==="git"?"active":"",onClick:()=>i("git"),children:[s.jsx(Bs,{}),s.jsx("span",{children:y("scmTab")})]}),(te("plugins")?o:[]).filter(T=>T.view!==!1).map(T=>{const ce=T.error?`${T.name}: ${T.error}`:T.description?`${T.name} — ${T.description}`:T.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":a===`plugin:${T.id}`,className:`plugin-tab${a===`plugin:${T.id}`?" active":""}${T.error?" broken":""}`,title:ce,onClick:()=>i(`plugin:${T.id}`),children:[T.icon?s.jsx("span",{"aria-hidden":!0,children:T.icon}):null,s.jsx("span",{children:T.name})]},T.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[te("search")&&s.jsxs("button",{type:"button",className:"chip",title:y("searchGlobalTip"),onClick:f,children:[s.jsx(zs,{}),s.jsx("span",{className:"chip-sub",children:y("searchGlobal")})]}),te("tasks")&&s.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":y("bgTasksTip"),onClick:u,children:[s.jsx(Qs,{}),s.jsx("span",{className:"chip-sub",children:y("bgTasks")}),e.bgServers.length>0&&s.jsx("span",{className:"bg-task-badge",children:e.bgServers.length})]}),te("settings")&&s.jsxs("button",{type:"button",className:"chip",title:y("settingsTitle"),onClick:d,children:[s.jsx(Gs,{}),s.jsx("span",{className:"chip-sub",children:y("settings")})]}),s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Hi,{}),s.jsx("span",{className:"chip-sub",children:y("sound")})]}),open:U,onOpenChange:H,children:[s.jsx(Pa,{settings:g,onChange:b,onPreview:x}),s.jsx(Ma,{})]}),s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx($i,{}),s.jsx("span",{className:"chip-sub",children:Fl(G)})]}),open:V,onOpenChange:se,children:[s.jsx("div",{className:"dd-header",children:y("language")}),R.map(T=>s.jsx(nt,{active:G===T.code,onClick:()=>{K(T.code),se(!1)},children:T.nativeName},T.code)),s.jsxs(nt,{onClick:()=>{se(!1),he(!0)},children:[s.jsx(Ht,{})," ",y("localeGetMore")]})]}),s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(rl,{}),s.jsx("span",{className:"chip-sub",children:y("theme")})]}),open:X,onOpenChange:A,children:[s.jsx("div",{className:"dd-header",children:y("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),A(!1)},children:y("themeDefault")}),N.map(T=>s.jsx(nt,{active:S===T.id,onClick:()=>{M(T.id),A(!1)},children:G==="zh"?T.name:T.nameEn??T.name},T.id))]}),e.managed?s.jsxs("span",{className:"chip",title:y("updatesManaged"),children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.appVersion??e.update?.current??"…"]})]}):s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.update?.current??"…"]}),e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot",title:y("updateAvailable",{version:e.update.latest??""})}),C>0&&s.jsx("span",{className:"update-badge",children:y("updatesAllBadge",{n:C})})]}),open:J,onOpenChange:T=>{k(T),T&&(t({type:"check_update"}),t({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:y("update")}),$(),P()]}),s.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:y("githubRepo"),children:s.jsx(La,{})})]}),s.jsxs("button",{type:"button",className:"chip newchat","data-tip":y("newChatTip"),onClick:()=>t({type:"new_chat"}),children:[s.jsx(ct,{}),s.jsx("span",{children:y("newChat")})]}),s.jsx("div",{className:"topbar-more",children:s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(ul,{}),s.jsx("span",{className:"chip-sub",children:y("more")}),!e.managed&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:le,onOpenChange:T=>{Y(T),T&&!e.managed&&(t({type:"check_update"}),t({type:"check_updates_all"}))},children:[s.jsx("div",{className:"dd-header",children:y("sound")}),s.jsx("div",{className:"dd-header",children:y("settings")}),s.jsxs(nt,{onClick:()=>{Y(!1),d()},children:[s.jsx(Gs,{})," ",y("settingsTitle")]}),s.jsxs(nt,{onClick:()=>{Y(!1),f()},children:[s.jsx(zs,{})," ",y("searchGlobal")]}),s.jsxs(nt,{onClick:()=>{Y(!1),u()},children:[s.jsx(Qs,{})," ",y("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(Pa,{settings:g,onChange:b,onPreview:x}),s.jsx(Ma,{}),s.jsx("div",{className:"dd-header",children:y("language")}),R.map(T=>s.jsx(nt,{active:G===T.code,onClick:()=>K(T.code),children:T.nativeName},T.code)),s.jsx("div",{className:"dd-header",children:y("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),Y(!1)},children:y("themeDefault")}),N.map(T=>s.jsx(nt,{active:S===T.id,onClick:()=>{M(T.id),Y(!1)},children:G==="zh"?T.name:T.nameEn??T.name},T.id)),s.jsx("div",{className:"dd-header",children:y("update")}),$(),P(),s.jsxs("a",{className:"dd-refresh dd-more-link",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",children:[s.jsx(La,{})," ",y("githubRepo")]})]})}),s.jsx("button",{type:"button",className:"panel-toggle",title:y("openFiles"),onClick:()=>c("right"),children:s.jsx(Rt,{})})]}),me&&s.jsx(Yl,{onClose:()=>he(!1)})]})}function Ba(e){const t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`:`${t.getMonth()+1}/${t.getDate()}`}function Vl(e,t){const n=new Map(e.map(i=>[i.id,i])),a=new Map;for(const i of e){const c=i.parentId?n.get(i.parentId)?.cwd??i.cwd:i.cwd,d=a.get(c)??[];d.push(i),a.set(c,d)}const o=[...a.entries()].map(([i,c])=>({cwd:i,isCurrent:i===t,convs:c}));return o.sort((i,c)=>i.isCurrent?-1:c.isCurrent?1:i.cwd<c.cwd?-1:i.cwd>c.cwd?1:0),o}const zl="pi-web-ui:lp-collapse-projects",Ql="pi-web-ui:lp-collapse-convs",Xl="pi-web-ui:lp-collapse-sessions";function xn(e,t=!1){const[n,a]=l.useState(()=>{try{const i=localStorage.getItem(e);if(i==="1")return!0;if(i==="0")return!1}catch{}return t}),o=l.useCallback(()=>{a(i=>{const c=!i;try{localStorage.setItem(e,c?"1":"0")}catch{}return c})},[e]);return[n,o]}const sr="pi-web-ui:lp-sizes",Bn={projects:1,convs:1,sessions:1};function Jl(){try{const e=localStorage.getItem(sr);if(e){const t=JSON.parse(e);return{projects:typeof t.projects=="number"&&t.projects>0?t.projects:1,convs:typeof t.convs=="number"&&t.convs>0?t.convs:1,sessions:typeof t.sessions=="number"&&t.sessions>0?t.sessions:1}}}catch{}return{...Bn}}const Zl=l.memo(function({ready:t,status:n,cwd:a,sessionFile:o,conversations:i,sessions:c,projects:d,activeConversationId:u,send:f,active:g,collapsible:b,onToggleCollapse:x}){const N=Ae(),S=o,M=a,[G,K]=l.useState(null),[y,R]=l.useState(null),[U,H]=l.useState(""),[V,se]=xn(zl,!1),[X,A]=xn(Ql,!1),[J,k]=xn(Xl,!1),le=l.useRef(null),[Y,me]=l.useState(()=>Jl());l.useEffect(()=>{try{localStorage.setItem(sr,JSON.stringify(Y))}catch{}},[Y]);const he=l.useCallback((P,$)=>T=>{T.preventDefault();const ce=T.currentTarget,F=T.clientY,ie={...Y},oe=le.current;if(!oe)return;const de=32,Te=72,we=[{key:"projects",visible:d.length>0,collapsed:V},{key:"convs",visible:i.length>0,collapsed:X},{key:"sessions",visible:!0,collapsed:J}].filter(ue=>ue.visible),v=we.filter(ue=>ue.collapsed).length,ae=we.filter(ue=>!ue.collapsed).map(ue=>ue.key).reduce((ue,ve)=>ue+(ie[ve]??1),0)||1,pe=Math.max(120,oe.clientHeight-v*de),Le=(ie[P]??1)+(ie[$]??1),Be=Te/pe*ae;ce.classList.add("dragging"),document.body.classList.add("lp-resizing");const Ye=ue=>{const xe=(ue.clientY-F)/pe*ae;let ye=(ie[P]??1)+xe;const Oe=Le-Be;ye=Math.max(Be,Math.min(Oe,ye));const Me=Le-ye;me(B=>({...B,[P]:ye,[$]:Me}))},_=()=>{window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",_),ce.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",_)},[Y,d.length,i.length,V,X,J]);l.useEffect(()=>{!g||!t||n!=="open"||a&&(f({type:"list_sessions"}),f({type:"list_projects"}))},[g,t,n,a,f]);const I=P=>{const $=P.name||P.firstMessage.trim();return $.length>0?$:N("emptyChat")},j=P=>P.split(/[\\/]/).pop()||P,D=(P,$,T,ce,F)=>{const ie=G===P;return s.jsx("button",{type:"button",className:`lp-del ${ie?"confirm":""}`,title:ie?T:$,onClick:oe=>{oe.stopPropagation(),ie?(K(null),ce()):K(P)},children:ie?s.jsx(Et,{}):F??s.jsx(et,{})})},re=(P,$,T,ce)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:T,title:N($?"expandSection":"collapseSection"),children:[s.jsxs("span",{className:"lp-section-title-text",children:[P,ce!==void 0?` (${ce})`:""]}),s.jsx("span",{className:"lp-section-chevron",children:$?s.jsx(Pt,{}):s.jsx(on,{})})]}),ge=[{key:"projects",visible:d.length>0,collapsed:V},{key:"convs",visible:i.length>0,collapsed:X},{key:"sessions",visible:!0,collapsed:J}].filter(P=>P.visible).filter(P=>!P.collapsed),C=ge.reduce((P,$)=>P+(Y[$.key]??1),0)||1,Q=P=>ge.length<=1?1:(Y[P]??1)/C*ge.length;return s.jsxs("aside",{ref:le,className:"panel panel-left lp-panel",children:[b&&x&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:N("collapsePanel"),onClick:x,children:s.jsx(Yi,{})}),d.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${V?"collapsed":""}`,style:V?void 0:{flex:`${Q("projects")} 1 0px`},children:[re(N("recentProjects"),V,se,d.length),!V&&s.jsx("div",{className:"lp-section-body projects-scroll",children:d.map(P=>{const $=M===P.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>K(T=>T===`proj:${P.path}`?null:T),children:[s.jsxs("button",{type:"button",className:`project-item ${$?"active":""}`,title:P.path,onClick:()=>{$||f({type:"set_cwd",path:P.path})},children:[s.jsx(Rt,{className:"project-icon"}),s.jsxs("span",{className:"project-info",children:[s.jsx("span",{className:"project-name",children:j(P.path)}),s.jsx("span",{className:"project-path",children:P.path})]}),s.jsx("span",{className:"project-time",children:Ba(P.lastUsed)})]}),D(`proj:${P.path}`,N("deleteProject"),N("deleteProjectConfirm"),()=>f({type:"remove_project",path:P.path}))]},P.path)})})]}),d.length>0&&!V&&(i.length>0?!X:!J)&&s.jsx("div",{className:"lp-sash",onPointerDown:he("projects",i.length>0?"convs":"sessions"),onDoubleClick:()=>me({...Bn}),title:N("dragToResize")}),i.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${X?"collapsed":""}`,style:X?void 0:{flex:`${Q("convs")} 1 0px`},children:[re(N("runningConversations"),X,A,i.length),!X&&s.jsx("div",{className:"lp-section-body convs-scroll",children:Vl(i,a).map(P=>s.jsxs("div",{className:"panel-conv-group",children:[!P.isCurrent&&s.jsx("div",{className:"panel-conv-group-title",title:P.cwd,children:j(P.cwd)}),(()=>{const $=new Map(P.convs.map(de=>[de.id,de])),T=new Map,ce=[];for(const de of P.convs)if(de.parentId&&$.has(de.parentId)){const Te=T.get(de.parentId)??[];Te.push(de),T.set(de.parentId,Te)}else ce.push(de);const F=[],ie=new Set,oe=(de,Te)=>{if(!ie.has(de.id)){ie.add(de.id),F.push({c:de,depth:Te});for(const we of T.get(de.id)??[])oe(we,Te+1)}};for(const de of ce)oe(de,0);for(const de of P.convs)oe(de,0);return F.map(({c:de,depth:Te})=>{const we=u===de.id;return s.jsxs("div",{className:`lp-row${Te>0?" lp-sub":""}`,style:Te>0?{marginLeft:Te*18}:void 0,onMouseLeave:()=>K(v=>v===`conv:${de.id}`?null:v),children:[s.jsxs("button",{type:"button",className:`session-item ${we?"active":""}`,title:`${de.title}${P.isCurrent?"":` — ${P.cwd}`}`,onClick:()=>{we||f({type:"switch_conversation",id:de.id})},children:[s.jsx(Jt,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[y===`conv:${de.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:U,placeholder:N("renameSessionPlaceholder"),onClick:v=>v.stopPropagation(),onChange:v=>H(v.target.value),onKeyDown:v=>{if(v.stopPropagation(),v.key==="Enter"&&!v.nativeEvent.isComposing){const ne=U.trim();ne&&f({type:"rename_conversation",id:de.id,name:ne}),R(null)}else v.key==="Escape"&&R(null)},onBlur:()=>R(null)}):s.jsxs("span",{className:"session-title",children:[de.isSubagent&&s.jsx("span",{className:"subagent-badge",children:N("subagentBadge")}),de.title,de.error&&s.jsx("span",{className:"conv-error-badge",title:N("convErrorBadge",{error:de.error})})]}),y===`conv:${de.id}`?null:s.jsx("span",{className:"session-sub",children:we?N("current"):N("messageCount",{n:de.messageCount})})]}),de.isStreaming&&s.jsx("span",{className:"conv-streaming",title:N("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:v=>{v.stopPropagation(),K(null),H(de.title),R(`conv:${de.id}`)},children:s.jsx(Xs,{})}),!de.isStreaming&&!we&&D(`conv:${de.id}`,N("dismissConversation"),N("dismissConversationConfirm"),()=>f({type:"dismiss_conversation",id:de.id}),s.jsx(Je,{})),de.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:N("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},de.id)})})()]},P.cwd))})]}),i.length>0&&!X&&!J&&s.jsx("div",{className:"lp-sash",onPointerDown:he("convs","sessions"),onDoubleClick:()=>me({...Bn}),title:N("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${J?"collapsed":""}`,style:J?void 0:{flex:`${Q("sessions")} 1 0px`},children:[re(N("historySessions"),J,k,c.length),!J&&s.jsxs("div",{className:"lp-section-body sessions-scroll",children:[c.length===0&&s.jsx("div",{className:"panel-empty",children:N("noHistory")}),c.map(P=>{const $=S===P.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>K(T=>T===`sess:${P.path}`?null:T),children:[s.jsxs("button",{type:"button",className:`session-item ${$?"active":""}`,title:P.path,onClick:()=>{y||$||f({type:"switch_session",path:P.path})},children:[s.jsx(Jt,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[y===P.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:U,placeholder:N("renameSessionPlaceholder"),onClick:T=>T.stopPropagation(),onChange:T=>H(T.target.value),onKeyDown:T=>{if(T.stopPropagation(),T.key==="Enter"&&!T.nativeEvent.isComposing){const ce=U.trim();ce&&f({type:"rename_session",path:P.path,name:ce}),R(null)}else T.key==="Escape"&&R(null)},onBlur:()=>R(null)}):s.jsx("span",{className:"session-title",children:I(P)}),y===P.path?null:s.jsxs("span",{className:"session-sub",children:[$?N("current"):N("messageCount",{n:P.messageCount}),P.source==="tui"&&s.jsx("span",{className:"session-src",title:N("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:Ba(P.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:T=>{T.stopPropagation(),K(null),H(P.name??""),R(P.path)},children:s.jsx(Xs,{})}),D(`sess:${P.path}`,N("deleteSession"),N("deleteSessionConfirm"),()=>f({type:"delete_session",path:P.path}))]},P.path)})]})]})]})});function ec(e,t){const n=t.assistantMessageEvent,a=e.stats.tokens,o=t.usage!==null?{...a,...t.usage}:a,i=o===a?e.stats:{...e.stats,tokens:o};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return i===e.stats?e:{...e,stats:i};const c=n.delta??"";if(!c)return i===e.stats?e:{...e,stats:i};const d=e.streamingMessage??null,u=d&&d.id===t.messageId?d:{id:t.messageId,content:[]},f=[...u.content],g=n.type==="thinking_delta"?"thinking":"text",b=n.contentIndex??f.length-1;return b>=0&&b<f.length&&f[b].type===g?f[b]=g==="thinking"?{type:"thinking",thinking:(f[b].thinking??"")+c}:{type:"text",text:(f[b].text??"")+c}:f.push(g==="thinking"?{type:"thinking",thinking:c}:{type:"text",text:c}),{...e,stats:i,streamingMessage:{...u,id:t.messageId,content:f}}}const Fn="pi-web-ui:plugin-data";function tc(e,t){window.dispatchEvent(new CustomEvent(Fn,{detail:{pluginId:e,payload:t}}))}function sc(e){const t=n=>{const a=n.detail;e(a.pluginId,a.payload)};return window.addEventListener(Fn,t),()=>window.removeEventListener(Fn,t)}const Gt=new Map,Hn=new Set,Kt=new Set;let Fa=-1;function nr(){return[...Gt.values()]}function nc(){const e=nr();for(const t of Hn)t(e)}function ac(e){return Hn.add(e),e(nr()),()=>Hn.delete(e)}async function ic(e,t){t!==Fa&&(Fa=t,Gt.clear(),Kt.clear());const n=new Set(e.map(a=>a.id));for(const a of[...Gt.keys()])n.has(a)||Gt.delete(a);for(const a of[...Kt])n.has(a)||Kt.delete(a);await Promise.all(e.filter(a=>a.hasClient&&a.view!==!1&&!a.error&&!Gt.has(a.id)&&!Kt.has(a.id)).map(async a=>{try{const i=(await import(it(`/plugins/${encodeURIComponent(a.id)}/client/entry.mjs?e=${t}`))).default;i&&typeof i.mount=="function"?Gt.set(a.id,{info:a,module:i}):(Kt.add(a.id),console.error(`[plugin:${a.id}] entry.mjs 缺少 default.mount`))}catch(o){Kt.add(a.id),console.error(`[plugin:${a.id}] 客户端加载失败:`,o)}})),nc()}function rc(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>sc((a,o)=>{a===e&&n(o)})}}const oc=15,lc="pi-web-ui:lang";function Ha(){try{return(localStorage.getItem(lc)??"").trim()}catch{return""}}const Ua="pi-web-ui:locale",yn=2e5,cc=2e5,uc="LIVE_OMIT",dc={conversationId:null,goal:null,reviewModel:null,maxRounds:3,locked:!0,reviewing:!1,round:0,status:"",verdict:"pending",wizard:{active:!1,draft:"",model:null,step:0,maxSteps:6,status:""}};function pc(){const e=new Map,t=new Map,n=(a,o)=>`${a}:${o}`;return{write(a,o,i){const c=n(a,o),d=e.get(c);if(d&&d.size>0){for(const g of d)try{g.write(i)}catch{}return}const u=t.get(c)??"",f=u.length+i.length>cc?i:u+i;t.set(c,f)},register(a,o,i){const c=n(a,o);let d=e.get(c);d||(d=new Set,e.set(c,d)),d.add(i);const u=t.get(c);if(u){try{i.write(u)}catch{}t.delete(c)}return()=>{const f=e.get(c);f&&(f.delete(i),f.size===0&&e.delete(c)),t.delete(c)}},clear(){e.clear(),t.clear()}}}function qa(e,t){const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId),o.role==="bashExecution"&&n.add(`bash-${o.id}`);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function $a(e,t){if(e.size===0)return e;const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function mc(e,t){switch(t.type){case"status":return{...e,status:t.status,ready:t.status==="open"?e.ready:!1,terminals:t.status==="closed"?[]:e.terminals};case"ready":return{...e,serverVersion:t.serverVersion,engine:t.engine,appVersion:t.appVersion,managed:t.managed===!0,tabs:t.tabs,ready:!0,protocolMismatch:t.protocolVersion!==void 0&&t.protocolVersion!==oc};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:qa(e.liveOutputs,t.state),toolStatuses:$a(e.toolStatuses,t.state)};case"snapshot_delta":{const n=e.state,a=t.msg;if(!n||n.conversationId!==a.conversationId||n.rev!==a.baseRev)return e;const o={...n,...a.state,messages:a.appended.length>0?[...n.messages,...a.appended]:n.messages};return{...e,ready:!0,state:o,activeConversationId:o.conversationId,liveOutputs:qa(e.liveOutputs,o),toolStatuses:$a(e.toolStatuses,o)}}case"tool_delta":{const a=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,o=a.length>yn?`…[${uc}:${a.length-yn}]…
305
- `+a.slice(a.length-yn):a,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:o}),{...e,liveOutputs:i}}case"message_delta":{const n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:ec(n,t.msg)}}case"tool_status":return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case"notice":return{...e,notices:[...e.notices,t.notice].slice(-6)};case"dismiss_notice":return{...e,notices:e.notices.filter(n=>n.id!==t.id)};case"sessions":return{...e,sessions:t.sessions};case"conversations":return{...e,conversations:t.conversations,activeConversationId:t.activeId};case"projects":return{...e,projects:t.projects};case"files":return{...e,files:t.files};case"file_changed":return{...e,fileChanged:{path:t.path}};case"file_content":return{...e,fileContent:t.content};case"models":return{...e,models:t.models,modelsLoading:t.loading};case"models_config":return{...e,modelsConfig:t.providers};case"providers_status":return{...e,providers:t.providers};case"provider_keys":return{...e,providerKeys:t.keys};case"fetch_models_result":return{...e,fetchModelsResult:t.result};case"refresh_provider_result":return{...e,refreshProviderResult:t.result};case"clone_provider_result":return{...e,cloneProviderResult:t.result};case"install_result":return{...e,installResult:t.result};case"scm_data":return{...e,scmData:t.data};case"file_search_result":return{...e,fileSearch:t.result};case"session_search_result":return{...e,sessionSearch:t.result};case"scm_changed":return{...e,scmDirty:e.scmDirty+1};case"path_completions":return{...e,pathCompletions:t.completions};case"update_status":return{...e,update:t.status};case"update_status_all":return{...e,updatesAll:t.items};case"updates_check_started":return{...e,updatesAll:null};case"widgets":return{...e,widgets:t.widgets};case"statuses":return{...e,statuses:t.statuses};case"dialog":return{...e,dialog:t.dialog};case"question":return{...e,question:t.question};case"commands":return{...e,commands:t.commands,commandsPath:t.path};case"slash_commands":return{...e,slashCommands:t.commands};case"goal_status":return{...e,goal:t.status};case"settings":return{...e,settings:t.settings};case"bg_servers":return{...e,bgServers:t.servers};case"plugins":return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case"plugin_catalog":return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case"dsh_patches":return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case"terminal_add":return{...e,terminals:[...e.terminals,t.meta]};case"terminal_remove":return{...e,terminals:e.terminals.filter(n=>n.id!==t.id)};case"terminal_exit":return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(n=>n.id===t.terminalId?{...n,running:!1,exitCode:t.exitCode}:n)};case"terminal_restart":return{...e,terminals:e.terminals.map(n=>n.id===t.terminalId?{...n,running:!0,exitCode:null}:n)};case"terminal_list":return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??""}))};case"terminal_active":return{...e,terminalActiveId:t.id};default:return e}}const Wa="pi-web-client-id";let Nn=null;function ra(){if(Nn)return Nn;let e=null;try{e=sessionStorage.getItem(Wa),e||(e=Ct(),sessionStorage.setItem(Wa,e))}catch{e=e??Ct()}return Nn=e,e}const ar="pi-web-last-cwd";function hc(){try{return localStorage.getItem(ar)}catch{return null}}function fc(e){try{localStorage.setItem(ar,e)}catch{}}function gc(){const e=location.protocol==="https:"?"wss:":"ws:";return Dt(`${e}//${location.host}${it("/ws")}`)}function bc(){const[e,t]=l.useReducer(mc,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],activeConversationId:"",projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],terminalActiveId:null,goal:dc,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginCatalog:[],pluginCatalogEpoch:0,dshPatches:null,protocolMismatch:!1}),n=l.useRef(null),a=l.useRef(pc()),o=l.useRef(0),i=l.useRef(null),c=l.useRef(!0),d=l.useRef(0),u=l.useRef(0),f=l.useRef(new Map),g=l.useRef(null),b=l.useRef(!1),x=l.useRef(null),N=()=>{g.current||(g.current=setTimeout(()=>{g.current=null;const A=n.current;A&&A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"get_state"}))},300))},S=(A,J)=>{const k=f.current,le=k.get(A);if(le!==void 0&&J!==le+1){const Y=X.current.chat,me=Y.activeConversationId||Y.state?.conversationId;A===me&&N()}k.set(A,J)},M=l.useCallback((A,J)=>{const k=++u.current;t({type:"notice",notice:{id:k,level:A,text:J}})},[]),G=l.useCallback(A=>{const J=n.current;return J&&J.readyState===WebSocket.OPEN?(A.type==="check_updates_all"&&A.force===!0&&t({type:"updates_check_started"}),J.send(JSON.stringify(A)),A.type==="question_answer"&&t({type:"question",question:null}),!0):!1},[]),K=l.useCallback(()=>{if(!c.current)return;t({type:"status",status:"connecting"});const A=new WebSocket(gc());n.current=A,A.onopen=()=>{n.current===A&&(t({type:"status",status:"open"}),o.current=0,d.current=Date.now(),A.send(JSON.stringify({type:"hello",clientId:ra(),locale:Ha()})))},A.onmessage=J=>{if(n.current!==A)return;d.current=Date.now();let k;try{k=JSON.parse(J.data)}catch{return}switch(k.type){case"ready":t({type:"ready",serverVersion:k.serverVersion,protocolVersion:k.protocolVersion,engine:k.engine,appVersion:k.appVersion,managed:k.managed,tabs:k.tabs}),A.send(JSON.stringify({type:"get_state"})),A.send(JSON.stringify({type:"list_files"})),A.send(JSON.stringify({type:"list_models"})),A.send(JSON.stringify({type:"list_commands"})),A.send(JSON.stringify({type:"get_commands"})),k.managed||(A.send(JSON.stringify({type:"check_update"})),A.send(JSON.stringify({type:"check_updates_all"})));break;case"snapshot":f.current=new Map,t({type:"snapshot",state:k.state});break;case"snapshot_delta":{const le=X.current.chat.state;(!le||le.conversationId!==k.conversationId||le.rev!==k.baseRev)&&N(),t({type:"snapshot_delta",msg:k});break}case"tool_delta":S(k.conversationId,k.seq),t({type:"tool_delta",toolCallId:k.toolCallId,toolName:k.toolName,delta:k.delta});break;case"tool_status":t({type:"tool_status",status:k});break;case"message_delta":{S(k.conversationId,k.seq),t({type:"message_delta",msg:k});break}case"notice":{const le=++u.current;t({type:"notice",notice:{id:le,level:k.level,text:k.text,textEn:k.textEn}});break}case"sessions":t({type:"sessions",sessions:k.sessions});break;case"conversations":t({type:"conversations",conversations:k.conversations,activeId:k.activeId});break;case"projects":t({type:"projects",projects:k.projects});break;case"files":t({type:"files",files:k});break;case"file_changed":t({type:"file_changed",path:k.path});break;case"file_content":t({type:"file_content",content:k});break;case"models":t({type:"models",models:k.models,loading:!1});break;case"models_config":t({type:"models_config",providers:k.providers});break;case"providers_status":t({type:"providers_status",providers:k.providers});break;case"provider_keys":t({type:"provider_keys",keys:k.keys});break;case"fetch_models_result":t({type:"fetch_models_result",result:{reqId:k.reqId,ok:k.ok,models:k.models,error:k.error}});break;case"refresh_provider_result":t({type:"refresh_provider_result",result:{reqId:k.reqId,ok:k.ok,added:k.added,total:k.total,error:k.error}});break;case"clone_provider_result":t({type:"clone_provider_result",result:{reqId:k.reqId,ok:k.ok,config:k.config,configs:k.configs,error:k.error}});break;case"scm_data":t({type:"scm_data",data:k});break;case"search_files_result":t({type:"file_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results,truncated:k.truncated}});break;case"session_search_results":t({type:"session_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results}});break;case"scm_changed":t({type:"scm_changed"});break;case"install_result":t({type:"install_result",result:k});break;case"path_completions":t({type:"path_completions",completions:k.completions});break;case"update_status":t({type:"update_status",status:k});break;case"update_status_all":t({type:"update_status_all",items:k.items});break;case"widgets":t({type:"widgets",widgets:k.widgets});break;case"statuses":t({type:"statuses",statuses:k.statuses});break;case"dialog":t({type:"dialog",dialog:{id:k.id,kind:k.kind,title:k.title,args:k.args}});break;case"dialog_closed":t({type:"dialog",dialog:null});break;case"question_pending":t({type:"question",question:{id:k.id,questions:k.questions}});break;case"terminal_output":a.current.write(k.conversationId??X.current.chat.activeConversationId,k.terminalId,k.data);break;case"terminal_exit":t({type:"terminal_exit",conversationId:k.conversationId,terminalId:k.terminalId,exitCode:k.exitCode});break;case"terminal_list":t({type:"terminal_list",conversationId:k.conversationId,terminals:k.terminals});break;case"commands":t({type:"commands",commands:k.commands,path:k.path});break;case"slash_commands":t({type:"slash_commands",commands:k.commands});break;case"goal_status":t({type:"goal_status",status:k.status});break;case"settings_state":t({type:"settings",settings:k.settings});break;case"bg_servers":t({type:"bg_servers",servers:k.servers});break;case"plugins":t({type:"plugins",plugins:k.plugins,epoch:k.epoch});break;case"plugin_catalog":t({type:"plugin_catalog",entries:k.entries,epoch:k.epoch});break;case"dsh_patches":t({type:"dsh_patches",patchDir:k.patchDir,files:k.files});break;case"plugin_data":tc(k.pluginId,k.payload);break}},A.onclose=()=>{if(n.current===A&&(n.current=null),a.current.clear(),!c.current||n.current&&n.current!==A)return;t({type:"status",status:"closed"});const J=Math.min(1e3*2**o.current,1e4);o.current+=1,i.current=setTimeout(()=>{i.current=null,K()},J)},A.onerror=()=>{}},[]);l.useEffect(()=>{const A=J=>{const k=J.detail??Ha();k&&G({type:"set_locale",locale:k})};return window.addEventListener(Ua,A),()=>window.removeEventListener(Ua,A)},[G]),l.useEffect(()=>{c.current=!0,K();const A=setInterval(()=>{if(!c.current)return;const J=n.current;J&&J.readyState===WebSocket.OPEN&&Date.now()-d.current>3e4&&J.close()},5e3);return()=>{c.current=!1,clearInterval(A),i.current&&(clearTimeout(i.current),i.current=null),n.current?.close(),n.current=null}},[K]),l.useEffect(()=>{const A=e.state?.cwd;if(A){if(!b.current){b.current=!0;const J=hc();if(J&&J!==A){G({type:"set_cwd",path:J});return}}x.current!==A&&(x.current=A,fc(A))}},[e.state?.cwd,G]);const y=l.useCallback(A=>t({type:"dismiss_notice",id:A}),[]),R=l.useCallback(A=>t({type:"terminal_add",meta:A}),[]),U=l.useCallback(A=>t({type:"terminal_remove",id:A}),[]),H=l.useCallback(A=>t({type:"terminal_restart",terminalId:A}),[]),V=l.useCallback(A=>t({type:"terminal_active",id:A}),[]),se=l.useCallback((A,J,k)=>a.current.register(A,J,k),[]),X=l.useRef({chat:e,send:G,pushNotice:M,dismissNotice:y,terminal:{create:R,close:U,register:se,restart:H,select:V}});return X.current={chat:e,send:G,pushNotice:M,dismissNotice:y,terminal:{create:R,close:U,register:se,restart:H,select:V}},X.current}const Ec=200*1024*1024,Tc=/windows/i.test(navigator.userAgent),xc=/[<>:"/\\|?*\u0000-\u001f]/g,yc=/[. ]+$/,Nc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function kc(e){const t=e.replace(xc,"_").replace(yc,"");return t?Nc.test(t)?`_${t}`:t:"_"}function Ka(e,t=!0){const n=new URLSearchParams({clientId:ra(),path:e,...t?{download:"1"}:{}});return Dt(it(`/api/file?${n}`))}const ir="FILE_NOT_FOUND";async function Cc(e,t){const n=Tc?kc(t):t;try{const a=await fetch(Ka(e));if(!a.ok)return{ok:!1,cancelled:!1,error:await a.text().catch(()=>"")||(a.status===404?ir:`HTTP ${a.status}`)};if(Number(a.headers.get("content-length")??"0")>Ec)return window.location.assign(Ka(e)),{ok:!0};const i=await a.blob();return window.showSaveFilePicker&&window.isSecureContext?vc(i,n):Un(i,n)}catch(a){return{ok:!1,cancelled:!1,error:a instanceof Error?a.message:String(a)}}}async function vc(e,t){let n;const a=window.showSaveFilePicker;if(!a)return Un(e,t);try{n=await a({suggestedName:t})}catch(o){return o instanceof DOMException&&o.name==="AbortError"?{ok:!1,cancelled:!0}:Un(e,t)}try{const o=await n.createWritable();return await o.write(e),await o.close(),{ok:!0}}catch(o){return{ok:!1,cancelled:!1,error:o instanceof Error?o.message:String(o)}}}function Un(e,t){const n=URL.createObjectURL(e),a=document.createElement("a");return a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const os="@root",_c=l.memo(function({files:t,fileChanged:n,widgets:a,cwd:o,send:i,onAttach:c,onPreview:d,onNotice:u,collapsible:f,onToggleCollapse:g}){const b=Ae(),[x,N]=l.useState(""),[S,M]=l.useState(null),[G,K]=l.useState(!1),[y,R]=l.useState(null),U=l.useRef(""),H=l.useRef(null),V=l.useRef(null),[se,X]=l.useState(null),A=l.useRef(null);l.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]);const J=l.useCallback(v=>{X(v),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>X(null),1200)},[]),k=v=>{try{const ne=document.createElement("textarea");ne.value=v,ne.style.position="fixed",ne.style.opacity="0",document.body.appendChild(ne),ne.select();const ae=document.execCommand("copy");return document.body.removeChild(ne),ae}catch{return!1}},le=l.useCallback((v,ne)=>{if(!v)return;const ae=()=>J(ne),pe=()=>u("error",b("slashCopyFailed")),Le=navigator;Le.clipboard?.writeText?Le.clipboard.writeText(v).then(ae,()=>{k(v)?ae():pe()}):k(v)?ae():pe()},[J,u,b]),Y=l.useCallback(v=>{if(!v)return o;if(/^[A-Za-z]:$/.test(v))return`${v}/`;if(v.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(v))return v;const ne=o.replace(/\\/g,"/").replace(/\/+$/,"");return ne?`${ne}/${v}`:v},[o]),me=l.useCallback(v=>!v||v===os?null:v.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(v)?v:`${o.replace(/\\/g,"/").replace(/\/+$/,"")}/${v}`,[o]),he=l.useCallback((v,ne,ae)=>{v.preventDefault(),U.current=ne,H.current=ae??null,R({x:Math.min(v.clientX,window.innerWidth-220),y:Math.min(v.clientY,window.innerHeight-90)})},[]),I=l.useCallback(()=>R(null),[]);l.useEffect(()=>{if(!y)return;const v=pe=>{pe.target?.closest(".ctx-menu")||I()},ne=pe=>{pe.key==="Escape"&&I()};window.addEventListener("mousedown",v,!0),window.addEventListener("keydown",ne);const ae=()=>I();return window.addEventListener("blur",ae),()=>{window.removeEventListener("mousedown",v,!0),window.removeEventListener("keydown",ne),window.removeEventListener("blur",ae)}},[y,I]);const j=l.useCallback(()=>{const v=H.current;I(),v&&i({type:"set_cwd",path:v.path})},[I,i]),D=l.useCallback(()=>{I(),V.current&&(V.current.value=""),V.current?.click()},[I]),re=l.useCallback((v,ne)=>{for(const ae of ne){const pe=new FileReader;pe.onload=()=>{const Le=pe.result,Be=Le.slice(Le.indexOf(",")+1);Be&&i({type:"upload_file",dirPath:v,name:ae.name,data:Be})},pe.readAsDataURL(ae)}},[i]),te=l.useCallback(v=>{re(U.current,Array.from(v.target.files??[]))},[re]),ge=l.useRef(null),C=v=>Array.from(v.dataTransfer?.types??[]).includes("Files"),Q=l.useCallback(()=>{ge.current?.querySelectorAll(".file-item.drop-target").forEach(v=>v.classList.remove("drop-target")),ge.current?.classList.remove("drop-root")},[]),P=l.useCallback(v=>{if(Q(),v==null)return;const ne=ge.current?.querySelector(`.file-item[data-path="${CSS.escape(v)}"]`);ne?ne.classList.add("drop-target"):ge.current?.classList.add("drop-root")},[Q]),$=v=>{const ne=v instanceof Element?v.closest(".file-item"):null;return ne?.dataset.type==="dir"?ne.dataset.path??x:x},T=l.useCallback(()=>{const v=document.querySelector(".app");v&&v.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),ce=1e4,F=l.useRef(0),ie=l.useRef(void 0),oe=l.useCallback((v,ne)=>{const ae=++F.current;N(v),ne?.silent||K(!0),i({type:"list_files",path:v===""?void 0:v})||F.current===ae&&K(!1)},[i]);l.useEffect(()=>{t&&t.path===x&&K(!1)},[t,x]),l.useEffect(()=>{if(o!==ie.current){ie.current=o,oe("",{silent:!0});return}const v=setInterval(()=>{document.visibilityState!=="hidden"&&oe(x,{silent:!0})},ce);return()=>clearInterval(v)},[o,x,oe]),l.useEffect(()=>{n&&n.path===x&&oe(x,{silent:!0})},[n,x,oe]);const de=v=>oe(v),Te=()=>{t?.parent!==null&&t?.parent!==void 0&&oe(t.parent)},we=(()=>{if(x===""||x===os)return[];const v=x.split("/").filter(ne=>!!ne&&ne!==os);return x.startsWith("/")?v.map((ne,ae)=>({label:ae===0?"/":v[ae],path:"/"+v.slice(0,ae+1).join("/")})):v.map((ne,ae)=>({label:v[ae],path:v.slice(0,ae+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",children:[f&&g&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:b("collapsePanel"),onClick:g,children:s.jsx(Ki,{})}),s.jsxs("div",{className:"panel-crumbs",children:[s.jsx("button",{type:"button",className:`crumb ${x===""?"active":""}`,onClick:()=>oe(""),children:b("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${x===os?"active":""}`,title:b("computer"),onClick:()=>oe(os),children:"💻"}),we.map(v=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx($t,{}),s.jsx("button",{type:"button",className:`crumb ${v.path===x?"active":""}`,onClick:()=>oe(v.path),children:v.label})]},v.path))]}),s.jsxs("div",{ref:ge,className:"panel-body",onContextMenu:v=>he(v,x),onDragOver:v=>{C(v)&&(v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect="copy",T(),P($(v.target)))},onDragLeave:v=>{v.relatedTarget&&v.currentTarget.contains(v.relatedTarget)||Q()},onDrop:v=>{if(Q(),!C(v))return;v.preventDefault(),v.stopPropagation(),T();const ne=Array.from(v.dataTransfer?.files??[]);if(ne.length===0){u("warning",b("foldersNotSupported"));return}re($(v.target),ne)},onDragEnd:Q,children:[s.jsx("input",{ref:V,type:"file",multiple:!0,hidden:!0,onChange:te}),G&&s.jsx("div",{className:"panel-empty",children:b("loading")}),!G&&t&&t.path===x&&s.jsxs(s.Fragment,{children:[t.parent!=null&&s.jsxs("button",{type:"button",className:"file-item dir",onClick:Te,children:[s.jsx(Rt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:".."})]}),t.entries.map(v=>v.type==="dir"?s.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":v.path,onContextMenu:ne=>{ne.stopPropagation();const ae=me(v.path);he(ne,v.path,ae?{path:ae,name:v.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>de(v.path),children:[s.jsx(Rt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:v.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":b("linkFolderTip"),"aria-label":b("linkFolderTip"),onClick:()=>c(v.path,v.name,"reference",!0),children:s.jsx(Rn,{})}),s.jsx("button",{type:"button",className:`file-attach copy${se===`name:${v.path}`?" copied":""}`,"data-tip":b("copyName"),"aria-label":b("copyName"),onClick:()=>le(v.name,`name:${v.path}`),children:se===`name:${v.path}`?s.jsx(Et,{}):s.jsx(kt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${se===`path:${v.path}`?" copied":""}`,"data-tip":b("copyPath"),"aria-label":b("copyPath"),onClick:()=>le(Y(v.path),`path:${v.path}`),children:se===`path:${v.path}`?s.jsx(Et,{}):s.jsx(Ra,{})})]},v.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":v.path,onContextMenu:ne=>{ne.stopPropagation(),he(ne,x)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${v.path} — ${b("previewFile")}`,onClick:()=>d(v.path,v.name),children:[s.jsx(yl,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:v.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":b("downloadFile"),onClick:()=>{Cc(v.path,v.name).then(ne=>{ne.ok||ne.cancelled||u("error",b("downloadFailed",{error:ne.error===ir?b("fileNotFoundShort"):ne.error}))})},children:s.jsx(Ht,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":b("attachInlineTip"),onClick:()=>c(v.path,v.name,"inline"),children:s.jsx(ct,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":b("referenceTip"),"aria-label":b("referenceTip"),onClick:()=>c(v.path,v.name,"reference"),children:s.jsx(Rn,{})}),s.jsx("button",{type:"button",className:`file-attach copy${se===`name:${v.path}`?" copied":""}`,"data-tip":b("copyName"),"aria-label":b("copyName"),onClick:()=>le(v.name,`name:${v.path}`),children:se===`name:${v.path}`?s.jsx(Et,{}):s.jsx(kt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${se===`path:${v.path}`?" copied":""}`,"data-tip":b("copyPath"),"aria-label":b("copyPath"),onClick:()=>le(Y(v.path),`path:${v.path}`),children:se===`path:${v.path}`?s.jsx(Et,{}):s.jsx(Ra,{})})]},v.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:b("filesTruncated")})]}),!G&&!t&&s.jsx("div",{className:"panel-empty",children:b("noFiles")})]}),a.filter(v=>v.lines.length>0).length>0&&s.jsx("div",{className:"panel-widgets",children:a.filter(v=>v.lines.length>0).map(v=>s.jsxs("div",{className:"widget",children:[s.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:b("widgetExpand"),onClick:()=>M(v.key),children:[s.jsx("span",{children:v.key}),s.jsx(fl,{})]}),s.jsx("pre",{className:"widget-lines",children:v.lines.join(`
306
- `)})]},v.key))}),S&&(()=>{const v=a.find(ne=>ne.key===S);return v?s.jsx("div",{className:"modal-backdrop",onClick:()=>M(null),children:s.jsxs("div",{className:"widget-expand",onClick:ne=>ne.stopPropagation(),children:[s.jsxs("div",{className:"widget-expand-head",children:[s.jsx("span",{className:"widget-expand-title",children:v.key}),s.jsx("button",{type:"button",className:"btn",title:b("close"),onClick:()=>M(null),children:s.jsx(Je,{})})]}),s.jsx("pre",{className:"widget-expand-lines",children:v.lines.join(`
307
- `)})]})}):null})(),y&&s.jsxs("div",{className:"ctx-menu",style:{left:y.x,top:y.y},onContextMenu:v=>{v.preventDefault(),v.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:D,children:[s.jsx(Ui,{}),U.current===x?b("uploadToCurrentDir"):b("uploadToFolder")]}),H.current&&s.jsxs("button",{type:"button",className:"ctx-item",onClick:j,children:[s.jsx(Rt,{}),b("openAsProject")]})]})]})});var Sc=Mi();function Ac(e){Fo(e,[/\r?\n|\r/g,wc])}function wc(){return{type:"break"}}function Ic(){return function(e){Ac(e)}}const Ya=/[#.]/g;function jc(e,t){const n=e||"",a={};let o=0,i,c;for(;o<n.length;){Ya.lastIndex=o;const d=Ya.exec(n),u=n.slice(o,d?d.index:n.length);u&&(i?i==="#"?a.id=u:Array.isArray(a.className)?a.className.push(u):a.className=[u]:c=u,o+=u.length),d&&(i=d[0],o++)}return{type:"element",tagName:c||t||"div",properties:a,children:[]}}function rr(e,t,n){const a=n?Pc(n):void 0;function o(i,c,...d){let u;if(i==null){u={type:"root",children:[]};const f=c;d.unshift(f)}else{u=jc(i,t);const f=u.tagName.toLowerCase(),g=a?a.get(f):void 0;if(u.tagName=g||f,Lc(c))d.unshift(c);else for(const[b,x]of Object.entries(c))Rc(e,u.properties,b,x)}for(const f of d)qn(u.children,f);return u.type==="element"&&u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}return o}function Lc(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const a of n){const o=t[a];if(o&&typeof o=="object"){if(!Array.isArray(o))return!0;const i=o;for(const c of i)if(typeof c!="number"&&typeof c!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function Rc(e,t,n,a){const o=ia(e,n);let i;if(a!=null){if(typeof a=="number"){if(Number.isNaN(a))return;i=a}else typeof a=="boolean"?i=a:typeof a=="string"?o.spaceSeparated?i=xa(a):o.commaSeparated?i=ya(a):o.commaOrSpaceSeparated?i=xa(ya(a).join(" ")):i=Ga(o,o.property,a):Array.isArray(a)?i=[...a]:i=o.property==="style"?Dc(a):String(a);if(Array.isArray(i)){const c=[];for(const d of i)c.push(Ga(o,o.property,d));i=c}o.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[o.property]=i}}function qn(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)qn(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?qn(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function Ga(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Na(n)===Na(t)))return!0}return n}function Dc(e){const t=[];for(const[n,a]of Object.entries(e))t.push([n,a].join(": "));return t.join("; ")}function Pc(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const Oc=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],Mc=rr(rn,"div"),Bc=rr(ws,"g",Oc);function Fc(e){const t=String(e),n=[];return{toOffset:o,toPoint:a};function a(i){if(typeof i=="number"&&i>-1&&i<=t.length){let c=0;for(;;){let d=n[c];if(d===void 0){const u=Va(t,n[c-1]);d=u===-1?t.length+1:u+1,n[c]=d}if(d>i)return{line:c+1,column:i-(c>0?n[c-1]:0)+1,offset:i};c++}}}function o(i){if(i&&typeof i.line=="number"&&typeof i.column=="number"&&!Number.isNaN(i.line)&&!Number.isNaN(i.column)){for(;n.length<i.line;){const d=n[n.length-1],u=Va(t,d),f=u===-1?t.length+1:u+1;if(d===f)break;n.push(f)}const c=(i.line>1?n[i.line-2]:0)+i.column-1;if(c<n[i.line-1])return c}}}function Va(e,t){const n=e.indexOf("\r",t),a=e.indexOf(`
308
- `,t);return a===-1?n:n===-1||n+1===a?a:n<a?n:a}const Bt={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},or={}.hasOwnProperty,Hc=Object.prototype;function Uc(e,t){const n=t||{};return oa({file:n.file||void 0,location:!1,schema:n.space==="svg"?ws:rn,verbose:n.verbose||!1},e)}function oa(e,t){let n;switch(t.nodeName){case"#comment":{const a=t;return n={type:"comment",value:a.data},Fs(e,a,n),n}case"#document":case"#document-fragment":{const a=t,o="mode"in a?a.mode==="quirks"||a.mode==="limited-quirks":!1;if(n={type:"root",children:lr(e,t.childNodes),data:{quirksMode:o}},e.file&&e.location){const i=String(e.file),c=Fc(i),d=c.toPoint(0),u=c.toPoint(i.length);n.position={start:d,end:u}}return n}case"#documentType":{const a=t;return n={type:"doctype"},Fs(e,a,n),n}case"#text":{const a=t;return n={type:"text",value:a.value},Fs(e,a,n),n}default:return n=qc(e,t),n}}function lr(e,t){let n=-1;const a=[];for(;++n<t.length;){const o=oa(e,t[n]);a.push(o)}return a}function qc(e,t){const n=e.schema;e.schema=t.namespaceURI===Bt.svg?ws:rn;let a=-1;const o={};for(;++a<t.attrs.length;){const d=t.attrs[a],u=(d.prefix?d.prefix+":":"")+d.name;or.call(Hc,u)||(o[u]=d.value)}const c=(e.schema.space==="svg"?Bc:Mc)(t.tagName,o,lr(e,t.childNodes));if(Fs(e,t,c),c.tagName==="template"){const d=t,u=d.sourceCodeLocation,f=u&&u.startTag&&Vt(u.startTag),g=u&&u.endTag&&Vt(u.endTag),b=oa(e,d.content);f&&g&&e.file&&(b.position={start:f.end,end:g.start}),c.content=b}return e.schema=n,c}function Fs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const a=$c(e,n,t.sourceCodeLocation);a&&(e.location=!0,n.position=a)}}function $c(e,t,n){const a=Vt(n);if(t.type==="element"){const o=t.children[t.children.length-1];if(a&&!n.endTag&&o&&o.position&&o.position.end&&(a.end=Object.assign({},o.position.end)),e.verbose){const i={};let c;if(n.attrs)for(c in n.attrs)or.call(n.attrs,c)&&(i[ia(e.schema,c).property]=Vt(n.attrs[c]));Ln(n.startTag);const d=Vt(n.startTag),u=n.endTag?Vt(n.endTag):void 0,f={opening:d};u&&(f.closing=u),f.properties=i,t.data={position:f}}}return a}function Vt(e){const t=za({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=za({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function za(e){return e.line&&e.column?e:void 0}const Wc={},Kc={}.hasOwnProperty,cr=Di("type",{handlers:{root:Gc,element:Jc,text:Qc,comment:Xc,doctype:zc}});function Yc(e,t){const a=(t||Wc).space;return cr(e,a==="svg"?ws:rn)}function Gc(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=la(e.children,n,t),ss(e,n),n}function Vc(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=la(e.children,n,t),ss(e,n),n}function zc(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return ss(e,t),t}function Qc(e){const t={nodeName:"#text",value:e.value,parentNode:null};return ss(e,t),t}function Xc(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return ss(e,t),t}function Jc(e,t){const n=t;let a=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(a=ws);const o=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&Kc.call(e.properties,i)){const u=Zc(a,i,e.properties[i]);u&&o.push(u)}}const c=a.space,d={nodeName:e.tagName,tagName:e.tagName,attrs:o,namespaceURI:Bt[c],childNodes:[],parentNode:null};return d.childNodes=la(e.children,d,a),ss(e,d),e.tagName==="template"&&e.content&&(d.content=Vc(e.content,a)),d}function Zc(e,t,n){const a=ia(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&a.boolean)return;Array.isArray(n)&&(n=a.commaSeparated?Ho(n):Uo(n));const o={name:a.attribute,value:n===!0?"":String(n)};if(a.space&&a.space!=="html"&&a.space!=="svg"){const i=o.name.indexOf(":");i<0?o.prefix="":(o.name=o.name.slice(i+1),o.prefix=a.attribute.slice(0,i)),o.namespace=Bt[a.space]}return o}function la(e,t,n){let a=-1;const o=[];if(e)for(;++a<e.length;){const i=cr(e[a],n);i.parentNode=t,o.push(i)}return o}function ss(e,t){const n=e.position;n&&n.start&&n.end&&(Ln(typeof n.start.offset=="number"),Ln(typeof n.end.offset=="number"),t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}const eu=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],tu=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),He="�";var m;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(m||(m={}));const st={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function ur(e){return e>=55296&&e<=57343}function su(e){return e>=56320&&e<=57343}function nu(e,t){return(e-55296)*1024+9216+t}function dr(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function pr(e){return e>=64976&&e<=65007||tu.has(e)}var O;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(O||(O={}));const au=65536;class iu{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=au,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:a,col:o,offset:i}=this,c=o+n,d=i+n;return{code:t,startLine:a,endLine:a,startCol:c,endCol:c,startOffset:d,endOffset:d}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if(su(n))return this.pos++,this._addGap(),nu(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,m.EOF;return this._err(O.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let a=0;a<t.length;a++)if((this.html.charCodeAt(this.pos+a)|32)!==t.charCodeAt(a))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,m.EOF;const a=this.html.charCodeAt(n);return a===m.CARRIAGE_RETURN?m.LINE_FEED:a}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,m.EOF;let t=this.html.charCodeAt(this.pos);return t===m.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,m.LINE_FEED):t===m.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,ur(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===m.LINE_FEED||t===m.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){dr(t)?this._err(O.controlCharacterInInputStream):pr(t)&&this._err(O.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var Ie;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(Ie||(Ie={}));function mr(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const ru=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),ou=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function lu(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=ou.get(e))!==null&&t!==void 0?t:e}var Xe;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(Xe||(Xe={}));const cu=32;var It;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(It||(It={}));function $n(e){return e>=Xe.ZERO&&e<=Xe.NINE}function uu(e){return e>=Xe.UPPER_A&&e<=Xe.UPPER_F||e>=Xe.LOWER_A&&e<=Xe.LOWER_F}function du(e){return e>=Xe.UPPER_A&&e<=Xe.UPPER_Z||e>=Xe.LOWER_A&&e<=Xe.LOWER_Z||$n(e)}function pu(e){return e===Xe.EQUALS||du(e)}var Qe;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(Qe||(Qe={}));var yt;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(yt||(yt={}));class mu{constructor(t,n,a){this.decodeTree=t,this.emitCodePoint=n,this.errors=a,this.state=Qe.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=yt.Strict}startEntity(t){this.decodeMode=t,this.state=Qe.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case Qe.EntityStart:return t.charCodeAt(n)===Xe.NUM?(this.state=Qe.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=Qe.NamedEntity,this.stateNamedEntity(t,n));case Qe.NumericStart:return this.stateNumericStart(t,n);case Qe.NumericDecimal:return this.stateNumericDecimal(t,n);case Qe.NumericHex:return this.stateNumericHex(t,n);case Qe.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|cu)===Xe.LOWER_X?(this.state=Qe.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=Qe.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,a,o){if(n!==a){const i=a-n;this.result=this.result*Math.pow(o,i)+Number.parseInt(t.substr(n,i),o),this.consumed+=i}}stateNumericHex(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if($n(o)||uu(o))n+=1;else return this.addToNumericResult(t,a,n,16),this.emitNumericEntity(o,3)}return this.addToNumericResult(t,a,n,16),-1}stateNumericDecimal(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if($n(o))n+=1;else return this.addToNumericResult(t,a,n,10),this.emitNumericEntity(o,2)}return this.addToNumericResult(t,a,n,10),-1}emitNumericEntity(t,n){var a;if(this.consumed<=n)return(a=this.errors)===null||a===void 0||a.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===Xe.SEMI)this.consumed+=1;else if(this.decodeMode===yt.Strict)return 0;return this.emitCodePoint(lu(this.result),this.consumed),this.errors&&(t!==Xe.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:a}=this;let o=a[this.treeIndex],i=(o&It.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const c=t.charCodeAt(n);if(this.treeIndex=hu(a,o,this.treeIndex+Math.max(1,i),c),this.treeIndex<0)return this.result===0||this.decodeMode===yt.Attribute&&(i===0||pu(c))?0:this.emitNotTerminatedNamedEntity();if(o=a[this.treeIndex],i=(o&It.VALUE_LENGTH)>>14,i!==0){if(c===Xe.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==yt.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:a}=this,o=(a[n]&It.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,o,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,a){const{decodeTree:o}=this;return this.emitCodePoint(n===1?o[t]&~It.VALUE_LENGTH:o[t+1],a),n===3&&this.emitCodePoint(o[t+2],a),a}end(){var t;switch(this.state){case Qe.NamedEntity:return this.result!==0&&(this.decodeMode!==yt.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Qe.NumericDecimal:return this.emitNumericEntity(0,2);case Qe.NumericHex:return this.emitNumericEntity(0,3);case Qe.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Qe.EntityStart:return 0}}}function hu(e,t,n,a){const o=(t&It.BRANCH_LENGTH)>>7,i=t&It.JUMP_TABLE;if(o===0)return i!==0&&a===i?n:-1;if(i){const u=a-i;return u<0||u>=o?-1:e[n+u]-1}let c=n,d=c+o-1;for(;c<=d;){const u=c+d>>>1,f=e[u];if(f<a)c=u+1;else if(f>a)d=u-1;else return e[u+o]}return-1}var z;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(z||(z={}));var Ut;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Ut||(Ut={}));var lt;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(lt||(lt={}));var w;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(w||(w={}));var r;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(r||(r={}));const fu=new Map([[w.A,r.A],[w.ADDRESS,r.ADDRESS],[w.ANNOTATION_XML,r.ANNOTATION_XML],[w.APPLET,r.APPLET],[w.AREA,r.AREA],[w.ARTICLE,r.ARTICLE],[w.ASIDE,r.ASIDE],[w.B,r.B],[w.BASE,r.BASE],[w.BASEFONT,r.BASEFONT],[w.BGSOUND,r.BGSOUND],[w.BIG,r.BIG],[w.BLOCKQUOTE,r.BLOCKQUOTE],[w.BODY,r.BODY],[w.BR,r.BR],[w.BUTTON,r.BUTTON],[w.CAPTION,r.CAPTION],[w.CENTER,r.CENTER],[w.CODE,r.CODE],[w.COL,r.COL],[w.COLGROUP,r.COLGROUP],[w.DD,r.DD],[w.DESC,r.DESC],[w.DETAILS,r.DETAILS],[w.DIALOG,r.DIALOG],[w.DIR,r.DIR],[w.DIV,r.DIV],[w.DL,r.DL],[w.DT,r.DT],[w.EM,r.EM],[w.EMBED,r.EMBED],[w.FIELDSET,r.FIELDSET],[w.FIGCAPTION,r.FIGCAPTION],[w.FIGURE,r.FIGURE],[w.FONT,r.FONT],[w.FOOTER,r.FOOTER],[w.FOREIGN_OBJECT,r.FOREIGN_OBJECT],[w.FORM,r.FORM],[w.FRAME,r.FRAME],[w.FRAMESET,r.FRAMESET],[w.H1,r.H1],[w.H2,r.H2],[w.H3,r.H3],[w.H4,r.H4],[w.H5,r.H5],[w.H6,r.H6],[w.HEAD,r.HEAD],[w.HEADER,r.HEADER],[w.HGROUP,r.HGROUP],[w.HR,r.HR],[w.HTML,r.HTML],[w.I,r.I],[w.IMG,r.IMG],[w.IMAGE,r.IMAGE],[w.INPUT,r.INPUT],[w.IFRAME,r.IFRAME],[w.KEYGEN,r.KEYGEN],[w.LABEL,r.LABEL],[w.LI,r.LI],[w.LINK,r.LINK],[w.LISTING,r.LISTING],[w.MAIN,r.MAIN],[w.MALIGNMARK,r.MALIGNMARK],[w.MARQUEE,r.MARQUEE],[w.MATH,r.MATH],[w.MENU,r.MENU],[w.META,r.META],[w.MGLYPH,r.MGLYPH],[w.MI,r.MI],[w.MO,r.MO],[w.MN,r.MN],[w.MS,r.MS],[w.MTEXT,r.MTEXT],[w.NAV,r.NAV],[w.NOBR,r.NOBR],[w.NOFRAMES,r.NOFRAMES],[w.NOEMBED,r.NOEMBED],[w.NOSCRIPT,r.NOSCRIPT],[w.OBJECT,r.OBJECT],[w.OL,r.OL],[w.OPTGROUP,r.OPTGROUP],[w.OPTION,r.OPTION],[w.P,r.P],[w.PARAM,r.PARAM],[w.PLAINTEXT,r.PLAINTEXT],[w.PRE,r.PRE],[w.RB,r.RB],[w.RP,r.RP],[w.RT,r.RT],[w.RTC,r.RTC],[w.RUBY,r.RUBY],[w.S,r.S],[w.SCRIPT,r.SCRIPT],[w.SEARCH,r.SEARCH],[w.SECTION,r.SECTION],[w.SELECT,r.SELECT],[w.SOURCE,r.SOURCE],[w.SMALL,r.SMALL],[w.SPAN,r.SPAN],[w.STRIKE,r.STRIKE],[w.STRONG,r.STRONG],[w.STYLE,r.STYLE],[w.SUB,r.SUB],[w.SUMMARY,r.SUMMARY],[w.SUP,r.SUP],[w.TABLE,r.TABLE],[w.TBODY,r.TBODY],[w.TEMPLATE,r.TEMPLATE],[w.TEXTAREA,r.TEXTAREA],[w.TFOOT,r.TFOOT],[w.TD,r.TD],[w.TH,r.TH],[w.THEAD,r.THEAD],[w.TITLE,r.TITLE],[w.TR,r.TR],[w.TRACK,r.TRACK],[w.TT,r.TT],[w.U,r.U],[w.UL,r.UL],[w.SVG,r.SVG],[w.VAR,r.VAR],[w.WBR,r.WBR],[w.XMP,r.XMP]]);function ns(e){var t;return(t=fu.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const Z=r,gu={[z.HTML]:new Set([Z.ADDRESS,Z.APPLET,Z.AREA,Z.ARTICLE,Z.ASIDE,Z.BASE,Z.BASEFONT,Z.BGSOUND,Z.BLOCKQUOTE,Z.BODY,Z.BR,Z.BUTTON,Z.CAPTION,Z.CENTER,Z.COL,Z.COLGROUP,Z.DD,Z.DETAILS,Z.DIR,Z.DIV,Z.DL,Z.DT,Z.EMBED,Z.FIELDSET,Z.FIGCAPTION,Z.FIGURE,Z.FOOTER,Z.FORM,Z.FRAME,Z.FRAMESET,Z.H1,Z.H2,Z.H3,Z.H4,Z.H5,Z.H6,Z.HEAD,Z.HEADER,Z.HGROUP,Z.HR,Z.HTML,Z.IFRAME,Z.IMG,Z.INPUT,Z.LI,Z.LINK,Z.LISTING,Z.MAIN,Z.MARQUEE,Z.MENU,Z.META,Z.NAV,Z.NOEMBED,Z.NOFRAMES,Z.NOSCRIPT,Z.OBJECT,Z.OL,Z.P,Z.PARAM,Z.PLAINTEXT,Z.PRE,Z.SCRIPT,Z.SECTION,Z.SELECT,Z.SOURCE,Z.STYLE,Z.SUMMARY,Z.TABLE,Z.TBODY,Z.TD,Z.TEMPLATE,Z.TEXTAREA,Z.TFOOT,Z.TH,Z.THEAD,Z.TITLE,Z.TR,Z.TRACK,Z.UL,Z.WBR,Z.XMP]),[z.MATHML]:new Set([Z.MI,Z.MO,Z.MN,Z.MS,Z.MTEXT,Z.ANNOTATION_XML]),[z.SVG]:new Set([Z.TITLE,Z.FOREIGN_OBJECT,Z.DESC]),[z.XLINK]:new Set,[z.XML]:new Set,[z.XMLNS]:new Set},Wn=new Set([Z.H1,Z.H2,Z.H3,Z.H4,Z.H5,Z.H6]);w.STYLE,w.SCRIPT,w.XMP,w.IFRAME,w.NOEMBED,w.NOFRAMES,w.PLAINTEXT;var h;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(h||(h={}));const $e={DATA:h.DATA,RCDATA:h.RCDATA,RAWTEXT:h.RAWTEXT,SCRIPT_DATA:h.SCRIPT_DATA,PLAINTEXT:h.PLAINTEXT,CDATA_SECTION:h.CDATA_SECTION};function bu(e){return e>=m.DIGIT_0&&e<=m.DIGIT_9}function hs(e){return e>=m.LATIN_CAPITAL_A&&e<=m.LATIN_CAPITAL_Z}function Eu(e){return e>=m.LATIN_SMALL_A&&e<=m.LATIN_SMALL_Z}function St(e){return Eu(e)||hs(e)}function Qa(e){return St(e)||bu(e)}function Ds(e){return e+32}function hr(e){return e===m.SPACE||e===m.LINE_FEED||e===m.TABULATION||e===m.FORM_FEED}function Xa(e){return hr(e)||e===m.SOLIDUS||e===m.GREATER_THAN_SIGN}function Tu(e){return e===m.NULL?O.nullCharacterReference:e>1114111?O.characterReferenceOutsideUnicodeRange:ur(e)?O.surrogateCharacterReference:pr(e)?O.noncharacterCharacterReference:dr(e)||e===m.CARRIAGE_RETURN?O.controlCharacterReference:null}class xu{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=h.DATA,this.returnState=h.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new iu(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new mu(ru,(a,o)=>{this.preprocessor.pos=this.entityStartPos+o-1,this._flushCodePointConsumedAsCharacterReference(a)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(O.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:a=>{this._err(O.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+a)},validateNumericCharacterReference:a=>{const o=Tu(a);o&&this._err(o,1)}}:void 0)}_err(t,n=0){var a,o;(o=(a=this.handler).onParseError)===null||o===void 0||o.call(a,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t?.())}write(t,n,a){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||a?.()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n<t;n++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,n){return this.preprocessor.startsWith(t,n)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:Ie.START_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Ie.END_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:Ie.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:Ie.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,n){this.currentCharacterToken={type:t,chars:n,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,n;const a=this.currentToken;if(mr(a,this.currentAttr.name)===null){if(a.attrs.push(this.currentAttr),a.location&&this.currentLocation){const o=(t=(n=a.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);o[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(O.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=ns(t.tagName),t.type===Ie.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(O.endTagWithAttributes),t.selfClosing&&this._err(O.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case Ie.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case Ie.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case Ie.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:Ie.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=hr(t)?Ie.WHITESPACE_CHARACTER:t===m.NULL?Ie.NULL_CHARACTER:Ie.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(Ie.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=h.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?yt.Attribute:yt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===h.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case h.DATA:{this._stateData(t);break}case h.RCDATA:{this._stateRcdata(t);break}case h.RAWTEXT:{this._stateRawtext(t);break}case h.SCRIPT_DATA:{this._stateScriptData(t);break}case h.PLAINTEXT:{this._statePlaintext(t);break}case h.TAG_OPEN:{this._stateTagOpen(t);break}case h.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case h.TAG_NAME:{this._stateTagName(t);break}case h.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case h.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case h.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case h.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case h.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case h.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case h.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case h.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case h.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case h.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case h.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case h.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case h.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case h.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case h.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case h.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case h.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case h.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case h.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case h.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case h.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case h.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case h.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case h.BOGUS_COMMENT:{this._stateBogusComment(t);break}case h.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case h.COMMENT_START:{this._stateCommentStart(t);break}case h.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case h.COMMENT:{this._stateComment(t);break}case h.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case h.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case h.COMMENT_END:{this._stateCommentEnd(t);break}case h.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case h.DOCTYPE:{this._stateDoctype(t);break}case h.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case h.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case h.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case h.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case h.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case h.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case h.CDATA_SECTION:{this._stateCdataSection(t);break}case h.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case h.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case h.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case h.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case m.LESS_THAN_SIGN:{this.state=h.TAG_OPEN;break}case m.AMPERSAND:{this._startCharacterReference();break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitCodePoint(t);break}case m.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case m.AMPERSAND:{this._startCharacterReference();break}case m.LESS_THAN_SIGN:{this.state=h.RCDATA_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case m.LESS_THAN_SIGN:{this.state=h.RAWTEXT_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(St(t))this._createStartTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case m.EXCLAMATION_MARK:{this.state=h.MARKUP_DECLARATION_OPEN;break}case m.SOLIDUS:{this.state=h.END_TAG_OPEN;break}case m.QUESTION_MARK:{this._err(O.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t);break}case m.EOF:{this._err(O.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=h.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(St(t))this._createEndTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case m.GREATER_THAN_SIGN:{this._err(O.missingEndTagName),this.state=h.DATA;break}case m.EOF:{this._err(O.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.BEFORE_ATTRIBUTE_NAME;break}case m.SOLIDUS:{this.state=h.SELF_CLOSING_START_TAG;break}case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.tagName+=He;break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(hs(t)?Ds(t):t)}}_stateRcdataLessThanSign(t){t===m.SOLIDUS?this.state=h.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){St(t)?(this.state=h.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=h.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const n=this.currentToken;switch(n.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=h.BEFORE_ATTRIBUTE_NAME,!1;case m.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=h.SELF_CLOSING_START_TAG,!1;case m.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=h.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===m.SOLIDUS?this.state=h.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){St(t)?(this.state=h.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case m.SOLIDUS:{this.state=h.SCRIPT_DATA_END_TAG_OPEN;break}case m.EXCLAMATION_MARK:{this.state=h.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=h.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){St(t)?(this.state=h.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===m.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===m.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case m.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case m.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case m.HYPHEN_MINUS:{this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case m.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===m.SOLIDUS?this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:St(t)?(this._emitChars("<"),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){St(t)?(this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&Xa(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case m.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case m.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case m.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case m.HYPHEN_MINUS:{this._emitChars("-");break}case m.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case m.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(He);break}case m.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===m.SOLIDUS?(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&Xa(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.SOLIDUS:case m.GREATER_THAN_SIGN:case m.EOF:{this.state=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case m.EQUALS_SIGN:{this._err(O.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=h.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=h.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:case m.SOLIDUS:case m.GREATER_THAN_SIGN:case m.EOF:{this._leaveAttrName(),this.state=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case m.EQUALS_SIGN:{this._leaveAttrName(),this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case m.QUOTATION_MARK:case m.APOSTROPHE:case m.LESS_THAN_SIGN:{this._err(O.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.name+=He;break}default:this.currentAttr.name+=String.fromCodePoint(hs(t)?Ds(t):t)}}_stateAfterAttributeName(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.SOLIDUS:{this.state=h.SELF_CLOSING_START_TAG;break}case m.EQUALS_SIGN:{this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=h.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.QUOTATION_MARK:{this.state=h.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case m.APOSTROPHE:{this.state=h.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case m.GREATER_THAN_SIGN:{this._err(O.missingAttributeValue),this.state=h.DATA,this.emitCurrentTagToken();break}default:this.state=h.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case m.QUOTATION_MARK:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case m.AMPERSAND:{this._startCharacterReference();break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=He;break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case m.APOSTROPHE:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case m.AMPERSAND:{this._startCharacterReference();break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=He;break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this._leaveAttrValue(),this.state=h.BEFORE_ATTRIBUTE_NAME;break}case m.AMPERSAND:{this._startCharacterReference();break}case m.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case m.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=He;break}case m.QUOTATION_MARK:case m.APOSTROPHE:case m.LESS_THAN_SIGN:case m.EQUALS_SIGN:case m.GRAVE_ACCENT:{this._err(O.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this._leaveAttrValue(),this.state=h.BEFORE_ATTRIBUTE_NAME;break}case m.SOLIDUS:{this._leaveAttrValue(),this.state=h.SELF_CLOSING_START_TAG;break}case m.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBetweenAttributes),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case m.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=h.DATA,this.emitCurrentTagToken();break}case m.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.unexpectedSolidusInTag),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case m.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.data+=He;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(st.DASH_DASH,!0)?(this._createCommentToken(st.DASH_DASH.length+1),this.state=h.COMMENT_START):this._consumeSequenceIfMatch(st.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(st.DOCTYPE.length+1),this.state=h.DOCTYPE):this._consumeSequenceIfMatch(st.CDATA_START,!0)?this.inForeignNode?this.state=h.CDATA_SECTION:(this._err(O.cdataInHtmlContent),this._createCommentToken(st.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=h.BOGUS_COMMENT):this._ensureHibernation()||(this._err(O.incorrectlyOpenedComment),this._createCommentToken(2),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case m.HYPHEN_MINUS:{this.state=h.COMMENT_START_DASH;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case m.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA,this.emitCurrentComment(n);break}case m.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case m.HYPHEN_MINUS:{this.state=h.COMMENT_END_DASH;break}case m.LESS_THAN_SIGN:{n.data+="<",this.state=h.COMMENT_LESS_THAN_SIGN;break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.data+=He;break}case m.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case m.EXCLAMATION_MARK:{n.data+="!",this.state=h.COMMENT_LESS_THAN_SIGN_BANG;break}case m.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===m.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=h.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===m.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=h.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==m.GREATER_THAN_SIGN&&t!==m.EOF&&this._err(O.nestedComment),this.state=h.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case m.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case m.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case m.EXCLAMATION_MARK:{this.state=h.COMMENT_END_BANG;break}case m.HYPHEN_MINUS:{n.data+="-";break}case m.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case m.HYPHEN_MINUS:{n.data+="--!",this.state=h.COMMENT_END_DASH;break}case m.GREATER_THAN_SIGN:{this._err(O.incorrectlyClosedComment),this.state=h.DATA,this.emitCurrentComment(n);break}case m.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=h.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.BEFORE_DOCTYPE_NAME;break}case m.GREATER_THAN_SIGN:{this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case m.EOF:{this._err(O.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBeforeDoctypeName),this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(hs(t))this._createDoctypeToken(String.fromCharCode(Ds(t))),this.state=h.DOCTYPE_NAME;else switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.NULL:{this._err(O.unexpectedNullCharacter),this._createDoctypeToken(He),this.state=h.DOCTYPE_NAME;break}case m.GREATER_THAN_SIGN:{this._err(O.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=h.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.AFTER_DOCTYPE_NAME;break}case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.name+=He;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(hs(t)?Ds(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(st.PUBLIC,!1)?this.state=h.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(st.SYSTEM,!1)?this.state=h.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(O.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case m.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case m.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.QUOTATION_MARK:{n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case m.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case m.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=He;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case m.APOSTROPHE:{this.state=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=He;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case m.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.QUOTATION_MARK:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.QUOTATION_MARK:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:{this.state=h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case m.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case m.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.QUOTATION_MARK:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case m.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case m.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case m.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=He;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case m.APOSTROPHE:{this.state=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case m.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=He;break}case m.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case m.SPACE:case m.LINE_FEED:case m.TABULATION:case m.FORM_FEED:break;case m.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case m.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=h.DATA;break}case m.NULL:{this._err(O.unexpectedNullCharacter);break}case m.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case m.RIGHT_SQUARE_BRACKET:{this.state=h.CDATA_SECTION_BRACKET;break}case m.EOF:{this._err(O.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===m.RIGHT_SQUARE_BRACKET?this.state=h.CDATA_SECTION_END:(this._emitChars("]"),this.state=h.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case m.GREATER_THAN_SIGN:{this.state=h.DATA;break}case m.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=h.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(m.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Qa(this.preprocessor.peek(1))?h.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){Qa(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===m.SEMICOLON&&this._err(O.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const fr=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),Ja=new Set([...fr,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),Js=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),yu=new Set([...Js,r.OL,r.UL]),Nu=new Set([...Js,r.BUTTON]),Za=new Set([r.ANNOTATION_XML,r.MI,r.MN,r.MO,r.MS,r.MTEXT]),ei=new Set([r.DESC,r.FOREIGN_OBJECT,r.TITLE]),ku=new Set([r.TR,r.TEMPLATE,r.HTML]),Cu=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),vu=new Set([r.TABLE,r.TEMPLATE,r.HTML]),_u=new Set([r.TD,r.TH]);class Su{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,a){this.treeAdapter=n,this.handler=a,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=r.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===r.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===z.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,n){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=n,this.currentTagId=n,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,n,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const a=this._indexOf(t);this.items[a]=n,a===this.stackTop&&(this.current=n)}insertAfter(t,n,a){const o=this._indexOf(t)+1;this.items.splice(o,0,n),this.tagIDs.splice(o,0,a),this.stackTop++,o===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,o===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==z.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop<t)}}popUntilElementPopped(t){const n=this._indexOf(t);this.shortenToLength(Math.max(n,0))}popUntilPopped(t,n){const a=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(a,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Wn,z.HTML)}popUntilTableCellPopped(){this.popUntilPopped(_u,z.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let a=this.stackTop;a>=0;a--)if(t.has(this.tagIDs[a])&&this.treeAdapter.getNamespaceURI(this.items[a])===n)return a;return-1}clearBackTo(t,n){const a=this._indexOfTagNames(t,n);this.shortenToLength(a+1)}clearBackToTableContext(){this.clearBackTo(vu,z.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Cu,z.HTML)}clearBackToTableRowContext(){this.clearBackTo(ku,z.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===r.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===r.HTML}hasInDynamicScope(t,n){for(let a=this.stackTop;a>=0;a--){const o=this.tagIDs[a];switch(this.treeAdapter.getNamespaceURI(this.items[a])){case z.HTML:{if(o===t)return!0;if(n.has(o))return!1;break}case z.SVG:{if(ei.has(o))return!1;break}case z.MATHML:{if(Za.has(o))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,Js)}hasInListItemScope(t){return this.hasInDynamicScope(t,yu)}hasInButtonScope(t){return this.hasInDynamicScope(t,Nu)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case z.HTML:{if(Wn.has(n))return!0;if(Js.has(n))return!1;break}case z.SVG:{if(ei.has(n))return!1;break}case z.MATHML:{if(Za.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===z.HTML)switch(this.tagIDs[n]){case t:return!0;case r.TABLE:case r.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===z.HTML)switch(this.tagIDs[t]){case r.TBODY:case r.THEAD:case r.TFOOT:return!0;case r.TABLE:case r.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===z.HTML)switch(this.tagIDs[n]){case t:return!0;case r.OPTION:case r.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&fr.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Ja.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Ja.has(this.currentTagId);)this.pop()}}const kn=3;var bt;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(bt||(bt={}));const ti={type:bt.Marker};class Au{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const a=[],o=n.length,i=this.treeAdapter.getTagName(t),c=this.treeAdapter.getNamespaceURI(t);for(let d=0;d<this.entries.length;d++){const u=this.entries[d];if(u.type===bt.Marker)break;const{element:f}=u;if(this.treeAdapter.getTagName(f)===i&&this.treeAdapter.getNamespaceURI(f)===c){const g=this.treeAdapter.getAttrList(f);g.length===o&&a.push({idx:d,attrs:g})}}return a}_ensureNoahArkCondition(t){if(this.entries.length<kn)return;const n=this.treeAdapter.getAttrList(t),a=this._getNoahArkConditionCandidates(t,n);if(a.length<kn)return;const o=new Map(n.map(c=>[c.name,c.value]));let i=0;for(let c=0;c<a.length;c++){const d=a[c];d.attrs.every(u=>o.get(u.name)===u.value)&&(i+=1,i>=kn&&this.entries.splice(d.idx,1))}}insertMarker(){this.entries.unshift(ti)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:bt.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const a=this.entries.indexOf(this.bookmark);this.entries.splice(a,0,{type:bt.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(ti);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(a=>a.type===bt.Marker||this.treeAdapter.getTagName(a.element)===t);return n&&n.type===bt.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===bt.Element&&n.element===t)}}const At={createDocument(){return{nodeName:"#document",mode:lt.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const a=e.childNodes.indexOf(n);e.childNodes.splice(a,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,a){const o=e.childNodes.find(i=>i.nodeName==="#documentType");if(o)o.name=t,o.publicId=n,o.systemId=a;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:a,parentNode:null};At.appendChild(e,i)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(At.isTextNode(n)){n.value+=t;return}}At.appendChild(e,At.createTextNode(t))},insertTextBefore(e,t,n){const a=e.childNodes[e.childNodes.indexOf(n)-1];a&&At.isTextNode(a)?a.value+=t:At.insertBefore(e,At.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(a=>a.name));for(let a=0;a<t.length;a++)n.has(t[a].name)||e.attrs.push(t[a])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},gr="html",wu="about:legacy-compat",Iu="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",br=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],ju=[...br,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Lu=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Er=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Ru=[...Er,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function si(e,t){return t.some(n=>e.startsWith(n))}function Du(e){return e.name===gr&&e.publicId===null&&(e.systemId===null||e.systemId===wu)}function Pu(e){if(e.name!==gr)return lt.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===Iu)return lt.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),Lu.has(n))return lt.QUIRKS;let a=t===null?ju:br;if(si(n,a))return lt.QUIRKS;if(a=t===null?Er:Ru,si(n,a))return lt.LIMITED_QUIRKS}return lt.NO_QUIRKS}const ni={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},Ou="definitionurl",Mu="definitionURL",Bu=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),Fu=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:z.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:z.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:z.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:z.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:z.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:z.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:z.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:z.XML}],["xml:space",{prefix:"xml",name:"space",namespace:z.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:z.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:z.XMLNS}]]),Hu=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),Uu=new Set([r.B,r.BIG,r.BLOCKQUOTE,r.BODY,r.BR,r.CENTER,r.CODE,r.DD,r.DIV,r.DL,r.DT,r.EM,r.EMBED,r.H1,r.H2,r.H3,r.H4,r.H5,r.H6,r.HEAD,r.HR,r.I,r.IMG,r.LI,r.LISTING,r.MENU,r.META,r.NOBR,r.OL,r.P,r.PRE,r.RUBY,r.S,r.SMALL,r.SPAN,r.STRONG,r.STRIKE,r.SUB,r.SUP,r.TABLE,r.TT,r.U,r.UL,r.VAR]);function qu(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:a})=>a===Ut.COLOR||a===Ut.SIZE||a===Ut.FACE)||Uu.has(t)}function Tr(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===Ou){e.attrs[t].name=Mu;break}}function xr(e){for(let t=0;t<e.attrs.length;t++){const n=Bu.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function ca(e){for(let t=0;t<e.attrs.length;t++){const n=Fu.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function $u(e){const t=Hu.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=ns(e.tagName))}function Wu(e,t){return t===z.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function Ku(e,t,n){if(t===z.MATHML&&e===r.ANNOTATION_XML){for(let a=0;a<n.length;a++)if(n[a].name===Ut.ENCODING){const o=n[a].value.toLowerCase();return o===ni.TEXT_HTML||o===ni.APPLICATION_XML}}return t===z.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function Yu(e,t,n,a){return(!a||a===z.HTML)&&Ku(e,t,n)||(!a||a===z.MATHML)&&Wu(e,t)}const Gu="hidden",Vu=8,zu=3;var E;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(E||(E={}));const Qu={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},yr=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),ai={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:At,onParseError:null};class ii{constructor(t,n,a=null,o=null){this.fragmentContext=a,this.scriptHandler=o,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...ai,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=n??this.treeAdapter.createDocument(),this.tokenizer=new xu(this.options,this),this.activeFormattingElements=new Au(this.treeAdapter),this.fragmentContextID=a?ns(this.treeAdapter.getTagName(a)):r.UNKNOWN,this._setContextModes(a??this.document,this.fragmentContextID),this.openElements=new Su(this.document,this.treeAdapter,this)}static parse(t,n){const a=new this(n);return a.tokenizer.write(t,!0),a.document}static getFragmentParser(t,n){const a={...ai,...n};t??(t=a.treeAdapter.createElement(w.TEMPLATE,z.HTML,[]));const o=a.treeAdapter.createElement("documentmock",z.HTML,[]),i=new this(a,o,t);return i.fragmentContextID===r.TEMPLATE&&i.tmplInsertionModeStack.unshift(E.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,a){var o;if(!this.onParseError)return;const i=(o=t.location)!==null&&o!==void 0?o:Qu,c={code:n,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:a?i.startLine:i.endLine,endCol:a?i.startCol:i.endCol,endOffset:a?i.startOffset:i.endOffset};this.onParseError(c)}onItemPush(t,n,a){var o,i;(i=(o=this.treeAdapter).onItemPush)===null||i===void 0||i.call(o,t),a&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var a,o;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(o=(a=this.treeAdapter).onItemPop)===null||o===void 0||o.call(a,t,this.openElements.current),n){let i,c;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,c=this.fragmentContextID):{current:i,currentTagId:c}=this.openElements,this._setContextModes(i,c)}}_setContextModes(t,n){const a=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===z.HTML;this.currentNotInHTML=!a,this.tokenizer.inForeignNode=!a&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,z.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.IN_BODY,this.tokenizer.state=$e.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===w.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==z.HTML))switch(this.fragmentContextID){case r.TITLE:case r.TEXTAREA:{this.tokenizer.state=$e.RCDATA;break}case r.STYLE:case r.XMP:case r.IFRAME:case r.NOEMBED:case r.NOFRAMES:case r.NOSCRIPT:{this.tokenizer.state=$e.RAWTEXT;break}case r.SCRIPT:{this.tokenizer.state=$e.SCRIPT_DATA;break}case r.PLAINTEXT:{this.tokenizer.state=$e.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",a=t.publicId||"",o=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,a,o),t.location){const c=this.treeAdapter.getChildNodes(this.document).find(d=>this.treeAdapter.isDocumentTypeNode(d));c&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const a=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,a)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const a=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(a??this.document,t)}}_appendElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location)}_insertElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID)}_insertFakeElement(t,n){const a=this.treeAdapter.createElement(t,z.HTML,[]);this._attachElementToTree(a,null),this.openElements.push(a,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,z.HTML,t.attrs),a=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,a),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(w.HTML,z.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,r.HTML)}_appendCommentNode(t,n){const a=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,a),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_insertCharacters(t){let n,a;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:a}=this._findFosterParentingLocation(),a?this.treeAdapter.insertTextBefore(n,t.chars,a):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const o=this.treeAdapter.getChildNodes(n),i=a?o.lastIndexOf(a):o.length,c=o[i-1];if(this.treeAdapter.getNodeSourceCodeLocation(c)){const{endLine:u,endCol:f,endOffset:g}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(c,{endLine:u,endCol:f,endOffset:g})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}_adoptNodes(t,n){for(let a=this.treeAdapter.getFirstChild(t);a;a=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(a),this.treeAdapter.appendChild(n,a)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const a=n.location,o=this.treeAdapter.getTagName(t),i=n.type===Ie.END_TAG&&o===n.tagName?{endTag:{...a},endLine:a.endLine,endCol:a.endCol,endOffset:a.endOffset}:{endLine:a.startLine,endCol:a.startCol,endOffset:a.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,i)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,a;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,a=this.fragmentContextID):{current:n,currentTagId:a}=this.openElements,t.tagID===r.SVG&&this.treeAdapter.getTagName(n)===w.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===z.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===r.MGLYPH||t.tagID===r.MALIGNMARK)&&a!==void 0&&!this._isIntegrationPoint(a,n,z.HTML)}_processToken(t){switch(t.type){case Ie.CHARACTER:{this.onCharacter(t);break}case Ie.NULL_CHARACTER:{this.onNullCharacter(t);break}case Ie.COMMENT:{this.onComment(t);break}case Ie.DOCTYPE:{this.onDoctype(t);break}case Ie.START_TAG:{this._processStartTag(t);break}case Ie.END_TAG:{this.onEndTag(t);break}case Ie.EOF:{this.onEof(t);break}case Ie.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,a){const o=this.treeAdapter.getNamespaceURI(n),i=this.treeAdapter.getAttrList(n);return Yu(t,o,i,a)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(o=>o.type===bt.Marker||this.openElements.contains(o.element)),a=n===-1?t-1:n-1;for(let o=a;o>=0;o--){const i=this.activeFormattingElements.entries[o];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=E.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(r.P),this.openElements.popUntilTagNamePopped(r.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case r.TR:{this.insertionMode=E.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=E.IN_TABLE;return}case r.BODY:{this.insertionMode=E.IN_BODY;return}case r.FRAMESET:{this.insertionMode=E.IN_FRAMESET;return}case r.SELECT:{this._resetInsertionModeForSelect(t);return}case r.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case r.HTML:{this.insertionMode=this.headElement?E.AFTER_HEAD:E.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=E.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const a=this.openElements.tagIDs[n];if(a===r.TEMPLATE)break;if(a===r.TABLE){this.insertionMode=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(t){return yr.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case r.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===z.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case r.TABLE:{const a=this.treeAdapter.getParentNode(n);return a?{parent:a,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const a=this.treeAdapter.getNamespaceURI(t);return gu[a].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){_p(this,t);return}switch(this.insertionMode){case E.INITIAL:{ls(this,t);break}case E.BEFORE_HTML:{gs(this,t);break}case E.BEFORE_HEAD:{bs(this,t);break}case E.IN_HEAD:{Es(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Ts(this,t);break}case E.AFTER_HEAD:{xs(this,t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{kr(this,t);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{wr(this,t);break}case E.IN_COLUMN_GROUP:{Zs(this,t);break}case E.AFTER_BODY:{en(this,t);break}case E.AFTER_AFTER_BODY:{Hs(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){vp(this,t);return}switch(this.insertionMode){case E.INITIAL:{ls(this,t);break}case E.BEFORE_HTML:{gs(this,t);break}case E.BEFORE_HEAD:{bs(this,t);break}case E.IN_HEAD:{Es(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Ts(this,t);break}case E.AFTER_HEAD:{xs(this,t);break}case E.TEXT:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_COLUMN_GROUP:{Zs(this,t);break}case E.AFTER_BODY:{en(this,t);break}case E.AFTER_AFTER_BODY:{Hs(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){Kn(this,t);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{Kn(this,t);break}case E.IN_TABLE_TEXT:{cs(this,t);break}case E.AFTER_BODY:{nd(this,t);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{ad(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{id(this,t);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(t,O.misplacedDoctype);break}case E.IN_TABLE_TEXT:{cs(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,O.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Sp(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{ls(this,t);break}case E.BEFORE_HTML:{rd(this,t);break}case E.BEFORE_HEAD:{ld(this,t);break}case E.IN_HEAD:{ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{dd(this,t);break}case E.AFTER_HEAD:{md(this,t);break}case E.IN_BODY:{Ze(this,t);break}case E.IN_TABLE:{Zt(this,t);break}case E.IN_TABLE_TEXT:{cs(this,t);break}case E.IN_CAPTION:{cp(this,t);break}case E.IN_COLUMN_GROUP:{pa(this,t);break}case E.IN_TABLE_BODY:{un(this,t);break}case E.IN_ROW:{dn(this,t);break}case E.IN_CELL:{pp(this,t);break}case E.IN_SELECT:{Lr(this,t);break}case E.IN_SELECT_IN_TABLE:{hp(this,t);break}case E.IN_TEMPLATE:{gp(this,t);break}case E.AFTER_BODY:{Ep(this,t);break}case E.IN_FRAMESET:{Tp(this,t);break}case E.AFTER_FRAMESET:{yp(this,t);break}case E.AFTER_AFTER_BODY:{kp(this,t);break}case E.AFTER_AFTER_FRAMESET:{Cp(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?Ap(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{ls(this,t);break}case E.BEFORE_HTML:{od(this,t);break}case E.BEFORE_HEAD:{cd(this,t);break}case E.IN_HEAD:{ud(this,t);break}case E.IN_HEAD_NO_SCRIPT:{pd(this,t);break}case E.AFTER_HEAD:{hd(this,t);break}case E.IN_BODY:{cn(this,t);break}case E.TEXT:{Zd(this,t);break}case E.IN_TABLE:{Ss(this,t);break}case E.IN_TABLE_TEXT:{cs(this,t);break}case E.IN_CAPTION:{up(this,t);break}case E.IN_COLUMN_GROUP:{dp(this,t);break}case E.IN_TABLE_BODY:{Yn(this,t);break}case E.IN_ROW:{jr(this,t);break}case E.IN_CELL:{mp(this,t);break}case E.IN_SELECT:{Rr(this,t);break}case E.IN_SELECT_IN_TABLE:{fp(this,t);break}case E.IN_TEMPLATE:{bp(this,t);break}case E.AFTER_BODY:{Pr(this,t);break}case E.IN_FRAMESET:{xp(this,t);break}case E.AFTER_FRAMESET:{Np(this,t);break}case E.AFTER_AFTER_BODY:{Hs(this,t);break}}}onEof(t){switch(this.insertionMode){case E.INITIAL:{ls(this,t);break}case E.BEFORE_HTML:{gs(this,t);break}case E.BEFORE_HEAD:{bs(this,t);break}case E.IN_HEAD:{Es(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Ts(this,t);break}case E.AFTER_HEAD:{xs(this,t);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{Sr(this,t);break}case E.TEXT:{ep(this,t);break}case E.IN_TABLE_TEXT:{cs(this,t);break}case E.IN_TEMPLATE:{Dr(this,t);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{da(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===m.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Nr(this,t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{Ar(this,t);break}}}}function Xu(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):_r(e,t),n}function Ju(e,t){let n=null,a=e.openElements.stackTop;for(;a>=0;a--){const o=e.openElements.items[a];if(o===t.element)break;e._isSpecialElement(o,e.openElements.tagIDs[a])&&(n=o)}return n||(e.openElements.shortenToLength(Math.max(a,0)),e.activeFormattingElements.removeEntry(t)),n}function Zu(e,t,n){let a=t,o=e.openElements.getCommonAncestor(t);for(let i=0,c=o;c!==n;i++,c=o){o=e.openElements.getCommonAncestor(c);const d=e.activeFormattingElements.getElementEntry(c),u=d&&i>=zu;!d||u?(u&&e.activeFormattingElements.removeEntry(d),e.openElements.remove(c)):(c=ed(e,d),a===t&&(e.activeFormattingElements.bookmark=d),e.treeAdapter.detachNode(a),e.treeAdapter.appendChild(c,a),a=c)}return a}function ed(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),a=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,a),t.element=a,a}function td(e,t,n){const a=e.treeAdapter.getTagName(t),o=ns(a);if(e._isElementCausesFosterParenting(o))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);o===r.TEMPLATE&&i===z.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function sd(e,t,n){const a=e.treeAdapter.getNamespaceURI(n.element),{token:o}=n,i=e.treeAdapter.createElement(o.tagName,a,o.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,o),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,o.tagID)}function ua(e,t){for(let n=0;n<Vu;n++){const a=Xu(e,t);if(!a)break;const o=Ju(e,a);if(!o)break;e.activeFormattingElements.bookmark=a;const i=Zu(e,o,a.element),c=e.openElements.getCommonAncestor(a.element);e.treeAdapter.detachNode(i),c&&td(e,c,i),sd(e,o,a)}}function Kn(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function nd(e,t){e._appendCommentNode(t,e.openElements.items[0])}function ad(e,t){e._appendCommentNode(t,e.document)}function da(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let a=e.openElements.stackTop;a>=n;a--)e._setEndLocation(e.openElements.items[a],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const a=e.openElements.items[0],o=e.treeAdapter.getNodeSourceCodeLocation(a);if(o&&!o.endTag&&(e._setEndLocation(a,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],c=e.treeAdapter.getNodeSourceCodeLocation(i);c&&!c.endTag&&e._setEndLocation(i,t)}}}}function id(e,t){e._setDocumentType(t);const n=t.forceQuirks?lt.QUIRKS:Pu(t);Du(t)||e._err(t,O.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=E.BEFORE_HTML}function ls(e,t){e._err(t,O.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,lt.QUIRKS),e.insertionMode=E.BEFORE_HTML,e._processToken(t)}function rd(e,t){t.tagID===r.HTML?(e._insertElement(t,z.HTML),e.insertionMode=E.BEFORE_HEAD):gs(e,t)}function od(e,t){const n=t.tagID;(n===r.HTML||n===r.HEAD||n===r.BODY||n===r.BR)&&gs(e,t)}function gs(e,t){e._insertFakeRootElement(),e.insertionMode=E.BEFORE_HEAD,e._processToken(t)}function ld(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.HEAD:{e._insertElement(t,z.HTML),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD;break}default:bs(e,t)}}function cd(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?bs(e,t):e._err(t,O.endTagWithoutMatchingOpenElement)}function bs(e,t){e._insertFakeElement(w.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD,e._processToken(t)}function ht(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:{e._appendElement(t,z.HTML),t.ackSelfClosing=!0;break}case r.TITLE:{e._switchToTextParsing(t,$e.RCDATA);break}case r.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,$e.RAWTEXT):(e._insertElement(t,z.HTML),e.insertionMode=E.IN_HEAD_NO_SCRIPT);break}case r.NOFRAMES:case r.STYLE:{e._switchToTextParsing(t,$e.RAWTEXT);break}case r.SCRIPT:{e._switchToTextParsing(t,$e.SCRIPT_DATA);break}case r.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=E.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:Es(e,t)}}function ud(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=E.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{Es(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function Wt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,O.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,O.endTagWithoutMatchingOpenElement)}function Es(e,t){e.openElements.pop(),e.insertionMode=E.AFTER_HEAD,e._processToken(t)}function dd(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASEFONT:case r.BGSOUND:case r.HEAD:case r.LINK:case r.META:case r.NOFRAMES:case r.STYLE:{ht(e,t);break}case r.NOSCRIPT:{e._err(t,O.nestedNoscriptInHead);break}default:Ts(e,t)}}function pd(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=E.IN_HEAD;break}case r.BR:{Ts(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function Ts(e,t){const n=t.type===Ie.EOF?O.openElementsLeftAfterEof:O.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=E.IN_HEAD,e._processToken(t)}function md(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BODY:{e._insertElement(t,z.HTML),e.framesetOk=!1,e.insertionMode=E.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,z.HTML),e.insertionMode=E.IN_FRAMESET;break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{e._err(t,O.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),ht(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:xs(e,t)}}function hd(e,t){switch(t.tagID){case r.BODY:case r.HTML:case r.BR:{xs(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function xs(e,t){e._insertFakeElement(w.BODY,r.BODY),e.insertionMode=E.IN_BODY,ln(e,t)}function ln(e,t){switch(t.type){case Ie.CHARACTER:{kr(e,t);break}case Ie.WHITESPACE_CHARACTER:{Nr(e,t);break}case Ie.COMMENT:{Kn(e,t);break}case Ie.START_TAG:{Ze(e,t);break}case Ie.END_TAG:{cn(e,t);break}case Ie.EOF:{Sr(e,t);break}}}function Nr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function kr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function fd(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function gd(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function bd(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_FRAMESET)}function Ed(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML)}function Td(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Wn.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,z.HTML)}function xd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function yd(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML),n||(e.formElement=e.openElements.current))}function Nd(e,t){e.framesetOk=!1;const n=t.tagID;for(let a=e.openElements.stackTop;a>=0;a--){const o=e.openElements.tagIDs[a];if(n===r.LI&&o===r.LI||(n===r.DD||n===r.DT)&&(o===r.DD||o===r.DT)){e.openElements.generateImpliedEndTagsWithExclusion(o),e.openElements.popUntilTagNamePopped(o);break}if(o!==r.ADDRESS&&o!==r.DIV&&o!==r.P&&e._isSpecialElement(e.openElements.items[a],o))break}e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML)}function kd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML),e.tokenizer.state=$e.PLAINTEXT}function Cd(e,t){e.openElements.hasInScope(r.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML),e.framesetOk=!1}function vd(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(w.A);n&&(ua(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function _d(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Sd(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(ua(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Ad(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function wd(e,t){e.treeAdapter.getDocumentMode(e.document)!==lt.QUIRKS&&e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,z.HTML),e.framesetOk=!1,e.insertionMode=E.IN_TABLE}function Cr(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function vr(e){const t=mr(e,Ut.TYPE);return t!=null&&t.toLowerCase()===Gu}function Id(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,z.HTML),vr(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function jd(e,t){e._appendElement(t,z.HTML),t.ackSelfClosing=!0}function Ld(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Rd(e,t){t.tagName=w.IMG,t.tagID=r.IMG,Cr(e,t)}function Dd(e,t){e._insertElement(t,z.HTML),e.skipNextNewLine=!0,e.tokenizer.state=$e.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=E.TEXT}function Pd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,$e.RAWTEXT)}function Od(e,t){e.framesetOk=!1,e._switchToTextParsing(t,$e.RAWTEXT)}function ri(e,t){e._switchToTextParsing(t,$e.RAWTEXT)}function Md(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===E.IN_TABLE||e.insertionMode===E.IN_CAPTION||e.insertionMode===E.IN_TABLE_BODY||e.insertionMode===E.IN_ROW||e.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function Bd(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML)}function Fd(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,z.HTML)}function Hd(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,z.HTML)}function Ud(e,t){e._reconstructActiveFormattingElements(),Tr(t),ca(t),t.selfClosing?e._appendElement(t,z.MATHML):e._insertElement(t,z.MATHML),t.ackSelfClosing=!0}function qd(e,t){e._reconstructActiveFormattingElements(),xr(t),ca(t),t.selfClosing?e._appendElement(t,z.SVG):e._insertElement(t,z.SVG),t.ackSelfClosing=!0}function oi(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,z.HTML)}function Ze(e,t){switch(t.tagID){case r.I:case r.S:case r.B:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.SMALL:case r.STRIKE:case r.STRONG:{_d(e,t);break}case r.A:{vd(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Td(e,t);break}case r.P:case r.DL:case r.OL:case r.UL:case r.DIV:case r.DIR:case r.NAV:case r.MAIN:case r.MENU:case r.ASIDE:case r.CENTER:case r.FIGURE:case r.FOOTER:case r.HEADER:case r.HGROUP:case r.DIALOG:case r.DETAILS:case r.ADDRESS:case r.ARTICLE:case r.SEARCH:case r.SECTION:case r.SUMMARY:case r.FIELDSET:case r.BLOCKQUOTE:case r.FIGCAPTION:{Ed(e,t);break}case r.LI:case r.DD:case r.DT:{Nd(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{Cr(e,t);break}case r.HR:{Ld(e,t);break}case r.RB:case r.RTC:{Fd(e,t);break}case r.RT:case r.RP:{Hd(e,t);break}case r.PRE:case r.LISTING:{xd(e,t);break}case r.XMP:{Pd(e,t);break}case r.SVG:{qd(e,t);break}case r.HTML:{fd(e,t);break}case r.BASE:case r.LINK:case r.META:case r.STYLE:case r.TITLE:case r.SCRIPT:case r.BGSOUND:case r.BASEFONT:case r.TEMPLATE:{ht(e,t);break}case r.BODY:{gd(e,t);break}case r.FORM:{yd(e,t);break}case r.NOBR:{Sd(e,t);break}case r.MATH:{Ud(e,t);break}case r.TABLE:{wd(e,t);break}case r.INPUT:{Id(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{jd(e,t);break}case r.IMAGE:{Rd(e,t);break}case r.BUTTON:{Cd(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Ad(e,t);break}case r.IFRAME:{Od(e,t);break}case r.SELECT:{Md(e,t);break}case r.OPTION:case r.OPTGROUP:{Bd(e,t);break}case r.NOEMBED:case r.NOFRAMES:{ri(e,t);break}case r.FRAMESET:{bd(e,t);break}case r.TEXTAREA:{Dd(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?ri(e,t):oi(e,t);break}case r.PLAINTEXT:{kd(e,t);break}case r.COL:case r.TH:case r.TD:case r.TR:case r.HEAD:case r.FRAME:case r.TBODY:case r.TFOOT:case r.THEAD:case r.CAPTION:case r.COLGROUP:break;default:oi(e,t)}}function $d(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=E.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Wd(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=E.AFTER_BODY,Pr(e,t))}function Kd(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function Yd(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(r.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(r.FORM):n&&e.openElements.remove(n))}function Gd(e){e.openElements.hasInButtonScope(r.P)||e._insertFakeElement(w.P,r.P),e._closePElement()}function Vd(e){e.openElements.hasInListItemScope(r.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(r.LI),e.openElements.popUntilTagNamePopped(r.LI))}function zd(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Qd(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function Xd(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function Jd(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(w.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function _r(e,t){const n=t.tagName,a=t.tagID;for(let o=e.openElements.stackTop;o>0;o--){const i=e.openElements.items[o],c=e.openElements.tagIDs[o];if(a===c&&(a!==r.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.stackTop>=o&&e.openElements.shortenToLength(o);break}if(e._isSpecialElement(i,c))break}}function cn(e,t){switch(t.tagID){case r.A:case r.B:case r.I:case r.S:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.NOBR:case r.SMALL:case r.STRIKE:case r.STRONG:{ua(e,t);break}case r.P:{Gd(e);break}case r.DL:case r.UL:case r.OL:case r.DIR:case r.DIV:case r.NAV:case r.PRE:case r.MAIN:case r.MENU:case r.ASIDE:case r.BUTTON:case r.CENTER:case r.FIGURE:case r.FOOTER:case r.HEADER:case r.HGROUP:case r.DIALOG:case r.ADDRESS:case r.ARTICLE:case r.DETAILS:case r.SEARCH:case r.SECTION:case r.SUMMARY:case r.LISTING:case r.FIELDSET:case r.BLOCKQUOTE:case r.FIGCAPTION:{Kd(e,t);break}case r.LI:{Vd(e);break}case r.DD:case r.DT:{zd(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Qd(e);break}case r.BR:{Jd(e);break}case r.BODY:{$d(e,t);break}case r.HTML:{Wd(e,t);break}case r.FORM:{Yd(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Xd(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:_r(e,t)}}function Sr(e,t){e.tmplInsertionModeStack.length>0?Dr(e,t):da(e,t)}function Zd(e,t){var n;t.tagID===r.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function ep(e,t){e._err(t,O.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Cn(e,t){if(e.openElements.currentTagId!==void 0&&yr.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=E.IN_TABLE_TEXT,t.type){case Ie.CHARACTER:{wr(e,t);break}case Ie.WHITESPACE_CHARACTER:{Ar(e,t);break}}else Is(e,t)}function tp(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_CAPTION}function sp(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_COLUMN_GROUP}function np(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(w.COLGROUP,r.COLGROUP),e.insertionMode=E.IN_COLUMN_GROUP,pa(e,t)}function ap(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_TABLE_BODY}function ip(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(w.TBODY,r.TBODY),e.insertionMode=E.IN_TABLE_BODY,un(e,t)}function rp(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function op(e,t){vr(t)?e._appendElement(t,z.HTML):Is(e,t),t.ackSelfClosing=!0}function lp(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,z.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Zt(e,t){switch(t.tagID){case r.TD:case r.TH:case r.TR:{ip(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{ht(e,t);break}case r.COL:{np(e,t);break}case r.FORM:{lp(e,t);break}case r.TABLE:{rp(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{ap(e,t);break}case r.INPUT:{op(e,t);break}case r.CAPTION:{tp(e,t);break}case r.COLGROUP:{sp(e,t);break}default:Is(e,t)}}function Ss(e,t){switch(t.tagID){case r.TABLE:{e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode());break}case r.TEMPLATE:{Wt(e,t);break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:Is(e,t)}}function Is(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ln(e,t),e.fosterParentingEnabled=n}function Ar(e,t){e.pendingCharacterTokens.push(t)}function wr(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function cs(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Is(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Ir=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function cp(e,t){const n=t.tagID;Ir.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,Zt(e,t)):Ze(e,t)}function up(e,t){const n=t.tagID;switch(n){case r.CAPTION:case r.TABLE:{e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,n===r.TABLE&&Ss(e,t));break}case r.BODY:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:cn(e,t)}}function pa(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.COL:{e._appendElement(t,z.HTML),t.ackSelfClosing=!0;break}case r.TEMPLATE:{ht(e,t);break}default:Zs(e,t)}}function dp(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case r.TEMPLATE:{Wt(e,t);break}case r.COL:break;default:Zs(e,t)}}function Zs(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE,e._processToken(t))}function un(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(w.TR,r.TR),e.insertionMode=E.IN_ROW,dn(e,t);break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,Zt(e,t));break}default:Zt(e,t)}}function Yn(e,t){const n=t.tagID;switch(t.tagID){case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,Ss(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TD:case r.TH:case r.TR:break;default:Ss(e,t)}}function dn(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,z.HTML),e.insertionMode=E.IN_CELL,e.activeFormattingElements.insertMarker();break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,un(e,t));break}default:Zt(e,t)}}function jr(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Yn(e,t));break}case r.TBODY:case r.TFOOT:case r.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(r.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Yn(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TD:case r.TH:break;default:Ss(e,t)}}function pp(e,t){const n=t.tagID;Ir.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),dn(e,t)):Ze(e,t)}function mp(e,t){const n=t.tagID;switch(n){case r.TD:case r.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),jr(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:cn(e,t)}}function Lr(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.OPTION:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._insertElement(t,z.HTML);break}case r.OPTGROUP:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._insertElement(t,z.HTML);break}case r.HR:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._appendElement(t,z.HTML),t.ackSelfClosing=!0;break}case r.INPUT:case r.KEYGEN:case r.TEXTAREA:case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),t.tagID!==r.SELECT&&e._processStartTag(t));break}case r.SCRIPT:case r.TEMPLATE:{ht(e,t);break}}}function Rr(e,t){switch(t.tagID){case r.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===r.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===r.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop();break}case r.OPTION:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop();break}case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode());break}case r.TEMPLATE:{Wt(e,t);break}}}function hp(e,t){const n=t.tagID;n===r.CAPTION||n===r.TABLE||n===r.TBODY||n===r.TFOOT||n===r.THEAD||n===r.TR||n===r.TD||n===r.TH?(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Lr(e,t)}function fp(e,t){const n=t.tagID;n===r.CAPTION||n===r.TABLE||n===r.TBODY||n===r.TFOOT||n===r.THEAD||n===r.TR||n===r.TD||n===r.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Rr(e,t)}function gp(e,t){switch(t.tagID){case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{ht(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=E.IN_TABLE,e.insertionMode=E.IN_TABLE,Zt(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,e.insertionMode=E.IN_COLUMN_GROUP,pa(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,e.insertionMode=E.IN_TABLE_BODY,un(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=E.IN_ROW,e.insertionMode=E.IN_ROW,dn(e,t);break}default:e.tmplInsertionModeStack[0]=E.IN_BODY,e.insertionMode=E.IN_BODY,Ze(e,t)}}function bp(e,t){t.tagID===r.TEMPLATE&&Wt(e,t)}function Dr(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):da(e,t)}function Ep(e,t){t.tagID===r.HTML?Ze(e,t):en(e,t)}function Pr(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=E.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===r.HTML){e._setEndLocation(e.openElements.items[0],t);const a=e.openElements.items[1];a&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(a))===null||n===void 0)&&n.endTag)&&e._setEndLocation(a,t)}}else en(e,t)}function en(e,t){e.insertionMode=E.IN_BODY,ln(e,t)}function Tp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.FRAMESET:{e._insertElement(t,z.HTML);break}case r.FRAME:{e._appendElement(t,z.HTML),t.ackSelfClosing=!0;break}case r.NOFRAMES:{ht(e,t);break}}}function xp(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=E.AFTER_FRAMESET))}function yp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function Np(e,t){t.tagID===r.HTML&&(e.insertionMode=E.AFTER_AFTER_FRAMESET)}function kp(e,t){t.tagID===r.HTML?Ze(e,t):Hs(e,t)}function Hs(e,t){e.insertionMode=E.IN_BODY,ln(e,t)}function Cp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function vp(e,t){t.chars=He,e._insertCharacters(t)}function _p(e,t){e._insertCharacters(t),e.framesetOk=!1}function Or(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==z.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Sp(e,t){if(qu(t))Or(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),a=e.treeAdapter.getNamespaceURI(n);a===z.MATHML?Tr(t):a===z.SVG&&($u(t),xr(t)),ca(t),t.selfClosing?e._appendElement(t,a):e._insertElement(t,a),t.ackSelfClosing=!0}}function Ap(e,t){if(t.tagID===r.P||t.tagID===r.BR){Or(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const a=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(a)===z.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(a);if(o.toLowerCase()===t.tagName){t.tagName=o,e.openElements.shortenToLength(n);break}}}w.AREA,w.BASE,w.BASEFONT,w.BGSOUND,w.BR,w.COL,w.EMBED,w.FRAME,w.HR,w.IMG,w.INPUT,w.KEYGEN,w.LINK,w.META,w.PARAM,w.SOURCE,w.TRACK,w.WBR;const wp=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,Ip=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),li={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function Mr(e,t){const n=Hp(e),a=Di("type",{handlers:{root:jp,element:Lp,text:Rp,comment:Fr,doctype:Dp,raw:Op},unknown:Mp}),o={parser:n?new ii(li):ii.getFragmentParser(void 0,li),handle(d){a(d,o)},stitches:!1,options:t||{}};a(e,o),as(o,qt());const i=n?o.parser.document:o.parser.getFragment(),c=Uc(i,{file:o.options.file});return o.stitches&&qo(c,"comment",function(d,u,f){const g=d;if(g.value.stitch&&f&&u!==void 0){const b=f.children;return b[u]=g.value.stitch,u}}),c.type==="root"&&c.children.length===1&&c.children[0].type===e.type?c.children[0]:c}function Br(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function jp(e,t){Br(e.children,t)}function Lp(e,t){Bp(e,t),Br(e.children,t),Fp(e,t)}function Rp(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Ie.CHARACTER,chars:e.value,location:js(e)};as(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Dp(e,t){const n={type:Ie.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:js(e)};as(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Pp(e,t){t.stitches=!0;const n=Up(e);if("children"in e&&"children"in n){const a=Mr({type:"root",children:e.children},t.options);n.children=a.children}Fr({type:"comment",value:{stitch:n}},t)}function Fr(e,t){const n=e.value,a={type:Ie.COMMENT,data:n,location:js(e)};as(t,qt(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function Op(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,Hr(t,qt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(wp,"&lt;$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function Mp(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))Pp(n,t);else{let a="";throw Ip.has(n.type)&&(a=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+a)}}function as(e,t){Hr(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=$e.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function Hr(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function Bp(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===$e.PLAINTEXT)return;as(t,qt(e));const a=t.parser.openElements.current;let o="namespaceURI"in a?a.namespaceURI:Bt.html;o===Bt.html&&n==="svg"&&(o=Bt.svg);const i=Yc({...e,children:[]},{space:o===Bt.svg?"svg":"html"}),c={type:Ie.START_TAG,tagName:n,tagID:ns(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:js(e)};t.parser.currentToken=c,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function Fp(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&eu.includes(n)||t.parser.tokenizer.state===$e.PLAINTEXT)return;as(t,Pi(e));const a={type:Ie.END_TAG,tagName:n,tagID:ns(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:js(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===$e.RCDATA||t.parser.tokenizer.state===$e.RAWTEXT||t.parser.tokenizer.state===$e.SCRIPT_DATA)&&(t.parser.tokenizer.state=$e.DATA)}function Hp(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function js(e){const t=qt(e)||{line:void 0,column:void 0,offset:void 0},n=Pi(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function Up(e){return"children"in e?ka({...e,children:[]}):ka(e)}function qp(e){return function(t,n){return Mr(t,{...e,file:n})}}const tn=l.memo(function({text:t}){const n=Ae(),[a,o]=l.useState(!1);return t?s.jsx("button",{type:"button",className:"copy-btn",title:n("copy"),onClick:()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1200)})},children:a?s.jsx(Et,{}):s.jsx(kt,{})}):null});function $p(e){const t=a=>{if(typeof a=="string"||typeof a=="number"){const o=String(a);return o===""?[[]]:o.split(`
309
- `).map(i=>i===""?[]:[i])}if(Array.isArray(a)){let o=[];for(const i of a){const c=t(i);if(o.length===0)o=c;else{const d=c[0]??[];o[o.length-1].push(...d),o.push(...c.slice(1))}}return o}if(a&&typeof a=="object"&&"props"in a){const o=a,i=o.props?.children,c={...o.props,children:void 0},d=i==null?[]:t(i);return d.length===0?[[l.createElement(o.type,c)]]:d.map(u=>[l.createElement(o.type,c,...u)])}return[[a]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Gn(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Gn).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Gn(t?.children)}return""}function Wp(e){const t=Array.isArray(e)?e[0]:e;return!t||typeof t!="object"||!("props"in t)?null:t}function Kp(e){const n=Wp(e)?.props?.className;if(typeof n!="string")return null;const a=n.match(/(?:^|\s)language-([A-Za-z0-9_+\-]+)(?:\s|$)/);return a?a[1]:null}const ci="pi-web-ui:plugin-data";let ys=new Map,Ns=new Map,Qt=new Set,Vn=-1,Ur=0;const zn=new Set;function Yp(){Ur++;for(const e of zn)e()}function Gp(e){return zn.add(e),()=>{zn.delete(e)}}function ui(){return Ur}let qr=null;function Vp(e){qr=e}function zp(e,t){t!==Vn&&(Vn=t,Ns.clear(),Qt.clear());const n=new Map;for(const o of e)if(!(o.error||!o.renderers))for(const i of o.renderers)n.has(i)||n.set(i,o.id);let a=n.size!==ys.size;if(!a){for(const[o,i]of n)if(ys.get(o)!==i){a=!0;break}}if(a){for(const o of Ns.keys())n.has(o)||Ns.delete(o);for(const o of Qt)n.has(o)||Qt.delete(o);ys=n,Yp()}}async function Qp(e,t){const n=ys.get(e);if(!n)return null;let a=Ns.get(e);if(!a&&!Qt.has(e))try{const c=(await import(it(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Vn}`))).default?.renderers?.[e];typeof c=="function"?(a={pluginId:n,renderer:c},Ns.set(e,a)):(Qt.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(i){Qt.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,i)}if(!a)return null;const o={pluginId:a.pluginId,send:i=>{qr?.({type:"plugin_message",pluginId:a.pluginId,payload:i})},onData:i=>{const c=d=>{const u=d.detail;u.pluginId===a.pluginId&&i(u.payload)};return window.addEventListener(ci,c),()=>window.removeEventListener(ci,c)}};try{const i=await a.renderer(t,o);return i instanceof HTMLElement?i:null}catch(i){return console.error(`[plugin:${a.pluginId}] renderer("${e}") 执行失败:`,i),null}}function Xp(e){return ys.has(e)}const Qn="pi-web-ui:theme",$r="dark",di="theme-stylesheet",jt="pi-web-ui:theme-change";function Wr(){try{const e=localStorage.getItem(Qn);if(e&&e!==$r)return e}catch{}return null}function Jp(e){try{e?localStorage.setItem(Qn,e):localStorage.removeItem(Qn)}catch{}}function Kr(e){let t=document.getElementById(di);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(jt));return}t||(t=document.createElement("link"),t.id=di,t.rel="stylesheet",document.head.appendChild(t)),t.href=it(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(jt))}async function Zp(){try{const e=await fetch(Dt(it("/api/themes")));if(!e.ok)return[];const t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function em(){const[e,t]=l.useState([]),[n,a]=l.useState(()=>Wr());return l.useEffect(()=>{let i=!1;return Zp().then(c=>{i||t(c)}),()=>{i=!0}},[]),l.useEffect(()=>{Kr(n),Jp(n)},[n]),{themes:e,theme:n,switchTheme:i=>a(i===$r?null:i)}}function yf(){const e=getComputedStyle(document.documentElement),t=(n,a)=>e.getPropertyValue(n).trim()||a;return{background:t("--term-bg","#0b0d12"),foreground:t("--term-fg","#e6e8ef"),cursor:t("--term-cursor","#8b5cf6"),cursorAccent:t("--term-cursor-accent","#0b0d12"),selectionBackground:t("--term-selection","rgba(139, 92, 246, 0.35)"),black:t("--term-black","#1a1d26"),red:t("--term-red","#f87171"),green:t("--term-green","#34d399"),yellow:t("--term-yellow","#fbbf24"),blue:t("--term-blue","#60a5fa"),magenta:t("--term-magenta","#c084fc"),cyan:t("--term-cyan","#22d3ee"),white:t("--term-white","#e6e8ef"),brightBlack:t("--term-bright-black","#6b7284"),brightRed:t("--term-bright-red","#f87171"),brightGreen:t("--term-bright-green","#34d399"),brightYellow:t("--term-bright-yellow","#fbbf24"),brightBlue:t("--term-bright-blue","#60a5fa"),brightMagenta:t("--term-bright-magenta","#c084fc"),brightCyan:t("--term-bright-cyan","#22d3ee"),brightWhite:t("--term-bright-white","#ffffff")}}function tm({lang:e,code:t}){const n=l.useRef(null),a=l.useRef(null),o=l.useRef(0),i=l.useRef(new WeakMap),[c,d]=l.useState(null);return l.useEffect(()=>{const u=()=>{const f=++o.current,g=a.current;g&&(g.dispatchEvent(new CustomEvent(jt)),i.current.set(g,f))};return window.addEventListener(jt,u),()=>window.removeEventListener(jt,u)},[]),l.useEffect(()=>{let u=!1;const f=o.current;return d(null),Qp(e,t).then(g=>{u||(g&&i.current.set(g,f),d(g))}),()=>{u=!0}},[e,t]),l.useEffect(()=>{a.current=c;const u=n.current;return u&&(u.replaceChildren(),c&&(u.appendChild(c),(i.current.get(c)??o.current)<o.current&&(c.dispatchEvent(new CustomEvent(jt)),i.current.set(c,o.current)))),()=>{a.current===c&&(a.current=null)}},[c]),c?s.jsx("div",{className:"plugin-fence",ref:n}):s.jsxs("div",{className:"codeblock",children:[s.jsx(tn,{text:t}),s.jsx("pre",{children:s.jsx("code",{children:t})})]})}const sm=[Oi],nm=[Oi,Ic],pi=[[Wo,{detect:!0,ignoreMissing:!0}]];function ma({text:e,rawHtml:t=!1,hardBreaks:n=!1}){const a=t?[qp,...pi]:pi;return s.jsx($o,{remarkPlugins:n?nm:sm,rehypePlugins:a,components:{pre:am},children:e})}const at=l.memo(function({text:t,rawHtml:n=!1,hardBreaks:a=!1}){return s.jsx("div",{className:"md",children:s.jsx(ma,{text:t,rawHtml:n,hardBreaks:a})})});function am({children:e,...t}){l.useSyncExternalStore(Gp,ui,ui);const n=Kp(e);return n&&Xp(n)?s.jsx(tm,{lang:n,code:Gn(e)}):s.jsx(im,{children:e,...t})}function im({children:e,...t}){const n=e&&typeof e=="object"&&"props"in e?e.props?.children:e,a=$p(n),o=a.length>1,i=o?`${String(a.length).length+1}ch`:void 0;return s.jsxs("div",{className:"codeblock",children:[s.jsx(tn,{text:Xn(e)}),s.jsx("pre",{...t,children:a.map((c,d)=>s.jsxs("div",{className:"code-line",children:[o&&s.jsx("span",{className:"code-num",style:i?{width:i}:void 0,children:d+1}),s.jsx("code",{className:"code-line-body hljs",children:c})]},d))})]})}function Xn(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Xn).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Xn(t?.children)}return""}const rm=/^\s{0,3}(`{3,}|~{3,})/,om=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function vn(e){return e.trim()===""}function mi(e){const t=rm.exec(e);return t?t[1]:null}function lm(e){const t=e.split(`
310
- `),n=[];let a=[],o=null;for(let i=0;i<t.length;i++){const c=t[i];if(o!==null){const u=mi(c);u&&u[0]===o[0]&&u.length>=o.length&&(o=null),a.push(c);continue}const d=mi(c);if(d&&!vn(c)){o=d,a.push(c);continue}if(vn(c)){let u=i;for(;u<t.length&&vn(t[u]);)u++;if(!(u<t.length&&om.test(t[u]))&&a.length>0){n.push(a.join(`
311
- `)),a=[];continue}a.push(c);continue}a.push(c)}return{frozen:n,active:a.join(`
312
- `),inFence:o!==null}}const cm=l.memo(function({text:t}){return s.jsx(ma,{text:t})}),hi=200;function um({text:e,inFence:t}){const[n,a]=l.useState(e),o=l.useRef(0),i=l.useRef(null);return l.useEffect(()=>{if(t)return;const c=Date.now()-o.current,d=()=>{o.current=Date.now(),a(e)};if(c>=hi){d();return}return i.current=setTimeout(d,hi-c),()=>{i.current&&clearTimeout(i.current)}},[e,t]),t?s.jsx("div",{className:"codeblock",children:s.jsx("pre",{children:s.jsx("code",{children:e})})}):s.jsx(ma,{text:n})}const dm=l.memo(function({text:t}){const{frozen:n,active:a,inFence:o}=l.useMemo(()=>lm(t),[t]);return s.jsxs("div",{className:"md",children:[n.map((i,c)=>s.jsx(cm,{text:i},c)),a.length>0&&s.jsx(um,{text:a,inFence:o},n.length)]})});function pm({thinking:e,streaming:t,wrap:n=!0,forceOpen:a=!1}){const o=Ae(),[i,c]=l.useState(null),d=i??n,u=d||a,f=t?e.trimEnd().slice(-80):e.split(`
313
- `)[0].slice(0,80),[g,b]=l.useState(!1),x=()=>{navigator.clipboard.writeText(e),b(!0),window.setTimeout(()=>b(!1),1200)};return s.jsxs("div",{className:`thinking ${u?"open":""} ${t?"live":""}`,children:[s.jsxs("div",{className:"chead thinking-head",role:"button",tabIndex:0,"aria-expanded":u,title:o(u?"collapseMsg":"expandMsg"),onClick:()=>c(!d),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(!d))},children:[s.jsx("button",{type:"button",className:"chead-toggle thinking-toggle",title:o(u?"collapseMsg":"expandMsg"),"aria-label":o(u?"collapseMsg":"expandMsg"),"aria-expanded":u,onClick:N=>{N.stopPropagation(),c(!d)},children:u?s.jsx(Pt,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon thinking-icon",children:s.jsx(vs,{})}),s.jsx("span",{className:"chead-title thinking-label",children:t&&u?s.jsxs("span",{className:"thinking-live-label",children:[o("thinkingNow"),s.jsx("span",{className:"dots"})]}):u?o("thinking"):o("thinkingPreview",{preview:f})}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy thinking-copy",title:o(g?"copied":"copyMessage"),"aria-label":o("copyMessage"),onClick:N=>{N.stopPropagation(),x()},children:g?s.jsx(ts,{}):s.jsx(kt,{})})]}),u&&s.jsx("div",{className:"thinking-body",children:e})]})}const mm={bash:"$",read:"📄",write:"✍️",edit:"✏️",edit_soft:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function hm(e){return mm[e]??"🛠"}const fm=l.memo(function({block:t,view:n,onKillBash:a,wrap:o=!0,forceOpen:i=!1}){const c=Ae(),[d,u]=l.useState(null),f=d??o,g=f||i,[b,x]=l.useState(!1),N=!n.result&&n.streaming&&!n.status,S=t.name==="bash"&&N,M=n.result!==void 0,G=!n.result&&!!n.status,K=n.result?.isError??n.status?.isError??!1,R=(n.result?n.result.content.map(A=>A.type==="text"?A.text:"").join(""):n.liveOutput??"").replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(A,J)=>c("liveOutputOmitted",{n:J})),U=K?"err":M?"ok":N||G?"run":"idle";let H=c(K?"error":M?"done":N?"running":G?"toolDoneWaitingModel":"toolQueued");const V=G&&n.status?.durationMs!==void 0?bm(n.status.durationMs):"";G&&V&&(H=`${H} · ${V}`);const se=G&&n.status?.exitCode!==void 0?`exit ${n.status.exitCode}`:"",X=()=>{t.argumentsText&&(navigator.clipboard.writeText(t.argumentsText),x(!0),setTimeout(()=>x(!1),1200))};return s.jsxs("div",{className:`toolcall ${U}`,children:[s.jsxs("div",{className:"chead toolcall-head",role:"button",tabIndex:0,"aria-expanded":g,title:c(g?"collapseMsg":"expandMsg"),onClick:()=>u(!f),onKeyDown:A=>{A.target===A.currentTarget&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),u(!f))},children:[s.jsx("button",{type:"button",className:"chead-toggle toolcall-toggle",title:c(g?"collapseMsg":"expandMsg"),"aria-label":c(g?"collapseMsg":"expandMsg"),"aria-expanded":g,onClick:A=>{A.stopPropagation(),u(!f)},children:g?s.jsx(Pt,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon toolcall-icon",children:hm(t.name)}),s.jsx("span",{className:"chead-title toolcall-name",children:t.name}),s.jsx("span",{className:"toolcall-status",title:se?`${H} · ${se}`:H,"aria-label":se?`${H} · ${se}`:H,children:K?s.jsx(Je,{}):M?s.jsx(Et,{}):N?s.jsx(bl,{}):G?s.jsx(Pn,{}):s.jsx(dl,{})}),s.jsx("span",{className:"toolcall-spacer"}),S&&a&&s.jsxs("button",{type:"button",className:"toolcall-kill",title:c("stopBashTip"),onClick:A=>{A.stopPropagation(),a?.()},children:[s.jsx(Ys,{}),s.jsx("span",{children:c("stopBash")})]}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy",title:c("copyArgs"),onClick:A=>{A.stopPropagation(),X()},children:b?s.jsx(ts,{}):s.jsx(kt,{})})]}),g&&s.jsxs("div",{className:"toolcall-body",children:[t.argumentsText&&s.jsx("div",{className:"toolcall-args",children:t.name==="bash"&&t.argumentsText.startsWith("{")?s.jsx(gm,{args:t.argumentsText}):s.jsx("pre",{children:t.argumentsText})}),R.length>0&&s.jsxs("div",{className:"toolcall-output",children:[s.jsxs("div",{className:"toolcall-output-label",children:[c(K?"errorOutput":"output"),(N||G)&&s.jsx("span",{className:"cursor"})]}),s.jsx("pre",{children:R})]}),N&&R.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",c("waitingOutput")]}),G&&R.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",c("waitingModel")]})]})]})});function gm({args:e}){let t=null;try{t=JSON.parse(e)}catch{return s.jsx("pre",{children:e})}return typeof t.command!="string"?s.jsx("pre",{children:e}):s.jsxs("div",{className:"termline",children:[s.jsx(Xt,{className:"termline-icon"}),s.jsx("code",{children:t.command}),typeof t.timeout=="number"&&s.jsxs("span",{className:"termline-timeout",children:["⏱ ",t.timeout,"s"]})]})}function bm(e){if(e===void 0)return"";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),a=Math.round(t%60);return`${n}m ${String(a).padStart(2,"0")}s`}const Em=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function ha(e){const t=e.match(Em);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}const Tm=1568,xm=2*1024*1024;function Nt(e){return e.startsWith("image/")&&e!=="image/svg+xml"&&e!=="image/svg"}async function fa(e){if(!e.type.startsWith("image/"))return null;let t;try{t=await createImageBitmap(e,{imageOrientation:"from-image"})}catch{return null}try{const n=Math.min(1,Tm/Math.max(t.width,t.height)),a=Math.max(1,Math.round(t.width*n)),o=Math.max(1,Math.round(t.height*n)),i=e.type==="image/jpeg"||e.type==="image/jpg"?[["image/jpeg",.85],["image/jpeg",.6],["image/webp",.8]]:[["image/png",1],["image/jpeg",.85],["image/jpeg",.6]];let c=null;for(const[d,u]of i){const f=document.createElement("canvas");f.width=a,f.height=o;const g=f.getContext("2d");if(!g)continue;d!=="image/png"&&(g.fillStyle="#ffffff",g.fillRect(0,0,a,o)),g.drawImage(t,0,0,a,o);const b=f.toDataURL(d,u),x=b.match(/^data:([^;]+);base64,/),N=x?x[1]:d,S=b.replace(/^data:[^;]*;base64,/,""),M=Math.floor(S.length*3/4);if(c={data:S,mimeType:N,name:e.name,size:M},M<=xm)return c}return c}finally{t.close()}}const ym=20*1024*1024;function es(e){return e.type==="text"&&typeof e.text=="string"?e:null}function Yr(e){return e.type==="thinking"&&typeof e.thinking=="string"?e:null}function Gr(e){return e.type==="toolCall"&&typeof e.id=="string"&&typeof e.name=="string"?e:null}function Vr(e){return e.type==="image"&&typeof e.dataUrl=="string"?e:null}function zr(e){return e.type==="bash"&&typeof e.command=="string"?e:null}function Nm(e){return e.imageData?"image":e.uploadPath?"upload":e.fileData?"file":"path"}function km(e,t){if(e.imageData)return t("attachImage",{name:e.name??"image"});if(e.uploadPath)return t("attachFile",{name:e.name??e.uploadPath});if(e.fileData)return t("attachFile",{name:e.name??"file"});const n=e.path.split("/").pop()??e.path;return e.mode==="lines"&&e.lines?t("attachLines",{path:n,start:e.lines.start,end:e.lines.end}):e.mode==="reference"?t("refOnly",{path:n}):t("attachContent",{path:n})}const fi=l.memo(function({message:t,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onEdit:d,onKillBash:u,onRetry:f,onCollapse:g,questionAttachments:b,qnIndex:x,qnActive:N,onJump:S,thinkingWrap:M,toolsWrap:G,searchActive:K,autoExpand:y}){const R=Ae(),[U,H]=l.useState(!1),[V,se]=l.useState(""),[X,A]=l.useState([]),[J,k]=l.useState(!1),[le,Y]=l.useState(null),me=F=>{Y(F),window.setTimeout(()=>Y(ie=>ie===F?null:ie),4e3)};if(t.role==="toolResult")return null;if(t.role==="compactionSummary")return s.jsx(_m,{message:t,forceOpen:K,autoExpand:y});const he=t.role==="custom"&&t.customType==="file",I=t.content.map(F=>es(F)?.text??"").filter(Boolean).join(`
314
- `),j=t.role==="user"?ha(I):null,D=j?j.userMessage??`skill:${j.name}`:I.split(`
315
- `).join(" ").trim(),re=i&&c&&t.content.length===0,te=t.role==="user"&&!i&&!re&&!!d,ge=async F=>{const ie=[];for(const oe of F){if(!Nt(oe.type))continue;const de=await fa(oe);de&&ie.push({path:"",imageData:de.data,mimeType:de.mimeType,name:de.name})}ie.length>0&&A(oe=>[...oe,...ie])},C=async F=>{if(F.size>ym){me(R("fileTooLarge",{name:F.name,size:20}));return}let ie;try{ie=(await new Promise((de,Te)=>{const we=new FileReader;we.onload=()=>de(we.result),we.onerror=()=>Te(we.error??new Error("read failed")),we.readAsDataURL(F)})).replace(/^data:[^;]*;base64,/,"")}catch{me(R("fileLoadFailed",{name:F.name}));return}A(oe=>[...oe,{path:"",fileData:ie,name:F.name,size:F.size,mimeType:F.type||void 0}])},Q=async F=>{const ie=[];for(const oe of F)Nt(oe.type)?ie.push(oe):C(oe);ie.length>0&&await ge(ie)},P=()=>{se(j?`/skill:${j.name}${j.userMessage?` ${j.userMessage}`:""}`:t.content.map(F=>es(F)?.text??"").filter(Boolean).join(`
316
- `)),A(b??[]),H(!0)},$=()=>{const F=V.trim();F&&(d?.(t.id,F,X.length>0?X:void 0),H(!1))},T=t.role==="custom"&&(t.customType==="goal-review"||t.customType==="goal-wizard"),ce=t.role==="custom"&&t.customType==="goal-wizard";return s.jsxs("div",{className:`msg msg-${t.role}${T?" msg-goal-review":""}`,"data-role":t.role,"data-msg-id":t.id,children:[s.jsxs("div",{className:"msg-meta",children:[s.jsx("span",{className:"msg-role",children:t.role==="custom"?ce?R("goalWizardCard"):T?R("goalBarTitle"):t.customType==="file"?R("attachment"):`${R("plugin")} · ${t.customType??R("unknown")}`:Qr(t.role,R)}),t.model&&s.jsx("span",{className:"msg-model",children:t.model}),t.timestamp&&s.jsx("span",{className:"msg-time",children:Xr(t.timestamp)}),g&&s.jsxs("button",{type:"button",className:"msg-collapse-btn",title:R("collapseMsg"),onClick:()=>g(t.id),children:[s.jsx(on,{})," ",R("collapseMsg")]}),x!==void 0&&S&&s.jsxs("button",{type:"button",className:`qn-tag ${N?"active":""}`,title:`${x+1}. ${D}`,"aria-label":`${x+1}. ${D}`,onClick:()=>S(t.id),children:[s.jsx("span",{className:"qn-tag-bar"}),s.jsx("span",{className:"qn-tag-idx",children:x+1})]})]}),s.jsx("div",{className:"msg-body",children:U?s.jsxs("div",{className:`msg-editor${J?" drag-over":""}`,onDragOver:F=>{F.preventDefault(),F.stopPropagation(),k(!0)},onDragLeave:F=>{F.currentTarget.contains(F.relatedTarget)||k(!1)},onDrop:F=>{F.preventDefault(),F.stopPropagation(),k(!1),Q(Array.from(F.dataTransfer?.files??[]))},children:[X.length>0&&s.jsx("div",{className:"msg-editor-images",children:X.map((F,ie)=>{const oe=Nm(F);return s.jsxs("span",{className:`msg-editor-img ${oe==="image"?"":"file-chip"}`,title:km(F,R),children:[oe==="image"?s.jsx("img",{src:`data:${F.mimeType??"image/png"};base64,${F.imageData}`,alt:F.name}):s.jsxs("span",{className:"msg-editor-file",children:[s.jsx("span",{className:"msg-editor-file-icon",children:oe==="path"?F.mode==="reference"?"🔗":"📎":"📄"}),s.jsx("span",{className:"msg-editor-file-name",children:F.name??F.path?.split("/").pop()})]}),s.jsx("button",{type:"button",className:"msg-editor-img-remove",title:R("removeAttachment"),onClick:()=>A(de=>de.filter((Te,we)=>we!==ie)),children:s.jsx(Je,{})})]},`${F.name??F.path??"att"}-${ie}`)})}),le&&s.jsx("div",{className:"msg-editor-notice",children:le}),s.jsx("textarea",{className:"msg-editor-input",value:V,autoFocus:!0,placeholder:R("editPlaceholder"),rows:Math.max(2,Math.min(10,V.split(`
317
- `).length+1)),onChange:F=>se(F.target.value),onPaste:F=>{const ie=[];for(const oe of F.clipboardData?.items??[])if(oe.kind==="file"&&Nt(oe.type)){const de=oe.getAsFile();de&&ie.push(de)}ie.length!==0&&(F.preventDefault(),ge(ie))},onKeyDown:F=>{F.key==="Enter"&&(F.metaKey||F.ctrlKey)?(F.preventDefault(),$()):F.key==="Escape"&&H(!1)}}),s.jsxs("div",{className:"msg-editor-actions",children:[s.jsxs("span",{className:"msg-editor-hint",children:[s.jsx(Tl,{})," ",R("editAttachmentHint")]}),s.jsx("button",{type:"button",className:"chip",onClick:()=>H(!1),children:R("cancel")}),s.jsxs("button",{type:"button",className:"chip primary",disabled:!V.trim(),title:R("reaskFromHere"),onClick:$,children:[s.jsx(zt,{})," ",R("reaskFromHere")]})]})]}):s.jsxs(s.Fragment,{children:[t.errorMessage&&s.jsxs("div",{className:"msg-error",children:[s.jsx("span",{className:"msg-error-text",children:t.errorMessage}),c&&!i&&f&&s.jsxs("button",{type:"button",className:"msg-retry-btn",title:R("retryLastTip"),onClick:f,children:[s.jsx(Lt,{})," ",R("retryNow")]})]}),he?s.jsx(Cm,{message:t,forceOpen:K}):j?s.jsxs(s.Fragment,{children:[s.jsx(Sm,{block:j,forceOpen:K}),j.userMessage&&s.jsx("div",{className:"msg-text",children:s.jsx(at,{text:j.userMessage,hardBreaks:!0})}),t.content.map((F,ie)=>F.type==="text"?null:s.jsx(bi,{block:F,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onKillBash:u,toolsWrap:G,thinkingWrap:M,searchActive:K,role:t.role},`${t.id}-${ie}`))]}):t.content.map((F,ie)=>s.jsx(bi,{block:F,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onKillBash:u,toolsWrap:G,thinkingWrap:M,searchActive:K,role:t.role},`${t.id}-${ie}`)),re&&s.jsxs("div",{className:"thinking-wait",children:[R("thinkingWait"),s.jsx("span",{className:"dot"})]}),i&&c&&!re&&s.jsx("span",{className:"stream-cursor"})]})}),te&&!U&&s.jsx("div",{className:"msg-actions",children:s.jsxs("button",{type:"button",className:"msg-action",title:R("editReaskTip"),onClick:P,children:[s.jsx(zt,{})," ",R("editReask")]})})]})});function Cm({message:e,forceOpen:t=!1}){const n=Ae(),[a,o]=l.useState(!1),[i,c]=l.useState(!1),d=a||t,u=e.details??{},f=u.name??u.path??n("attachment"),g=u.type==="folder",b=u.mode==="reference",x=u.mode==="bridged",N=e.content.filter(y=>y.type==="text").map(y=>y.text).join(`
318
- `),S=vm(N),M=e.content.find(y=>y.type==="image"),G=S.split(`
319
- `).length,K=!b&&S.length>0;return s.jsxs("div",{className:`attachcard ${b?"reference":""}`,children:[s.jsxs("div",{className:"chead attachcard-head",role:"button",tabIndex:0,"aria-expanded":d,title:n(d?"collapseMsg":"expandMsg"),onClick:()=>o(y=>t?!0:!y),onKeyDown:y=>{y.target===y.currentTarget&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),o(R=>t?!0:!R))},children:[!b&&s.jsx("span",{className:"chead-toggle",children:d?s.jsx(Pt,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon attachcard-icon",children:g?"📁":"📎"}),s.jsx("span",{className:"chead-title attachcard-name",children:f}),u.path&&s.jsx("span",{className:"attachcard-path",children:u.path}),s.jsx("span",{className:`attachcard-mode ${u.mode==="lines"?"lines":b?"ref":x?"bridged":"inline"}`,children:b?g?n("folderRefShort"):`${n("refOnlyShort")} · ${gi(u.size)}`:x?n("bridgedVision"):M?n("image"):u.mode==="lines"?n("inlineLinesRange",{start:u.startLine??1,end:u.endLine??u.lines??1}):n("inlineLines",{n:u.lines??G})}),K&&s.jsx("button",{type:"button",className:"chead-copy",title:n(i?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:y=>{y.stopPropagation(),navigator.clipboard.writeText(S),c(!0),window.setTimeout(()=>c(!1),1200)},children:i?s.jsx(ts,{}):s.jsx(kt,{})})]}),!b&&d&&(x?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),M?.dataUrl&&s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:M.dataUrl,alt:f})}),S&&s.jsx("pre",{className:"attachcard-content",children:S})]}):M?.dataUrl?s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:M.dataUrl,alt:f})}):s.jsx("pre",{className:"attachcard-content",children:S})),b&&s.jsx("div",{className:"attachcard-refnote",children:g?n("folderNotExpanded"):n("fileNotExpanded",{size:gi(u.size)})})]})}function gi(e){return e===void 0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function vm(e){const t=e.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(t)return t[1].trim();const n=e.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():e.trim()}function _m({message:e,forceOpen:t=!1,autoExpand:n=!1}){const a=Ae(),[o,i]=l.useState(!1),[c,d]=l.useState(!1),[u,f]=l.useState(n);n!==u&&(f(n),n&&i(!0));const g=o||t,b=e.content.map(N=>es(N)?.text??"").filter(Boolean).join(`
320
- `),x=typeof e.tokensBefore=="number"?e.tokensBefore.toLocaleString():null;return s.jsxs("div",{className:"msg msg-compactionSummary","data-role":e.role,"data-msg-id":e.id,children:[s.jsxs("div",{className:"msg-meta",children:[s.jsx("span",{className:"msg-role",children:a("role.compaction")}),e.timestamp&&s.jsx("span",{className:"msg-time",children:Xr(e.timestamp)})]}),s.jsxs("div",{className:`compaction-card${o?" expanded":""}`,children:[s.jsxs("div",{className:"chead compaction-head",role:"button",tabIndex:0,"aria-expanded":g,title:a(g?"collapseMsg":"expandMsg"),onClick:()=>i(N=>t?!0:!N),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),i(S=>t?!0:!S))},children:[s.jsx("span",{className:"chead-toggle",children:g?s.jsx(Pt,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon compaction-icon",children:s.jsx(zi,{})}),s.jsx("span",{className:"chead-title compaction-title",children:x?a("compactionFrom",{tokens:x}):a("role.compaction")}),b&&s.jsx("button",{type:"button",className:"chead-copy",title:a(c?"copied":"copyMessage"),"aria-label":a("copyMessage"),onClick:N=>{N.stopPropagation(),navigator.clipboard.writeText(b),d(!0),window.setTimeout(()=>d(!1),1200)},children:c?s.jsx(ts,{}):s.jsx(kt,{})})]}),g&&s.jsxs("div",{className:"compaction-body",children:[s.jsx(at,{text:b}),s.jsx("div",{className:"compaction-hint",children:a("compactionKeptHint")})]})]})]})}function Sm({block:e,forceOpen:t=!1}){const n=Ae(),[a,o]=l.useState(!1),[i,c]=l.useState(!1),d=a||t;return s.jsxs("div",{className:`skillcard${a?" expanded":""}`,children:[s.jsxs("div",{className:"chead skillcard-head",role:"button",tabIndex:0,"aria-expanded":d,title:e.location,onClick:()=>o(u=>t?!0:!u),onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(f=>t?!0:!f))},children:[s.jsx("span",{className:"chead-toggle",children:d?s.jsx(Pt,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon skillcard-icon",children:s.jsx(Cl,{})}),s.jsx("span",{className:"chead-title skillcard-name",children:e.name}),s.jsx("span",{className:"skillcard-path",children:e.location}),s.jsx("button",{type:"button",className:"chead-copy",title:n(i?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:u=>{u.stopPropagation(),navigator.clipboard.writeText(e.content),c(!0),window.setTimeout(()=>c(!1),1200)},children:i?s.jsx(ts,{}):s.jsx(kt,{})})]}),d&&s.jsx("div",{className:"skillcard-body",children:s.jsx(at,{text:e.content})})]})}function bi({block:e,toolResults:t,liveOutputs:n,toolStatuses:a,streaming:o,isLast:i,onKillBash:c,thinkingWrap:d,toolsWrap:u,searchActive:f,role:g}){const b=Ae(),[x,N]=l.useState(!1),S=es(e);if(S){const R=o&&i,U=g==="assistant"||g==="user",H=U&&!S.text.includes(`
321
- `)&&!S.truncated,V=g==="user"?s.jsx(at,{text:S.text,hardBreaks:!0}):R?s.jsx(dm,{text:S.text}):s.jsx(at,{text:S.text});return s.jsxs("div",{className:`msg-text${H?" single":""}`,children:[H?s.jsx("div",{className:"msg-text-main",children:V}):s.jsxs(s.Fragment,{children:[V,S.truncated&&s.jsx("div",{className:"trunc-note",children:b("truncated")})]}),U?s.jsx("button",{type:"button",className:"msg-text-copy",title:b(x?"copied":"copyMessage"),"aria-label":b("copyMessage"),onClick:()=>{navigator.clipboard.writeText(S.text),N(!0),window.setTimeout(()=>N(!1),1200)},children:x?s.jsx(ts,{}):s.jsx(kt,{})}):null]})}const M=Yr(e);if(M)return s.jsx(pm,{thinking:M.thinking,streaming:o&&i,wrap:d,forceOpen:f});const G=Gr(e);if(G){const R=t.get(G.id),U=n.get(G.id),H={result:R,liveOutput:U?.text,streaming:o,status:a.get(G.id)};return s.jsx(fm,{block:G,view:H,onKillBash:c,wrap:u,forceOpen:f})}const K=Vr(e);if(K&&K.dataUrl)return s.jsx("div",{className:"msg-image",children:s.jsx("img",{src:K.dataUrl,alt:"attachment"})});const y=zr(e);return y?s.jsxs("div",{className:"bashblock",children:[s.jsxs("div",{className:"bashblock-command",children:[s.jsx("span",{className:"bashblock-prompt",children:"$"}),s.jsx("code",{children:y.command}),y.exitCode!==void 0&&s.jsx("span",{className:`bashblock-exit ${y.exitCode===0?"ok":"err"}`,children:b("exitCode",{code:y.exitCode})}),y.cancelled&&s.jsx("span",{className:"bashblock-exit err",children:b("cancelled")})]}),y.output&&s.jsx("pre",{className:"bashblock-output",children:y.output}),y.truncated&&s.jsx("div",{className:"trunc-note",children:b("outputTruncated")})]}):null}function Qr(e,t){switch(e){case"user":return t("role.user");case"assistant":return t("role.assistant");case"toolResult":return t("role.tool");case"bashExecution":return t("role.bash");case"branchSummary":return t("role.branch");case"compactionSummary":return t("role.compaction");default:return e}}function Xr(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${n}:${a}`}function Ei(e,t,n){let a=!1;for(const o of t){const i=o;if(i.type!=="image"||typeof i.dataUrl!="string"||!i.dataUrl.startsWith("data:"))continue;const c=i.dataUrl.match(/^data:([^;]*);base64,(.+)$/);c&&(a=!0,e.push({path:"",imageData:c[2],mimeType:c[1]||"image/png",name:n??`image.${(c[1]||"image/png").split("/")[1]??"png"}`}))}return a}function Am(e){const t=new Map;for(let n=0;n<e.length;n++){const a=e[n];if(a.role!=="user"||!a.id)continue;const o=[];Ei(o,a.content);for(let i=n+1;i<e.length&&e[i].role==="custom"&&e[i].customType==="file";i++){const c=e[i].details??{};if(!Ei(o,e[i].content,c.name)){if(c.upload&&c.path){o.push({path:"",uploadPath:c.path,name:c.name??c.path,size:c.size});continue}if(c.path&&c.mode){const d=c.mode==="inline"||c.mode==="lines"?c.mode:"reference",u={path:c.path,mode:d};c.mode==="lines"&&typeof c.startLine=="number"&&typeof c.endLine=="number"&&(u.lines={start:c.startLine,end:c.endLine}),o.push(u)}}}o.length>0&&t.set(a.id,o)}return t}const wm=l.memo(function({message:t,onExpand:n}){const a=Ae();let o="";for(const b of t.content){const x=es(b);if(x&&x.text.trim()){const N=ha(x.text);N?o=`skill:${N.name}`+(N.userMessage?` · ${N.userMessage.replace(/\s+/g," ").trim()}`:""):o=x.text.replace(/\s+/g," ").trim();break}}if(!o&&t.role==="custom"&&t.customType==="file"){const b=t.details??{};o=b.name??b.path??""}o.length>90&&(o=`${o.slice(0,90)}…`);let c=0,d=0,u=0,f=0;for(const b of t.content)Yr(b)?c++:Gr(b)?d++:zr(b)?u++:Vr(b)&&f++;const g=[];return c&&g.push(`${a("thinking")} ${c}`),d&&g.push(`${a("toolCalls")} ${d}`),u&&g.push(`${a("bashRuns")} ${u}`),f&&g.push(`${a("images")} ${f}`),s.jsxs("div",{role:"button",tabIndex:0,className:"msg-collapsed","data-msg-id":t.id,title:`${a("expandMsg")} · ${o||g.join(" · ")||t.role}`,onClick:()=>n(t.id),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),n(t.id))},children:[s.jsx("span",{className:`msg-collapsed-role role-${t.role}`,children:t.role==="custom"&&t.customType==="file"?a("attachment"):Qr(t.role,a)}),s.jsxs("span",{className:"msg-collapsed-body",children:[o&&s.jsx("span",{className:"msg-collapsed-preview",children:o}),g.length>0&&s.jsx("span",{className:"msg-collapsed-chips",children:g.map((b,x)=>s.jsx("span",{className:"msg-collapsed-chip",children:b},x))})]}),t.timestamp?s.jsx("span",{className:"msg-collapsed-time",children:Im(t.timestamp)}):null,s.jsxs("span",{className:"msg-collapsed-action",children:[s.jsx($t,{})," ",a("expandMsg")]})]})});function Im(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${n}:${a}`}const jm=l.memo(function({id:t,show:n,height:a,containerRef:o,onMeasured:i,lazyRef:c,children:d}){const u=l.useRef(null),f=l.useRef(null);return l.useLayoutEffect(()=>{const g=f.current;if(f.current=n,!n||g!==!1)return;const b=u.current,x=o.current;if(!b||!x)return;const N=b.offsetHeight;i?.(t,N);const S=N-a;if(S!==0){const M=b.parentElement;M&&M.getBoundingClientRect().bottom<=x.getBoundingClientRect().top&&(x.scrollTop+=S)}},[n]),n?s.jsx("div",{ref:c,"data-lazy-id":t,children:s.jsx("div",{ref:u,children:d})}):s.jsx("div",{ref:c,className:"msg-lazy-ph","data-msg-id":t,"data-lazy-id":t,style:{height:a},"aria-hidden":"true"})});function Lm(e,t,n,a){const o=[],i=[];let c=0;for(const d of e){if(n.has(d.id))continue;d.top<t.bottom&&d.bottom>t.top?a.has(d.id)&&o.push(d.id):a.has(d.id)||(i.push(d.id),d.bottom<=t.top&&(c+=d.bottom-d.top))}return{show:o,hide:i,shrinkAbove:c}}function Rm(e,t){if(t.show.length===0&&t.hide.length===0)return e;const n=new Set(e);for(const a of t.show)n.delete(a);for(const a of t.hide)n.add(a);return n}function Dm(e,t,n){const a=new Set;let o=0;for(let i=e.length-1;i>=0&&!(i<e.length-1&&o>=n);i--){const c=e[i];a.add(c.id),o+=t.get(c.id)??Jr(c.role,c.customType)}return a}function Jr(e,t){switch(e){case"user":return 72;case"assistant":return 280;case"toolResult":return 8;case"custom":return t==="file"?96:72;default:return 60}}const Pm=["text","thinking","argumentsText","output","command"];function Om(e){let t=0;for(const n of e.content){n.type==="image"&&(t+=1);for(const a of Pm){const o=n[a];typeof o=="string"&&(t+=o.length)}}return t}function Mm(e,t,n,a){const o=n.get(e);return o&&o.len===t?o.h:a}function Bm(e){const t=[];for(const n of e.content)n.type==="text"&&typeof n.text=="string"&&t.push(n.text);return t.join(`
322
- `)}function Fm(e,t){const n=[];for(const a of e.content)if(a.type==="text"&&typeof a.text=="string")n.push(a.text);else if(a.type==="thinking"&&typeof a.thinking=="string")n.push(a.thinking);else if(a.type==="toolCall"){if(typeof a.name=="string"&&n.push(a.name),typeof a.argumentsText=="string"&&n.push(a.argumentsText),typeof a.id=="string"){const o=t.get(a.id);if(o){const i=Bm(o);i&&n.push(i)}}}else a.type==="bash"&&(typeof a.command=="string"&&n.push(a.command),typeof a.output=="string"&&n.push(a.output));return n.join(`
323
- `)}function Hm(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n++,a=e.indexOf(t,a+t.length);return n}function Um(e,t,n,a){const o=new Map,i=n.toLowerCase();if(!i)return o;for(const c of e){if(!t.has(c.id))continue;const d=Hm(Fm(c,a).toLowerCase(),i);d>0&&o.set(c.id,d)}return o}function qm(e,t){const n=[],a=t.toLowerCase();if(!a)return n;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(i){const c=i.parentElement;return!c||c.closest(".search-bar")||c.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(i.textContent??"").toLowerCase().includes(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let i=o.nextNode();i;i=o.nextNode()){const c=(i.textContent??"").toLowerCase();if(!i.parentElement?.closest("[data-msg-id]"))continue;let d=c.indexOf(a);for(;d!==-1;){const u=document.createRange();u.setStart(i,d),u.setEnd(i,d+a.length),n.push(u),d=c.indexOf(a,d+a.length)}}return n}function $m(e,t,n,a,o){const i=Um(n,a,t,o),c=new Map;for(const u of qm(e,t)){const f=u.startContainer.parentElement?.closest("[data-msg-id]");if(!f?.dataset.msgId)continue;const g=c.get(f.dataset.msgId);g?g.push(u):c.set(f.dataset.msgId,[u])}const d=[];for(const u of n){const f=c.get(u.id);if(f)for(let b=0;b<f.length;b++)d.push({kind:"dom",range:f[b],msgId:u.id,k:b});const g=i.get(u.id);if(g)for(let b=0;b<g;b++)d.push({kind:"folded",msgId:u.id,k:b})}return d}function _n(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function pt(e,t){const n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}const a=window.Highlight;a&&n.highlights.set(e,new a(...t))}function Wm(e,t){const n=[];let a=e;for(;a&&a!==t;){const o=getComputedStyle(a);/(auto|scroll|hidden)/.test(o.overflowY+o.overflowX)&&(a.scrollHeight>a.clientHeight||a.scrollWidth>a.clientWidth)&&n.push(a),a=a.parentElement}return n}function Km(e,t){const n=t.startContainer.parentElement;for(const d of Wm(n,e)){const u=t.getBoundingClientRect(),f=d.getBoundingClientRect();if(u.height<=0||u.width<=0)return;u.top>=f.top+4&&u.bottom<=f.bottom-4||(d.scrollTop+=u.top-f.top-(d.clientHeight-u.height)/2),u.left>=f.left+4&&u.right<=f.right-4||(d.scrollLeft+=u.left-f.left-(d.clientWidth-u.width)/2)}const a=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(a.height<=0||a.width<=0)return;const i=a.top>=o.top+6&&a.bottom<=o.bottom-6,c=a.left>=o.left+6&&a.right<=o.right-6;i&&c||(i||(e.scrollTop+=a.top-o.top-(o.height-a.height)/2),c||(e.scrollLeft+=a.left-o.left-(o.width-a.width)/2))}function Ym({containerRef:e,messages:t,collapsedIds:n,toolResults:a,onExpand:o,onProgrammaticScroll:i,open:c,onClose:d}){const u=Ae(),f=l.useRef(null),[g,b]=l.useState(""),[x,N]=l.useState(null),[S,M]=l.useState(0),[,G]=l.useState(0),K=l.useDeferredValue(g),y=c?K.trim():"",R=l.useRef(null);R.current=x;const U=l.useRef([]),H=l.useRef({key:null}),V=l.useRef("");l.useEffect(()=>{c&&(N(null),requestAnimationFrame(()=>f.current?.select()))},[c]),l.useEffect(()=>{if(!c)return;const A=J=>{J.key==="Escape"&&(J.preventDefault(),J.stopPropagation(),d())};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},[c,d]),l.useEffect(()=>(c||(pt("msg-search",[]),pt("msg-search-active",[])),()=>{pt("msg-search",[]),pt("msg-search-active",[])}),[c]),l.useLayoutEffect(()=>{const A=()=>{M(0),N(null),G(0),U.current=[],pt("msg-search",[]),pt("msg-search-active",[]),H.current={key:null},V.current=""};if(!c||!y){A();return}const J=e.current;if(!J)return;let k=!1,le=0;return le=requestAnimationFrame(()=>{if(k)return;const Y=$m(J,y,t,n,a);U.current=Y;const me=Y.length;if(M(me),me===0){N(null),G(0),pt("msg-search",[]),pt("msg-search-active",[]),H.current={key:null},V.current=y;return}const he=R.current;let I;if(he){if(I=_n(Y,he),I===-1){const ge=[];for(let C=0;C<Y.length;C++)Y[C].msgId===he.msgId&&ge.push(C);if(ge.length>0){const C=Math.min(he.k,ge.length-1);I=ge[C]}else I=0}}else I=0;I<0&&(I=0),I>=me&&(I=me-1),(!he||he.msgId!==Y[I].msgId||he.k!==Y[I].k)&&N({msgId:Y[I].msgId,k:Y[I].k}),G(I);const j=Y[I],D=H.current,re=D.key?.msgId!==j.msgId||D.key?.k!==j.k||D.kind==="folded"&&j.kind==="dom"||y!==V.current;H.current={key:{msgId:j.msgId,k:j.k},kind:j.kind},V.current=y;const te=Y.filter(ge=>ge.kind==="dom").map(ge=>ge.range);if(pt("msg-search",te),j.kind==="folded"){pt("msg-search-active",[]),re&&o(j.msgId);return}pt("msg-search-active",[j.range]),re&&(i?.(),Km(J,j.range))}),()=>{k=!0,cancelAnimationFrame(le)}},[c,y,t,e,x,n,a,o,i]);const se=l.useCallback(A=>{const J=U.current,k=J.length;if(k===0)return;const le=R.current,Y=le?_n(J,le):0,me=J[(Y+A+k)%k];N(me.kind==="dom"||me.kind==="folded"?{msgId:me.msgId,k:me.k}:null)},[]);if(!c)return null;const X=x?(()=>{const A=_n(U.current,x);return A===-1?0:A})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:f,className:"search-input",type:"text",value:g,placeholder:u("searchPlaceholder"),onChange:A=>{b(A.target.value)},onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),se(A.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${S===0?"empty":""}`,children:S===0?u("searchNoResults"):`${Math.min(X+1,S)}/${S}`}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchPrev"),disabled:S===0,onClick:()=>se(-1),children:s.jsx(on,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchNext"),disabled:S===0,onClick:()=>se(1),children:s.jsx(Pt,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchClose"),onClick:d,children:s.jsx(Je,{})})]})}function Gm(e){const{dSt:t,dSh:n,escaped:a,graceActive:o,stuck:i}=e;return o?{flipEscape:!1,reassert:!1}:t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:i&&!a}:{flipEscape:!0,reassert:!1}}const Zr=[{id:"setup-matt-pocock-skills",icon:"🛠",titleKey:"tpl.sk.setup",descKey:"tpl.sk.setup.desc",promptKey:"tpl.sk.setup.prompt"},{id:"ask-matt",icon:"🧭",titleKey:"tpl.sk.ask",descKey:"tpl.sk.ask.desc",promptKey:"tpl.sk.ask.prompt"},{id:"grill-with-docs",icon:"🗣",titleKey:"tpl.sk.grilldocs",descKey:"tpl.sk.grilldocs.desc",promptKey:"tpl.sk.grilldocs.prompt"},{id:"to-spec",icon:"📝",titleKey:"tpl.sk.tospec",descKey:"tpl.sk.tospec.desc",promptKey:"tpl.sk.tospec.prompt"},{id:"to-tickets",icon:"🎫",titleKey:"tpl.sk.totickets",descKey:"tpl.sk.totickets.desc",promptKey:"tpl.sk.totickets.prompt"},{id:"implement",icon:"🏗",titleKey:"tpl.sk.implement",descKey:"tpl.sk.implement.desc",promptKey:"tpl.sk.implement.prompt"},{id:"code-review",icon:"🧹",titleKey:"tpl.sk.codeview",descKey:"tpl.sk.codeview.desc",promptKey:"tpl.sk.codeview.prompt"},{id:"wayfinder",icon:"🗺",titleKey:"tpl.sk.wayfinder",descKey:"tpl.sk.wayfinder.desc",promptKey:"tpl.sk.wayfinder.prompt"},{id:"prototype",icon:"🔬",titleKey:"tpl.sk.prototype",descKey:"tpl.sk.prototype.desc",promptKey:"tpl.sk.prototype.prompt"},{id:"research",icon:"📚",titleKey:"tpl.sk.research",descKey:"tpl.sk.research.desc",promptKey:"tpl.sk.research.prompt"},{id:"improve-codebase-architecture",icon:"🏛",titleKey:"tpl.sk.arch",descKey:"tpl.sk.arch.desc",promptKey:"tpl.sk.arch.prompt"},{id:"diagnosing-bugs",icon:"🐛",titleKey:"tpl.sk.debug",descKey:"tpl.sk.debug.desc",promptKey:"tpl.sk.debug.prompt"},{id:"resolving-merge-conflicts",icon:"🔀",titleKey:"tpl.sk.merge",descKey:"tpl.sk.merge.desc",promptKey:"tpl.sk.merge.prompt"},{id:"triage",icon:"🗂",titleKey:"tpl.sk.triage",descKey:"tpl.sk.triage.desc",promptKey:"tpl.sk.triage.prompt"},{id:"wizard",icon:"✨",titleKey:"tpl.sk.wizard",descKey:"tpl.sk.wizard.desc",promptKey:"tpl.sk.wizard.prompt"},{id:"grill-me",icon:"🔍",titleKey:"tpl.sk.grillme",descKey:"tpl.sk.grillme.desc",promptKey:"tpl.sk.grillme.prompt"},{id:"handoff",icon:"🤝",titleKey:"tpl.sk.handoff",descKey:"tpl.sk.handoff.desc",promptKey:"tpl.sk.handoff.prompt"},{id:"to-questionnaire",icon:"📋",titleKey:"tpl.sk.questionnaire",descKey:"tpl.sk.questionnaire.desc",promptKey:"tpl.sk.questionnaire.prompt"},{id:"teach",icon:"🎓",titleKey:"tpl.sk.teach",descKey:"tpl.sk.teach.desc",promptKey:"tpl.sk.teach.prompt"},{id:"wait-what",icon:"💬",titleKey:"tpl.sk.ww",descKey:"tpl.sk.ww.desc",promptKey:"tpl.sk.ww.prompt"},{id:"writing-for-agents",icon:"📄",titleKey:"tpl.sk.wfa",descKey:"tpl.sk.wfa.desc",promptKey:"tpl.sk.wfa.prompt"},{id:"codebase-design",icon:"🧱",titleKey:"tpl.sk.codesign",descKey:"tpl.sk.codesign.desc",promptKey:"tpl.sk.codesign.prompt"},{id:"domain-modeling",icon:"🏷",titleKey:"tpl.sk.domain",descKey:"tpl.sk.domain.desc",promptKey:"tpl.sk.domain.prompt"},{id:"grilling",icon:"🔥",titleKey:"tpl.sk.grilling",descKey:"tpl.sk.grilling.desc",promptKey:"tpl.sk.grilling.prompt"},{id:"tdd",icon:"🧪",titleKey:"tpl.sk.tdd",descKey:"tpl.sk.tdd.desc",promptKey:"tpl.sk.tdd.prompt"}],eo="pi-web-ui:prompt-templates";function Vm(){try{const e=localStorage.getItem(eo);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}catch{return[]}}function Ti(e){return Zr.some(t=>t.id===e)}function Ps(e){return typeof e.title=="string"}const to=l.createContext(null);function so(){const e=l.useContext(to);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function zm({send:e,children:t}){const n=Ae(),[a,o]=l.useState(Vm),[i,c]=l.useState(!1),[d,u]=l.useState(null),[f,g]=l.useState(!1),[b,x]=l.useState(!1),[N,S]=l.useState(!1);l.useEffect(()=>{try{localStorage.setItem(eo,JSON.stringify(a))}catch{}},[a]);const M=l.useMemo(()=>{const Y=new Map,me=new Set;for(const j of a)j.hidden?me.add(j.id):(Ps(j)&&!Ti(j.id)||Ps(j))&&Y.set(j.id,j);const he=Zr.filter(j=>!me.has(j.id)).map(j=>{const D=Y.get(j.id);return{id:j.id,icon:D?.icon??j.icon,title:D?.title??n(j.titleKey),desc:D?.desc??n(j.descKey),prompt:D?.prompt??n(j.promptKey),builtin:!0}}),I=a.filter(j=>Ps(j)&&!Ti(j.id)).map(j=>({id:j.id,icon:j.icon??"📌",title:j.title??"",desc:j.desc??"",prompt:j.prompt??""}));return[...he,...I]},[a,n]),G=l.useCallback(()=>c(!0),[]),K=l.useCallback(Y=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:Y}))},[]),y=l.useCallback((Y,me=!1)=>{S(me),Y?(g(!1),u({...Y})):(g(!0),u({id:Ct(),icon:"📌",title:"",desc:"",prompt:""}))},[]),R=l.useCallback(()=>{c(!1),u(null),S(!1)},[]),U=l.useCallback(()=>{b?(o([]),x(!1)):(x(!0),setTimeout(()=>x(!1),5e3))},[b]),H=l.useCallback(Y=>{c(!1),K(Y.prompt)},[K]),V=l.useCallback(Y=>{c(!1),y(Y,!0)},[y]),se=l.useCallback(()=>{c(!1),y(void 0,!0)},[y]),X=l.useCallback(Y=>{o(me=>{const he=me.findIndex(I=>I.id===Y.id);if(he>=0){const I=[...me];return I[he]=Y,I}return[...me,Y]}),u(null),N&&(c(!0),S(!1))},[N]),A=l.useCallback(Y=>{o(me=>Y.builtin?[...me.filter(I=>I.id!==Y.id),{id:Y.id,hidden:!0}]:me.filter(he=>he.id!==Y.id)),u(null),N&&(c(!0),S(!1))},[N]),J=l.useCallback(Y=>{o(me=>me.filter(he=>he.id!==Y.id||he.hidden)),u(null),N&&(c(!0),S(!1))},[N]),k=l.useMemo(()=>({templates:M,fill:K,openPicker:G,openEdit:y,resetConfirm:b,toggleReset:U}),[M,K,G,y,b,U]),le=d?a.some(Y=>Y.id===d.id&&!Y.hidden&&Ps(Y)):!1;return s.jsxs(to.Provider,{value:k,children:[t,i&&s.jsx(Xm,{templates:M,resetConfirm:b,onFill:H,onEditTpl:V,onNew:se,onResetToggle:U,onClose:R}),d&&s.jsx(Jm,{editing:d,isNew:f,hasOverride:le,onDraft:u,onSave:X,onRestore:()=>J(d),onRemove:()=>A(d),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:d.prompt})),R()},onSend:()=>{const Y=d.prompt.trim();Y&&e({type:"prompt",text:Y,queue:!1})&&R()},onClose:R})]})}function Qm(){const e=Ae(),{templates:t,fill:n,openEdit:a,toggleReset:o,resetConfirm:i}=so();return s.jsxs("div",{className:"empty-templates",children:[s.jsxs("div",{className:"empty-templates-head",children:[s.jsx("span",{className:"empty-templates-title",children:e("tpl.title")}),s.jsx("span",{className:"empty-templates-hint",children:e("tpl.hint")})]}),s.jsxs("div",{className:"empty-templates-grid",children:[t.map(c=>s.jsx(no,{tpl:c,title:e("tpl.clickCard"),onFill:()=>n(c.prompt),onEdit:()=>a(c),editTitle:e("tpl.editTpl")},c.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>a(),title:e("tpl.add"),children:[s.jsx("span",{className:"empty-template-icon",children:s.jsx(ct,{})}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:e("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:e("tpl.addDesc")})]})]})]}),s.jsx("div",{className:"empty-templates-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:o,children:[s.jsx(qi,{}),e(i?"tpl.resetConfirm":"tpl.reset")]})})]})}function no({tpl:e,title:t,onFill:n,onEdit:a,editTitle:o}){const i=Ae();return s.jsxs("button",{type:"button",className:"empty-template",title:t,onClick:n,children:[s.jsx("span",{className:"empty-template-icon",children:e.icon}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:e.title}),s.jsx("span",{className:"empty-template-desc",children:e.desc})]}),s.jsx("span",{className:"template-card-ops",role:"button",title:o??i("tpl.editTpl"),onClick:c=>{c.stopPropagation(),a()},children:s.jsx(Xs,{})})]})}function Xm({templates:e,resetConfirm:t,onFill:n,onEditTpl:a,onNew:o,onResetToggle:i,onClose:c}){const d=Ae();return l.useEffect(()=>{const u=f=>{f.key==="Escape"&&c()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[c]),s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal template-picker",onClick:u=>u.stopPropagation(),children:[s.jsxs("div",{className:"template-picker-head",children:[s.jsx("span",{className:"template-picker-title",children:d("tpl.pickerTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:d("close"),onClick:c,children:s.jsx(Je,{})})]}),s.jsx("div",{className:"template-picker-hint",children:d("tpl.pickerHint")}),s.jsxs("div",{className:"template-picker-grid",children:[e.map(u=>s.jsx(no,{tpl:u,title:d("tpl.clickCard"),onFill:()=>n(u),onEdit:()=>a(u),editTitle:d("tpl.editTpl")},u.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:o,title:d("tpl.add"),children:[s.jsx("span",{className:"empty-template-icon",children:s.jsx(ct,{})}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:d("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:d("tpl.addDesc")})]})]})]}),s.jsx("div",{className:"template-picker-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:i,children:[s.jsx(qi,{}),d(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function Jm({editing:e,isNew:t,hasOverride:n,onDraft:a,onSave:o,onRestore:i,onRemove:c,onFill:d,onSend:u,onClose:f}){const g=Ae(),b=l.useRef(null);l.useEffect(()=>{const S=M=>{M.key==="Escape"&&f()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[f]),l.useEffect(()=>{const S=b.current;if(!S)return;S.style.height="auto";const M=S.scrollHeight>300;S.style.height=`${Math.min(S.scrollHeight,300)}px`,S.style.overflowY=M?"auto":"hidden"},[e.prompt]);const x=()=>{const S=e.title.trim(),M=e.prompt.trim();if(!S||!M){a({...e,error:g("tpl.required")});return}o({id:e.id,icon:e.icon.trim()||"📌",title:S,desc:e.desc.trim(),prompt:M})},N=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:f,children:s.jsxs("div",{className:"modal template-modal",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"template-modal-head",children:[s.jsx("span",{className:"template-modal-icon",children:e.icon}),s.jsx("span",{className:"template-modal-badge",children:g(N?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:g(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:g("close"),onClick:f,children:s.jsx(Je,{})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:g("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:S=>a({...e,icon:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:g("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:g("tpl.fieldTitlePh"),onChange:S=>a({...e,title:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:g("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:g("tpl.fieldDescPh"),onChange:S=>a({...e,desc:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:g("tpl.fieldPrompt")}),s.jsx("textarea",{ref:b,className:"template-field-prompt",value:e.prompt,placeholder:g("tpl.fieldPromptPh"),onChange:S=>a({...e,prompt:S.target.value})})]}),e.error&&s.jsx("div",{className:"template-error",children:e.error}),s.jsxs("div",{className:"template-modal-actions",children:[s.jsxs("div",{className:"template-modal-actions-left",children:[!t&&N&&n&&s.jsx("button",{type:"button",className:"btn template-btn ghost",title:g("tpl.restoreTip"),onClick:i,children:g("tpl.restore")}),!t&&N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:g("tpl.removeTip"),onClick:c,children:[s.jsx(et,{})," ",g("tpl.remove")]}),!t&&!N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:g("tpl.deleteTip"),onClick:c,children:[s.jsx(et,{})," ",g("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:x,children:g("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:d,title:g("tpl.fillTip"),children:g("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:u,title:g("tpl.sendTip"),children:[s.jsx(Vs,{})," ",g("tpl.sendNow")]})]})]})]})})}const xi=new Map,Zm=15,yi=30,Sn=250,Ni=1200,eh=1600;function th({compaction:e}){const t=Ae(),[,n]=l.useState(0);l.useEffect(()=>{const i=setInterval(()=>n(c=>c+1),1e3);return()=>clearInterval(i)},[]);const a=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),o=e.reason==="manual"?t("compactingReasonManual"):e.reason==="overflow"?t("compactingReasonOverflow"):t("compactingReasonThreshold");return s.jsxs("div",{className:"compact-notice",role:"status",children:[s.jsx("span",{className:"compact-pulse"}),s.jsxs("span",{className:"compact-text",children:[t("compactingContext")," · ",a,"s"]}),s.jsx("span",{className:"compact-reason",children:o})]})}function ki(e){return e.content.some(t=>t.type==="toolCall")}function sh({state:e,liveOutputs:t,toolStatuses:n,onEdit:a,onKillBash:o,onRetry:i,onRemoveQueued:c,thinkingWrap:d,toolsWrap:u,jumpTarget:f,onJumpDone:g}){const b=Ae(),x=l.useRef(null),[N,S]=l.useState(!0),M=l.useRef(!0),G=l.useRef(0),K=l.useRef(0),y=l.useRef(!1),R=l.useRef(0),[U,H]=l.useState(()=>new Set),[V,se]=l.useState(!1),X=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,A=l.useMemo(()=>{const L=new Map;for(const W of e.messages)W.role==="toolResult"&&W.toolCallId&&L.set(W.toolCallId,W);return L},[e.messages]),J=l.useMemo(()=>Am(e.messages),[e.messages]),k=X.length>0?X[X.length-1].id:null,le=e.messages.length>yi?Math.max(0,e.messages.length-Zm):0,Y=l.useMemo(()=>{const L=new Set;for(let W=0;W<le;W++){const ke=e.messages[W];ke.role!=="toolResult"&&(U.has(ke.id)||L.add(ke.id))}return L},[e.messages,le,U]),[me,he]=l.useState(()=>new Set),[I,j]=l.useState(()=>new Set),D=l.useRef(new Map),re=l.useRef(new Map),te=l.useRef(new Map),ge=l.useRef(0),C=l.useMemo(()=>{const L=new Map;for(const W of e.messages)L.set(W.id,Om(W));return L},[e.messages]),Q=l.useRef(C);Q.current=C;const P=l.useRef(me);P.current=me;const $=e.messages.length>yi&&!V,T=l.useRef($);T.current=$;const ce=Dm(e.messages,D.current,eh),F=l.useRef(ce);F.current=ce;const ie=l.useCallback(()=>{const L=x.current;if(!L)return;if(!T.current){he(Pe=>Pe.size?new Set:Pe);return}const W=L.getBoundingClientRect(),ke={top:W.top-Ni,bottom:W.bottom+Ni},Ne=[];for(const[Pe,rt]of te.current){const xt=rt.getBoundingClientRect();Ne.push({id:Pe,top:xt.top,bottom:xt.bottom}),P.current.has(Pe)||Te(Pe,xt.bottom-xt.top,Q.current.get(Pe))}const De=Lm(Ne,ke,F.current,P.current);for(const Pe of De.hide){const rt=te.current.get(Pe);rt&&Te(Pe,rt.offsetHeight,Q.current.get(Pe))}he(Pe=>Rm(Pe,De))},[]),oe=l.useCallback(()=>{ge.current||(ge.current=requestAnimationFrame(()=>{ge.current=0,ie()}))},[ie]);l.useLayoutEffect(()=>{ie()},[ie]);const de=l.useRef(V);l.useLayoutEffect(()=>{de.current&&!V&&ie(),de.current=V},[V,ie]);const Te=l.useCallback((L,W,ke)=>{ke!==void 0&&(re.current.set(L,{h:W,len:ke}),D.current.set(L,W))},[]),we=l.useCallback((L,W)=>{Te(L,W,Q.current.get(L))},[Te]),v=l.useCallback(L=>{L&&te.current.set(L.dataset.lazyId??"",L)},[]);l.useEffect(()=>{const L=new Set(e.messages.map(W=>W.id));for(const W of te.current.keys())L.has(W)||(te.current.delete(W),D.current.delete(W),re.current.delete(W));he(W=>{let ke=!1;const Ne=new Set;for(const De of W)L.has(De)?Ne.add(De):ke=!0;return ke?Ne:W})},[e.messages,U]),l.useEffect(()=>()=>cancelAnimationFrame(ge.current),[]);const ne=l.useMemo(()=>{const L=[];for(const W of e.messages){if(W.role!=="user")continue;const ke=W.content.map(Pe=>es(Pe)?.text??"").filter(Boolean).join(" "),Ne=ha(ke),De=Ne?Ne.userMessage??`skill:${Ne.name}`:ke.trim();De&&L.push({id:W.id,text:De})}return L},[e.messages]),ae=l.useMemo(()=>{const L=new Map;return ne.forEach((W,ke)=>L.set(W.id,ke)),L},[ne]),[pe,Le]=l.useState(-1),Be=l.useRef(-1),Ye=l.useRef(ne);l.useEffect(()=>{Ye.current=ne},[ne]);const _=l.useCallback(()=>{const L=x.current,W=Ye.current;if(!L||W.length===0)return;const ke=L.getBoundingClientRect().top,Ne=140;let De=-1;for(let Pe=0;Pe<W.length;Pe++){const rt=L.querySelector(`[data-msg-id="${W[Pe].id}"]`);if(rt)if(rt.getBoundingClientRect().top<=ke+Ne)De=Pe;else break}De!==Be.current&&(Be.current=De,Le(De))},[]);l.useEffect(()=>{_()},[ne,_]);const ue=l.useCallback(L=>{H(W=>W.has(L)?W:new Set(W).add(L))},[]);l.useEffect(()=>{const L=W=>{if(!(W.ctrlKey||W.metaKey)||W.key.toLowerCase()!=="f")return;const ke=W.target;ke&&(ke.tagName==="INPUT"||ke.tagName==="TEXTAREA"||ke.isContentEditable)||(W.preventDefault(),se(!0))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const ve=l.useCallback(L=>{H(W=>{if(!W.has(L))return W;const ke=new Set(W);return ke.delete(L),ke})},[]),xe=l.useCallback(L=>{const W=e.messages.findIndex(Ne=>Ne.id===L);Sc.flushSync(()=>{W>=0&&W<le&&!U.has(L)&&ue(L),j(Ne=>Ne.has(L)?Ne:new Set(Ne).add(L))});const ke=Ye.current.findIndex(Ne=>Ne.id===L);Be.current=ke,Le(ke),requestAnimationFrame(()=>{const Ne=x.current?.querySelector(`[data-msg-id="${L}"]`);Ne&&(x.current?.querySelectorAll(".msg-flash").forEach(De=>De.classList.remove("msg-flash")),Ne.scrollIntoView({block:"start"}),Ne.classList.remove("msg-flash"),Ne.offsetWidth,Ne.classList.add("msg-flash"),Ne!==x.current?.lastElementChild&&(y.current=!0))})},[e.messages,le,U,ue]),[ye,Oe]=l.useState(null),Me=l.useRef(null),B=l.useRef(null);l.useEffect(()=>{const L=Me.current;if(!L||L.convId!==e.conversationId){Me.current={convId:e.conversationId,ids:new Set(e.messages.filter(W=>W.role==="compactionSummary").map(W=>W.id))},B.current=null,Oe(null);return}for(const W of e.messages)if(W.role==="compactionSummary"&&!L.ids.has(W.id)){L.ids.add(W.id),Oe(W.id);break}},[e.messages,e.conversationId]),l.useEffect(()=>{!ye||B.current===ye||(B.current=ye,xe(ye))},[ye,xe]);const _e=l.useMemo(()=>f?e.messages.find(L=>L.role===f.role&&L.timestamp===f.timestamp)?.id??null:null,[e.messages,f]);l.useEffect(()=>{if(f){if(_e){xe(_e),g?.();return}e.sessionFile===f.path&&e.messages.length>0&&g?.()}},[_e,xe,g,f,e.sessionFile,e.messages.length]);const Ce=l.useCallback(()=>{const L=x.current;if(!L)return;const W=L.scrollTop-G.current,ke=L.scrollHeight-K.current;G.current=L.scrollTop,K.current=L.scrollHeight;const Ne=L.scrollHeight-L.scrollTop-L.clientHeight<80,De=Date.now()<R.current,Pe=Gm({dSt:W,dSh:ke,escaped:y.current,graceActive:De,stuck:M.current});Pe.reassert&&(R.current=Date.now()+Sn,L.scrollTop=L.scrollHeight),Pe.flipEscape&&(y.current=!0),Ne&&W>=0&&(y.current=!1),De||(W<0?M.current=Ne&&!y.current:Ne&&(M.current=!0)),S(M.current),_(),oe()},[_,oe]),Ue=l.useRef(!1);l.useEffect(()=>{const L=Ue.current;if(Ue.current=!!e.isStreaming,L&&!e.isStreaming&&!y.current){const W=()=>{const Ne=x.current;Ne&&!y.current&&(Ne.scrollTop=Ne.scrollHeight,M.current=!0,S(!0))};requestAnimationFrame(()=>requestAnimationFrame(W));const ke=setTimeout(W,180);return()=>clearTimeout(ke)}},[e.isStreaming]),l.useEffect(()=>{const L=x.current;L&&M.current&&(L.scrollTop=L.scrollHeight)},[X,e.isStreaming,t]);const Re=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");l.useEffect(()=>{const L=x.current;L&&M.current&&(L.scrollTop=L.scrollHeight)},[Re]),l.useEffect(()=>{const L=x.current;if(!L||typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{M.current&&!y.current&&(L.scrollTop=L.scrollHeight,S(!0))});return W.observe(L),()=>W.disconnect()},[]),l.useEffect(()=>{const L=x.current;if(!L||typeof MutationObserver>"u")return;let W=!1;const ke=new MutationObserver(()=>{W||(W=!0,requestAnimationFrame(()=>{W=!1;const Ne=x.current;Ne&&M.current&&!y.current&&(Ne.scrollTop=Ne.scrollHeight,S(!0))}))});return ke.observe(L,{childList:!0,subtree:!0,characterData:!0}),()=>ke.disconnect()},[]);const We=l.useCallback(()=>{if(!x.current)return;M.current=!0,y.current=!1,S(!0),R.current=Date.now()+Sn;const W=()=>{const ke=x.current;!ke||!M.current||y.current||(R.current=Date.now()+Sn,ke.scrollTop=ke.scrollHeight)};W(),requestAnimationFrame(()=>requestAnimationFrame(W)),setTimeout(W,120),setTimeout(W,300),setTimeout(W,600)},[]),Tt=l.useRef(null);l.useEffect(()=>{const L=Tt.current,W=x.current;if(!L||!W)return;const ke=Ne=>{Ne.preventDefault();const De=L.querySelector(".qn-list");if(De&&De.contains(Ne.target)&&De.scrollHeight>De.clientHeight){De.scrollTop+=Ne.deltaY;return}W.scrollTop+=Ne.deltaY};return L.addEventListener("wheel",ke,{passive:!1}),()=>L.removeEventListener("wheel",ke)},[]);const[Mt,is]=l.useState(0);l.useEffect(()=>{const L=()=>{is(x.current?.clientHeight??0),oe()};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[oe]);const ut=ne.length,ft=l.useMemo(()=>ut===0?27:Math.max(4,Math.min(27,Math.floor(((Mt||600)-16)/ut)-3)),[ut,Mt]),vt=ft<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${V||N?"":" anchor-live"}`,ref:x,onScroll:Ce,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(Qm,{})}),e.messages.map((L,W)=>{const ke=W<le,Ne=ke&&U.has(L.id);if(ke&&!Ne)return L.role==="toolResult"?null:s.jsx(wm,{message:L,onExpand:ue},L.id);const De=L.role==="user"?ae.get(L.id):void 0,Pe=!$||ce.has(L.id)||I.has(L.id)||!me.has(L.id);return s.jsx(jm,{id:L.id,show:Pe,height:Mm(L.id,C.get(L.id)??-1,re.current,Jr(L.role,L.customType)),containerRef:x,onMeasured:we,lazyRef:v,children:s.jsx(fi,{message:L,qnIndex:De,qnActive:De!==void 0?De===pe:void 0,onJump:xe,toolResults:A,liveOutputs:ki(L)?t:xi,toolStatuses:n,streaming:e.isStreaming,onKillBash:o,onRetry:L.id===k?i:void 0,toolsWrap:u,thinkingWrap:d,isLast:L.id===k,onEdit:a,questionAttachments:J.get(L.id),onCollapse:Ne?ve:void 0,searchActive:V,autoExpand:L.id===ye},L.id)},L.id)}),e.streamingMessage&&s.jsx(fi,{message:e.streamingMessage,toolResults:A,liveOutputs:ki(e.streamingMessage)?t:xi,toolStatuses:n,streaming:!0,isLast:!0,onEdit:a,onKillBash:o,toolsWrap:u,thinkingWrap:d,searchActive:V},e.streamingMessage.id),e.retry&&e.isStreaming&&s.jsxs("div",{className:"retry-notice",role:"status",title:e.retry.errorMessage||void 0,children:[s.jsx("span",{className:"retry-pulse"}),s.jsx("span",{className:"retry-text",children:e.retry.maxAttempts>0?b("retryingApi",{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):b("retryingApiSoon",{error:e.retry.errorMessage})})]}),e.compaction&&s.jsx(th,{compaction:e.compaction}),e.isStreaming&&X.length===0&&s.jsx("div",{className:"streaming-wait",children:b("waitingResponse")}),e.queue.steering.map((L,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag steer",children:b("queueSteerTag")}),s.jsx("div",{className:"queued-text",children:L}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:b("queueRemoveTip"),onClick:()=>c("steer",L),children:"✕"})]})},`q-steer-${W}`)),e.queue.followUp.map((L,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag follow",children:b("queueFollowTag")}),s.jsx("div",{className:"queued-text",children:L}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:b("queueRemoveTip"),onClick:()=>c("followUp",L),children:"✕"})]})},`q-fu-${W}`))]}),!N&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:We,children:[s.jsx(Vi,{})," ",b("backToBottom")]}),s.jsx(Ym,{containerRef:x,messages:X,collapsedIds:Y,toolResults:A,onExpand:ue,onProgrammaticScroll:()=>{y.current=!0,M.current=!1,S(!1)},open:V,onClose:()=>se(!1)}),ne.length>0&&s.jsxs("div",{className:`qn-rail ${vt?"many":""}`,ref:Tt,"aria-label":b("questionNavTitle"),style:{"--rail-gap":`${ft}px`},children:[ne.map((L,W)=>s.jsx("button",{type:"button",className:`qn-bar ${W===pe?"active":""}`,"aria-label":`${W+1}. ${L.text}`,onClick:()=>xe(L.id),children:s.jsxs("span",{className:"qn-bar-text",children:[W+1,". ",L.text]})},L.id)),vt&&s.jsx("div",{className:"qn-list",children:ne.map((L,W)=>s.jsxs("button",{type:"button",className:`qn-list-item ${W===pe?"active":""}`,"aria-label":`${W+1}. ${L.text}`,onClick:()=>xe(L.id),children:[s.jsx("span",{className:"qn-list-idx",children:W+1}),s.jsx("span",{className:"qn-list-text",children:L.text})]},L.id))})]})]})}const ao="pi-web-model-usage";function nh(e){if(!e||typeof e!="object")return{};const t={};for(const[n,a]of Object.entries(e)){const o=typeof a=="number"?Math.floor(a):0;Number.isFinite(o)&&o>0&&(t[n]=o)}return t}function ah(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function ih(e,t){const n=t;return e.map((a,o)=>({m:a,i:o,count:n[a.id]??0})).sort((a,o)=>o.count-a.count||a.i-o.i).map(a=>a.m)}function io(){try{const e=localStorage.getItem(ao);return e?nh(JSON.parse(e)):{}}catch{return{}}}function rh(e){try{localStorage.setItem(ao,JSON.stringify(e))}catch{}}function Ci(e){const t=ah(io(),e);return rh(t),t}const ga="pi-web-ui:prompt-history",oh=100,ro="pi-web-ui:prompt-history-settings",Jn={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function oo(e){const t=Jn;if(!e||typeof e!="object")return{...t};const n=e;let a=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(a)||a<1)&&(a=1),a>500&&(a=500);let o=typeof n.charLimit=="number"?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(o)||o<100)&&(o=100),o>2e4&&(o=2e4);const i=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:a,charLimitEnabled:i,charLimit:o}}function lo(){try{const e=localStorage.getItem(ro);return e?oo(JSON.parse(e)):{...Jn}}catch{return{...Jn}}}function An(e){const t=oo(e);try{localStorage.setItem(ro,JSON.stringify(t))}catch{}try{let n=As();t.charLimitEnabled&&(n=n.map(a=>a.length>t.charLimit?a.slice(0,t.charLimit):a)),n.length>t.maxEntries&&(n=n.slice(n.length-t.maxEntries)),co(n)}catch{}}function lh(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const a=n.trim();a&&t.push(a)}return t}function ch(e,t,n=oh){const a=t.trim();if(!a||e.length>0&&e[e.length-1]===a)return e;const o=[...e,a];return o.length>n?o.slice(o.length-n):o}function As(){try{const e=localStorage.getItem(ga);return e?lh(JSON.parse(e)):[]}catch{return[]}}function co(e){let t=e;for(;t;)try{localStorage.setItem(ga,JSON.stringify(t));return}catch(n){if(!(n instanceof DOMException&&(n.name==="QuotaExceededError"||n.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function vi(e){let t=e.trim();if(!t)return;const n=lo();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const a=As(),o=ch(a,t,n.maxEntries);o!==a&&co(o)}function uh(){try{localStorage.removeItem(ga)}catch{}}const dh=["off","minimal","low","medium","high","xhigh","max"],ph=l.memo(function({state:t,models:n,modelsLoading:a,send:o,onManageModels:i,providerKeys:c,compact:d=!1}){const u=Ae(),f=t?.model,g=f?`${f.provider}/${f.id}`:null,[b,x]=l.useState(!1),[N,S]=l.useState(!1),[M,G]=l.useState(""),[K,y]=l.useState(null),[R,U]=l.useState({}),H=l.useRef(null),V=l.useRef(null),[se,X]=l.useState(null);l.useEffect(()=>{if(!b){X(null);return}if(n.length===0)return;const D=requestAnimationFrame(()=>{const re=V.current;re&&X(re.offsetWidth)});return()=>cancelAnimationFrame(D)},[b,n.length]),l.useEffect(()=>{b&&U(io())},[b]),l.useEffect(()=>{b||(G(""),y(null))},[b]);const A=l.useMemo(()=>{const D=new Map;for(const te of n)D.set(te.provider,(D.get(te.provider)??0)+1);const re=[];for(const[te,ge]of[...D.entries()].sort((C,Q)=>C[0].localeCompare(Q[0]))){const C=c[te];if(C&&C.length>1)for(const Q of C)re.push({provider:te,keyName:Q.name,count:ge});else re.push({provider:te,keyName:null,count:ge})}return re},[n,c]),J=l.useMemo(()=>ih(n,R),[n,R]),k=l.useMemo(()=>{let D=J;K&&(D=D.filter(te=>te.provider===K.provider));const re=M.trim().toLowerCase();return re?D.filter(te=>te.name.toLowerCase().includes(re)||te.provider.toLowerCase().includes(re)||te.id.toLowerCase().includes(re)):D},[J,M,K]),le=l.useMemo(()=>{const D=[];for(const re of k){const te=c[re.provider];if(!te||te.length<=1){D.push({model:re,key:null});continue}let ge=te.find(C=>C.active)??te[0];if(K?.provider===re.provider&&K.keyName){const C=te.find(Q=>Q.name===K.keyName);C&&(ge=C)}D.push({model:re,key:ge})}return D},[k,c,K]),[Y,me]=l.useState(!1),he=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,I=dh.map(D=>({value:D,label:u(`thinking.${D}`),supported:he?he.has(D):!0})),j=D=>I.find(re=>re.value===D)?.label??D;return l.useEffect(()=>{b&&n.length===0&&!Y&&!a&&(me(!0),o({type:"list_models"}))},[b,n.length,Y,a,o]),l.useEffect(()=>{n.length>0&&me(!1)},[n.length]),l.useEffect(()=>{if(!b)return;H.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[b,g,n.length]),s.jsxs(s.Fragment,{children:[s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(vs,{}),s.jsx("span",{className:"chip-model",children:f?f.name:u("selectModel")}),!d&&f?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!d&&f&&s.jsx("span",{className:"chip-sub",children:f.provider})]}),open:b,onOpenChange:x,menuClassName:"dd-menu-model",menuRef:V,menuStyle:se!=null?{width:se}:void 0,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("availableModels")}),s.jsxs("div",{className:"dd-search-row",children:[s.jsx(zs,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:M,onChange:D=>G(D.target.value)})]}),s.jsxs("div",{className:"dd-model-body",children:[A.length>1&&s.jsxs("div",{className:"dd-provider-col",children:[s.jsx("div",{className:"dd-provider-head",children:u("providers")}),s.jsx("button",{type:"button",className:`dd-provider-item ${K===null?"active":""}`,onClick:()=>y(null),children:s.jsx("span",{children:u("allProviders")})}),A.map(D=>{const re=K?.provider===D.provider&&K?.keyName===D.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${re?"active":""}`,onClick:()=>y(re?null:{provider:D.provider,keyName:D.keyName}),title:D.keyName?`${D.provider} · ${D.keyName}`:`${D.provider} · ${D.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:D.provider}),D.keyName&&s.jsx("span",{className:"dd-provider-key",children:D.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:D.count})]},D.keyName?`${D.provider}::${D.keyName}`:D.provider)})]}),s.jsxs("div",{className:"dd-model-scroll",ref:H,children:[(Y||a)&&s.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!Y&&!a&&s.jsx("div",{className:"dd-loading",children:u("noModels")}),k.length===0&&n.length>0&&s.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),le.map(D=>{const re=D.model,te=g===re.id&&(!D.key||D.key.active);return s.jsx(nt,{active:te,onClick:()=>{D.key&&!D.key.active&&o({type:"activate_provider_key",provider:re.provider,keyName:D.key.name}),g!==re.id&&o({type:"set_model",modelId:re.id}),x(!1)},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:re.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:re.provider}),D.key&&s.jsxs("span",{className:`dd-model-key ${D.key.active?"active":""}`,children:[D.key.active?"●":"○"," ",D.key.name]}),(R[re.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:R[re.id]})}),(re.reasoning||re.vision)&&s.jsxs("span",{className:"dd-model-badges",children:[re.reasoning&&s.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),re.vision&&s.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},D.key?`${re.id}::${D.key.name}`:re.id)})]})]}),s.jsxs("div",{className:"dd-footer",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>o({type:"list_models"}),children:u("refreshModels")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{x(!1),i()},children:u("manageModels")})]})]}),s.jsxs(wt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ms,{}),s.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:t?j(t.thinkingLevel):"—"})})]}),open:N,onOpenChange:S,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),I.map(D=>s.jsx(nt,{active:t?.thinkingLevel===D.value,disabled:!D.supported,title:D.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==D.value&&o({type:"set_thinking",level:D.value}),S(!1)},children:D.label},D.value))]})]})}),_i=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,mh=l.memo(function({ready:t,streaming:n,messages:a,slashCommands:o,modelState:i,models:c,modelsLoading:d,send:u,attachments:f,onRemoveAttachment:g,onAddImageFiles:b,onAddLocalFiles:x,onNotice:N,onSent:S,onManageModels:M,providerKeys:G,quickPhrases:K,quickPhrasesEnabled:y}){const R=Ae(),{locale:U}=Ot(),{openPicker:H}=so(),V=_=>U!=="zh"&&_.descriptionEn?_.descriptionEn:_.description??"",se=_=>U!=="zh"&&_.argumentHintEn?_.argumentHintEn:_.argumentHint??"",[X,A]=l.useState(""),[J,k]=l.useState(!1),[le,Y]=l.useState(null),[me,he]=l.useState(0),[I,j]=l.useState(!1),[D,re]=l.useState(void 0),te=l.useRef(null),ge=l.useRef(null),C=l.useRef(null),Q=l.useRef(-1),P=l.useRef(""),$={builtin:R("slashBuiltin"),extension:R("slashExtension"),prompt:R("slashPrompt"),skill:R("slashSkill"),plugin:R("slashPlugin")},T=_=>{const ue=_.match(/^\/([^\s]*)$/);if(ue&&t){const ve=ue[1].toLowerCase(),xe=o.filter(ye=>ye.name.toLowerCase().startsWith(ve));Y(xe.length>0?xe:null),he(0)}else Y(null)};l.useEffect(()=>{C.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[me,le]);const ce=_=>{const ue=le??[],ve=_??ue[me%Math.max(ue.length,1)];if(!ve){Y(null);return}const xe=X.match(/^\/([^\s]*)([\s\S]*)$/),ye=xe?xe[2]:"";A(`/${ve.name} ${ye}`),Y(null),te.current?.focus()},F=async()=>{const ve=[...a].reverse().find(xe=>xe.role==="assistant"&&xe.content.some(ye=>ye.type==="text"&&ye.text))?.content.filter(xe=>xe.type==="text").map(xe=>xe.text).join(`
324
- `);if(!ve){N("warning",R("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(ve),N("info",R("slashCopied"))}catch{N("error",R("slashCopyFailed"))}},ie=_=>{if(!_||_.length===0){N("warning",R("foldersNotSupported"));return}const ue=Array.from(_).filter(ye=>Nt(ye.type)),ve=Array.from(_).filter(ye=>!Nt(ye.type)),xe=de();ue.length>0&&xe?N("warning",xe):ue.length>0&&b(ue),ve.length>0&&x(ve)},oe=_=>{const ue=_.clipboardData?.items;if(!ue)return;const ve=[];for(const ye of ue)if(ye.kind==="file"&&Nt(ye.type)){const Oe=ye.getAsFile();Oe&&ve.push(Oe)}if(ve.length===0)return;_.preventDefault();const xe=de();if(xe){N("warning",xe);return}b(ve)},de=()=>{const _=i?.model;if(!_?.id)return null;const ue=c.find(ve=>ve.id===_.id);return ue&&ue.vision===!1?R("modelNoVision",{name:ue.name}):null},Te=t,we=l.useRef(X);l.useEffect(()=>{we.current=X},[X]),l.useEffect(()=>{T(we.current)},[o]),l.useEffect(()=>{const _=ue=>{const ve=ue.detail;A(ve),te.current?.focus()};return window.addEventListener("pi-web:fill",_),()=>window.removeEventListener("pi-web:fill",_)},[]),l.useEffect(()=>{if(!I)return;const _=ue=>{ue.key==="Escape"&&j(!1)};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[I]),l.useEffect(()=>{const _=te.current;if(!_)return;_.style.height="auto";const ue=_.scrollHeight>220;_.style.height=`${Math.min(_.scrollHeight,220)}px`,_.style.overflowY=ue?"auto":"hidden"},[X]);const v=_=>_.selectionStart!==_.selectionEnd?!1:!_.value.slice(0,_.selectionStart).includes(`
325
- `),ne=_=>_.selectionStart!==_.selectionEnd?!1:!_.value.slice(_.selectionStart).includes(`
326
- `),ae=()=>f.map(_=>_.imageData?{path:"",imageData:_.imageData,mimeType:_.mimeType,name:_.name}:_.fileData?{path:"",fileData:_.fileData,mimeType:_.mimeType,name:_.name,size:_.size}:{path:_.path,mode:_.mode,..._.lines?{lines:_.lines}:{}}),pe=(_=!1)=>{const ue=X.trim(),ve=f.some(xe=>xe.imageData||xe.fileData);if(!(!Te||!ue&&!ve)){if(ue==="/help"){const xe=te.current?.closest(".inputbox")?.getBoundingClientRect();re(xe?.width),j(!0),A(""),te.current?.focus();return}if(ue==="/copy"){A(""),te.current?.focus(),F();return}if(u({type:"prompt",text:ue,queue:_,attachments:ae()})){ue&&vi(ue),Q.current=-1,P.current="",A(""),S();const xe=i?.model;xe&&Ci(`${xe.provider}/${xe.id}`),te.current?.focus()}}},Le=_=>{const ue=_.trim();if(!(!Te||!ue)&&u({type:"prompt",text:ue,attachments:ae()})){ue&&vi(ue),Q.current=-1,P.current="",S();const ve=i?.model;ve&&Ci(`${ve.provider}/${ve.id}`),_i||te.current?.focus()}},Be=_=>{if(!_.nativeEvent.isComposing){if(le&&le.length>0)switch(_.key){case"ArrowDown":_.preventDefault(),he(ue=>(ue+1)%le.length);return;case"ArrowUp":_.preventDefault(),he(ue=>(ue-1+le.length)%le.length);return;case"Tab":case"Enter":_.preventDefault(),ce();return;case"Escape":_.preventDefault(),Y(null);return}if(_.key==="ArrowUp"||_.key==="ArrowDown"){if(_.ctrlKey||_.metaKey||_.altKey)return;const ue=te.current;if(!ue)return;const ve=_.key==="ArrowUp";if(ve&&!v(ue)||!ve&&!ne(ue)||!ve&&Q.current===-1)return;const xe=As();if(xe.length===0)return;if(_.preventDefault(),ve){if(Q.current===-1){P.current=X;const ye=xe.length-1;Q.current=ye;const Oe=xe[ye];A(Oe),T(Oe),requestAnimationFrame(()=>{const Me=te.current;Me&&(Me.selectionStart=Me.selectionEnd=Oe.length)})}else if(Q.current>0){const ye=Q.current-1;Q.current=ye;const Oe=xe[ye];A(Oe),T(Oe),requestAnimationFrame(()=>{const Me=te.current;Me&&(Me.selectionStart=Me.selectionEnd=Oe.length)})}}else{const ye=Q.current+1;if(ye<xe.length){Q.current=ye;const Oe=xe[ye];A(Oe),T(Oe),requestAnimationFrame(()=>{const Me=te.current;Me&&(Me.selectionStart=Me.selectionEnd=Oe.length)})}else{Q.current=-1;const Oe=P.current;A(Oe),T(Oe),requestAnimationFrame(()=>{const Me=te.current;Me&&(Me.selectionStart=Me.selectionEnd=Oe.length)})}}return}if(_.key==="Escape"&&Q.current!==-1){_.preventDefault();const ue=P.current;Q.current=-1,A(ue),T(ue),requestAnimationFrame(()=>{const ve=te.current;ve&&(ve.selectionStart=ve.selectionEnd=ue.length)});return}if(_.key==="Enter"){if(_i&&!_.shiftKey&&!(_.ctrlKey||_.metaKey))return;_.shiftKey||(_.preventDefault(),pe())}}},Ye=()=>s.jsx("div",{className:"inputbox-actions",children:n?s.jsxs(s.Fragment,{children:[X.trim()!==""&&s.jsxs("button",{type:"button",className:"btn supplement",title:R("supplementTip"),onClick:()=>pe(!0),children:[s.jsx(Vs,{})," ",R("supplement")]}),s.jsx("button",{type:"button",className:"btn stop",title:R("stopAgent"),onClick:()=>u({type:"abort"}),children:s.jsx(Ys,{})})]}):s.jsx("button",{type:"button",className:"btn send",title:R("sendTip"),disabled:!Te||!X.trim()&&!f.some(_=>_.imageData||_.fileData),onClick:()=>pe(),children:s.jsx(Gi,{})})});return s.jsxs("div",{className:`inputbar${J?" drop-active":""}`,onDragOver:_=>{_.preventDefault(),_.stopPropagation(),k(!0)},onDragLeave:_=>{_.currentTarget.contains(_.relatedTarget)||k(!1)},onDrop:_=>{_.preventDefault(),_.stopPropagation(),k(!1),ie(_.dataTransfer?.files??null)},children:[J&&s.jsx("div",{className:"drop-overlay",children:s.jsxs("span",{children:["📎 ",R("dropHereToAttach")]})}),f.length>0&&s.jsxs("div",{className:"attach-row",children:[f.map(_=>s.jsxs("span",{className:`attach-chip ${_.imageData?"image":_.fileData?"file":_.mode}`,title:_.imageData?R("attachImage",{name:_.name}):_.fileData?R("attachFile",{name:_.name}):_.isDir?R("folderRef",{path:_.path}):_.mode==="reference"?R("refOnly",{path:_.path}):_.mode==="lines"&&_.lines?R("attachLines",{path:_.path,start:_.lines.start,end:_.lines.end}):R("attachContent",{path:_.path}),children:[_.imageData?"🖼":_.fileData?"📄":_.isDir?"📁":_.mode==="reference"?"🔗":"📎"," ",_.name,_.mode==="lines"&&_.lines&&s.jsxs("span",{className:"attach-range",children:["L",_.lines.start,"-",_.lines.end]}),s.jsx("button",{type:"button",className:"attach-remove",title:R("removeAttachment"),onClick:()=>g(_.key??_.path),children:"×"})]},_.key??`${_.path}|${_.mode}|${_.lines?`${_.lines.start}-${_.lines.end}`:""}`)),s.jsx("span",{className:"attach-hint",children:R("attachHint")})]}),le&&le.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:C,"aria-label":R("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:R("slashMenuHint")}),s.jsx("span",{className:"slash-menu-close",onClick:()=>Y(null),children:"Esc"})]}),le.map((_,ue)=>s.jsxs("button",{type:"button",className:`slash-item${ue===me?" active":""}`,onMouseEnter:()=>he(ue),onClick:()=>ce(_),children:[s.jsxs("span",{className:"slash-name",children:["/",_.name]}),s.jsx("span",{className:`slash-source ${_.source}`,children:$[_.source]}),s.jsxs("span",{className:"slash-desc",children:[V(_),_.argumentHint&&s.jsx("span",{className:"slash-hint",children:se(_)})]})]},_.name))]}),I&&s.jsx("div",{className:"modal-backdrop",onClick:()=>j(!1),children:s.jsxs("div",{className:"slash-help",style:D?{width:D}:void 0,onClick:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",R("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>j(!1),children:R("close")})]}),s.jsx("div",{className:"slash-help-body",children:o.length===0?s.jsx("div",{className:"slash-help-empty",children:R("slashLoading")}):o.map(_=>s.jsxs("div",{className:"slash-help-row",children:[s.jsxs("span",{className:"slash-help-cmd",children:["/",_.name]}),s.jsx("span",{className:`slash-source ${_.source}`,children:$[_.source]}),s.jsxs("span",{className:"slash-help-desc",children:[V(_),_.argumentHint&&s.jsx("span",{className:"slash-hint",children:se(_)})]})]},_.name))})]})}),y&&K.length>0&&s.jsx("div",{className:"quick-row","aria-label":R("quickPhrases"),children:K.map(_=>s.jsx("button",{type:"button",className:"quick-chip",title:R("quickPhrasesTip",{text:_}),disabled:!Te,onClick:()=>Le(_),children:_},_))}),s.jsxs("div",{className:"inputbox",children:[s.jsx("input",{ref:ge,type:"file",multiple:!0,hidden:!0,onChange:_=>{ie(_.target.files),_.target.value=""}}),s.jsx("textarea",{ref:te,value:X,rows:1,placeholder:R(Te?n?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!Te,onChange:_=>{Q.current=-1,A(_.target.value),T(_.target.value)},onKeyDown:Be,onPaste:oe}),s.jsxs("div",{className:"composer-tools",children:[s.jsxs("div",{className:"composer-tools-left",children:[s.jsx("button",{type:"button",className:"btn attach-img",title:R("uploadFile"),disabled:!Te,onClick:()=>ge.current?.click(),children:s.jsx(cl,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:R("tpl.openPicker"),onClick:H,children:s.jsx(xl,{})}),s.jsx(ph,{state:i,models:c,modelsLoading:d,send:u,onManageModels:M,providerKeys:G,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:Ye()})]})]})]})}),hh=l.memo(function({goal:t,models:n,modelsLoading:a,activeConversationId:o,engine:i,send:c}){const d=Ae(),{locale:u}=Ot(),f=u!=="zh"&&t.statusEn?t.statusEn:t.status||"",g=u!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",b=i==="dsh",x=!t.conversationId||t.conversationId===o,N=t.goal!==null&&x,[S,M]=l.useState(""),[G,K]=l.useState(t.reviewModel??""),[y,R]=l.useState(t.maxRounds),[U,H]=l.useState(t.locked),[V,se]=l.useState(!1),[X,A]=l.useState(!1),[J,k]=l.useState(!0);l.useEffect(()=>{K(t.reviewModel??""),R(t.maxRounds||0),H(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),l.useEffect(()=>{V&&n.length===0&&!X&&!a&&(A(!0),c({type:"list_models"}))},[V,n.length,X,a,c]),l.useEffect(()=>{n.length>0&&A(!1)},[n.length]);const le=()=>G?n.find(I=>I.id===G)?.name??G:d("goalBarUseMainModel"),Y=()=>{const I=S.trim();I&&(c({type:"set_goal",goal:I,...G?{reviewModel:G}:{},maxRounds:y,locked:U}),M(""),k(!1))},me=()=>{const I=S.trim();I&&(c({type:"start_goal_wizard",text:I,...G?{wizardModel:G}:{},maxRounds:y,locked:U}),M(""),k(!1))},he=(t.wizard?.active??!1)&&x;return he?s.jsx("div",{className:`goalbar goalbar-active ${he?"wizard":""}`,children:s.jsxs("div",{className:"goalbar-active-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx("span",{className:"goalbar-spin",children:"🔍"})}),s.jsxs("span",{className:"goalbar-text",title:t.wizard?.draft??"",children:[d("goalWizardRunning"),": ",t.wizard?.draft]}),s.jsxs("span",{className:"goalbar-chip reviewing",children:[d("goalBarRound",{n:(t.wizard?.step??0)+1})," / ",t.wizard?.maxSteps??6]}),s.jsx("span",{className:"goalbar-detail",children:g||d("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx(Je,{})})]})}):N?s.jsx("div",{className:`goalbar goalbar-active ${t.reviewing?"reviewing":""}`,children:s.jsxs("div",{className:"goalbar-active-row",children:[s.jsx("span",{className:"goalbar-icon",children:t.reviewing?s.jsx("span",{className:"goalbar-spin",children:"◌"}):"🎯"}),s.jsx("span",{className:"goalbar-text",title:t.goal??"",children:t.goal}),t.reviewing?s.jsxs("span",{className:"goalbar-chip reviewing",children:[d("goalBarReviewing")," ",d("goalBarRound",{n:t.round})]}):s.jsx("span",{className:`goalbar-chip ${t.verdict==="pass"?"pass":t.verdict==="fail"?"fail":""}`,children:t.verdict==="pass"?d("goalBarPassed"):t.verdict==="fail"?d("goalBarFailed"):`${d("goalBarRound",{n:t.round||1})} · ${t.locked?d("goalBarLocked"):d("goalBarUnlocked")}`}),s.jsx("span",{className:"goalbar-detail",children:f}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),disabled:t.reviewing,onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx(Je,{})})]})}):J?s.jsx("div",{className:"goalbar goalbar-collapsed",children:s.jsxs("button",{type:"button",className:"goalbar-hint",title:d("goalBarPlaceholder"),onClick:()=>k(!1),children:[s.jsx(wa,{})," ",s.jsx("span",{children:d("goalBarTitle")})]})}):s.jsxs("div",{className:"goalbar",children:[s.jsxs("div",{className:"goalbar-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx(wa,{})}),s.jsx("input",{className:"goalbar-input",value:S,placeholder:d("goalBarPlaceholder"),onChange:I=>M(I.target.value),onKeyDown:I=>{I.key==="Enter"&&Y()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!S.trim(),onClick:Y,children:d("goalBarSet")}),s.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!S.trim(),title:d("goalWizardTip"),onClick:me,children:["🔍 ",d("goalWizardBtn")]}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d(U?"goalBarLocked":"goalBarUnlocked"),onClick:()=>H(I=>(c({type:"set_goal_prefs",locked:!I}),!I)),children:U?s.jsx(gl,{}):s.jsx(il,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d("goalBarClear"),onClick:()=>k(!0),children:s.jsx(on,{})})]}),s.jsxs("div",{className:"goalbar-opts",children:[b?s.jsx("p",{className:"goalbar-dsh-note",children:d("dshNoReviewModel")}):s.jsxs(wt,{trigger:s.jsxs("span",{className:"goalbar-opt",children:[d("goalBarReviewModel"),": ",s.jsx("b",{children:le()})]}),open:V,onOpenChange:se,direction:"up",children:[s.jsx("div",{className:"dd-header",children:d("goalBarReviewModel")}),(X||a)&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.length===0&&!X&&!a&&s.jsx("div",{className:"dd-loading",children:d("noModels")}),s.jsx(nt,{active:G==="",onClick:()=>{K(""),se(!1),c({type:"set_goal_prefs",reviewModel:""})},children:d("goalBarUseMainModel")}),n.map(I=>s.jsx(nt,{active:G===I.id,onClick:()=>{K(I.id),se(!1),c({type:"set_goal_prefs",reviewModel:I.id})},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:I.name}),s.jsx("span",{className:"dd-model-meta",children:s.jsx("span",{className:"dd-model-provider",children:I.provider})})]})},I.id)),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:d("refreshModels")})]}),s.jsxs("label",{className:"goalbar-round",title:d("goalBarMaxRoundsTip"),children:[s.jsx("span",{children:d("goalBarMaxRounds")}),s.jsx("input",{type:"number",min:0,step:1,value:y,placeholder:d("goalBarUnlimitedShort"),onChange:I=>{const j=parseInt(I.target.value,10);if(Number.isNaN(j)||j<0){R(0);return}R(j)},onBlur:()=>c({type:"set_goal_prefs",maxRounds:y}),onKeyDown:I=>{I.key==="Enter"&&(c({type:"set_goal_prefs",maxRounds:y}),I.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:d(U?"goalBarLocked":"goalBarUnlocked")})]})]})});function fh(e){const t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),a=Math.max(0,e.cacheWrite??0),o=t+n+a;return{totalInput:o,miss:t,read:n,write:a,hitRate:o>0?Math.min(n/o,1):0,writeRate:o>0?Math.min(a/o,1):0}}const uo=2e3;function gh(e,t,n=uo){return e.filter(a=>t-a.t<=n)}function bh(e,t=uo){if(e.length<2)return 0;const n=e[e.length-1],a=e.find(i=>i.t>=n.t-t)??e[0],o=(n.t-a.t)/1e3;return o<=0?0:Math.max(0,(n.out-a.out)/o)}function Si(e){if(!e)return 0;let t=0;for(let a=0;a<e.length;a++){const o=e.charCodeAt(a);(o>=12352&&o<=12543||o>=13312&&o<=19903||o>=19968&&o<=40959||o>=63744&&o<=64255||o>=65280&&o<=65519||o===12288)&&t++}const n=e.length-t;return Math.round(t+n/4)}function Eh(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=Si(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=Si(n.thinking));return t}const gt="@root";function Th({chat:e,send:t}){const n=Ae(),a=e.state,[o,i]=l.useState(!1),[c,d]=l.useState(""),[u,f]=l.useState(""),[g,b]=l.useState(!1),[x,N]=l.useState(""),[S,M]=l.useState(-1),G=l.useRef(null),K=l.useRef(null),y=e.pathCompletions.filter(T=>T.type==="dir"),R=T=>T.endsWith("/")?T:T+"/",U=T=>{let ce=T.endsWith("/")&&T!=="/"?T.slice(0,-1):T;if(ce===gt||ce==="/")return null;const F=ce.lastIndexOf("/");if(F<0)return/^[A-Za-z]:$/.test(ce)?gt:null;if(F===0)return"/";const ie=ce.slice(0,F);return/^[A-Za-z]:$/.test(ie)?ie+"/":ie};l.useEffect(()=>{if(!o)return;const T=setTimeout(()=>{t({type:"complete_path",path:R(c)})},60);return()=>clearTimeout(T)},[c,o,t]),l.useEffect(()=>{if(!o||u===c)return;const T=setTimeout(()=>{t({type:"complete_path",path:u})},150);return()=>clearTimeout(T)},[u,c,o,t]);const H=l.useRef([]),V=a?.isStreaming??!1,se=a?.streamingMessage?Eh(a.streamingMessage.content):0;if(l.useEffect(()=>{if(!V){H.current=[];return}const T=Date.now(),ce=H.current,F=ce[ce.length-1];F&&T-F.t<250||(H.current=gh([...ce,{t:T,out:se}],T))},[V,se]),!a)return null;const X=a.stats,A=fh(X.tokens),J=A.hitRate*100,k=A.totalInput===0?"":A.hitRate>=.7?"ok":A.hitRate>=.4?"mid":"warn",le=A.totalInput>0?`${J.toFixed(1)}%`:"—",Y=V?bh(H.current):0,me=e.ready?"ok":"busy",he=e.ready?n("connected"):n("connecting"),I=X.contextUsage,j=I.tokens!==null&&I.percent!==null?`${I.estimated?"~":""}${Yt(I.tokens)} / ${Yt(I.contextWindow)}`:"—",D=I.percent??null,re=D===null?"":D>=80?"warn":D>=50?"mid":"ok",te=a.queue.steering.length+a.queue.followUp.length,ge=()=>{const T=a.cwd.replace(/\\/g,"/");f(T),d(T),b(!1),N(""),i(!0)},C=T=>{const ce=T.trim();ce!==gt&&(ce&&ce!==a.cwd&&t({type:"set_cwd",path:ce}),i(!1))},Q=()=>{const T=x.trim();T&&(t({type:"make_dir",path:`${R(c)}${T}`}),setTimeout(()=>{t({type:"complete_path",path:R(c)})},80),N(""),b(!1))},P=T=>{if(T.key==="Escape")T.stopPropagation(),i(!1);else if(T.key==="Enter"&&!T.nativeEvent.isComposing)C(u);else if(T.key==="Tab"){if(y.length===0)return;T.preventDefault();const ce=S>=0?(S+1)%y.length:0;M(ce),f(y[ce].path),d(y[ce].path)}},$=U(c);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${me}`,title:he}),s.jsx("span",{className:"status-item",children:he}),s.jsx("span",{className:"status-sep",children:"·"}),e.engine&&e.engine!=="pi"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`status-item engine-badge engine-${e.engine}`,title:`${n("engineBadge")}: ${e.engine}`,children:e.engine==="dsh"?"DSH":e.engine}),s.jsx("span",{className:"status-sep",children:"·"})]}),s.jsxs("span",{className:"status-item status-ctx",title:n("contextUsage"),children:[n("context"),s.jsx("span",{className:`ctx-bar ${re}`,children:D!==null&&s.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(D,100)}%`}})}),j]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("cumulativeCost"),children:["$",xh(X.cost)]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item status-cache",title:n("cacheHitTip",{read:Yt(A.read),write:Yt(A.write),miss:Yt(A.miss),input:Yt(A.totalInput)}),children:[n("cacheHit"),s.jsx("b",{className:`cache-pct ${k}`,children:le})]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("sessionMessages"),children:[n("messages")," ",X.totalMessages]}),e.statuses.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"status-sep",children:"·"}),s.jsx("span",{className:"status-item ext-status",title:n("pluginStatus"),children:e.statuses.map(T=>T.text).join(" · ")})]}),a.isStreaming&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item working",children:[s.jsx("span",{className:"working-spin"}),n("working"),te>0&&s.jsxs("span",{className:"status-queue",children:["⏳ ",te," ",n("queued")]})]}),s.jsx("span",{className:"status-item status-rate",title:n("rateTip"),children:Y>0?`${Math.round(Y)}${n("tps")}`:"…"})]}),o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"status-cwd-backdrop",onClick:()=>i(!1)}),s.jsxs("div",{className:"cwd-picker",children:[s.jsxs("div",{className:"cwd-picker-head",children:[s.jsxs("span",{className:"cwd-picker-title",title:c===gt?n("computer"):c,children:[c===gt?"💻":s.jsx(Rt,{}),s.jsx("span",{children:c===gt?n("computer"):c})]}),s.jsx("button",{type:"button",className:"cwd-up",disabled:c===gt,title:n("computer"),onClick:()=>{d(gt),f(gt),M(-1)},children:"💻"}),s.jsxs("button",{type:"button",className:"cwd-up",disabled:!$,title:n("cwdGoUp"),onClick:()=>{$&&(d($),f($),M(-1))},children:["↑ ",n("cwdGoUp")]})]}),s.jsxs("div",{className:"cwd-picker-row",children:[s.jsx("input",{ref:G,className:"status-cwd-input cwd-picker-input",value:u,placeholder:n("enterPath"),spellCheck:!1,onChange:T=>{f(T.target.value),M(-1)},onKeyDown:P}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:n("cwdPickCurrent"),disabled:c===gt,onClick:()=>C(c),children:n("cwdPickCurrent")})]}),s.jsxs("div",{className:"cwd-list",children:[y.length===0&&s.jsx("div",{className:"cwd-empty",children:n("cwdEmpty")}),y.map(T=>s.jsxs("div",{className:"cwd-item",children:[s.jsxs("button",{type:"button",className:"cwd-enter",title:`${n("cwdEnter")} ${T.path}`,onClick:()=>{d(T.path),f(T.path),M(-1)},children:[s.jsx(Rt,{}),s.jsx("span",{className:"cwd-name",children:T.name})]}),s.jsx("button",{type:"button",className:"cwd-choose-btn",title:n("cwdChoose"),onClick:()=>C(T.path),children:n("cwdChoose")})]},T.path))]}),s.jsx("div",{className:"cwd-picker-foot",children:g?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:K,value:x,autoFocus:!0,spellCheck:!1,placeholder:n("cwdNewName"),onChange:T=>N(T.target.value),onKeyDown:T=>{T.key==="Enter"&&!T.nativeEvent.isComposing?(T.preventDefault(),Q()):T.key==="Escape"&&(T.stopPropagation(),b(!1),N(""))}}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:Q,children:n("cwdCreate")}),s.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{b(!1),N("")},children:n("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>b(!0),children:["+ ",n("cwdNewFolder")]})})]})]}):s.jsxs("button",{type:"button",className:"status-item status-cwd",title:n("cwdTip",{path:a.cwd}),onClick:ge,children:["📁 ",a.cwd]})]})}function Yt(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function xh(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function yh({dialog:e,send:t}){const n=Ae(),[a,o]=l.useState(""),[i,c]=l.useState(0),d=g=>{t({type:"dialog_response",id:e.id,value:g})};l.useEffect(()=>{o(""),c(0);const g=b=>{b.key==="Escape"&&d(null)};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[e.id]);const u=Array.isArray(e.args[0])?e.args[0]:[],f=typeof e.args[0]=="string"?e.args[0]:"";return s.jsxs("div",{className:"dialog-inline","data-dialog-kind":e.kind,children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("span",{className:"dialog-badge",children:n("pluginRequest")}),e.title&&e.title!==n("pluginRequest")&&s.jsx("span",{className:"dialog-title",children:e.title}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>d(null),children:"✕"})]}),e.kind==="select"&&s.jsxs("div",{className:"dialog-options",children:[u.map((g,b)=>s.jsx("button",{type:"button",className:`dialog-option ${b===i?"sel":""}`,onMouseEnter:()=>c(b),onClick:()=>d(g),children:s.jsx(at,{text:g,rawHtml:!0})},b)),u.length===0&&s.jsx("div",{className:"dialog-hint",children:n("noOptions")})]}),e.kind==="confirm"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx(at,{text:f,rawHtml:!0}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(!1),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(!0),children:n("ok")})]})]}),e.kind==="input"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx("input",{className:"dialog-input",value:a,placeholder:f||n("inputPlaceholder"),autoFocus:!0,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.nativeEvent.isComposing&&d(a)}}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(null),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(a),children:n("ok")})]})]})]})}function Nh({question:e,send:t}){const n=Ae(),[a,o]=l.useState({}),[i,c]=l.useState({}),[d,u]=l.useState(0),[f,g]=l.useState(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);l.useEffect(()=>{o({}),c({}),u(0),g(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),l.useEffect(()=>{if(!e.deadline)return;const U=setInterval(()=>{g(H=>{const V=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return V<=0&&H>0&&t({type:"question_answer",id:e.id,answers:[],cancelled:!0}),V})},1e3);return()=>clearInterval(U)},[e.id,e.deadline]),l.useEffect(()=>{const U=H=>{H.key==="Escape"&&S()};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[e.id]);const b=e.questions.length,x=e.questions[d];if(!x)return null;const N=U=>{const H=e.questions.map(V=>{const se=U[V.id]??[],X=(i[V.id]??"").trim();return{id:V.id,selected:se,...X?{custom:X}:{}}});t({type:"question_answer",id:e.id,answers:H})},S=()=>{t({type:"question_answer",id:e.id,answers:[],cancelled:!0})},M=(U,H)=>{o(V=>{const se=V[U]??[];return{...V,[U]:se.includes(H)?se.filter(X=>X!==H):[...se,H]}})},G=(U,H,V)=>{if(V){M(U,H);return}const se={...a,[U]:[H]};o(se),d===b-1?N(se):u(d+1)},K=()=>{d===b-1?N(a):u(d+1)},y=U=>(e.questions.find(V=>V.id===U)?.options?.length??0)===0?!0:(a[U]?.length??0)>0||(i[U]??"").trim()!=="",R=(x.options??[]).filter(U=>(a[x.id]??[]).includes(U.label)&&U.preview).map(U=>U.preview);return s.jsxs("div",{className:"dialog-inline","data-dialog-kind":"select",children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("span",{className:"dialog-badge",children:n("modelQuestion")}),b>1&&s.jsx("span",{className:"question-progress",children:n("questionStep",{cur:d+1,total:b})}),f>=0&&s.jsx("span",{className:"question-timer",children:f>0?n("questionTimeout",{s:f}):n("questionTimeoutExpired")}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:S,children:"✕"})]}),s.jsxs("div",{className:"set-section",children:[s.jsx("div",{className:"set-section-title",children:x.header??`${n("modelQuestion")} ${d+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(at,{text:x.question,rawHtml:!0})}),x.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(at,{text:x.detail,rawHtml:!0})}),(x.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:x.options.map(U=>{const H=(a[x.id]??[]).includes(U.label);return s.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>G(x.id,U.label,!!x.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:x.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ "}),s.jsx(at,{text:U.label,rawHtml:!0})]}),U.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(at,{text:U.description,rawHtml:!0})})]},U.label)})}),R.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:n("optionPreview")}),R.map((U,H)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(at,{text:U,rawHtml:!0})},H))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:n("modelQuestionCustom"),value:i[x.id]??"",onChange:U=>c(H=>({...H,[x.id]:U.target.value})),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),y(x.id)&&K())}})]},x.id),s.jsxs("div",{className:"dialog-nav",children:[s.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:S,children:n("cancel")}),s.jsxs("div",{className:"dialog-nav-right",children:[s.jsx("button",{type:"button",className:"dialog-prev",disabled:d===0,onClick:()=>u(d-1),children:n("previous")}),s.jsx("button",{type:"button",className:"dialog-submit",disabled:!y(x.id),onClick:K,children:d===b-1?n("modelQuestionSubmit"):n("next")})]})]})]})}const Ai=e=>`'${e.replace(/'/g,"'\\''")}'`;function kh(e){if(e.x==="?"&&e.y==="?")return"untracked";const t=e.x!==" "&&e.x!=="?",n=e.y!==" "&&e.y!=="?";return t&&n?"both":t?"staged":"unstaged"}function Ch({chat:e,send:t,terminal:n,active:a,onSwitchToTerminal:o}){const i=Ae(),[c,d]=l.useState(null),[u,f]=l.useState([]),[g,b]=l.useState(""),[x,N]=l.useState(new Map),[S,M]=l.useState("changes"),[G,K]=l.useState([]),[y,R]=l.useState(null),[U,H]=l.useState(""),[V,se]=l.useState(!1),[X,A]=l.useState(null),[J,k]=l.useState(null),[le,Y]=l.useState(!1),[me,he]=l.useState(!1),[I,j]=l.useState(!1),[D,re]=l.useState(null),[te,ge]=l.useState(!1),[C,Q]=l.useState(""),P=l.useRef(0),$=l.useRef(-1),T=l.useRef(-1),ce=l.useRef(-1),F=l.useRef(-1),ie=l.useRef(void 0),oe=l.useRef(null),de=l.useRef([]),Te=l.useCallback(B=>{if(B.reqId===$.current){if($.current=-1,he(!1),re(null),!B.ok){re(B.error??i("scmQueryFailedShort"));return}if(B.notRepo){ge(!0),d(null),f([]),N(new Map),K([]),R(null),H(""),k(null);return}ge(!1);const _e={branch:B.branch??"",detached:!!B.detached,upstream:B.upstream??null,ahead:B.ahead??0,behind:B.behind??0,upstreamGone:!!B.upstreamGone,files:(B.files??[]).map(Re=>({...Re}))},Ce=(B.branches??[]).map(Re=>({...Re})),Ue=new Map;for(const[Re,We]of Object.entries(B.stats??{}))Ue.set(Re,{add:We[0],del:We[1]});d(_e),f(Ce),N(Ue),b(Re=>_e.detached?Re||"":_e.branch&&Ce.some(We=>We.name===_e.branch)?_e.branch:Re&&Ce.some(We=>We.name===Re)?Re:Ce[0]?.name??""),k(Re=>Re&&!_e.files.some(We=>We.path===Re.file.path)?null:Re)}else if(B.reqId===T.current){if(T.current=-1,Y(!1),!B.ok){re(B.error??i("scmQueryFailedShort"));return}const _e=oe.current;if(!_e)return;k({file:_e,staged:B.stagedText??"",worktree:B.worktreeText??"",untracked:!1})}else if(B.reqId===F.current){if(F.current=-1,j(!1),!B.ok){re(B.error??i("scmQueryFailedShort"));return}K((B.history??[]).map(_e=>({..._e})))}else if(B.reqId===ce.current){if(ce.current=-1,se(!1),!B.ok){re(B.error??i("scmQueryFailedShort"));return}H(B.text??"")}},[]);l.useEffect(()=>{const B=e.scmData;B&&B.type==="scm_data"&&Te(B)},[e.scmData,Te]);const we=l.useCallback((B,_e)=>{if(!e.ready||e.status!=="open")return!1;const Ce=++P.current;return t({...B,reqId:Ce})?(_e.current=Ce,!0):(P.current-=1,!1)},[e.ready,e.status,t]),v=l.useCallback((B=!1,_e=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(ie.current!==void 0&&ie.current!==e.state.cwd&&(d(null),f([]),N(new Map),K([]),j(!1),F.current=-1,R(null),H(""),k(null),A(null)),ie.current=e.state.cwd,re(null),we({type:"scm_status"},$)&&(_e||he(!0)))},[e.ready,e.state?.cwd,e.status,we]),ne=l.useCallback(B=>{if(A(B),R(null),oe.current=B,B.x==="?"&&B.y==="?"){k({file:B,staged:"",worktree:"",untracked:!0});return}Y(!0),re(null),we({type:"scm_filediff",path:B.path},T)||Y(!1)},[we]),ae=l.useCallback(B=>{R(B),A(null),k(null),H(""),se(!0),re(null),we({type:"scm_commit",hash:B.hash},ce)||se(!1)},[we]),pe=l.useCallback((B,_e)=>{if(!e.ready)return;const Ce={name:B,command:_e,cwd:"${pwd}"};let Ue;const Re=e.terminals.find(We=>We.title===B);Re?(n.restart(Re.id),t({type:"run_command",terminalId:Re.id,conversationId:Re.conversationId,command:Ce,cols:80,rows:24}),Ue=Re.id):(Ue=Ct(),n.create({id:Ue,conversationId:e.activeConversationId||e.state?.conversationId||"",title:B,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ce})),n.select(Ue),o()},[e.ready,e.state?.cwd,e.terminals,o,t,n]),Le=l.useCallback(()=>{const B=C.trim();if(!B||te)return;const _e=B.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");pe("git commit",`git commit -m "${_e}"`),Q("")},[C,te,pe]),Be=l.useCallback(()=>{const B=C.trim();if(!B||te)return;const _e=B.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");pe("git commit",`git add -A && git commit -m "${_e}"`),Q("")},[C,te,pe]),Ye=l.useCallback(B=>{te||pe("git add",`git add -- ${Ai(B.path)}`)},[te,pe]),_=l.useCallback(B=>{te||pe("git reset",`git reset HEAD -- ${Ai(B.path)}`)},[te,pe]),ue=l.useCallback(()=>{if(!g||te)return;const B=u.find(_e=>_e.name===g);if(B?.remote&&typeof B.remote=="string"){const _e=g.slice(B.remote.length+1);pe("git checkout",`git checkout -b ${_e} ${g} || git checkout ${g}`)}else pe("git checkout",`git checkout ${g}`)},[g,u,te,pe]),ve=l.useCallback(()=>pe("git push","git push"),[pe]),xe=l.useCallback(()=>pe("git pull","git pull"),[pe]),ye=l.useCallback(()=>{we({type:"scm_history"},F)||(F.current=-1)},[we]);l.useEffect(()=>{a&&v()},[a,v]),l.useEffect(()=>{S==="history"&&c&&ye()},[S,c,ye]),l.useEffect(()=>{e.scmDirty>0&&a&&v(!1,!0)},[e.scmDirty]),l.useEffect(()=>{if(!a||!e.ready||e.status!=="open")return;const B=setInterval(()=>{document.visibilityState!=="hidden"&&v(!1,!0)},3e4);return()=>clearInterval(B)},[a,e.ready,e.status,v]),l.useEffect(()=>{const B=de.current;if(de.current=e.terminals,!a)return;e.terminals.some(Ce=>Ce.running!==!1?!1:B.find(Re=>Re.id===Ce.id)?.running===!0&&Ce.title.startsWith("git "))&&e.ready&&e.status==="open"&&(v(!1,!0),S==="history"&&c&&ye())},[e.terminals,a,e.ready,e.status,v,S,c,ye]);const Oe={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},Me=B=>{const _e=B.split(`
327
- `);return s.jsx("pre",{className:"scm-diff-pre",children:_e.map((Ce,Ue)=>{let Re="";return Ce.startsWith("diff --git")||Ce.startsWith("index ")||Ce.startsWith("new file")||Ce.startsWith("deleted file")||Ce.startsWith("old mode")||Ce.startsWith("new mode")||Ce.startsWith("similarity index")||Ce.startsWith("rename ")||Ce.startsWith("copy ")||Ce.startsWith("Binary files")||Ce.startsWith("---")||Ce.startsWith("+++")?Re="hdr":Ce.startsWith("@@")?Re="hunk":Ce.startsWith("+")?Re="add":Ce.startsWith("-")&&(Re="del"),s.jsx("div",{className:`scm-diff-line ${Re}`,children:Ce||" "},Ue)})})};return s.jsxs("div",{className:"scm-view",children:[s.jsxs("div",{className:"scm-header",children:[s.jsxs("div",{className:"scm-title-row",children:[s.jsxs("span",{className:"scm-title",children:[s.jsx(Bs,{}),i("scmTitle")]}),s.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":S==="changes",className:S==="changes"?"active":"",onClick:()=>{M("changes"),re(null)},children:i("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":S==="history",className:S==="history"?"active":"",onClick:()=>{M("history"),re(null)},children:i("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:me,onClick:()=>v(!0),children:s.jsx(Lt,{className:me?"scm-spin":""})})]}),s.jsxs("div",{className:"scm-row",children:[s.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[s.jsx(Bs,{}),c?c.detached?i("scmDetached"):c.branch:"…",c?.upstream&&s.jsx("span",{className:"scm-upstream",children:c.upstreamGone?i("scmUpstreamGone"):c.ahead>0||c.behind>0?i("scmAheadBehind",{ahead:c.ahead,behind:c.behind}):c.upstream})]}),s.jsxs("select",{className:"scm-select",value:g,disabled:te||u.length===0,title:i("scmSwitchBranch"),onChange:B=>b(B.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),u.filter(B=>!B.remote).map(B=>s.jsx("option",{value:B.name,children:B.current?`* ${B.name}`:B.name},B.name)),u.some(B=>B.remote)&&s.jsx("optgroup",{label:i("scmRemoteBranches"),children:u.filter(B=>B.remote).map(B=>s.jsx("option",{value:B.name,children:B.name},B.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!g||g===c?.branch||te,title:i("scmSwitchBranchTip",{branch:g}),onClick:ue,children:[s.jsx(Bs,{}),i("scmSwitch")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||te,title:i("scmPushTip"),onClick:ve,children:[s.jsx(Gi,{}),i("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||te,title:i("scmPullTip"),onClick:xe,children:[s.jsx(Vi,{}),i("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:C,placeholder:i("scmCommitPlaceholder"),disabled:te,onChange:B=>Q(B.target.value),onKeyDown:B=>{B.key==="Enter"&&!B.nativeEvent.isComposing&&Le()}}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!C.trim()||te,title:i("scmCommitTip"),onClick:Le,children:[s.jsx(Et,{}),i("scmCommit")]}),s.jsx("button",{type:"button",className:"btn",disabled:!C.trim()||te,title:i("scmCommitAllTip"),onClick:Be,children:i("scmCommitAll")})]})]}),s.jsxs("div",{className:"scm-body",children:[S==="history"?s.jsxs("div",{className:"scm-history",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmHistory")}),G.length>0&&s.jsx("span",{className:"scm-files-count",children:G.length})]}),s.jsx("div",{className:"scm-history-list",children:te?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!c||I?s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")}):G.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):G.map(B=>s.jsxs("button",{type:"button",className:`scm-commit ${y?.hash===B.hash?"active":""}`,onClick:()=>ae(B),title:B.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:B.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:B.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[B.shortHash," · ",B.author," · ",B.date]}),B.decorations&&s.jsx("span",{className:"scm-commit-refs",children:B.decorations})]})]},B.hash))})]}):s.jsxs("div",{className:"scm-files",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmChanges")}),c&&c.files.length>0&&s.jsx("span",{className:"scm-files-count",children:c.files.length})]}),s.jsx("div",{className:"scm-files-list",children:te?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):c?c.files.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):c.files.map(B=>{const _e=kh(B),Ce=x.get(B.path);return s.jsxs("div",{className:`scm-file ${X?.path===B.path?"active":""}`,title:Oe[_e],onClick:()=>ne(B),children:[s.jsx("span",{className:`scm-file-xy ${_e==="untracked"?"q":"x"}`,children:B.x!==" "?B.x:" "}),s.jsx("span",{className:`scm-file-xy ${_e==="untracked"?"q":"y"}`,children:B.y!==" "?B.y:" "}),s.jsx("span",{className:"scm-file-path",children:B.path}),Ce&&(Ce.add>0||Ce.del>0)&&s.jsxs("span",{className:"scm-file-stat",children:[Ce.add>0&&s.jsxs("span",{className:"add",children:["+",Ce.add]}),Ce.del>0&&s.jsxs("span",{className:"del",children:["-",Ce.del]})]}),s.jsxs("span",{className:"scm-file-actions",children:[(B.y!==" "||_e==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:B.path}),onClick:Ue=>{Ue.stopPropagation(),Ye(B)},children:"+"}),_e==="staged"||_e==="both"?s.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:B.path}),onClick:Ue=>{Ue.stopPropagation(),_(B)},children:"−"}):null]})]},B.path)}):s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),s.jsxs("div",{className:"scm-diff",children:[s.jsxs("div",{className:"scm-diff-header",children:[s.jsx("span",{children:S==="history"?y?`${y.shortHash} ${y.subject}`:i("scmCommitDetail"):X?X.path:i("scmDiff")}),(S==="history"?V:le)&&s.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),s.jsx("div",{className:"scm-diff-body",children:S==="history"?s.jsxs(s.Fragment,{children:[D&&s.jsx("div",{className:"scm-error",children:D}),!y&&!D&&s.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),y&&V&&!D&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),y&&!V&&!D&&U?Me(U):null]}):s.jsxs(s.Fragment,{children:[D&&s.jsx("div",{className:"scm-error",children:D}),!X&&!D&&s.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),X&&!J&&!D&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),X&&J&&J.untracked&&s.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),X&&J&&!J.untracked&&s.jsxs(s.Fragment,{children:[J.staged&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),Me(J.staged)]}),J.worktree&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),Me(J.worktree)]}),!J.staged&&!J.worktree&&s.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),s.jsxs("div",{className:"scm-hint",children:[s.jsx(Xt,{}),s.jsx("span",{children:i("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:o,children:i("scmViewTerminal")})]})]})}function vh({entry:e,send:t}){const n=l.useRef(null),a=Ae();return l.useEffect(()=>{const o=n.current;if(!o)return;let i;try{i=e.module.mount(o,rc(e.info.id,c=>t(c)))}catch(c){console.error(`[plugin:${e.info.id}] mount failed:`,c),o.textContent=a("pluginMountFailed",{name:e.info.name})}return()=>{if(typeof i=="function")try{i()}catch(c){console.error(`[plugin:${e.info.id}] cleanup failed:`,c)}o.textContent=""}},[e,t]),s.jsx("div",{className:"plugin-view",ref:n})}function _h({send:e,piConfigured:t,piAgentInstalled:n,managed:a,providers:o,installResult:i,onClose:c}){const d=Ae(),[u,f]=l.useState(!1),[g,b]=l.useState(""),[x,N]=l.useState(""),[S,M]=l.useState(!1);l.useEffect(()=>{e({type:"list_providers"})},[e]),l.useEffect(()=>{t&&c()},[t,c]),l.useEffect(()=>{i&&f(!1)},[i]),l.useEffect(()=>{!g&&o.length>0&&b(o.find(H=>!H.configured)?.id??o[0].id)},[o,g]);const G=()=>{u||(f(!0),e({type:"install_pi_agent"}))},K=()=>{!x.trim()||S||(M(!0),e({type:"set_provider_api_key",provider:g.trim(),apiKey:x.trim()}),setTimeout(()=>M(!1),3e3))},y=()=>{e({type:"get_state"}),e({type:"list_providers"})},R=o.find(H=>H.id===g),U=i!==null&&!i.ok;return s.jsx("div",{className:"modal-backdrop",children:s.jsxs("div",{className:"modal setup-modal",children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":d("close"),onClick:c,children:s.jsx(Je,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(vs,{className:"modal-head-icon"}),s.jsx("h2",{children:d("setupTitle")})]}),s.jsx("p",{className:"modal-desc",children:d("setupDesc")}),U?s.jsxs("div",{className:"setup-failed",children:[s.jsx("div",{className:"setup-done",children:d("installFailed")}),s.jsx("pre",{className:"setup-detail",children:i.detail}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:G,children:d("retryInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]}):n||i?.ok?s.jsxs("div",{className:"setup-key-form",children:[s.jsx("div",{className:"setup-done",children:i?.ok?d("installDone"):d("cliReadyHint")}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("provider")}),s.jsxs("select",{value:g,onChange:H=>b(H.target.value),children:[o.length===0&&s.jsx("option",{value:"",children:d("loading")}),o.map(H=>s.jsxs("option",{value:H.id,children:[H.name,"(",H.id,")",H.configured?` · ${d("configured")}`:""]},H.id))]}),R?.configured&&s.jsx("div",{className:"field-hint",children:d("providerKeyReady")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:x,onChange:H=>N(H.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!x.trim()||S||!g,onClick:K,children:d(S?"saving":"saveAndStart")}),s.jsxs("button",{type:"button",className:"btn",onClick:y,children:[s.jsx(Lt,{})," ",d("recheck")]})]})]}):a?s.jsxs("div",{className:"setup-actions",children:[s.jsx("div",{className:"setup-done",children:d("updatesManaged")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]}):s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:G,children:d(u?"installing":"autoInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]})})}const Sh=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],ba=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),Ah=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[ba()]});function wn(e){return{providerId:e.providerId,name:e.name??"",api:e.api??"openai-completions",baseUrl:e.baseUrl??"",apiKey:e.apiKey??"",authHeader:e.authHeader??!1,models:(e.models.length?e.models:[ba()]).map(t=>({id:t.id,name:t.name??"",reasoning:t.reasoning??!1,input:t.input?.includes("image")?"text-image":"text",contextWindow:t.contextWindow?String(t.contextWindow):"",maxTokens:t.maxTokens?String(t.maxTokens):""}))}}function wh({send:e,providers:t,providerStatus:n,providerKeys:a,fetchModelsResult:o,cloneProviderResult:i,onClose:c}){const d=Ae(),[u,f]=l.useState(null),[g,b]=l.useState({}),[x,N]=l.useState({}),[S,M]=l.useState(null),[G,K]=l.useState(!1),[y,R]=l.useState(0),[U,H]=l.useState(null),V=l.useRef(0),[se,X]=l.useState(null),[A,J]=l.useState(""),[k,le]=l.useState(null);l.useEffect(()=>{e({type:"list_models_config"}),e({type:"list_providers"}),e({type:"list_provider_keys"})},[e]);const Y=()=>{if(!u)return;const C=u.baseUrl.trim();if(!C){H({ok:!1,text:d("fetchModelsNeedBaseUrl")});return}if(G)return;K(!0),H(null);const Q=y+1;R(Q),e({type:"fetch_models",reqId:Q,baseUrl:C,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};l.useEffect(()=>{if(!(!o||o.reqId===V.current))if(V.current=o.reqId,K(!1),o.ok&&o.models?.length){const C=o.models;f(Q=>{if(!Q)return Q;const P=Q.models.map(F=>{if(!F.id.trim())return F;const ie=C.find(de=>de.id===F.id.trim());if(!ie)return F;const oe={...F};return!oe.name&&ie.name&&(oe.name=ie.name),!oe.contextWindow&&ie.contextWindow&&(oe.contextWindow=String(ie.contextWindow)),!oe.maxTokens&&ie.maxTokens&&(oe.maxTokens=String(ie.maxTokens)),oe.input==="text"&&ie.input?.includes("image")&&(oe.input="text-image"),!oe.reasoning&&ie.reasoning&&(oe.reasoning=!0),oe}),$=new Set(P.map(F=>F.id.trim()).filter(Boolean)),T=C.filter(F=>!$.has(F.id)).map(F=>({id:F.id,name:F.name??"",reasoning:F.reasoning??!1,input:F.input?.includes("image")?"text-image":"text",contextWindow:F.contextWindow?String(F.contextWindow):"",maxTokens:F.maxTokens?String(F.maxTokens):""})),ce=[...P,...T];return ce.some(F=>F.id.trim())?{...Q,models:ce.filter(F=>F.id.trim())}:Q}),H({ok:!0,text:d("fetchModelsOk",{n:C.length})})}else H({ok:!1,text:o.error||d("fetchModelsEmpty")})},[o]);const me=C=>{const Q=(g[C.id]??"").trim();!Q||S||(M(C.id),e({type:"add_provider_key",provider:C.id,apiKey:Q,name:(x[C.id]??"").trim()||void 0}),setTimeout(()=>{M(null),b(P=>({...P,[C.id]:""})),N(P=>({...P,[C.id]:""})),e({type:"list_providers"}),e({type:"list_provider_keys"})},1500))},he=(C,Q)=>{e({type:"activate_provider_key",provider:C,keyName:Q}),e({type:"list_provider_keys"})},I=(C,Q)=>{window.confirm(d("removeKeyConfirm"))&&(e({type:"remove_provider_key",provider:C,keyName:Q}),e({type:"list_provider_keys"}))},j=()=>{if(!k)return;const C=k.providerId.trim();if(!C||!k.apiKey.trim())return;const Q=k.models.filter($=>$.id.trim()).map($=>({id:$.id.trim(),name:$.name.trim()||void 0,reasoning:$.reasoning||void 0,input:$.input==="text-image"?["text","image"]:void 0,contextWindow:$.contextWindow?Number($.contextWindow):void 0,maxTokens:$.maxTokens?Number($.maxTokens):void 0})),P={providerId:C,name:k.name.trim()||void 0,api:k.api.trim()||void 0,baseUrl:k.baseUrl.trim()||void 0,apiKey:k.apiKey.trim()||void 0,authHeader:k.authHeader||void 0,models:Q};e({type:"save_model_config",providerId:C,config:P}),le(null),c()},D=()=>{if(!u)return;const C=u.providerId.trim(),Q=u.models.filter($=>$.id.trim()).map($=>({id:$.id.trim(),name:$.name.trim()||void 0,reasoning:$.reasoning||void 0,input:$.input==="text-image"?["text","image"]:void 0,contextWindow:$.contextWindow?Number($.contextWindow):void 0,maxTokens:$.maxTokens?Number($.maxTokens):void 0})),P={providerId:C,name:u.name.trim()||void 0,api:u.api.trim()||void 0,baseUrl:u.baseUrl.trim()||void 0,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader||void 0,models:Q};e({type:"save_model_config",providerId:C,config:P}),c()};l.useEffect(()=>{if(i&&i.ok){const C=i.configs;if(C&&C.length>1){X(C.map(Q=>wn({...Q,apiKey:""}))),J("");return}if(i.config){le(wn({...i.config,apiKey:""}));return}}},[i]);const re=C=>{window.confirm(d("clearKeyConfirm",{id:C}))&&e({type:"clear_provider_api_key",provider:C})},te=C=>{window.confirm(d("deleteProviderConfirm",{id:C.providerId,n:C.models.length}))&&e({type:"delete_model_config",providerId:C.providerId})},ge=(C,Q)=>{u&&f({...u,models:u.models.map((P,$)=>$===C?{...P,...Q}:P)})};return s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal model-modal",onClick:C=>C.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":d("close"),onClick:c,children:s.jsx(Je,{})}),s.jsx("div",{className:"modal-head",children:s.jsx("h2",{children:k?d("addKey"):se?d("batchCreateProviders",{n:se.length}):d(u?"editProvider":"manageModelsTitle")})}),k?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:d("secondKeyTitle",{api:k.api,baseUrl:k.baseUrl||d("noBaseUrlShort"),n:k.models.length})}),s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[d("providerNameLabel")," ",s.jsx("em",{children:d("providerNameHint")})]}),s.jsx("input",{type:"text",value:k.providerId,onChange:C=>le({...k,providerId:C.target.value}),placeholder:"opencode-2"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKeyLabel")}),s.jsx("input",{type:"password",value:k.apiKey,onChange:C=>le({...k,apiKey:C.target.value}),placeholder:d("secondKeyPlaceholder")})]})]}),s.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[k.models.slice(0,5).map(C=>C.id).join(", "),k.models.length>5?` … +${k.models.length-5}`:""]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>le(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{const C=k;le(null),f(C)},children:d("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!k.providerId.trim()||!k.apiKey.trim(),onClick:j,children:d("save")})]})]}):se?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:d("batchDesc",{apis:se.map(C=>C.api).join("、"),n:se.length})}),s.jsxs("label",{className:"field",style:{marginBottom:16},children:[s.jsx("span",{className:"field-label",children:d("batchKeyLabel",{n:se.length})}),s.jsx("input",{type:"password",value:A,onChange:C=>J(C.target.value),placeholder:d("secondKeyPlaceholder")})]}),s.jsx("div",{className:"provider-list",style:{marginBottom:16},children:se.map((C,Q)=>s.jsxs("div",{className:"provider-row",style:{flexDirection:"column",alignItems:"stretch",gap:6},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[s.jsx("strong",{children:C.providerId}),s.jsx("span",{style:{opacity:.7},children:C.api})]}),s.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[C.baseUrl||d("noBaseUrlShort")," · ",d("modelsCountShort",{n:C.models.length}),C.models.slice(0,3).map(P=>P.id).join(", "),C.models.length>3?` … +${C.models.length-3}`:""]}),s.jsx("input",{type:"text",value:C.providerId,onChange:P=>X($=>$.map((T,ce)=>ce===Q?{...T,providerId:P.target.value}:T)),placeholder:d("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:C.baseUrl,onChange:P=>X($=>$.map((T,ce)=>ce===Q?{...T,baseUrl:P.target.value}:T)),placeholder:d("baseUrlExamplePh"),style:{fontSize:12}})]},Q))})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>X(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!A.trim(),onClick:()=>{for(const C of se){const Q=C.providerId.trim();if(!Q)continue;const P=C.models.filter(T=>T.id.trim()).map(T=>({id:T.id.trim(),name:T.name.trim()||void 0,reasoning:T.reasoning||void 0,input:T.input==="text-image"?["text","image"]:void 0,contextWindow:T.contextWindow?Number(T.contextWindow):void 0,maxTokens:T.maxTokens?Number(T.maxTokens):void 0})),$={providerId:Q,name:C.name.trim()||void 0,api:C.api.trim()||void 0,baseUrl:C.baseUrl.trim()||void 0,apiKey:A.trim()||void 0,authHeader:C.authHeader||void 0,models:P};e({type:"save_model_config",providerId:Q,config:$})}X(null),c()},children:d("saveAllBatch",{n:se.length})})]})]}):u?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[d("providerId")," ",s.jsx("em",{children:d("providerIdHint")})]}),s.jsx("input",{type:"text",value:u.providerId,disabled:t.some(C=>C.providerId===u.providerId),onChange:C=>f({...u,providerId:C.target.value}),placeholder:"my-proxy"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("displayName")}),s.jsx("input",{type:"text",value:u.name,onChange:C=>f({...u,name:C.target.value}),placeholder:d("displayNamePh")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiType")}),s.jsx("select",{value:u.api,onChange:C=>f({...u,api:C.target.value}),children:Sh.map(C=>s.jsx("option",{value:C,children:C},C))})]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:["baseUrl ",s.jsx("em",{children:d("baseUrlHint")})]}),s.jsx("input",{type:"text",value:u.baseUrl,onChange:C=>f({...u,baseUrl:C.target.value}),placeholder:"http://localhost:11434/v1"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:u.apiKey,onChange:C=>f({...u,apiKey:C.target.value}),placeholder:d("apiKeyHint")})]}),s.jsxs("label",{className:"field check",children:[s.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:C=>f({...u,authHeader:C.target.checked})}),s.jsx("span",{children:d("authHeader")})]})]}),s.jsxs("div",{className:"model-section-head",children:[s.jsx("span",{className:"form-section-title",children:d("modelsTitle")}),s.jsxs("span",{className:"model-section-actions",children:[U&&s.jsx("span",{className:`fetch-msg ${U.ok?"ok":"err"}`,title:U.text,children:U.text}),s.jsxs("button",{type:"button",className:"btn sm",disabled:G||!u.baseUrl.trim(),title:d("fetchModelsHint"),onClick:Y,children:[s.jsx(Ht,{})," ",d(G?"fetchingModels":"fetchModels")]})]})]}),u.models.map((C,Q)=>s.jsxs("div",{className:"model-row",children:[s.jsx("input",{type:"text",value:C.id,onChange:P=>ge(Q,{id:P.target.value}),placeholder:d("modelIdReq")}),s.jsx("input",{type:"text",value:C.name,onChange:P=>ge(Q,{name:P.target.value}),placeholder:d("displayName")}),s.jsxs("select",{value:C.input,onChange:P=>ge(Q,{input:P.target.value}),children:[s.jsx("option",{value:"text",children:d("text")}),s.jsx("option",{value:"text-image",children:d("textImage")})]}),s.jsxs("label",{className:"check",children:[s.jsx("input",{type:"checkbox",checked:C.reasoning,onChange:P=>ge(Q,{reasoning:P.target.checked})}),s.jsx("span",{children:d("reasoning")})]}),s.jsx("input",{type:"number",value:C.contextWindow,onChange:P=>ge(Q,{contextWindow:P.target.value}),placeholder:d("contextWindow"),title:"contextWindow"}),s.jsx("input",{type:"number",value:C.maxTokens,onChange:P=>ge(Q,{maxTokens:P.target.value}),placeholder:d("maxOutput"),title:"maxTokens"}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeModel"),onClick:()=>f({...u,models:u.models.filter((P,$)=>$!==Q)}),children:s.jsx(et,{})})]},Q)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>f({...u,models:[...u.models,ba()]}),children:[s.jsx(ct,{})," ",d("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>f(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(C=>C.id.trim()),onClick:D,children:d("save")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-fixed-hint",children:s.jsxs("div",{className:"form-section-title",children:[d("builtinProviders")," ",s.jsx("em",{className:"section-hint",children:d("hintKeyOnly")})]})}),s.jsxs("div",{className:"model-modal-body",children:[s.jsxs("div",{className:"provider-list",children:[n.length===0&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.map(C=>{const Q=a[C.id]??[];return s.jsxs("div",{className:"provider-row provider-key-row",children:[s.jsxs("div",{className:"provider-key-head",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:C.name}),s.jsxs("span",{className:"provider-sub",children:[C.id,C.configured&&s.jsx("span",{className:"auth-badge",children:d("configuredBadge")}),C.source&&!C.configured&&s.jsx("span",{className:"auth-badge dim",children:C.source})]})]}),C.source==="stored"&&s.jsxs("button",{type:"button",className:"btn sm danger",title:d("clearKeyTitle"),onClick:()=>re(C.id),children:[s.jsx(et,{})," ",d("clearKey")]})]}),s.jsxs("div",{className:"provider-keys",children:[Q.length===0&&s.jsx("div",{className:"provider-key-empty",children:d("noKeyYet")}),Q.map(P=>s.jsxs("div",{className:`provider-key-item ${P.active?"active":""}`,children:[s.jsx("span",{className:"provider-key-dot",children:P.active?"●":"○"}),s.jsx("span",{className:"provider-key-label",children:P.name}),!P.active&&s.jsx("button",{type:"button",className:"iconbtn",title:d("activateKey"),onClick:()=>he(C.id,P.name),children:s.jsx(Et,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeKey"),onClick:()=>I(C.id,P.name),children:s.jsx(et,{})})]},P.name)),s.jsxs("div",{className:"provider-add-key",children:[s.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:d("keyNamePh"),value:x[C.id]??"",onChange:P=>N($=>({...$,[C.id]:P.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:d("addKeyPlaceholder"),value:g[C.id]??"",onChange:P=>b($=>({...$,[C.id]:P.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(g[C.id]??"").trim()||S===C.id,onClick:()=>me(C),children:[s.jsx(ct,{})," ",S===C.id?d("savingKey"):d("addKey")]})]})]})]},C.id)})]}),s.jsx("div",{className:"form-section-title",children:d("customProviders")}),s.jsx("p",{className:"modal-desc",children:d("customDesc")}),t.length===0&&s.jsx("div",{className:"dd-loading",children:d("noCustomProviders")}),s.jsx("div",{className:"provider-list",children:t.map(C=>s.jsxs("div",{className:"provider-row",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:C.providerId}),s.jsxs("span",{className:"provider-sub",children:[C.api??"—",C.baseUrl?` · ${C.baseUrl}`:"",C.models.length>0&&` · ${d("modelsCount",{n:C.models.length})}`]})]}),s.jsxs("div",{className:"provider-actions",children:[s.jsx("button",{type:"button",className:"iconbtn",title:d("edit"),onClick:()=>f(wn(C)),children:s.jsx(Xs,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("delete"),onClick:()=>te(C),children:s.jsx(et,{})})]})]},C.providerId))})]}),s.jsx("div",{className:"modal-actions",children:s.jsxs("button",{type:"button",className:"btn primary",onClick:()=>f(Ah()),children:[s.jsx(ct,{})," ",d("addProvider")]})})]})]})})}function Ih({plugin:e,send:t}){const n=Ae(),a=e.settingsSchema??[],[o,i]=l.useState(()=>({...e.settingsValues})),[c,d]=l.useState(!1);if(a.length===0)return null;const u=(x,N)=>i(S=>({...S,[x]:N})),f=a.some(x=>o[x.key]!==e.settingsValues?.[x.key]),g=()=>{d(!0),t({type:"plugin_settings",pluginId:e.id,values:o}),setTimeout(()=>d(!1),800)},b=()=>i({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:a.map(x=>s.jsxs("label",{className:"plugin-settings-field",title:x.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:x.label}),x.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!o[x.key],onChange:N=>u(x.key,N.target.checked)}):x.type==="select"?s.jsx("select",{value:String(o[x.key]??""),onChange:N=>u(x.key,N.target.value),children:(x.options??[]).map(N=>s.jsx("option",{value:N,children:N},N))}):s.jsx("input",{type:x.type==="password"?"password":x.type==="number"?"number":"text",value:String(o[x.key]??""),min:x.min,max:x.max,onChange:N=>u(x.key,x.type==="number"?Number(N.target.value):N.target.value)})]},x.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!f||c,onClick:g,children:n(c?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:b,children:n("pluginSettingsReset")})]})]})}const po="pi-web-ui:wide-chat",sn={wide:!1};function mo(e){if(!e||typeof e!="object")return{...sn};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:sn.wide}}function jh(){try{const e=localStorage.getItem(po);return e?mo(JSON.parse(e)):{...sn}}catch{return{...sn}}}function Lh(e){const t=mo(e);try{localStorage.setItem(po,JSON.stringify(t))}catch{}Us=t;for(const n of Zn)n()}let Us=null;const Zn=new Set;function Rh(e){return Zn.add(e),()=>{Zn.delete(e)}}function Dh(){return Us||(Us=jh()),Us.wide}function ho(){return l.useSyncExternalStore(Rh,Dh)}const fo="pi-web-ui:project-title",nn={projectName:!0};function go(e){if(!e||typeof e!="object")return{...nn};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:nn.projectName}}function Ph(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function Oh(){try{const e=localStorage.getItem(fo);return e?go(JSON.parse(e)):{...nn}}catch{return{...nn}}}function Mh(e){const t=go(e);try{localStorage.setItem(fo,JSON.stringify(t))}catch{}qs=t;for(const n of ea)n()}let qs=null;const ea=new Set;function Bh(e){return ea.add(e),()=>{ea.delete(e)}}function Fh(){return qs||(qs=Oh()),qs.projectName}function bo(){return l.useSyncExternalStore(Bh,Fh)}const Eo="pi-web-ui:wallpaper",Hh="has-wallpaper",ks={url:"",dim:78,blur:0},Uh=2e3,qh=28e5;function ta(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?qh:Uh;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const wi=(e,t,n,a)=>typeof e!="number"||!Number.isFinite(e)?a:Math.min(n,Math.max(t,Math.round(e)));function To(e){if(!e||typeof e!="object")return{...ks};const t=e;return{url:ta(t.url),dim:wi(t.dim,0,95,ks.dim),blur:wi(t.blur,0,24,ks.blur)}}function xo(){try{const e=localStorage.getItem(Eo);return e?To(JSON.parse(e)):{...ks}}catch{return{...ks}}}function $h(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function Wh(e){const t=await fa(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function $s(){const e=Cs??xo(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${$h(e.url)}")`),t.style.setProperty("--bg-image-dim",String(e.dim/100)),t.style.setProperty("--bg-image-blur",`${e.blur}px`)):(t.style.removeProperty("--bg-image"),t.style.removeProperty("--bg-image-dim"),t.style.removeProperty("--bg-image-blur"));const n=getComputedStyle(t).getPropertyValue("--bg-image").trim();document.body.classList.toggle(Hh,e.url!==""||n!==""&&n!=="none")}function us(e){const t=To(e);Cs=t;try{localStorage.setItem(Eo,JSON.stringify(t))}catch{}for(const n of sa)n();$s()}let Cs=null;const sa=new Set;function Kh(e){return sa.add(e),()=>{sa.delete(e)}}function Yh(){return Cs||(Cs=xo()),Cs}function yo(){return l.useSyncExternalStore(Kh,Yh)}function Gh(){const e=yo();l.useEffect(()=>{$s()},[e]),l.useEffect(()=>{const t=()=>$s();return window.addEventListener(jt,t),$s(),()=>window.removeEventListener(jt,t)},[])}const an={zh:["继续","总结一下","详细解释一下","检查并修复问题","补充测试覆盖","发布上传"],en:["Continue","Summarize","Explain in detail","Check and fix issues","Add test coverage","Publish release"],it:["Continua","Riassumi","Spiega in dettaglio","Verifica e correggi i problemi","Aggiungi copertura dei test","Pubblica la release"],ja:["続ける","要約して","詳しく説明して","問題を確認して修正","テストカバレッジを追加","公開・リリース"],ko:["계속","요약해줘","자세히 설명해줘","문제를 확인하고 수정","테스트 커버리지 추가","게시/릴리스"],fr:["Continuer","Résumer","Expliquer en détail","Vérifier et corriger les problèmes","Ajouter des tests","Publier"],de:["Weiter","Zusammenfassen","Ausführlich erklären","Probleme prüfen und beheben","Testabdeckung ergänzen","Veröffentlichen"],es:["Continuar","Resumir","Explicar en detalle","Revisar y corregir problemas","Añadir cobertura de pruebas","Publicar"],ru:["Продолжить","Подведи итог","Объясни подробно","Проверь и исправь проблемы","Добавь покрытие тестами","Опубликовать"],pt:["Continuar","Resumir","Explique em detalhes","Verifique e corrija os problemas","Adicione cobertura de testes","Publique a release"]},na=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],Vh=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function zh(e){return Vh.includes(e)}const Os=na.map(e=>`{{${e}}}`).join(`
328
-
329
- `);function Qh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function mt({text:e}){const t=l.useRef(null),[n,a]=l.useState(!1),o=()=>{const i=t.current?.getBoundingClientRect();i&&a(window.innerWidth-i.right<340)};return s.jsxs("span",{ref:t,className:`set-tip${n?" flip":""}`,tabIndex:0,"aria-label":e,onMouseEnter:o,onFocus:o,children:["?",s.jsx("span",{className:"set-tip-bubble",role:"tooltip",children:e})]})}function ze({title:e,subtitle:t,tip:n,enabled:a,onToggle:o,action:i}){const c=Ae();return s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[e,n&&s.jsx(mt,{text:n})]}),t&&s.jsx("div",{className:"set-row-desc",children:t})]}),i,s.jsx("button",{type:"button",className:`set-switch ${a?"on":""}`,role:"switch","aria-checked":a,title:c(a?"settingsEnabled":"settingsDisabled"),onClick:o,children:s.jsx("span",{className:"set-switch-knob"})})]})}function Xh({chat:e,send:t,terminal:n,onSwitchToTerminal:a,onClose:o}){const i=Ae(),{locale:c}=Ot(),d=p=>i(p),u=e.settings,f=e.engine==="dsh",[g,b]=l.useState("prompt"),x=l.useRef(null);l.useEffect(()=>{x.current?.scrollTo({top:0})},[g]),l.useEffect(()=>{g==="plugins"&&e.engine==="dsh"&&t({type:"dsh_patches_list"})},[g,e.engine,t]);const[N,S]=l.useState(""),[M,G]=l.useState({}),K=l.useRef(!1),y=l.useRef(null),[R,U]=l.useState(null),[H,V]=l.useState({}),[se,X]=l.useState(""),[A,J]=l.useState("append"),k=l.useRef(!1),[le,Y]=l.useState(""),me=l.useRef(!1),[he,I]=l.useState(""),[j,D]=l.useState(null),[re,te]=l.useState(null),[ge,C]=l.useState(!1),Q=ho(),P=bo(),$=yo(),[T,ce]=l.useState($.url),F=l.useRef(!1),ie=l.useRef(null),[oe,de]=l.useState(!1),[Te,we]=l.useState(!1);l.useEffect(()=>{F.current||ce($.url.startsWith("data:")?"":$.url)},[$.url]);const v=async p=>{const ee=p.target.files?.[0];if(p.target.value="",!!ee){de(!0),we(!1);try{const Ee=await Wh(ee),Ve=Ee?ta(Ee):"";if(!Ve){we(!0);return}ce(""),us({...$,url:Ve})}finally{de(!1)}}},[ne,ae]=l.useState(()=>lo()),[pe,Le]=l.useState(()=>{try{return As().length}catch{return 0}}),[Be,Ye]=l.useState(!1),_=()=>{try{Le(As().length)}catch{Le(0)}};l.useEffect(()=>{g==="prompt-history"&&_()},[g]),l.useEffect(()=>{if(!Be)return;const p=window.setTimeout(()=>Ye(!1),3e3);return()=>window.clearTimeout(p)},[Be]);const[ue,ve]=l.useState(null),[xe,ye]=l.useState(null),[Oe,Me]=l.useState(""),[B,_e]=l.useState(""),[Ce,Ue]=l.useState(""),[Re,We]=l.useState(""),[Tt,Mt]=l.useState(""),[is,ut]=l.useState(!1),[ft,vt]=l.useState(""),[L,W]=l.useState(null);l.useEffect(()=>{u&&(K.current||S(u.promptTemplate??""),G(p=>{const ee={};for(const[Ee,Ve]of Object.entries(u.promptOverrides??{}))ee[Ee]=Ve??"";return y.current&&(ee[y.current]=p[y.current]??""),ee}),J(u.visionBridgePromptMode),!k.current&&(X(A==="append"||u.visionBridgePrompt?u.visionBridgePrompt:u.visionBridgeDefaultPrompt||""),me.current||Y(u.reviewPrompt)))},[u,A]);const[ke,Ne]=l.useState(String(u?.terminalBashIdleMs??15e3));l.useEffect(()=>{Ne(String(u?.terminalBashIdleMs??15e3))},[u?.terminalBashIdleMs]);const[De,Pe]=l.useState(String(u?.retryMaxAttempts??6));if(l.useEffect(()=>{Pe(String(u?.retryMaxAttempts??6))},[u?.retryMaxAttempts]),!u)return null;const rt=[{id:"prompt",icon:s.jsx(Wi,{}),label:i("settingsSystemPrompt")},{id:"prompt-history",icon:s.jsx(Pn,{}),label:i("settingsPromptHistory"),count:pe},{id:"terminal",icon:s.jsx(Xt,{}),label:i("settingsTerminalTools")},{id:"question",icon:s.jsx(ja,{}),label:i("settingsQuestionnaire")},...f?[]:[{id:"edit",icon:s.jsx(zt,{}),label:i("settingsEditTools")}],{id:"display",icon:s.jsx(Jt,{}),label:i("settingsMessageDisplay")},{id:"quick",icon:s.jsx(Vs,{}),label:i("quickPhrases"),count:u.quickPhrases.length},{id:"markers",icon:s.jsx(Ia,{}),label:i("settingsMarkers"),count:u.markers?.length??0},{id:"skills",icon:s.jsx(vs,{}),label:i("settingsSkills"),count:u.skills.length},{id:"extensions",icon:s.jsx(fn,{}),label:i("settingsExtensions"),count:u.extensions.length},{id:"plugins",icon:s.jsx(gn,{}),label:i("settingsUiPlugins"),count:e.plugins.length},{id:"review",icon:s.jsx(Ms,{}),label:i("settingsReview"),count:u.reviewSkills.length},...f?[]:[{id:"vision",icon:s.jsx(Dn,{}),label:i("settingsVisionBridge")}],{id:"presets",icon:s.jsx(ol,{}),label:i("settingsPresets"),count:u.presets.length},...f?[]:[{id:"subagent-templates",icon:s.jsx(Aa,{}),label:i("settingsSubagentTemplates"),count:u.subagentTemplates.length}]],xt=new Set(u.disabledSkills),pn=new Set(u.disabledExtensions),je=p=>t({type:"set_settings",...p}),q=()=>{if(!L||!u)return;const p=L.value.trim(),ee=L.index;if(W(null),!p||p===u.quickPhrases[ee])return;const Ee=[...u.quickPhrases];Ee[ee]=p,je({quickPhrases:Ee})},be=p=>{const ee=new Set(xt);ee.has(p.name)?ee.delete(p.name):ee.add(p.name),je({disabledSkills:[...ee]})},Se=new Set(u.disabledPlugins??[]),Ke=new Set(e.plugins.map(p=>p.id)),Ge=p=>{const ee=new Set(Se);ee.has(p.id)?ee.delete(p.id):ee.add(p.id),je({disabledPlugins:[...ee]})},_t=p=>{const ee=new Set(pn);ee.has(p.id)?ee.delete(p.id):ee.add(p.id),je({disabledExtensions:[...ee]})},qe=u.markersEnabled??!0,dt=new Set(u.disabledMarkers??[]),Ao=p=>{const ee=new Set(dt);!ee.has(p)?ee.add(p):ee.delete(p),je({disabledMarkers:[...ee]})},Ls=(p,ee)=>{const Ee={name:p,command:ee,cwd:"${pwd}"};let Ve;const ot=e.terminals.find(Fe=>Fe.title===p);ot?(n.restart(ot.id),t({type:"run_command",terminalId:ot.id,conversationId:ot.conversationId,command:Ee,cols:80,rows:24}),Ve=ot.id):(Ve=Ct(),n.create({id:Ve,conversationId:e.activeConversationId||e.state?.conversationId||"",title:p,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ee})),n.select(Ve),a(),o()},wo=p=>{ve(null),Ls(`${i("uninstallTitle")} ${p}`,`pi remove npm:${p}`)},Ea=p=>{ye(null),Ls(`${i("uninstallTitle")} ${p}`,`pi-web-ui uninstall ${p}`)},Ta=(p,ee)=>{Ls(`${i("pluginUpdate")} ${p}`,`pi-web-ui install ${ee} --name ${p} --force`)},Io=p=>{Ls(`${i("pluginInstall")} ${p.id}`,`pi-web-ui install ${p.source} --name ${p.id}`)},jo=p=>{t({type:"plugin_catalog_remove",id:p})},Lo=()=>{const p=Oe.trim();p&&(t({type:"plugin_catalog_add",entry:{source:p,...B.trim()?{id:B.trim()}:{},...Ce.trim()?{name:Ce.trim()}:{},...Re.trim()?{description:Re.trim()}:{},...Tt.trim()?{icon:Tt.trim()}:{}}}),Me(""),_e(""),Ue(""),We(""),Mt(""),ut(!1))},Ro=p=>{const ee=new Set(u.reviewSkills.filter(Ee=>!Ee.enabled).map(Ee=>Ee.name));ee.has(p.name)?ee.delete(p.name):ee.add(p.name),je({reviewDisabledSkills:[...ee]})},Do=()=>je({promptTemplate:N}),Po=p=>{je({promptOverrides:{[p]:M[p]??""}})},mn=p=>{y.current===p&&(y.current=null),U(null),G(ee=>{const Ee={...ee};return delete Ee[p],Ee}),je({promptOverrides:{[p]:""}})},rs=p=>V(ee=>({...ee,[p]:!ee[p]})),hn=(p,ee)=>{G(Ee=>({...Ee,[p]:ee})),U(p)},Oo=()=>{K.current=!1,y.current=null,S(Os),G({}),je({promptTemplate:Os,promptOverrides:{}})},Mo=p=>{S(ee=>ee.trim()?`${ee}
330
-
331
- {{${p}}}`:`{{${p}}}`)},Bo=N.trim()&&N.trim()!==Os||Object.values(M).some(p=>p.trim());return s.jsx("div",{className:"modal-backdrop",onClick:o,children:s.jsxs("div",{className:"modal settings-modal",onClick:p=>p.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":i("close"),onClick:o,children:s.jsx(Je,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(Gs,{className:"modal-head-icon"}),s.jsx("h2",{children:i("settingsTitle")}),s.jsx(mt,{text:i("settingsDesc")})]}),s.jsxs("div",{className:"settings-layout",children:[s.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:rt.map(p=>s.jsxs("button",{type:"button",className:`settings-tab${g===p.id?" active":""}`,"aria-current":g===p.id?"true":void 0,title:p.label,onClick:()=>b(p.id),children:[s.jsx("span",{className:"settings-tab-icon",children:p.icon}),s.jsx("span",{className:"settings-tab-label",children:p.label}),p.count!==void 0&&s.jsx("span",{className:"set-count",children:p.count})]},p.id))}),s.jsxs("div",{className:"modal-body",ref:x,children:[g==="prompt"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ms,{className:"set-section-icon"}),i("settingsSystemPrompt"),s.jsx(mt,{text:i("promptComposeHint")})]}),s.jsx("p",{className:"set-hint",children:i("promptComposeDesc")}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:i("promptTemplateLabel")}),s.jsx("textarea",{className:"set-prompt-input",rows:8,spellCheck:!1,placeholder:Os,value:N,onFocus:()=>K.current=!0,onBlur:()=>{K.current=!1,Do()},onChange:p=>S(p.target.value)}),s.jsxs("div",{className:"compose-toolbar",children:[s.jsx("span",{className:"set-field-label set-muted",children:i("promptInsertTokens")}),na.map(p=>s.jsx("button",{type:"button",className:"token-chip",title:d(`promptTok_${p}_desc`),onClick:()=>Mo(p),children:`{{${p}}}`},p))]})]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:i("promptSourcesLabel")}),na.map(p=>{const ee=M[p]??"",Ee=u.promptSourceDefaults?.[p]??"",Ve=R===p,ot=Ee.split(`
332
- `).length>6||Ee.length>480;if(zh(p)){const Fe=ee.trim()?ee:Ee;return s.jsxs("div",{className:"override-row readonly",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${p}}}`,s.jsxs("span",{className:"set-muted",children:[d(`promptTok_${p}`)," — ",d(`promptTok_${p}_desc`)]}),ee.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",title:i("promptReadonlyLockedHint"),onClick:()=>mn(p),children:i("promptResetSource")}):s.jsx("span",{className:"set-muted",children:i("promptReadonlyBadge")})]}),s.jsx("div",{className:`source-default readonly${Fe.trim()?"":" empty"}`,title:i("promptReadonlyTitle"),children:Fe.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ot?H[p]?" expanded":" clamped":""}`,children:Fe}),ot&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:tt=>{tt.stopPropagation(),rs(p)},onKeyDown:tt=>{(tt.key==="Enter"||tt.key===" ")&&(tt.preventDefault(),tt.stopPropagation(),rs(p))},children:H[p]?i("promptSourceCollapse"):i("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")})})]},p)}return s.jsxs("div",{className:"override-row",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${p}}}`,s.jsxs("span",{className:"set-muted",children:[d(`promptTok_${p}`)," — ",d(`promptTok_${p}_desc`)]}),ee.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",onClick:()=>mn(p),children:i("promptResetSource")}):s.jsx("span",{className:"set-muted",children:i("promptAutoBadge")})]}),ee.trim()||Ve?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"set-prompt-input override-input",rows:Math.min(10,Math.max(1,ee.split(`
333
- `).length)),autoFocus:Ve,placeholder:i("promptOverridePlaceholder"),value:ee,onFocus:Fe=>{y.current=p,U(p);const tt=Fe.currentTarget;tt.value&&tt.value===Ee&&tt.setSelectionRange(tt.value.length,tt.value.length)},onBlur:()=>{y.current===p&&(y.current=null);const Fe=M[p]??"";if(Fe.trim()&&Fe===Ee){mn(p);return}Po(p),Fe.trim()||U(null)},onChange:Fe=>G(tt=>({...tt,[p]:Fe.target.value}))}),s.jsxs("div",{className:"override-edit-foot",children:[s.jsxs("div",{className:"override-edit-foot-head",children:[s.jsx("span",{className:"set-muted",children:i("promptSourceRefLabel")}),ot&&s.jsx("button",{type:"button",className:"source-default-toggle",onClick:()=>rs(p),children:H[p]?i("promptSourceCollapse"):i("promptSourceExpand")})]}),Ee.trim()?s.jsx("pre",{className:`source-default-text${ot?H[p]?" expanded":" clamped":""}`,children:Ee}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")}),!ee.trim()&&Ee.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:i("promptSourceSeedTip"),onClick:()=>hn(p,Ee),children:i("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:i("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>hn(p,Ee),onKeyDown:Fe=>{(Fe.key==="Enter"||Fe.key===" ")&&(Fe.preventDefault(),hn(p,Ee))},children:Ee.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ot?H[p]?" expanded":" clamped":""}`,children:Ee}),ot&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:Fe=>{Fe.stopPropagation(),rs(p)},onKeyDown:Fe=>{(Fe.key==="Enter"||Fe.key===" ")&&(Fe.preventDefault(),Fe.stopPropagation(),rs(p))},children:H[p]?i("promptSourceCollapse"):i("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")})})]},p)}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"set-btn",onClick:Oo,disabled:!Bo,children:i("promptResetAll")})})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":ge,onClick:()=>C(p=>!p),children:[i("settingsViewPrompt")," ",ge?"▴":"▾"]}),ge&&s.jsxs("div",{className:"set-prompt-view",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewPromptHint")}),s.jsx(tn,{text:u.effectiveSystemPrompt})]}),u.effectiveSystemPrompt?s.jsx("pre",{className:"set-prompt-view-text",children:u.effectiveSystemPrompt}):s.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")}),s.jsxs("div",{className:"set-prompt-tools",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewToolsSchema")}),s.jsx(tn,{text:u.toolsSchema})]}),s.jsx("p",{className:"set-hint",children:i("settingsViewToolsSchemaHint")}),u.toolsSchema?s.jsx("pre",{className:"set-prompt-view-text",children:u.toolsSchema}):s.jsx("p",{className:"set-empty",children:i("settingsViewToolsSchemaEmpty")})]})]})]}),g==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Pn,{className:"set-section-icon"}),i("settingsPromptHistory"),s.jsx(mt,{text:i("settingsPromptHistoryDesc")}),s.jsx("span",{className:"set-count",children:i("promptHistoryCount",{n:String(pe)})})]}),pe===0?s.jsx("p",{className:"set-empty",children:i("promptHistoryEmpty")}):s.jsx("p",{className:"set-hint",children:i("promptHistoryCount",{n:String(pe)})}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:i("promptHistoryMax")}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("input",{id:"ph-max",className:"set-input",type:"number",min:1,max:500,step:1,value:String(ne.maxEntries),onChange:p=>{const ee=Math.floor(Number(p.target.value)||0),Ee={...ne,maxEntries:ee};ae(Ee)},onBlur:()=>{const p={...ne};(!Number.isFinite(p.maxEntries)||p.maxEntries<1)&&(p.maxEntries=1),p.maxEntries>500&&(p.maxEntries=500),p.maxEntries=Math.floor(p.maxEntries),ae(p),An(p),_()}}),s.jsx(mt,{text:i("promptHistoryMaxHint")})]})]}),s.jsx(ze,{title:i("promptHistoryCharLimit"),tip:i("promptHistoryCharLimitHint"),enabled:ne.charLimitEnabled,onToggle:()=>{const p={...ne,charLimitEnabled:!ne.charLimitEnabled};ae(p),An(p),_()}}),ne.charLimitEnabled&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:i("promptHistoryCharLimit")}),s.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:i("promptHistoryCharLimitPlaceholder"),value:String(ne.charLimit),onChange:p=>{const ee=Math.floor(Number(p.target.value)||0);ae({...ne,charLimit:ee})},onBlur:()=>{let p=Math.floor(Number(ne.charLimit)||0);(!Number.isFinite(p)||p<100)&&(p=100),p>2e4&&(p=2e4);const ee={...ne,charLimit:p};ae(ee),An(ee),_()}})]}),s.jsxs("div",{className:"set-field",style:{marginTop:12},children:[s.jsxs("button",{type:"button",className:`set-uninstall${Be?" confirm":""}`,disabled:pe===0,title:i(pe===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!Be){Ye(!0);return}uh(),Ye(!1),_()},children:[s.jsx(et,{})," ",i(Be?"promptHistoryClearConfirm":"promptHistoryClear")]}),pe>0&&s.jsx("span",{className:"set-hint",style:{marginLeft:8},children:i("promptHistoryCount",{n:String(pe)})})]}),s.jsxs("p",{className:"set-hint",children:[s.jsx(zi,{style:{verticalAlign:"-2px",marginRight:4}}),i("settingsPromptHistoryDesc")]})]}),g==="terminal"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Xt,{className:"set-section-icon"}),i("settingsTerminalTools")]}),s.jsx(ze,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:u.terminalToolsEnabled,onToggle:()=>je({terminalToolsEnabled:!u.terminalToolsEnabled})}),!u.terminalToolsEnabled&&s.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),s.jsx(ze,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:u.terminalBash,onToggle:()=>je({terminalBash:!u.terminalBash})}),u.terminalBash&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:i("terminalBashIdleMs")}),s.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:ke,onChange:p=>Ne(p.target.value),onBlur:()=>{const p=Math.max(0,Math.floor(Number(ke)||0));Ne(String(p)),p!==u.terminalBashIdleMs&&je({terminalBashIdleMs:p})}})]})]}),g==="edit"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(zt,{className:"set-section-icon"}),i("settingsEditTools")]}),s.jsx(ze,{title:i("editSoftEnabled"),tip:i("editSoftEnabledDesc"),enabled:u.editSoftEnabled,onToggle:()=>je({editSoftEnabled:!u.editSoftEnabled})}),!u.editSoftEnabled&&s.jsx("p",{className:"set-hint",children:i("editSoftOffHint")})]}),g==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ja,{className:"set-section-icon"}),i("settingsQuestionnaire")]}),s.jsx(ze,{title:i("questionnaireEnabled"),tip:i("questionnaireEnabledDesc"),enabled:u.questionnaireEnabled,onToggle:()=>je({questionnaireEnabled:!u.questionnaireEnabled})}),!u.questionnaireEnabled&&s.jsx("p",{className:"set-hint",children:i("questionnaireOffHint")})]}),g==="display"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Jt,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"model-retry-max",children:i("modelRetryAttempts")}),s.jsx("input",{id:"model-retry-max",className:"set-input",type:"number",min:0,max:100,step:1,value:De,onChange:p=>Pe(p.target.value),onBlur:()=>{const p=Math.min(100,Math.max(0,Math.floor(Number(De)||0)));Pe(String(p)),p!==u.retryMaxAttempts&&je({retryMaxAttempts:p})},onKeyDown:p=>{p.key==="Enter"&&p.target.blur()}}),s.jsx("p",{className:"set-hint",children:i("modelRetryHint")})]}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:u.thinkingWrap??!0,onToggle:()=>je({thinkingWrap:!(u.thinkingWrap??!0)})}),s.jsx(ze,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:u.toolsWrap??!0,onToggle:()=>je({toolsWrap:!(u.toolsWrap??!0)})}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("wideChat"),tip:i("wideChatDesc"),enabled:Q,onToggle:()=>Lh({wide:!Q})}),s.jsx(ze,{title:i("projectTitle"),tip:i("projectTitleDesc"),enabled:P,onToggle:()=>Mh({projectName:!P})}),s.jsx("hr",{className:"set-sep"}),s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[i("wallpaperTitle"),s.jsx(mt,{text:i("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:i("wallpaperUrlPh"),value:T,maxLength:2e3,spellCheck:!1,onFocus:()=>{F.current=!0},onChange:p=>ce(p.target.value),onBlur:()=>{if(F.current=!1,!T.trim()&&$.url.startsWith("data:")){ce("");return}const p=ta(T);ce(p),p!==$.url&&us({...$,url:p})},onKeyDown:p=>{p.key==="Enter"?p.target.blur():p.key==="Escape"&&(ce($.url.startsWith("data:")?"":$.url),p.target.blur())}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:oe,onClick:()=>ie.current?.click(),children:[s.jsx(Ui,{})," ",i("wallpaperUpload")]}),s.jsx("input",{ref:ie,type:"file",accept:"image/*",hidden:!0,onChange:v})]}),Te&&s.jsx("p",{className:"set-hint",children:i("wallpaperUploadFailed")}),s.jsxs("div",{className:"wallpaper-sliders",children:[s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperDim")}),s.jsx("input",{type:"range",min:0,max:95,step:1,value:$.dim,onChange:p=>us({...$,dim:Number(p.target.value)})}),s.jsxs("output",{children:[$.dim,"%"]})]}),s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperBlur")}),s.jsx("input",{type:"range",min:0,max:24,step:1,value:$.blur,onChange:p=>us({...$,blur:Number(p.target.value)})}),s.jsxs("output",{children:[$.blur,"px"]})]})]})]}),$.url&&s.jsxs("div",{className:"wallpaper-current",children:[s.jsx("img",{className:"wallpaper-preview",src:$.url,alt:""}),s.jsx("button",{type:"button",className:"wallpaper-clear",onClick:()=>{ce(""),us({...$,url:""})},children:i("wallpaperClear")})]})]})]}),g==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Vs,{className:"set-section-icon"}),i("quickPhrases"),s.jsx(mt,{text:i("quickPhrasesDesc")}),s.jsx("span",{className:"set-count",children:u.quickPhrases.length})]}),s.jsx(ze,{title:i("quickPhrasesEnabled"),tip:i("quickPhrasesDesc"),enabled:u.quickPhrasesEnabled,onToggle:()=>je({quickPhrasesEnabled:!u.quickPhrasesEnabled})}),!u.quickPhrasesEnabled&&s.jsx("p",{className:"set-hint",children:i("quickPhrasesOffHint")}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:i("quickPhrasesPlaceholder"),value:ft,maxLength:200,onChange:p=>vt(p.target.value),onKeyDown:p=>{p.key==="Enter"&&ft.trim()&&(je({quickPhrases:[...u.quickPhrases,ft.trim()]}),vt(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!ft.trim(),onClick:()=>{je({quickPhrases:[...u.quickPhrases,ft.trim()]}),vt("")},children:[s.jsx(ct,{})," ",i("quickPhrasesAdd")]})]}),u.quickPhrases.length===0?s.jsx("p",{className:"set-empty",children:i("quickPhrasesEmpty")}):s.jsx("div",{className:"set-list",children:u.quickPhrases.map((p,ee)=>s.jsx("div",{className:"set-row",children:L?.index===ee?s.jsx("div",{className:"set-row-info",children:s.jsx("input",{className:"set-input",autoFocus:!0,value:L.value,maxLength:200,placeholder:i("quickPhrasesEditPh"),onChange:Ee=>W({index:ee,value:Ee.target.value}),onKeyDown:Ee=>{Ee.key==="Enter"?q():Ee.key==="Escape"&&W(null)},onBlur:q})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"set-row-info",children:s.jsx("div",{className:"set-row-name",title:p,children:p})}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesEdit"),onClick:()=>W({index:ee,value:p}),children:s.jsx(zt,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveUp"),disabled:ee===0,onClick:()=>{const Ee=[...u.quickPhrases];[Ee[ee-1],Ee[ee]]=[Ee[ee],Ee[ee-1]],je({quickPhrases:Ee})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveDown"),disabled:ee===u.quickPhrases.length-1,onClick:()=>{const Ee=[...u.quickPhrases];[Ee[ee],Ee[ee+1]]=[Ee[ee+1],Ee[ee]],je({quickPhrases:Ee})},children:"↓"}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("quickPhrasesDelete"),onClick:()=>je({quickPhrases:u.quickPhrases.filter((Ee,Ve)=>Ve!==ee)}),children:s.jsx(et,{})})]})]})},`${ee}:${p}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{W(null),je({quickPhrases:an[c]??an.en})},children:i("quickPhrasesReset")})})]}),g==="markers"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ia,{className:"set-section-icon"}),i("settingsMarkers"),s.jsx(mt,{text:i("settingsMarkersDesc")}),s.jsx("span",{className:"set-count",children:u.markers?.length??0})]}),s.jsx(ze,{title:i("markersEnabled"),tip:i("markersEnabledDesc"),enabled:qe,onToggle:()=>je({markersEnabled:!qe})}),!qe&&s.jsx("p",{className:"set-hint",children:i("markersOffHint")}),qe&&(u.markers?.length??0)===0&&s.jsxs("p",{className:"set-empty",children:[i("loading"),"..."]}),qe&&u.markers&&u.markers.length>0&&s.jsx("div",{className:"set-list",children:u.markers.map(p=>s.jsx(ze,{title:p.name==="todo"?i("markerGroupTodo"):p.name==="notify"?i("markerGroupNotify"):p.name==="conv"?i("markerGroupRename"):p.name,subtitle:(p.guidance[0]??"").slice(0,120),tip:p.guidance.join(`
334
- `),enabled:p.enabled,onToggle:()=>Ao(p.name)},p.name))}),qe&&s.jsx("p",{className:"set-hint",children:i("markerRenameTip")})]}),g==="skills"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(vs,{className:"set-section-icon"}),i("settingsSkills"),s.jsx("span",{className:"set-count",children:u.skills.length})]}),u.skills.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshSkillsNote":"noSkills")}):s.jsx("div",{className:"set-list",children:u.skills.map(p=>s.jsx(ze,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>be(p)},p.name))})]}),g==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(fn,{className:"set-section-icon"}),i("settingsExtensions"),s.jsx("span",{className:"set-count",children:u.extensions.length})]}),u.extensions.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(p=>{const ee=p.id.startsWith("npm:")?p.id.slice(4):null;return s.jsx(ze,{title:p.name,subtitle:p.path,enabled:p.enabled,onToggle:()=>_t(p),action:ee?ue===p.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>wo(ee),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>ve(p.id),children:[s.jsx(et,{}),i("uninstallExt")]}):void 0},p.id)})})]}),g==="plugins"&&e.managed&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:i("updatesManaged")})}),g==="plugins"&&!e.managed&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(fn,{className:"set-section-icon"}),i("pluginMarket"),s.jsx("span",{className:"set-count",children:e.pluginCatalog.length}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogAddHint"),onClick:()=>ut(p=>!p),children:[s.jsx(ct,{}),i("pluginCatalogAdd")]})]}),is&&s.jsxs("div",{className:"set-catalog-add",children:[s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogSource"),value:Oe,onChange:p=>Me(p.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogId"),value:B,onChange:p=>_e(p.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogName"),value:Ce,onChange:p=>Ue(p.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogIcon"),value:Tt,onChange:p=>Mt(p.target.value)}),s.jsx("textarea",{className:"set-input",rows:2,placeholder:i("pluginCatalogDesc"),value:Re,onChange:p=>We(p.target.value)}),s.jsxs("div",{className:"set-catalog-add-actions",children:[s.jsx("button",{type:"button",className:"set-uninstall confirm",disabled:!Oe.trim(),onClick:Lo,children:i("pluginCatalogAddSubmit")}),s.jsx("button",{type:"button",className:"set-uninstall",onClick:()=>ut(!1),children:i("cancel")})]})]}),e.pluginCatalog.length===0?s.jsx("p",{className:"set-empty",children:i("noPluginCatalog")}):s.jsx("div",{className:"set-list",children:e.pluginCatalog.map(p=>{const ee=Ke.has(p.id);return s.jsxs("div",{className:"set-catalog-row",children:[s.jsxs("div",{className:"set-catalog-main",children:[s.jsxs("div",{className:"set-catalog-title",children:[s.jsxs("span",{children:[p.icon?`${p.icon} `:"",p.name]}),ee&&s.jsx("span",{className:"set-catalog-installed",children:i("pluginInstalled")}),!p.builtin&&s.jsx("span",{className:"set-catalog-custom",children:i("pluginCatalogCustom")})]}),p.description&&s.jsx("div",{className:"set-catalog-desc",children:p.description}),s.jsx("div",{className:"set-catalog-source",children:p.source})]}),s.jsxs("div",{className:"set-row-actions",children:[ee?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Ta(p.id,p.source),children:[s.jsx(Lt,{}),i("pluginUpdate")]}),xe===p.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>Ea(p.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ye(p.id),children:[s.jsx(et,{}),i("uninstallExt")]})]}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginInstallHint"),onClick:()=>Io(p),children:[s.jsx(Ht,{}),i("pluginInstall")]}),!p.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogRemoveHint"),onClick:()=>jo(p.id),children:s.jsx(Je,{})})]})]},p.id)})})]}),g==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(gn,{className:"set-section-icon"}),i("settingsUiPlugins"),s.jsx("span",{className:"set-count",children:e.plugins.length})]}),e.plugins.length===0?s.jsx("p",{className:"set-empty",children:i("noUiPlugins")}):s.jsx("div",{className:"set-list",children:e.plugins.map(p=>s.jsxs(s.Fragment,{children:[s.jsx(ze,{title:`${p.icon?`${p.icon} `:""}${p.name}`,subtitle:(p.error?`${p.id} · ${p.error}`:p.source?`${p.id} · ${p.source}`:`${p.id} · ${i("uiPluginNoSource")}`)+(p.permissions?.length?` · ${i("uiPluginPerms")}: ${p.permissions.join(", ")}`:""),enabled:!Se.has(p.id)&&!p.error,onToggle:()=>!p.error&&Ge(p),action:s.jsxs("div",{className:"set-row-actions",children:[p.source&&s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Ta(p.id,p.source),children:[s.jsx(Lt,{}),i("pluginUpdate")]}),xe===p.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>Ea(p.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ye(p.id),children:[s.jsx(et,{}),i("uninstallExt")]})]})},p.id),p.settingsSchema&&p.settingsSchema.length>0&&s.jsx(Ih,{plugin:p,send:t})]}))})]}),g==="plugins"&&e.engine==="dsh"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(gn,{className:"set-section-icon"}),i("dshPatches"),s.jsx(mt,{text:i("dshPatchesDesc")}),s.jsx("span",{className:"set-count",children:e.dshPatches?.files.length??0}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("dshPatchesRescanHint"),onClick:()=>t({type:"dsh_patches_rescan"}),children:[s.jsx(Lt,{}),i("dshPatchesRescan")]})]}),(e.dshPatches?.files.length??0)===0?s.jsx("p",{className:"set-empty",children:i("dshPatchesEmpty")}):s.jsx("div",{className:"set-list",children:e.dshPatches.files.map(p=>s.jsx("div",{className:"set-row",children:s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:p.name}),s.jsxs("div",{className:"set-row-desc",children:[Qh(p.size)," · ",new Date(p.mtimeMs).toLocaleString()]})]})},p.name))}),s.jsxs("p",{className:"set-hint",children:[i("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),g==="review"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ms,{className:"set-section-icon"}),i("settingsReview"),s.jsx(mt,{text:i("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(ze,{title:i("goalModeEnabled"),tip:i("goalModeEnabledDesc"),enabled:u.goalModeEnabled,onToggle:()=>je({goalModeEnabled:!u.goalModeEnabled})}),!u.goalModeEnabled&&s.jsx("p",{className:"set-hint",children:i("goalModeOffHint")}),f&&s.jsx("p",{className:"set-hint",children:i("dshReviewPromptNote")}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:le,onFocus:()=>me.current=!0,onBlur:()=>{me.current=!1,je({reviewPrompt:le})},onChange:p=>Y(p.target.value)}),s.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),u.reviewSkills.length===0?s.jsx("p",{className:"set-empty",children:i("noSkills")}):s.jsx("div",{className:"set-list",children:u.reviewSkills.map(p=>s.jsx(ze,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>Ro(p)},`review-${p.name}`))})]}),g==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Dn,{className:"set-section-icon"}),i("settingsVisionBridge")]}),s.jsx(ze,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:u.visionBridgeEnabled,onToggle:()=>je({visionBridgeEnabled:!u.visionBridgeEnabled})}),!u.visionBridgeEnabled&&s.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgeModel")}),s.jsxs("select",{className:"set-select",value:u.visionBridgeModel??"",onChange:p=>je({visionBridgeModel:p.target.value||null}),children:[s.jsx("option",{value:"",children:i("visionBridgeAuto")}),u.visionModels.map(p=>s.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgePromptMode")}),s.jsxs("select",{className:"set-select",value:A,onChange:p=>{const ee=p.target.value;J(ee),je({visionBridgePromptMode:ee})},children:[s.jsx("option",{value:"append",children:i("promptModeAppend")}),s.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),u.visionBridgeEnabled&&s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:se,onFocus:()=>k.current=!0,onBlur:()=>{k.current=!1;const p=A==="replace"&&u.visionBridgeDefaultPrompt&&se===u.visionBridgeDefaultPrompt?"":se;je({visionBridgePromptMode:A,visionBridgePrompt:p})},onChange:p=>X(p.target.value)}),u.visionBridgeEnabled&&(u.visionModels.length===0?s.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):s.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:u.visionBridgeModel??i("visionBridgeAuto")})}))]}),g==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Gs,{className:"set-section-icon"}),i("settingsPresets"),s.jsx("span",{className:"set-count",children:u.presets.length})]}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:i("presetNamePlaceholder"),value:he,onChange:p=>I(p.target.value),onKeyDown:p=>{p.key==="Enter"&&he.trim()&&(t({type:"save_preset",name:he.trim()}),I(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!he.trim(),onClick:()=>{t({type:"save_preset",name:he.trim()}),I("")},children:[s.jsx(ct,{})," ",i("saveAsPreset")]})]}),u.presets.length===0?s.jsx("p",{className:"set-empty",children:i("noPresets")}):s.jsx("div",{className:"set-list",children:u.presets.map(p=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:p.name}),s.jsxs("div",{className:"set-row-desc",children:[p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),p.disabledSkills.length>0&&` · ${i("settingsSkills")} ${p.disabledSkills.length}`,p.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${p.disabledExtensions.length}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"apply_preset",name:p.name}),children:i("applyPreset")}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>t({type:"delete_preset",name:p.name}),children:s.jsx(et,{})})]})]},p.name))})]}),g==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Aa,{className:"set-section-icon"}),i("settingsSubagentTemplates"),s.jsx(mt,{text:i("settingsSubagentTemplatesDesc")}),s.jsx("span",{className:"set-count",children:u.subagentTemplates.length}),s.jsxs("button",{type:"button",className:"set-save-btn",title:i("subagentTemplateNew"),onClick:()=>D({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",enabled:!0}),children:[s.jsx(ct,{})," ",i("subagentTemplateNew")]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("subagentDefaultModelLabel")}),s.jsxs("select",{className:"set-select",value:u.subagentDefaultModel??"",onChange:p=>je({subagentDefaultModel:p.target.value||null}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(p=>s.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),u.subagentModels.length===0?s.jsx("p",{className:"set-hint",children:i("subagentNoModels")}):s.jsx("p",{className:"set-hint",children:i("subagentDefaultModelHint")}),j&&s.jsxs("div",{className:"tpl-editor",children:[s.jsxs("div",{className:"tpl-fields",children:[s.jsx("input",{className:"set-input",placeholder:i("tplNamePlaceholder"),value:j.name,onChange:p=>D({...j,name:p.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionPlaceholder"),value:j.description,onChange:p=>D({...j,description:p.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionEnPlaceholder"),value:j.descriptionEn??"",onChange:p=>D({...j,descriptionEn:p.target.value})})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplPromptModeLabel")}),s.jsxs("select",{className:"set-select",value:j.promptMode,onChange:p=>D({...j,promptMode:p.target.value}),children:[s.jsx("option",{value:"replace",children:i("promptModeReplace")}),s.jsx("option",{value:"append",children:i("promptModeAppend")})]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplModelLabel")}),s.jsxs("select",{className:"set-select",value:j.model??"",onChange:p=>D({...j,model:p.target.value}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(p=>s.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}:${i("tplSystemPromptPlaceholder")}`,value:j.systemPrompt,onChange:p=>D({...j,systemPrompt:p.target.value})}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}: ${i("tplSystemPromptEnPlaceholder")}`,value:j.systemPromptEn??"",onChange:p=>D({...j,systemPromptEn:p.target.value})}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplSkillsLabel")," · ",i("tplWhitelistHint")]})}),u.skills.length===0?s.jsx("p",{className:"set-hint",children:i("noSkills")}):s.jsx("div",{className:"tpl-pick",children:u.skills.map(p=>s.jsxs("label",{className:`tpl-chip${j.enabledSkills.includes(p.name)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:j.enabledSkills.includes(p.name),onChange:ee=>{const Ee=ee.target.checked;D({...j,enabledSkills:Ee?[...j.enabledSkills,p.name]:j.enabledSkills.filter(Ve=>Ve!==p.name)})}}),p.name]},p.name))})]}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplExtensionsLabel")," · ",i("tplWhitelistHint")]})}),u.extensions.length===0?s.jsx("p",{className:"set-hint",children:i("noExtensions")}):s.jsx("div",{className:"tpl-pick",children:u.extensions.map(p=>s.jsxs("label",{className:`tpl-chip${j.enabledExtensions.includes(p.id)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:j.enabledExtensions.includes(p.id),onChange:ee=>{const Ee=ee.target.checked;D({...j,enabledExtensions:Ee?[...j.enabledExtensions,p.id]:j.enabledExtensions.filter(Ve=>Ve!==p.id)})}}),p.name]},p.id))})]}),s.jsxs("div",{className:"tpl-actions",children:[s.jsx("button",{type:"button",className:"set-save-btn",disabled:!j.name.trim(),onClick:()=>{t({type:"save_subagent_template",template:{...j,name:j.name.trim()}}),D(null)},children:i("tplSave")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>D(null),children:i("tplCancel")})]})]}),u.subagentTemplates.length===0?s.jsx("p",{className:"set-empty",children:i("noSubagentTemplates")}):s.jsx("div",{className:"set-list",children:u.subagentTemplates.map(p=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[p.name,u.subagentDefaultTemplates.includes(p.name)&&s.jsx("span",{className:"tpl-badge default",children:i("tplDefaultBadge")}),!p.enabled&&s.jsx("span",{className:"tpl-badge",children:i("subagentTemplateClosed")})]}),s.jsxs("div",{className:"set-row-desc",children:[(c!=="zh"&&p.descriptionEn?p.descriptionEn:p.description)||`${p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend")}`,p.model?` · ${i("tplModelLabel")} ${p.model}`:` · ${i("subagentFollowMain")}`,p.enabledSkills.length>0&&` · ${i("tplSkillsLabel")} ${p.enabledSkills.length}`,p.enabledExtensions.length>0&&` · ${i("tplExtensionsLabel")} ${p.enabledExtensions.length}`,!p.description&&p.enabledSkills.length===0&&p.enabledExtensions.length===0&&` · ${i("tplInherit")}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:`set-switch${p.enabled?" on":""}`,role:"switch","aria-checked":p.enabled,title:`${p.enabled?i("subagentTemplateDisable"):i("subagentTemplateEnable")} · ${i("subagentTemplateOffHint")}`,onClick:()=>t({type:"save_subagent_template",template:{...p,enabled:!p.enabled}}),children:s.jsx("span",{className:"set-switch-knob"})}),s.jsx("button",{type:"button",className:"dd-refresh",title:i("subagentTemplateEdit"),onClick:()=>D({...p}),children:i("subagentTemplateEdit")}),re===p.name?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>{t({type:"delete_subagent_template",name:p.name}),te(null)},children:i("uninstallConfirm")}):s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("tplDelete"),onClick:()=>te(p.name),children:s.jsx(et,{})})]})]},p.name))})]})]})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:o,children:i("close")})})]})})}function Jh(e,t){const n=Math.max(0,Date.now()-e),a=Math.floor(n/6e4);if(a<1)return t("bgTaskJustNow");if(a<60)return t("bgTaskMinutes",{n:a});const o=Math.floor(a/60);return o<24?t("bgTaskHours",{n:o}):t("bgTaskDays",{n:Math.floor(o/24)})}function Zh({servers:e,send:t,onClose:n}){const a=Ae(),[o,i]=l.useState(new Set),c=d=>i(u=>{const f=new Set(u);return f.has(d)?f.delete(d):f.add(d),f});return l.useEffect(()=>{t({type:"list_bg_servers"})},[]),s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"bg-task-modal",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(Qs,{})," ",a("bgTasks"),e.length>0&&s.jsx("em",{className:"bg-task-count",children:e.length})]}),s.jsx("button",{type:"button",className:"btn",title:a("close"),onClick:n,children:s.jsx(Je,{})})]}),e.length===0?s.jsxs("div",{className:"bg-task-empty",children:[s.jsx(Qs,{}),s.jsx("span",{children:a("bgTasksEmpty")}),s.jsx("small",{children:a("bgTasksDesc")})]}):s.jsx("ul",{className:"bg-task-list",children:e.map(d=>{const u=!!d.taskId,f=d.taskId??String(d.port);return s.jsxs("li",{className:"bg-task-item",children:[s.jsx("span",{className:"bg-task-icon",title:u?d.plugin:a("bgTaskPort")}),s.jsxs("div",{className:"bg-task-info",children:[s.jsxs("div",{className:"bg-task-line1",children:[u?s.jsxs("span",{className:"bg-task-port",title:d.taskId,children:["🧩 ",d.plugin]}):s.jsxs("span",{className:"bg-task-port",children:[":",d.port]}),d.name&&s.jsx("span",{className:"bg-task-name",children:d.name})]}),s.jsxs("div",{className:"bg-task-line2",children:[!u&&s.jsxs("span",{children:[a("bgTaskPid")," ",d.pid]}),s.jsxs("span",{children:[a("bgTaskSince")," ",Jh(d.since,a)]}),u&&d.status&&s.jsx("span",{className:"bg-task-status",children:d.status})]}),d.command&&s.jsxs("button",{type:"button",className:`bg-task-cmd ${o.has(f)?"open":""}`,title:`${a("bgTaskCommand")}: ${d.command}`,onClick:()=>c(f),children:[s.jsx(Xt,{}),s.jsx("code",{children:d.command})]})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stop",title:a("bgTaskStop"),onClick:()=>t(u?{type:"kill_background_server",taskId:d.taskId}:{type:"kill_background_server",port:d.port}),children:[s.jsx(Ys,{}),s.jsx("span",{children:a("bgTaskStop")})]})]},f)})}),s.jsxs("div",{className:"bg-task-foot",children:[s.jsxs("button",{type:"button",className:"btn",title:a("bgTaskRefresh"),onClick:()=>t({type:"list_bg_servers"}),children:[s.jsx(Lt,{}),s.jsx("span",{children:a("bgTaskRefresh")})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:e.length===0,title:a("bgTaskStopAll"),onClick:()=>t({type:"kill_background_servers"}),children:[s.jsx(Ys,{}),s.jsx("span",{children:a("bgTaskStopAll")})]})]})]})})}function ef(e,t){return e.toLowerCase().includes(t)}function tf({open:e,send:t,projects:n,cwd:a,fileSearch:o,sessionSearch:i,onClose:c,onSwitchSession:d,onSwitchProject:u,onPreviewFile:f}){const g=Ae(),b=l.useRef(null),[x,N]=l.useState(""),S=l.useDeferredValue(x),[M,G]=l.useState(0),K=l.useRef(1),y=l.useRef(0),R=l.useRef(null);l.useEffect(()=>{if(!e)return;t({type:"list_sessions"}),t({type:"list_projects"});const I=x.trim();if(I){const j=++K.current;y.current=j,H(!0),t({type:"search_files",reqId:j,query:I}),t({type:"search_sessions",reqId:j,query:I})}requestAnimationFrame(()=>b.current?.select())},[e]);const[U,H]=l.useState(!1);l.useEffect(()=>{R.current&&clearTimeout(R.current);const I=S.trim();if(!I){H(!1);return}return R.current=setTimeout(()=>{const j=++K.current;y.current=j,H(!0),t({type:"search_files",reqId:j,query:I}),t({type:"search_sessions",reqId:j,query:I})},300),()=>{R.current&&clearTimeout(R.current)}},[S]);const V=S.trim().toLowerCase(),se=l.useMemo(()=>!V||!i||i.reqId!==y.current||!i.ok?[]:i.results,[i,V]),X=l.useMemo(()=>V?n.filter(I=>ef(I.path,V)).slice(0,10):[],[n,V]),A=l.useMemo(()=>!V||!o||o.reqId!==y.current||!o.ok?[]:o.results,[o,V]);l.useEffect(()=>{o&&o.reqId===y.current&&i&&i.reqId===y.current&&y.current!==0&&H(!1)},[o,i]);const J=!!o&&o.ok&&o.truncated,k=l.useMemo(()=>[...se.map(I=>({kind:"session",path:I.path,anchors:I.anchors})),...X.map(I=>({kind:"project",path:I.path})),...A.filter(I=>I.type==="file").map(I=>({kind:"file",path:I.path,name:I.name}))],[se,X,A]);l.useEffect(()=>{G(0)},[S]);const le=l.useCallback(I=>{if(I)if(I.kind==="session")d(I.path,I.anchors),c();else if(I.kind==="project"){u(I.path),t({type:"list_sessions"}),t({type:"list_projects"});const j=S.trim();if(j){const D=++K.current;y.current=D,H(!0),t({type:"search_files",reqId:D,query:j}),t({type:"search_sessions",reqId:D,query:j})}}else f(I.path,I.name)},[d,u,f,t,S]);l.useEffect(()=>{if(!e)return;const I=j=>{j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),c()):j.key==="ArrowDown"?(j.preventDefault(),G(D=>Math.min(D+1,k.length-1))):j.key==="ArrowUp"?(j.preventDefault(),G(D=>Math.max(D-1,0))):j.key==="Enter"&&(j.preventDefault(),le(k[M]))};return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[k,M,le,c,e]);const Y=se.length+X.length+A.length,me=(I,j,D)=>s.jsxs("div",{className:"gs-section-head",children:[D,s.jsx("span",{children:I}),s.jsx("em",{children:j})]});let he=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:c,children:s.jsxs("div",{className:"gs-modal",onClick:I=>I.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(zs,{}),s.jsx("input",{ref:b,type:"text",value:x,placeholder:g("gsPlaceholder"),onChange:I=>N(I.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:g("close"),onClick:c,children:s.jsx(Je,{})})]}),s.jsxs("div",{className:"gs-results",children:[!V&&s.jsx("div",{className:"gs-empty",children:g("gsHint")}),V&&Y===0&&!J&&s.jsx("div",{className:"gs-empty",children:g(U?"gsSearching":"gsNoResults")}),se.length>0&&s.jsxs("div",{className:"gs-section",children:[me(g("gsSessions"),se.length,s.jsx(Jt,{})),se.map(I=>{he++;const j=he;return s.jsxs("button",{type:"button",className:j===M?"gs-item active":"gs-item",onMouseEnter:()=>G(j),onClick:()=>le({kind:"session",path:I.path,anchors:I.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[I.name||I.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:I.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:I.firstMessage})]},I.path)})]}),X.length>0&&s.jsxs("div",{className:"gs-section",children:[me(g("gsProjects"),X.length,s.jsx(Rt,{})),X.map(I=>{he++;const j=he,D=a&&I.path===a;return s.jsxs("button",{type:"button",className:j===M?"gs-item active":"gs-item",onMouseEnter:()=>G(j),onClick:()=>le({kind:"project",path:I.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[I.path.split(/[\\/]/).pop(),D&&s.jsx("em",{className:"gs-item-meta",children:g("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:I.path})]},I.path)})]}),(A.length>0||V&&J)&&s.jsxs("div",{className:"gs-section",children:[me(g("gsFiles"),A.length,s.jsx(Wi,{})),A.map(I=>{he++;const j=he;return s.jsxs("button",{type:"button",className:j===M?"gs-item active":"gs-item",disabled:I.type==="dir",title:I.type==="dir"?void 0:g("gsOpenPreview"),onMouseEnter:()=>G(j),onClick:()=>{I.type==="file"&&le({kind:"file",path:I.path,name:I.name})},children:[s.jsx("span",{className:"gs-item-title",children:I.name}),s.jsx("span",{className:"gs-item-sub",children:I.path})]},`${I.type}:${I.path}`)}),J&&s.jsx("div",{className:"gs-truncated",children:g("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",g("gsNavigate")]}),s.jsxs("span",{children:["Enter ",g("gsOpen")]}),s.jsxs("span",{children:["Esc ",g("gsCloseHint")]})]})]})}):null}const In=5e3;function sf({file:e,content:t,send:n,onAddLines:a,onAttach:o,onClose:i}){const c=Ae(),[d,u]=l.useState(null),[f,g]=l.useState(!1),[b,x]=l.useState(null),[N,S]=l.useState(!1),[M,G]=l.useState(!1),[K,y]=l.useState(!1),[R,U]=l.useState(""),[H,V]=l.useState(!0),se=l.useRef(!1),[X,A]=l.useState(!0),[J,k]=l.useState(!1),[le,Y]=l.useState(100),me=l.useRef(0),he=l.useRef(!1),I=l.useRef(null);l.useEffect(()=>{g(!0),u(null),x(null),y(!1),U(""),V(!0),se.current=!1,n({type:"read_file",path:e.path})},[e.path,n]),l.useEffect(()=>{t&&t.path===e.path&&(u(t),K||U(t.text),g(!1))},[t,K,e.path]),l.useEffect(()=>{const ae=pe=>{if(pe.key==="Escape"){ce();return}if((pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="s"&&K){pe.preventDefault(),T();return}const Le=pe.target,Be=Le&&(Le.tagName==="INPUT"||Le.tagName==="TEXTAREA"||Le.isContentEditable);(pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="a"&&!Be&&(pe.preventDefault(),ge())};return document.addEventListener("keydown",ae),()=>document.removeEventListener("keydown",ae)},[i,d,K,R]),l.useEffect(()=>{const ae=()=>{he.current=!1,S(!1)};return window.addEventListener("mouseup",ae),()=>window.removeEventListener("mouseup",ae)},[]);const j=l.useMemo(()=>{if(!d)return[];const ae=d.text.split(`
335
- `);return ae.length>0&&ae[ae.length-1]===""&&ae.pop(),ae.slice(0,In)},[d]),D=d?.lines??0,re=D>In,te=(ae,pe)=>{if(pe){const Le=me.current>0?me.current:ae;x({start:Math.min(Le,ae),end:Math.max(Le,ae)})}else me.current=ae,x({start:ae,end:ae})},ge=()=>{j.length!==0&&(me.current=1,x({start:1,end:j.length}))},C=()=>{b&&(a(e.path,e.name,b.start,b.end),G(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>G(!1),1400))},Q=d!==null&&d.kind==="text"&&!d.binary&&!d.truncated,P=()=>{U(d?.text??""),y(!1),se.current&&V(!0)},$=()=>{if(K){if(R!==(d?.text??"")&&!window.confirm(c("discardFileChanges")))return;P();return}!Q||!d||(se.current=jn(e.name)&&H,jn(e.name)&&V(!1),x(null),U(d.text),y(!0))},T=()=>{!K||!d||!Q||n({type:"write_file",path:e.path,text:R})&&(y(!1),se.current&&V(!0),x(null))},ce=()=>{K&&R!==(d?.text??"")&&!window.confirm(c("discardFileChanges"))||i()},F=ae=>{Y(Math.min(200,Math.max(50,ae)))},ie=b?b.end-b.start+1:0,oe=d?.binary??!1,de=d?.truncated??!1,Te=d?.kind??"text",we=jn(e.name),v=we&&H&&!K&&Te==="text"&&!oe,ne=ae=>Dt(it(`/api/file?clientId=${encodeURIComponent(ra())}&path=${encodeURIComponent(ae)}`));return s.jsx("div",{className:`fp-overlay ${J?"fullscreen":""}`,onMouseDown:ae=>{ae.target===ae.currentTarget&&ce()},children:s.jsxs("div",{className:`fp ${J?"fullscreen":""}`,style:{"--fp-zoom":le/100},children:[s.jsxs("div",{className:"fp-head",children:[s.jsx("span",{className:"fp-name",title:e.path,children:e.name}),s.jsx("span",{className:"fp-path",children:e.path}),s.jsxs("span",{className:"fp-meta",children:[d&&Te==="text"&&!oe&&c("fileLines",{n:D}),d&&` · ${nf(d.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[we&&Te==="text"&&!oe&&d&&s.jsx("button",{type:"button",className:`fp-attach markdown ${H?"on":""}`,"data-tip":c(H?"showMarkdownSource":"showMarkdownPreview"),disabled:K,onClick:()=>V(ae=>!ae),children:H?s.jsx(Dn,{}):s.jsx(kl,{})}),Te==="text"&&!oe&&d&&s.jsx("button",{type:"button",className:`fp-attach edit ${K?"on":""}`,"data-tip":c(de?"fileEditTruncated":K?"exitEditFile":"editFile"),disabled:!Q&&!K,onClick:$,children:s.jsx(zt,{})}),Te==="text"&&!oe&&!v&&s.jsx("button",{type:"button",className:`fp-attach wrap ${X?"on":""}`,"data-tip":c(X?"disableWrap":"enableWrap"),onClick:()=>A(ae=>!ae),children:s.jsx(Nl,{})}),Te==="text"&&d&&s.jsxs("span",{className:"fp-zoom",children:[s.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":c("zoomOut"),disabled:le<=50,onClick:()=>F(le-10),children:s.jsx(nl,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:c("resetZoom"),onClick:()=>Y(100),children:[le,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":c("zoomIn"),disabled:le>=200,onClick:()=>F(le+10),children:s.jsx(al,{})})]}),Te!=="video"&&Te!=="none"&&s.jsx("button",{type:"button",className:"fp-attach inline","data-tip":c("attachInlineTip"),onClick:()=>o(e.path,e.name,"inline"),children:s.jsx(ct,{})}),s.jsx("button",{type:"button",className:"fp-attach ref","data-tip":c("referenceTip"),onClick:()=>o(e.path,e.name,"reference"),children:s.jsx(Rn,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${J?"on":""}`,"data-tip":c(J?"exitFullscreen":"fullscreen"),onClick:()=>k(ae=>!ae),children:J?s.jsx(pl,{}):s.jsx(hl,{})}),s.jsx("button",{type:"button",className:"fp-close",title:c("close"),onClick:ce,children:s.jsx(Je,{})})]})]}),de&&Te==="text"&&!oe&&s.jsx("div",{className:"fp-notice",children:c("previewTruncated")}),f&&!d&&s.jsx("div",{className:"fp-empty",children:c("loading")}),!f&&Te==="none"&&!oe&&s.jsx("div",{className:"fp-empty",children:c("previewNotSupported")}),!f&&Te==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:ne(e.path),alt:e.name})}),!f&&Te==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:ne(e.path),controls:!0,preload:"metadata"})}),!f&&v&&d&&s.jsx("div",{className:"fp-markdown msg-text",children:s.jsx("div",{className:"fp-markdown-zoom",children:s.jsx(at,{text:d.text})})}),!f&&oe&&Te!=="image"&&Te!=="video"&&d&&s.jsxs("div",{className:"fp-hex-wrap",children:[s.jsxs("div",{className:"fp-notice",children:[c("binaryFile"),d.truncated&&c("binaryHexTruncated")]}),s.jsx("pre",{className:"fp-hex",children:d.text})]}),!f&&K&&Te==="text"&&!oe&&d&&s.jsx("textarea",{className:`fp-editor ${X?"":"no-wrap"}`,value:R,onChange:ae=>U(ae.target.value),wrap:X?"soft":"off",spellCheck:!1,autoFocus:!0}),!f&&!v&&!K&&Te==="text"&&!oe&&d&&j.length===0&&s.jsx("div",{className:"fp-empty",children:c("emptyFile")}),!f&&!v&&!K&&Te==="text"&&!oe&&j.length>0&&s.jsxs("div",{className:`fp-code ${N?"dragging":""} ${X?"":"no-wrap"}`,onMouseDown:ae=>{ae.button===0&&ae.preventDefault()},children:[j.map((ae,pe)=>{const Le=pe+1,Be=b!==null&&Le>=b.start&&Le<=b.end;return s.jsxs("div",{className:`fp-line ${Be?"sel":""}`,onMouseDown:Ye=>{Ye.button===0&&(te(Le,Ye.shiftKey),he.current=!0,S(!0))},onMouseEnter:()=>{he.current&&te(Le,!0)},children:[s.jsx("span",{className:"fp-num",children:Le}),s.jsx("span",{className:"fp-code-text",children:ae})]},Le)}),re&&s.jsx("div",{className:"fp-lines-note",children:c("previewLinesTruncated",{n:In})})]}),s.jsx("div",{className:"fp-foot",children:K?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:c("editFile")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:$,children:c("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:R===(d?.text??""),onClick:T,children:[s.jsx(ll,{})," ",c("saveFile")]})]})]}):!v&&Te==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:b?c("selectedRange",{n:ie,start:b.start,end:b.end}):c("selectLinesHint")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",disabled:j.length===0,onClick:ge,children:c("selectAll")}),s.jsx("button",{type:"button",className:"btn",disabled:!b,onClick:()=>x(null),children:c("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!b||oe,onClick:C,children:[M?s.jsx(Et,{}):null,c(M?"addedToChat":"addToChat")]})]})]})})]})})}function jn(e){const t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")}function nf(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const No="pi-web-sounds",ds={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function ko(){try{const e=localStorage.getItem(No);if(!e)return{...ds};const t=JSON.parse(e),n={...ds,...t};for(const a of["enabled","question","done","start","error"])typeof n[a]!="boolean"&&(n[a]=ds[a]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=ds.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...ds}}}function af(e){try{localStorage.setItem(No,JSON.stringify(e))}catch{}}let ps=null;function rf(){try{if(!ps){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;ps=new e}return ps.state==="suspended"&&ps.resume(),ps}catch{return null}}const of=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],lf=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],cf=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],uf=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],df={question:of,done:lf,start:cf,error:uf};function pf(e,t,n){const a=e.createOscillator(),o=e.createGain();a.type=t.type,a.frequency.value=t.freq;const i=e.currentTime+t.start,c=Math.max(1e-4,t.peak*n);o.gain.setValueAtTime(1e-4,i),o.gain.exponentialRampToValueAtTime(c,i+.012),o.gain.exponentialRampToValueAtTime(1e-4,i+t.dur),a.connect(o),o.connect(e.destination),a.start(i),a.stop(i+t.dur+.05)}function ms(e,t=ko()){if(!t.enabled||!t[e])return;const n=rf();if(!n)return;const a=Math.max(0,Math.min(1,t.volume/100));for(const o of df[e])pf(n,o,a)}const mf=l.lazy(()=>zo(()=>import("./TerminalPanel-SG88Uj0n.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function hf({notice:e,onDismiss:t}){const n=Ae(),{locale:a}=Ot(),o=a!=="zh"&&e.textEn?e.textEn:e.text,[i,c]=l.useState(!1);l.useEffect(()=>{if(i)return;const u=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(u)},[i,e.id,e.level,t]);const d=e.level==="error"?Sl:e.level==="warning"?_l:El;return s.jsxs("div",{className:`notice notice-${e.level}${i?" paused":""}`,role:"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s.jsx(d,{className:"notice-icon"}),s.jsx("span",{className:"notice-text",children:o}),s.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>t(e.id),children:s.jsx(Je,{})})]})}const ff=[],Co=180,vo=520,_o=240,So=e=>`pi-web-ui:${e}-panel-width`;function Ii(e){const t=Number(localStorage.getItem(So(e)));return Number.isFinite(t)&&t>=Co&&t<=vo?t:_o}const aa=e=>`pi-web-ui:${e}-panel-collapsed`;function ji(e){return localStorage.getItem(aa(e))==="1"}function Li({side:e,width:t,onResize:n}){const a=Ae(),o=l.useCallback(i=>{i.preventDefault();const c=i.clientX,d=t;let u=d;const f=b=>{const x=e==="left"?b.clientX-c:c-b.clientX;u=Math.min(vo,Math.max(Co,Math.round(d+x))),n(u)},g=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",g),document.body.classList.remove("panel-resizing"),localStorage.setItem(So(e),String(u))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",g),document.body.classList.add("panel-resizing")},[e,t,n]);return s.jsx("div",{className:`resize-handle resize-${e}`,title:a("dragToResize"),onPointerDown:o,onDoubleClick:()=>n(_o)})}function Ri({side:e,onClick:t}){const n=Ae();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(Ki,{}):s.jsx(Yi,{})})}function gf(){const e=Ae(),{locale:t}=Ot(),{chat:n,send:a,dismissNotice:o,pushNotice:i,terminal:c}=bc(),d=l.useRef(!1);l.useEffect(()=>{!n.ready||!n.settings||d.current||n.settings.quickPhrasesSeeded||(d.current=!0,n.settings.quickPhrases.length===0&&a({type:"set_settings",quickPhrases:an[t]??an.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,a,t]);const u=n.state?.cwd??"",f=bo();l.useEffect(()=>{const q=f?Ph(u):"";document.title=q?`${q} — pi-web-ui`:e("docTitle")},[u,f,e]);const[g,b]=l.useState([]),[x,N]=l.useState(null),[S,M]=l.useState(!1),[G,K]=l.useState("chat"),y=q=>!n.tabs||q==="chat"||n.tabs.includes(q),R=G.startsWith("plugin:")?"plugins":G,U=y(R)?G:"chat",H=l.useMemo(()=>n.plugins.filter(q=>!n.settings?.disabledPlugins?.includes(q.id)),[n.plugins,n.settings?.disabledPlugins]),[V,se]=l.useState([]);l.useEffect(()=>ac(se),[]),l.useEffect(()=>{Vp(a),zp(H,n.pluginsEpoch),ic(H,n.pluginsEpoch)},[H,n.pluginsEpoch,a]);const[X,A]=l.useState(()=>Ii("left")),[J,k]=l.useState(()=>Ii("right")),le=l.useCallback(q=>A(q),[]),Y=l.useCallback(q=>k(q),[]),[me,he]=l.useState(()=>ji("left")),[I,j]=l.useState(()=>ji("right")),D=l.useCallback(()=>{he(q=>(localStorage.setItem(aa("left"),q?"0":"1"),!q))},[]),re=l.useCallback(()=>{j(q=>(localStorage.setItem(aa("right"),q?"0":"1"),!q))},[]),[te,ge]=l.useState(null),[C,Q]=l.useState(()=>window.matchMedia("(max-width: 768px)").matches);l.useEffect(()=>{const q=window.matchMedia("(max-width: 768px)"),be=Se=>Q(Se.matches);return q.addEventListener("change",be),()=>q.removeEventListener("change",be)},[]);const[P,$]=l.useState(!1),[T,ce]=l.useState(!1),[F,ie]=l.useState(!1),oe=ho(),[de,Te]=l.useState(!1),[we,v]=l.useState(!1),[ne,ae]=l.useState(null);l.useEffect(()=>{if(!ne)return;const q=setTimeout(()=>ae(null),15e3);return()=>clearTimeout(q)},[ne]),l.useEffect(()=>{const q=be=>{const Se=be.detail,Ke=Se?.title||e("pluginCommandFallback"),Ge=Se?.command;if(!Ge||!n.ready)return;const _t={name:Ke,command:Ge,cwd:"${pwd}"},qe=n.terminals.find(dt=>dt.title===Ke);if(qe)c.restart(qe.id),a({type:"run_command",terminalId:qe.id,conversationId:qe.conversationId,command:_t,cols:80,rows:24});else{const dt=Ct();c.create({id:dt,conversationId:n.activeConversationId||n.state?.conversationId||"",title:Ke,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:_t})}K("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",q),()=>window.removeEventListener("pi-web-ui:plugin-run-command",q)},[n,c,a]),l.useEffect(()=>{const q=be=>{!(be.ctrlKey||be.metaKey)||be.key.toLowerCase()!=="k"||(be.preventDefault(),v(Se=>!Se))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const[pe,Le]=l.useState(ko),{themes:Be,theme:Ye,switchTheme:_}=em();Gh();const ue=l.useRef(null),ve=l.useRef(null),xe=l.useRef(0),ye=l.useRef(!1),Oe=l.useRef(n.terminals);l.useEffect(()=>{af(pe)},[pe]),l.useEffect(()=>{const q=Oe.current;Oe.current=n.terminals;for(const be of n.terminals){const Se=be.command?.command??"";!q.find(Ge=>Ge.id===be.id)?.running||be.running||(Se.startsWith("pi remove ")?a({type:"extensions_reload"}):Se.startsWith("pi-web-ui install ")||Se.startsWith("pi-web-ui uninstall ")?a({type:"plugins_reload"}):Se.startsWith("npm i -g ")&&(a({type:"extensions_reload"}),a({type:"plugins_reload"}),a({type:"check_updates_all",force:!0})))}},[n.terminals,a]),l.useEffect(()=>{const q=n.state?.isStreaming??!1,be=ue.current;ue.current=q,be!==null&&(!be&&q?ms("start",pe):be&&!q&&(ms("done",pe),Tn(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,pe]),l.useEffect(()=>{const q=n.dialog?.id??null;q!==null&&q!==ve.current&&(ms("question",pe),Tn(e("notifyQuestionTitle"),e("notifyQuestionBody"))),ve.current=q},[n.dialog,pe]),l.useEffect(()=>{const q=[...n.notices].reverse().find(be=>be.level==="error");q&&q.id!==xe.current&&(xe.current=q.id,ms("error",pe),Tn(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,pe]);const Me=(q,be,Se,Ke=!1,Ge)=>{const _t=`${q}|${Se}|${Ge?`${Ge.start}-${Ge.end}`:""}`;b(qe=>qe.some(dt=>`${dt.path}|${dt.mode}|${dt.lines?`${dt.lines.start}-${dt.lines.end}`:""}`===_t)?qe:[...qe,{path:q,name:be,mode:Se,isDir:Ke,...Ge?{lines:Ge}:{}}])},B=q=>b(be=>be.filter(Se=>Se.key?Se.key!==q:Se.path!==q)),_e=l.useCallback(q=>(!q.type.startsWith("list_")&&!q.type.startsWith("get_")&&ge(null),a(q)),[a]),Ce=l.useRef(0),Ue=l.useRef(0),Re=q=>{const be=Date.now();n.state?.model&&!n.state.model.vision&&be-Ue.current>1e4&&(Ue.current=be,i("warning",e("imageNotSupported")));const Se=`paste-${++Ce.current}`;b(Ke=>[...Ke,{path:"",key:Se,name:q.name,mode:"inline",imageData:q.data,mimeType:q.mimeType}])},We=async q=>{for(const be of q){const Se=await fa(be);if(!Se){i("error",e("imageLoadFailed",{name:be.name}));continue}Re(Se)}},Tt=20*1024*1024,Mt=l.useRef(0),is=async q=>{if(q.size>Tt){i("warning",e("fileTooLarge",{name:q.name,size:Tt/1024/1024}));return}let be;try{be=(await new Promise((Ge,_t)=>{const qe=new FileReader;qe.onload=()=>Ge(qe.result),qe.onerror=()=>_t(qe.error??new Error("read failed")),qe.readAsDataURL(q)})).replace(/^data:[^;]*;base64,/,"")}catch{i("error",e("fileLoadFailed",{name:q.name}));return}const Se=`upload-${++Mt.current}`;b(Ke=>[...Ke,{path:"",key:Se,name:q.name,mode:"inline",fileData:be,size:q.size,mimeType:q.type||void 0}])},ut=async q=>{for(const be of q)Nt(be.type)?await We([be]):await is(be)},ft=l.useCallback((q,be,Se)=>{a({type:"edit_message",messageId:q,text:be,attachments:Se})},[a]),vt=l.useCallback((q,be)=>{a({type:"queue_remove",kind:q,text:be})},[a]),L=l.useCallback(()=>ce(!0),[]),W=l.useCallback(()=>b([]),[]),ke=l.useCallback(B,[]),Ne=l.useCallback(We,[We]),De=l.useCallback(ut,[ut]),Pe=n.state?.model,rt=n.state?.thinkingLevel,xt=n.state?.availableThinkingLevels,pn=l.useMemo(()=>Pe?{model:Pe,thinkingLevel:rt??"off",availableThinkingLevels:xt??[]}:null,[Pe,rt,xt]),je=l.useCallback(()=>!n.ready||n.terminals.length!==0?!1:(c.create({id:Ct(),conversationId:n.activeConversationId||n.state?.conversationId||"",title:e("terminalTitle",{n:1}),cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,c]);return l.useEffect(()=>{if(ye.current){if(U!=="terminal"||n.terminals.length!==0){ye.current=!1;return}je()&&(ye.current=!1)}},[n.terminals.length,je,U]),s.jsxs("div",{className:"app",onDragOver:q=>{Array.from(q.dataTransfer?.types??[]).includes("Files")&&(q.preventDefault(),M(!0))},onDragLeave:q=>{q.currentTarget.contains(q.relatedTarget)||M(!1)},onDrop:q=>{if(M(!1),!Array.from(q.dataTransfer?.types??[]).includes("Files"))return;q.preventDefault();const be=Array.from(q.dataTransfer?.files??[]);if(be.length===0){i("warning",e("foldersNotSupported"));return}const Se=be.filter(Ge=>Nt(Ge.type)),Ke=be.filter(Ge=>!Nt(Ge.type));Se.length>0&&We(Se),Ke.length>0&&ut(Ke)},children:[S&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(Gl,{chat:n,send:a,terminal:c,view:U,plugins:H,onViewChange:q=>{ye.current=q==="terminal"&&n.terminals.length===0,ye.current&&je()&&(ye.current=!1),K(q),ge(null)},onOpenPanel:ge,onOpenSettings:()=>ie(!0),onOpenBgTasks:()=>Te(!0),onOpenGlobalSearch:()=>v(!0),sound:pe,onSoundChange:Le,onSoundPreview:q=>ms(q,pe),themes:Be,theme:Ye,onThemeChange:_}),n.protocolMismatch&&s.jsxs("div",{className:"protocol-banner",children:["⚠ ",e("protocolMismatch")]}),s.jsx("div",{className:"notices",children:n.notices.map(q=>s.jsx(hf,{notice:q,onDismiss:o},q.id))}),s.jsx(zm,{send:a,children:s.jsxs("div",{className:"layout",style:{"--left-w":`${X}px`,"--right-w":`${J}px`},children:[te&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>ge(null)}),s.jsxs("div",{className:`view-pane ${U==="chat"?"":"hidden"}`,children:[!C&&me&&s.jsx(Ri,{side:"left",onClick:D}),s.jsx("div",{className:`panel-drawer drawer-left ${te==="left"?"open":""}${C?"":me?" hidden":""}`,children:s.jsx(Zl,{collapsible:!C,onToggleCollapse:D,send:_e,active:!C||te==="left",ready:n.ready,status:n.status,cwd:n.state?.cwd??"",sessionFile:n.state?.sessionFile??null,conversations:n.conversations,sessions:n.sessions,projects:n.projects,activeConversationId:n.activeConversationId})}),!C&&s.jsx(Li,{side:"left",width:X,onResize:le}),s.jsxs("main",{className:oe?"main wide-chat":"main",children:[n.state?s.jsx(sh,{state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:ft,onKillBash:()=>a({type:"abort_bash"}),onRetry:()=>a({type:"retry_last"}),onRemoveQueued:vt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,jumpTarget:ne,onJumpDone:()=>ae(null)},n.state.conversationId??"boot"):s.jsx("div",{className:"boot-wait",children:n.ready?e("loadingSession"):e("connectingServer")}),n.settings?.goalModeEnabled!==!1&&s.jsx(hh,{send:a,goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,engine:n.engine}),n.dialog&&s.jsx(yh,{dialog:n.dialog,send:a}),n.question&&s.jsx(Nh,{question:n.question,send:a}),s.jsx(mh,{send:a,ready:n.ready,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??ff,slashCommands:n.slashCommands,modelState:pn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:g,onRemoveAttachment:ke,onAddImageFiles:Ne,onAddLocalFiles:De,onNotice:i,onManageModels:L,onSent:W,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0})]}),!C&&s.jsx(Li,{side:"right",width:J,onResize:Y}),s.jsx("div",{className:`panel-drawer drawer-right ${te==="right"?"open":""}${C?"":I?" hidden":""}`,children:s.jsx(_c,{collapsible:!C,onToggleCollapse:re,send:_e,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,cwd:n.state?.cwd??"",onAttach:(q,be,Se,Ke)=>{ge(null),Me(q,be,Se,Ke)},onPreview:(q,be)=>{ge(null),N({path:q,name:be})},onNotice:(q,be)=>i(q,be)})}),!C&&I&&s.jsx(Ri,{side:"right",onClick:re})]}),s.jsx("div",{className:`view-pane ${U==="terminal"?"":"hidden"}`,children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(mf,{chat:n,send:a,terminal:c})})}),s.jsx("div",{className:`view-pane ${U==="git"?"":"hidden"}`,children:s.jsx(Ch,{chat:n,send:a,terminal:c,active:U==="git",onSwitchToTerminal:()=>K("terminal")})}),V.map(q=>{const be=`plugin:${q.info.id}`;return s.jsx("div",{className:`view-pane ${U===be?"":"hidden"}`,children:s.jsx(vh,{entry:q,send:a})},q.info.id)})]})}),s.jsx(Th,{chat:n,send:a}),x&&s.jsx(sf,{file:x,content:n.fileContent,send:a,onAddLines:(q,be,Se,Ke)=>Me(q,be,"lines",!1,{start:Se,end:Ke}),onAttach:(q,be,Se)=>Me(q,be,Se),onClose:()=>N(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!P&&!T&&s.jsx(_h,{send:a,piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,managed:n.managed,providers:n.providers,installResult:n.installResult,onClose:()=>$(!0)}),T&&s.jsx(wh,{send:a,providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>ce(!1)}),F&&s.jsx(Xh,{chat:n,send:a,terminal:c,onSwitchToTerminal:()=>K("terminal"),onClose:()=>ie(!1)}),de&&s.jsx(Zh,{servers:n.bgServers,send:a,onClose:()=>Te(!1)}),s.jsx(tf,{open:we,send:a,projects:n.projects,cwd:n.state?.cwd??"",fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>v(!1),onSwitchSession:(q,be)=>{a({type:"switch_session",path:q});const Se=be&&be[0];ae(Se?{path:q,role:Se.role,timestamp:Se.timestamp}:null)},onSwitchProject:q=>{a({type:"set_cwd",path:q})},onPreviewFile:(q,be)=>{N({path:q,name:be})}})]})}function bf(){if(typeof document>"u")return;const e=document.documentElement,t=document.createElement("div");t.style.cssText="position:fixed;top:-9999px;left:0;width:100px;height:100px;overflow-y:scroll;visibility:hidden;pointer-events:none;",document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;document.body.removeChild(t),e.style.setProperty("--msgs-gutter",`${n}px`)}jl();Kr(Wr());bf();Yo.createRoot(document.getElementById("root")).render(s.jsx(l.StrictMode,{children:s.jsx(ql,{children:s.jsx(gf,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=Qi();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(t=>{console.warn("Service worker registration failed:",t)})});export{Lt as F,jt as T,Ae as a,yf as b,ct as c,xf as d,Xs as e,et as f,ml as g,Xt as h,Je as i,Ct as r,Ot as u};