linkshell-cli 0.5.35 → 0.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/src/runtime/bridge-session.d.ts +2 -0
- package/dist/cli/src/runtime/bridge-session.js +52 -27
- package/dist/cli/src/runtime/bridge-session.js.map +1 -1
- package/dist/cli/src/runtime/hook-command.d.ts +34 -0
- package/dist/cli/src/runtime/hook-command.js +67 -0
- package/dist/cli/src/runtime/hook-command.js.map +1 -0
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/runtime/bridge-session.ts +55 -29
- package/src/runtime/hook-command.ts +73 -0
- package/web/assets/{FileBrowser-Dn_avjeH.js → FileBrowser-Coy7Szjx.js} +1 -1
- package/web/assets/{PortPreview-KYkYV_-p.js → PortPreview-D-XovbV1.js} +1 -1
- package/web/assets/{TerminalPanel-BjxX8Jui.js → TerminalPanel-Cah56AtC.js} +1 -1
- package/web/assets/{UsageDashboard-cYiZs8c8.js → UsageDashboard-DfkjJagC.js} +1 -1
- package/web/assets/index-BsnDaeCt.css +33 -0
- package/web/assets/index-ClZzQ4ba.js +35 -0
- package/web/assets/{vendor-highlight-Cus7zBI4.js → vendor-highlight-NXWAAyIv.js} +1 -1
- package/web/assets/{vendor-react-0zU5oKmd.js → vendor-react-M7xG3qiw.js} +8 -8
- package/web/index.html +4 -4
- package/web/assets/index-6vyVf_xQ.js +0 -35
- package/web/assets/index-Ct5fhCTS.css +0 -33
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-BjxX8Jui.js","assets/vendor-react-0zU5oKmd.js","assets/vendor-xterm-D15THcI4.js","assets/vendor-highlight-Cus7zBI4.js","assets/UsageDashboard-cYiZs8c8.js","assets/PortPreview-KYkYV_-p.js","assets/FileBrowser-Dn_avjeH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as v,j as l,g as Xa,c as sc}from"./vendor-react-0zU5oKmd.js";import{o as ot,u as ac,g as oc,c as lc}from"./vendor-highlight-Cus7zBI4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const Ja="linkshell_gateway_url",cc="http://localhost:8787";function uc(){var e;return typeof window<"u"&&((e=window.location)!=null&&e.origin)?window.location.origin.replace(/\/+$/,""):cc}function Ga(){let e=uc();try{const t=localStorage.getItem(Ja);t&&(e=t)}catch{}return{httpUrl:e}}function eo(e){try{localStorage.setItem(Ja,e.replace(/\/+$/,""))}catch{}}const to="linkshell_device_token";let Vt=null;function ai(){return typeof(crypto==null?void 0:crypto.randomUUID)=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Hn(){if(Vt)return Vt;try{Vt=localStorage.getItem(to)}catch{Vt=null}return Vt}function dc(){const e=Hn();if(e)return e;const t=ai();return Mi(t),t}function Mi(e){Vt=e;try{localStorage.setItem(to,e)}catch{}}const vs="linkshell_device_id";let cn=null;function fc(){if(cn)return cn;try{let e=localStorage.getItem(vs);e||(e=ai(),localStorage.setItem(vs,e)),cn=e}catch{cn=ai()}return cn}const no="linkshell_theme",Zn=new Set;let sr=hc();function hc(){try{const e=localStorage.getItem(no);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function pc(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function mc(e=sr){return e==="system"?pc()?"dark":"light":e}function oi(){typeof document>"u"||document.documentElement.setAttribute("data-theme",mc())}function ws(){return sr}function Ri(e){sr=e;try{localStorage.setItem(no,e)}catch{}oi();for(const t of Zn)t()}function gc(e){return Zn.add(e),()=>Zn.delete(e)}function xc(){var e;if(oi(),typeof window<"u"&&window.matchMedia){const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{if(sr==="system"){oi();for(const r of Zn)r()}};(e=t.addEventListener)==null||e.call(t,"change",n)}}const ro=1,io="linkshell_view",ar="linkshell_conv_",or="linkshell_timeline_",lr="linkshell_known_sessions";function cr(e){try{const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return n&&n.version===ro&&n.data!==void 0?n.data:null}catch{return null}}function rn(e,t){try{const n={version:ro,data:t};localStorage.setItem(e,JSON.stringify(n))}catch{}}function yc(){return cr(io)??{name:"list"}}function Ss(e){rn(io,e)}function _t(){return cr(lr)??[]}function li(e){if(e.length===0)return _t();const t=new Set(e.map(i=>i.id)),n=new Map;for(const i of _t())n.set(i.id,t.has(i.id)?i:{...i,hasHost:!1});for(const i of e)n.set(i.id,{...n.get(i.id),...i});const r=[...n.values()].sort((i,s)=>(s.lastActivity??0)-(i.lastActivity??0)).slice(0,50);return rn(lr,r),r}function bc(){const e=_t().map(t=>({...t,hasHost:!1}));return rn(lr,e),e}function kc(e){const t=_t().filter(n=>n.id!==e);return rn(lr,t),so(e),t}function so(e){try{for(const t of ao(e))localStorage.removeItem(Wn+t.id);localStorage.removeItem(ar+e),localStorage.removeItem(or+e)}catch{}}function vc(){try{const e=new Set(_t().map(n=>n.id)),t=new Set;for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);if(!r)continue;const i=[ar,or].find(a=>r.startsWith(a));if(!i)continue;const s=r.slice(i.length);e.has(s)||t.add(s)}for(const n of t)so(n)}catch{}}function ao(e){return cr(ar+e)??[]}function _s(e,t){rn(ar+e,t)}const Wn="linkshell_draft_";function wc(e){try{return localStorage.getItem(Wn+e)??""}catch{return""}}function Sc(e,t){try{t?localStorage.setItem(Wn+e,t):localStorage.removeItem(Wn+e)}catch{}}function _c(e){return cr(or+e)??{}}function js(e,t){const n={};for(const[r,i]of t){const s=i.filter(a=>{var o;return((o=a.metadata)==null?void 0:o.optimistic)!==!0}).slice(-200);n[r]=s}rn(or+e,n)}vc();function jc(){try{const e=new URLSearchParams(window.location.search),t=e.get("embed")==="1",n=e.get("theme");return{embed:t,sessionId:e.get("session"),gateway:e.get("gateway"),token:e.get("token"),theme:n==="dark"||n==="light"?n:null}}catch{return{embed:!1,sessionId:null,gateway:null,token:null,theme:null}}}function Cc(e){return!e.embed||!e.sessionId||!e.token||!e.gateway?null:(eo(e.gateway),Mi(e.token),e.theme&&Ri(e.theme),li([{id:e.sessionId,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),{name:"console",sessionId:e.sessionId})}function oo(){try{const e=window.ReactNativeWebView;e==null||e.postMessage(JSON.stringify({type:"requestClose"}))}catch{}}const Nc="linkshell_embed";function Li(){try{return new URLSearchParams(window.location.search).get("embed")==="1"?!0:localStorage.getItem(Nc)==="1"}catch{return!1}}class Ic extends v.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error("[ErrorBoundary]",t)}render(){return this.state.error?l.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 px-6",children:[l.jsx("div",{className:"text-lg font-medium text-content-primary",children:"页面出错了"}),l.jsx("div",{className:"max-w-md break-all text-center font-mono text-xs text-content-muted",children:this.state.error.message}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",className:"codex-btn-primary",onClick:()=>window.location.reload(),children:"重新加载"}),Li()&&l.jsx("button",{type:"button",className:"codex-btn-outline",onClick:()=>oo(),children:"关闭"})]})]}):this.props.children}}const jn="https://mkbeusztkzffnzjdwmqk.supabase.co",Cn="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0",Di="linkshell_session",lo=1;function zi(e){const t={version:lo,session:e};localStorage.setItem(Di,JSON.stringify(t))}function ur(){try{const e=localStorage.getItem(Di);if(!e)return null;const t=JSON.parse(e);return t&&t.version===lo&&t.session?t.session:null}catch{return null}}function co(){localStorage.removeItem(Di)}const ci=new Set;function Tc(e){return ci.add(e),()=>{ci.delete(e)}}function Ac(){for(const e of ci)try{e()}catch{}}function Ec(e){return(e==null?void 0:e.plan)==="pro"}async function Oi(e,t,n="free"){try{const r=await fetch(`${jn}/rest/v1/profiles?id=eq.${t}&select=plan,plan_expires_at&limit=1`,{headers:{Authorization:`Bearer ${e}`,apikey:Cn}});if(r.ok){const i=await r.json();if(i.length>0){const s=i[0];if(s.plan==="pro"&&s.plan_expires_at&&new Date(s.plan_expires_at)>new Date)return"pro"}return"free"}return n}catch{return n}}async function Pc(e,t){try{const n=await fetch(`${jn}/auth/v1/token?grant_type=password`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Cn},body:JSON.stringify({email:e,password:t})}),r=await n.json();if(!n.ok)return{session:null,error:r.error_description||"登录失败"};const i=await Oi(r.access_token,r.user.id),s={accessToken:r.access_token,refreshToken:r.refresh_token,expiresAt:Date.now()+(r.expires_in??3600)*1e3,user:{id:r.user.id,email:r.user.email},plan:i};return zi(s),{session:s,error:null}}catch(n){return{session:null,error:n.message||"网络错误"}}}async function Mc(e,t){try{const n=await fetch(`${jn}/auth/v1/signup`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Cn},body:JSON.stringify({email:e,password:t})}),r=await n.json();if(!n.ok)return{session:null,error:r.error_description||r.msg||"注册失败"};if(!r.access_token)return{session:null,error:null};const i=await Oi(r.access_token,r.user.id),s={accessToken:r.access_token,refreshToken:r.refresh_token,expiresAt:Date.now()+(r.expires_in??3600)*1e3,user:{id:r.user.id,email:r.user.email},plan:i};return zi(s),{session:s,error:null}}catch(n){return{session:null,error:n.message||"网络错误"}}}async function Rc(){const e=ur();if(e)try{await fetch(`${jn}/auth/v1/logout`,{method:"POST",headers:{Authorization:`Bearer ${e.accessToken}`,apikey:Cn}})}catch{}co()}let un=null;async function Lc(){if(un)return un;un=(async()=>{const e=ur();if(!(e!=null&&e.refreshToken))return null;try{const t=await fetch(`${jn}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Cn},body:JSON.stringify({refresh_token:e.refreshToken})});if(!t.ok)return t.status>=400&&t.status<500&&(co(),Ac()),null;const n=await t.json(),r=await Oi(n.access_token,n.user.id,e.plan),i={accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:Date.now()+(n.expires_in??3600)*1e3,user:{id:n.user.id,email:n.user.email},plan:r};return zi(i),i}catch{return null}})();try{return await un}finally{un=null}}async function uo(){const e=ur();return e?e.expiresAt-Date.now()<6e4?Lc():e:null}function ve({size:e=16,children:t,...n}){return l.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:t})}const Rr=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"m4 17 6-6-6-6"}),l.jsx("path",{d:"M12 19h8"})]}),Pt=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),kn=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),l.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"})]}),Dc=e=>l.jsxs(ve,{...e,children:[l.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4"})]}),fo=e=>l.jsx(ve,{...e,children:l.jsx("rect",{width:"14",height:"14",x:"5",y:"5",rx:"2"})}),ft=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),zc=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})}),et=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"m9 18 6-6-6-6"})}),Cs=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"m15 18-6-6 6-6"})}),bt=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"m6 9 6 6 6-6"})}),ho=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"m5 12 7-7 7 7M12 19V5"})}),po=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),l.jsx("path",{d:"M21 3v5h-5M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),l.jsx("path",{d:"M8 16H3v5"})]}),dr=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M5 12h14M12 5v14"})}),Fi=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),Rt=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M20 6 9 17l-5-5"})}),Oc=e=>l.jsxs(ve,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"4"}),l.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}),Fc=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})}),$c=e=>l.jsxs(ve,{...e,children:[l.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4"})]}),mo=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M12 22v-5M9 8V2M15 8V2M18 8v3a6 6 0 0 1-12 0V8Z"})}),$i=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),l.jsx("circle",{cx:"9",cy:"7",r:"4"}),l.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"})]}),Bc=e=>l.jsxs(ve,{...e,children:[l.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),l.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),Wt=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),l.jsx("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]}),Ns=e=>l.jsxs(ve,{...e,children:[l.jsx("rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}),l.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),l.jsx("path",{d:"M10 12h4"})]}),qc=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M3 6h18"}),l.jsx("path",{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"}),l.jsx("path",{d:"M10 11v6M14 11v6"})]}),Mt=e=>l.jsxs(ve,{...e,children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("path",{d:"m21 21-4.3-4.3"})]}),go=e=>l.jsxs(ve,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"1"}),l.jsx("circle",{cx:"19",cy:"12",r:"1"}),l.jsx("circle",{cx:"5",cy:"12",r:"1"})]}),Lr=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})}),$k=e=>l.jsxs(ve,{...e,children:[l.jsx("path",{d:"M15 3h6v6"}),l.jsx("path",{d:"M10 14 21 3"}),l.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"})]}),Vc=e=>l.jsxs(ve,{...e,children:[l.jsx("circle",{cx:"12",cy:"18",r:"3"}),l.jsx("circle",{cx:"6",cy:"6",r:"3"}),l.jsx("circle",{cx:"18",cy:"6",r:"3"}),l.jsx("path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}),l.jsx("path",{d:"M12 12v3"})]}),qn=e=>l.jsxs(ve,{...e,children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20M2 12h20"})]}),Bk=e=>l.jsxs(ve,{...e,children:[l.jsx("rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}),l.jsx("path",{d:"M12 18h.01"})]}),qk=e=>l.jsx(ve,{...e,children:l.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})});function Bi({size:e=28,className:t}){return l.jsx("img",{src:"/logos/linkshell.png",alt:"LinkShell",width:e,height:e,className:`rounded-lg object-contain ${t??""}`,style:{width:e,height:e}})}function Qt({provider:e,size:t=14,className:n}){const r=e==="codex"?"/logos/codex.png":e==="claude"?"/logos/claude.png":e==="gemini"?"/logos/gemini.png":e==="copilot"?"/logos/copilot.png":null;return r?l.jsx("img",{src:r,alt:e,width:t,height:t,className:`shrink-0 rounded-sm object-contain ${n??""}`,style:{width:t,height:t}}):l.jsx(Fi,{size:t,className:n??"text-content-faint"})}function Uc({onLogin:e,onCancel:t}){const[n,r]=v.useState(""),[i,s]=v.useState(""),[a,o]=v.useState(null),[c,u]=v.useState(!1),[d,f]=v.useState(null),p=async m=>{m.preventDefault(),u(!0),o(null);const b=await Pc(n,i);u(!1),b.error?o(b.error):b.session&&e(b.session)},h=async()=>{u(!0),o(null),f(null);const m=await Mc(n,i);u(!1),m.error?o(m.error):m.session?e(m.session):f("请查收邮件以确认账户。")};return l.jsx("div",{className:"flex min-h-screen items-center justify-center px-4",children:l.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"mx-auto mb-3 flex items-center justify-center",children:l.jsx(Bi,{size:56})}),l.jsx("h1",{className:"font-mono text-xl font-bold text-content-primary",children:"LinkShell"}),l.jsx("p",{className:"mt-1 text-sm text-content-muted",children:"登录以连接你的 agent 会话"})]}),l.jsxs("form",{onSubmit:p,className:"space-y-3",children:[l.jsx("input",{type:"email",placeholder:"邮箱",value:n,onChange:m=>r(m.target.value),required:!0,className:"codex-input",autoComplete:"email"}),l.jsx("input",{type:"password",placeholder:"密码",value:i,onChange:m=>s(m.target.value),required:!0,minLength:6,className:"codex-input",autoComplete:"current-password"}),a&&l.jsx("p",{className:"text-sm text-danger",children:a}),d&&l.jsx("p",{className:"text-sm text-success",children:d}),l.jsx("button",{type:"submit",disabled:c,className:"codex-btn-primary w-full",children:c?"…":"登录"}),l.jsx("button",{type:"button",onClick:h,disabled:c||!n||!i,className:"codex-btn-outline w-full",children:"创建账户"}),t&&l.jsx("button",{type:"button",onClick:t,className:"codex-btn-ghost w-full",children:"暂不登录,用配对码连接"})]}),l.jsx("p",{className:"text-center text-2xs text-content-faint",children:"登录可选 · Pro 账户登录后免扫码直接看到自己的会话"})]})})}function fr(e){return e.httpUrl.replace(/\/+$/,"")}function xo(e){return e.wsUrl?e.wsUrl.replace(/\/+$/,""):fr(e).replace(/^http/,"ws")}function Hc(e){const t={},n=e.jwt??e.deviceToken;return n&&(t.Authorization=`Bearer ${n}`),t}function Zc(e,t){if(!t.deviceToken)return e;const n=new URL(e);return n.searchParams.set("token",t.deviceToken),n.toString()}async function Wc(e,t){const n=await fetch(`${fr(e)}/pairings/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pairingCode:t,deviceToken:Hn()??void 0})});if(!n.ok){const i=await n.json().catch(()=>null);throw new Error((i==null?void 0:i.error)||`配对失败 (HTTP ${n.status})`)}const r=await n.json();return r.deviceToken&&Mi(r.deviceToken),r}async function Qc(e,t){const n=await fetch(Zc(`${fr(e)}/sessions`,t),{headers:Hc(t)});return n.ok?(await n.json()).sessions??[]:[]}async function Kc(e,t){if(!t)return[];const n=await fetch(`${fr(e)}/sessions/mine`,{headers:{Authorization:`Bearer ${t}`}});return n.ok?(await n.json()).sessions??[]:[]}function Yc(e,t){const n=new URL(`${xo(e)}/ws`);return n.searchParams.set("sessionId",t.sessionId),n.searchParams.set("role","client"),n.searchParams.set("deviceId",t.deviceId),t.deviceToken&&n.searchParams.set("token",t.deviceToken),t.jwt&&n.searchParams.set("auth_token",t.jwt),n.toString()}function Xc(e,t){const n=new URL(`${xo(e)}/ws`);return n.searchParams.set("role","watcher"),t.deviceToken&&n.searchParams.set("token",t.deviceToken),t.jwt&&n.searchParams.set("auth_token",t.jwt),n.toString()}var ke;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},e.find=(i,s)=>{for(const a of i)if(s(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(ke||(ke={}));var Is;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Is||(Is={}));const H=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),St=e=>{switch(typeof e){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(e)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?H.promise:typeof Map<"u"&&e instanceof Map?H.map:typeof Set<"u"&&e instanceof Set?H.set:typeof Date<"u"&&e instanceof Date?H.date:H.object;default:return H.unknown}},z=ke.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class pt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),r}static assert(t){if(!(t instanceof pt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}pt.create=e=>new pt(e);const ui=(e,t)=>{let n;switch(e.code){case z.invalid_type:e.received===H.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case z.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ke.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:n=`Unrecognized key(s) in object: ${ke.joinValues(e.keys,", ")}`;break;case z.invalid_union:n="Invalid input";break;case z.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ke.joinValues(e.options)}`;break;case z.invalid_enum_value:n=`Invalid enum value. Expected ${ke.joinValues(e.options)}, received '${e.received}'`;break;case z.invalid_arguments:n="Invalid function arguments";break;case z.invalid_return_type:n="Invalid function return type";break;case z.invalid_date:n="Invalid date";break;case z.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ke.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case z.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case z.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case z.custom:n="Invalid input";break;case z.invalid_intersection_types:n="Intersection results could not be merged";break;case z.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case z.not_finite:n="Number must be finite";break;default:n=t.defaultError,ke.assertNever(e)}return{message:n}};let Jc=ui;function Gc(){return Jc}const eu=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:t,defaultError:o}).message;return{...i,path:s,message:o}};function V(e,t){const n=Gc(),r=eu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ui?void 0:ui].filter(i=>!!i)});e.common.issues.push(r)}class He{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return re;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,a=await i.value;r.push({key:s,value:a})}return He.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return re;s.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:t.value,value:r}}}const re=Object.freeze({status:"aborted"}),gn=e=>({status:"dirty",value:e}),tt=e=>({status:"valid",value:e}),Ts=e=>e.status==="aborted",As=e=>e.status==="dirty",Xt=e=>e.status==="valid",Qn=e=>typeof Promise<"u"&&e instanceof Promise;var Z;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Z||(Z={}));class mt{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Es=(e,t)=>{if(Xt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new pt(e.common.issues);return this._error=n,this._error}}};function ue(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,o)=>{const{message:c}=e;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:i}}class xe{get description(){return this._def.description}_getType(t){return St(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:St(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new He,ctx:{common:t.parent.common,data:t.data,parsedType:St(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Qn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:St(t)},i=this._parseSync({data:t,path:r.path,parent:r});return Es(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:St(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Xt(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Xt(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:St(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Qn(i)?i:Promise.resolve(i));return Es(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const a=t(i),o=()=>s.addIssue({code:z.custom,...r(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new en({schema:this,typeName:ee.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return jt.create(this,this._def)}nullable(){return tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ht.create(this)}promise(){return Gn.create(this,this._def)}or(t){return Yn.create([this,t],this._def)}and(t){return Xn.create(this,t,this._def)}transform(t){return new en({...ue(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new mi({...ue(this._def),innerType:this,defaultValue:n,typeName:ee.ZodDefault})}brand(){return new Su({typeName:ee.ZodBranded,type:this,...ue(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new gi({...ue(this._def),innerType:this,catchValue:n,typeName:ee.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return qi.create(this,t)}readonly(){return xi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const tu=/^c[^\s-]{8,}$/i,nu=/^[0-9a-z]+$/,ru=/^[0-9A-HJKMNP-TV-Z]{26}$/i,iu=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,su=/^[a-z0-9_-]{21}$/i,au=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ou=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lu=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Dr;const uu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,du=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,fu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,hu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yo="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",gu=new RegExp(`^${yo}$`);function bo(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function xu(e){return new RegExp(`^${bo(e)}$`)}function yu(e){let t=`${yo}T${bo(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function bu(e,t){return!!((t==="v4"||!t)&&uu.test(e)||(t==="v6"||!t)&&fu.test(e))}function ku(e,t){if(!au.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function vu(e,t){return!!((t==="v4"||!t)&&du.test(e)||(t==="v6"||!t)&&hu.test(e))}class yt extends xe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==H.string){const s=this._getOrReturnCtx(t);return V(s,{code:z.invalid_type,expected:H.string,received:s.parsedType}),re}const r=new He;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),V(i,{code:z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),V(i,{code:z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const a=t.data.length>s.value,o=t.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(t,i),a?V(i,{code:z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&V(i,{code:z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")lu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"email",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Dr||(Dr=new RegExp(cu,"u")),Dr.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"emoji",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")iu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"uuid",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")su.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"nanoid",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")tu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"cuid",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")nu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"cuid2",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")ru.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"ulid",code:z.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),V(i,{validation:"url",code:z.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"regex",code:z.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?yu(s).test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?gu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?xu(s).test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{code:z.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?ou.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"duration",code:z.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?bu(t.data,s.version)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"ip",code:z.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?ku(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"jwt",code:z.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?vu(t.data,s.version)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"cidr",code:z.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?pu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"base64",code:z.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?mu.test(t.data)||(i=this._getOrReturnCtx(t,i),V(i,{validation:"base64url",code:z.invalid_string,message:s.message}),r.dirty()):ke.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:z.invalid_string,...Z.errToObj(r)})}_addCheck(t){return new yt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Z.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Z.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Z.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Z.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Z.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Z.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Z.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Z.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Z.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Z.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Z.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Z.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Z.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Z.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Z.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Z.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Z.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Z.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Z.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Z.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Z.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Z.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Z.errToObj(n)})}nonempty(t){return this.min(1,Z.errToObj(t))}trim(){return new yt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new yt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new yt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}yt.create=e=>new yt({checks:[],typeName:ee.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...ue(e)});function wu(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}class Jt extends xe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==H.number){const s=this._getOrReturnCtx(t);return V(s,{code:z.invalid_type,expected:H.number,received:s.parsedType}),re}let r;const i=new He;for(const s of this._def.checks)s.kind==="int"?ke.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:z.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?wu(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),V(r,{code:z.not_finite,message:s.message}),i.dirty()):ke.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Z.toString(n))}setLimit(t,n,r,i){return new Jt({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Z.toString(i)}]})}_addCheck(t){return new Jt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Z.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Z.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ke.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Jt.create=e=>new Jt({checks:[],typeName:ee.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...ue(e)});class vn extends xe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==H.bigint)return this._getInvalidInput(t);let r;const i=new He;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),V(r,{code:z.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ke.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return V(n,{code:z.invalid_type,expected:H.bigint,received:n.parsedType}),re}gte(t,n){return this.setLimit("min",t,!0,Z.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Z.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Z.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Z.toString(n))}setLimit(t,n,r,i){return new vn({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Z.toString(i)}]})}_addCheck(t){return new vn({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Z.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}vn.create=e=>new vn({checks:[],typeName:ee.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...ue(e)});class di extends xe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==H.boolean){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.boolean,received:r.parsedType}),re}return tt(t.data)}}di.create=e=>new di({typeName:ee.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...ue(e)});class Kn extends xe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==H.date){const s=this._getOrReturnCtx(t);return V(s,{code:z.invalid_type,expected:H.date,received:s.parsedType}),re}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return V(s,{code:z.invalid_date}),re}const r=new He;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),V(i,{code:z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),V(i,{code:z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):ke.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Kn({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Z.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Z.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Kn.create=e=>new Kn({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:ee.ZodDate,...ue(e)});class Ps extends xe{_parse(t){if(this._getType(t)!==H.symbol){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.symbol,received:r.parsedType}),re}return tt(t.data)}}Ps.create=e=>new Ps({typeName:ee.ZodSymbol,...ue(e)});class Ms extends xe{_parse(t){if(this._getType(t)!==H.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.undefined,received:r.parsedType}),re}return tt(t.data)}}Ms.create=e=>new Ms({typeName:ee.ZodUndefined,...ue(e)});class Rs extends xe{_parse(t){if(this._getType(t)!==H.null){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.null,received:r.parsedType}),re}return tt(t.data)}}Rs.create=e=>new Rs({typeName:ee.ZodNull,...ue(e)});class Ls extends xe{constructor(){super(...arguments),this._any=!0}_parse(t){return tt(t.data)}}Ls.create=e=>new Ls({typeName:ee.ZodAny,...ue(e)});class fi extends xe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return tt(t.data)}}fi.create=e=>new fi({typeName:ee.ZodUnknown,...ue(e)});class Ct extends xe{_parse(t){const n=this._getOrReturnCtx(t);return V(n,{code:z.invalid_type,expected:H.never,received:n.parsedType}),re}}Ct.create=e=>new Ct({typeName:ee.ZodNever,...ue(e)});class Ds extends xe{_parse(t){if(this._getType(t)!==H.undefined){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.void,received:r.parsedType}),re}return tt(t.data)}}Ds.create=e=>new Ds({typeName:ee.ZodVoid,...ue(e)});class ht extends xe{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==H.array)return V(n,{code:z.invalid_type,expected:H.array,received:n.parsedType}),re;if(i.exactLength!==null){const a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(V(n,{code:a?z.too_big:z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(V(n,{code:z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(V(n,{code:z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new mt(n,a,n.path,o)))).then(a=>He.mergeArray(r,a));const s=[...n.data].map((a,o)=>i.type._parseSync(new mt(n,a,n.path,o)));return He.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ht({...this._def,minLength:{value:t,message:Z.toString(n)}})}max(t,n){return new ht({...this._def,maxLength:{value:t,message:Z.toString(n)}})}length(t,n){return new ht({...this._def,exactLength:{value:t,message:Z.toString(n)}})}nonempty(t){return this.min(1,t)}}ht.create=(e,t)=>new ht({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...ue(t)});function Ut(e){if(e instanceof Me){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=jt.create(Ut(r))}return new Me({...e._def,shape:()=>t})}else return e instanceof ht?new ht({...e._def,type:Ut(e.element)}):e instanceof jt?jt.create(Ut(e.unwrap())):e instanceof tn?tn.create(Ut(e.unwrap())):e instanceof Lt?Lt.create(e.items.map(t=>Ut(t))):e}class Me extends xe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ke.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==H.object){const u=this._getOrReturnCtx(t);return V(u,{code:z.invalid_type,expected:H.object,received:u.parsedType}),re}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ct&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const d=s[u],f=i.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new mt(i,f,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Ct){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of o)c.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(u==="strict")o.length>0&&(V(i,{code:z.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of o){const f=i.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new mt(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const f=await d.key,p=await d.value;u.push({key:f,value:p,alwaysSet:d.alwaysSet})}return u}).then(u=>He.mergeObjectSync(r,u)):He.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return Z.errToObj,new Me({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,a;const i=((a=(s=this._def).errorMap)==null?void 0:a.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:Z.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Me({...this._def,unknownKeys:"strip"})}passthrough(){return new Me({...this._def,unknownKeys:"passthrough"})}extend(t){return new Me({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Me({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ee.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Me({...this._def,catchall:t})}pick(t){const n={};for(const r of ke.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Me({...this._def,shape:()=>n})}omit(t){const n={};for(const r of ke.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Me({...this._def,shape:()=>n})}deepPartial(){return Ut(this)}partial(t){const n={};for(const r of ke.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Me({...this._def,shape:()=>n})}required(t){const n={};for(const r of ke.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof jt;)s=s._def.innerType;n[r]=s}return new Me({...this._def,shape:()=>n})}keyof(){return ko(ke.objectKeys(this.shape))}}Me.create=(e,t)=>new Me({shape:()=>e,unknownKeys:"strip",catchall:Ct.create(),typeName:ee.ZodObject,...ue(t)});Me.strictCreate=(e,t)=>new Me({shape:()=>e,unknownKeys:"strict",catchall:Ct.create(),typeName:ee.ZodObject,...ue(t)});Me.lazycreate=(e,t)=>new Me({shape:e,unknownKeys:"strip",catchall:Ct.create(),typeName:ee.ZodObject,...ue(t)});class Yn extends xe{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new pt(o.ctx.common.issues));return V(n,{code:z.invalid_union,unionErrors:a}),re}if(n.common.async)return Promise.all(r.map(async s=>{const a={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new pt(c));return V(n,{code:z.invalid_union,unionErrors:o}),re}}get options(){return this._def.options}}Yn.create=(e,t)=>new Yn({options:e,typeName:ee.ZodUnion,...ue(t)});function hi(e,t){const n=St(e),r=St(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&r===H.object){const i=ke.objectKeys(t),s=ke.objectKeys(e).filter(o=>i.indexOf(o)!==-1),a={...e,...t};for(const o of s){const c=hi(e[o],t[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===H.array&&r===H.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const a=e[s],o=t[s],c=hi(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===H.date&&r===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Xn extends xe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,a)=>{if(Ts(s)||Ts(a))return re;const o=hi(s.value,a.value);return o.valid?((As(s)||As(a))&&n.dirty(),{status:n.value,value:o.data}):(V(r,{code:z.invalid_intersection_types}),re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Xn.create=(e,t,n)=>new Xn({left:e,right:t,typeName:ee.ZodIntersection,...ue(n)});class Lt extends xe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.array)return V(r,{code:z.invalid_type,expected:H.array,received:r.parsedType}),re;if(r.data.length<this._def.items.length)return V(r,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),re;!this._def.rest&&r.data.length>this._def.items.length&&(V(r,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new mt(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>He.mergeArray(n,a)):He.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new Lt({...this._def,rest:t})}}Lt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Lt({items:e,typeName:ee.ZodTuple,rest:null,...ue(t)})};class Jn extends xe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.object)return V(r,{code:z.invalid_type,expected:H.object,received:r.parsedType}),re;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in r.data)i.push({key:s._parse(new mt(r,o,r.path,o)),value:a._parse(new mt(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?He.mergeObjectAsync(n,i):He.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof xe?new Jn({keyType:t,valueType:n,typeName:ee.ZodRecord,...ue(r)}):new Jn({keyType:yt.create(),valueType:t,typeName:ee.ZodRecord,...ue(n)})}}class zs extends xe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.map)return V(r,{code:z.invalid_type,expected:H.map,received:r.parsedType}),re;const i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([o,c],u)=>({key:i._parse(new mt(r,o,r.path,[u,"key"])),value:s._parse(new mt(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return re;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),o.set(u.value,d.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return re;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),o.set(u.value,d.value)}return{status:n.value,value:o}}}}zs.create=(e,t,n)=>new zs({valueType:t,keyType:e,typeName:ee.ZodMap,...ue(n)});class wn extends xe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==H.set)return V(r,{code:z.invalid_type,expected:H.set,received:r.parsedType}),re;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(V(r,{code:z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(V(r,{code:z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const d of c){if(d.status==="aborted")return re;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const o=[...r.data.values()].map((c,u)=>s._parse(new mt(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(t,n){return new wn({...this._def,minSize:{value:t,message:Z.toString(n)}})}max(t,n){return new wn({...this._def,maxSize:{value:t,message:Z.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}wn.create=(e,t)=>new wn({valueType:e,minSize:null,maxSize:null,typeName:ee.ZodSet,...ue(t)});class Os extends xe{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Os.create=(e,t)=>new Os({getter:e,typeName:ee.ZodLazy,...ue(t)});class pi extends xe{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return V(n,{received:n.data,code:z.invalid_literal,expected:this._def.value}),re}return{status:"valid",value:t.data}}get value(){return this._def.value}}pi.create=(e,t)=>new pi({value:e,typeName:ee.ZodLiteral,...ue(t)});function ko(e,t){return new Gt({values:e,typeName:ee.ZodEnum,...ue(t)})}class Gt extends xe{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{expected:ke.joinValues(r),received:n.parsedType,code:z.invalid_type}),re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return V(n,{received:n.data,code:z.invalid_enum_value,options:r}),re}return tt(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Gt.create(t,{...this._def,...n})}exclude(t,n=this._def){return Gt.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Gt.create=ko;class Fs extends xe{_parse(t){const n=ke.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==H.string&&r.parsedType!==H.number){const i=ke.objectValues(n);return V(r,{expected:ke.joinValues(i),received:r.parsedType,code:z.invalid_type}),re}if(this._cache||(this._cache=new Set(ke.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=ke.objectValues(n);return V(r,{received:r.data,code:z.invalid_enum_value,options:i}),re}return tt(t.data)}get enum(){return this._def.values}}Fs.create=(e,t)=>new Fs({values:e,typeName:ee.ZodNativeEnum,...ue(t)});class Gn extends xe{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.promise&&n.common.async===!1)return V(n,{code:z.invalid_type,expected:H.promise,received:n.parsedType}),re;const r=n.parsedType===H.promise?n.data:Promise.resolve(n.data);return tt(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Gn.create=(e,t)=>new Gn({type:e,typeName:ee.ZodPromise,...ue(t)});class en extends xe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:a=>{V(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(r.data,s);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return re;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?re:c.status==="dirty"||n.value==="dirty"?gn(c.value):c});{if(n.value==="aborted")return re;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?re:o.status==="dirty"||n.value==="dirty"?gn(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?re:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?re:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(i.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Xt(a))return re;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Xt(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:n.value,value:o})):re);ke.assertNever(i)}}en.create=(e,t,n)=>new en({schema:e,typeName:ee.ZodEffects,effect:t,...ue(n)});en.createWithPreprocess=(e,t,n)=>new en({schema:t,effect:{type:"preprocess",transform:e},typeName:ee.ZodEffects,...ue(n)});class jt extends xe{_parse(t){return this._getType(t)===H.undefined?tt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}jt.create=(e,t)=>new jt({innerType:e,typeName:ee.ZodOptional,...ue(t)});class tn extends xe{_parse(t){return this._getType(t)===H.null?tt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tn.create=(e,t)=>new tn({innerType:e,typeName:ee.ZodNullable,...ue(t)});class mi extends xe{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===H.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}mi.create=(e,t)=>new mi({innerType:e,typeName:ee.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ue(t)});class gi extends xe{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Qn(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new pt(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new pt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}gi.create=(e,t)=>new gi({innerType:e,typeName:ee.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ue(t)});class $s extends xe{_parse(t){if(this._getType(t)!==H.nan){const r=this._getOrReturnCtx(t);return V(r,{code:z.invalid_type,expected:H.nan,received:r.parsedType}),re}return{status:"valid",value:t.data}}}$s.create=e=>new $s({typeName:ee.ZodNaN,...ue(e)});class Su extends xe{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class qi extends xe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?re:s.status==="dirty"?(n.dirty(),gn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?re:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new qi({in:t,out:n,typeName:ee.ZodPipeline})}}class xi extends xe{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Xt(i)&&(i.value=Object.freeze(i.value)),i);return Qn(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}xi.create=(e,t)=>new xi({innerType:e,typeName:ee.ZodReadonly,...ue(t)});var ee;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(ee||(ee={}));const g=yt.create,U=Jt.create,he=di.create,hr=fi.create;Ct.create;const pe=ht.create,T=Me.create;Yn.create;Xn.create;Lt.create;const kt=Jn.create,vo=pi.create,de=Gt.create;Gn.create;jt.create;tn.create;const _u=1,wo=1048576,ju=4194304,Cu=8388608,So=8388608,Nu=1048576,Iu=8388608,Tu=8192,Au=16,Eu=de(["host","client"]);de(["pending_pairing","connecting","active","reconnecting","idle","terminated"]);const Vi=de(["claude","codex","gemini","copilot","custom"]);de(["session_not_found","pairing_expired","pairing_not_found","control_conflict","session_terminated","ack_out_of_range","invalid_message","unauthorized"]);const Pu=T({id:g().min(1),type:g().min(1),sessionId:g().min(1),terminalId:g().min(1).optional(),deviceId:g().min(1).optional(),timestamp:g().datetime(),traceId:g().min(1).optional(),seq:U().int().nonnegative().optional(),ack:U().int().nonnegative().optional(),payload:hr()}),Mu=T({stream:de(["stdout","stderr"]),data:g().max(wo),encoding:vo("utf8").default("utf8"),isReplay:he().default(!1),isFinal:he().default(!1)}),Ru=T({data:g().max(wo)}),Lu=T({cols:U().int().positive(),rows:U().int().positive()}),Du=T({role:Eu,clientName:g().min(1),provider:Vi.optional(),protocolVersion:U().int().optional(),machineId:g().min(1).optional(),hostname:g().optional(),platform:g().optional(),cwd:g().optional(),projectName:g().optional()}),zu=T({exitCode:U().int().nullable(),signal:U().int().nullable().optional()}),Ou=T({seq:U().int().nonnegative()}),Fu=T({lastAckedSeq:U().int().min(-1).optional().default(-1),lastAckedSeqByTerminal:kt(U().int().min(-1)).optional().default({}),machineId:g().min(1).optional()}),$u=T({ts:U()}),Bu=T({pairingCode:g().regex(/^\d{6}$/),sessionId:g().min(1),expiresAt:g().datetime()}),qu=T({pairingCode:g().regex(/^\d{6}$/)}),Vu=T({sessionId:g().min(1)}),Uu=T({deviceId:g().min(1)}),Hu=T({deviceId:g().min(1)}),Zu=T({deviceId:g().min(1),reason:g().min(1)}),Wu=T({deviceId:g().min(1)}),Qu=T({reason:g().optional()}),Ku=T({}),Yu=T({fps:U().int().min(1).max(30).default(5),quality:U().int().min(10).max(100).default(60),scale:U().min(.1).max(1).default(.5)}),Xu=T({}),Ju=T({data:g().max(ju),width:U().int(),height:U().int(),frameId:U().int(),chunkIndex:U().int().default(0),chunkTotal:U().int().default(1)}),Gu=T({active:he(),mode:de(["webrtc","fallback","off"]).default("off"),error:g().optional()}),ed=T({sdp:g()}),td=T({sdp:g()}),nd=T({candidate:g(),sdpMid:g().nullable().optional(),sdpMLineIndex:U().nullable().optional()}),rd=T({cwd:g().min(1),provider:Vi.optional(),forceNew:he().optional()}),id=T({terminalId:g().min(1),cwd:g(),projectName:g(),provider:g(),status:de(["running","exited"])}),sd=T({terminals:pe(id)}),ad=T({terminalId:g().min(1),cwd:g(),projectName:g(),provider:g().optional()}),od=T({terminalId:g().min(1)}),ld=T({path:g().min(1)}),cd=T({path:g().min(1),includeFiles:he().optional().default(!1),requestId:g().min(1).optional()}),ud=T({name:g(),path:g(),isDirectory:he(),size:U().int().nonnegative().optional(),modifiedAt:g().datetime().optional()}),dd=T({path:g(),entries:pe(ud),error:g().optional(),requestId:g().min(1).optional()}),fd=T({path:g().min(1),maxBytes:U().int().positive().max(1e6).optional().default(256e3),requestId:g().min(1).optional()}),hd=T({path:g(),content:g().default(""),encoding:vo("utf8").default("utf8"),size:U().int().nonnegative().optional(),truncated:he().default(!1),error:g().optional(),requestId:g().min(1).optional()}),pd=T({phase:de(["thinking","tool_use","outputting","waiting","idle","error"]),provider:Vi.optional(),seq:U().optional(),toolName:g().optional(),toolInput:g().optional(),permissionRequest:g().optional(),summary:g().optional(),topPermission:T({requestId:g(),toolName:g(),toolInput:g(),permissionRequest:g(),timestamp:U()}).optional(),permissionResolution:T({requestId:g(),outcome:de(["allow","deny","cancelled"]),source:g().optional(),delivered:he()}).optional(),pendingPermissionCount:U().optional(),machineId:g().min(1).optional()}),md=T({data:g().max(Cu),filename:g().min(1).refine(e=>!e.includes("..")&&!e.startsWith("/"),"invalid filename")}),gd=T({requestId:g().min(1),decision:de(["allow","deny"])}),xd=T({requestId:g().min(1),decision:de(["allow","deny"]),resolved:he(),delivered:he(),source:g().optional(),message:g().optional()}),yd=T({code:g().min(1),message:g().min(1)}),bd=T({requestId:g().min(1),method:g().min(1).max(Au),url:g().max(Tu),headers:kt(g()),body:g().max(So).nullable(),port:U().int().min(1).max(65535)}),kd=T({requestId:g().min(1),statusCode:U().int(),headers:kt(g()),body:g().max(So),isFinal:he()}),vd=T({requestId:g().min(1),data:g().max(Nu),isBinary:he()}),wd=T({requestId:g().min(1),code:U().int().optional(),reason:g().optional()}),Sd=T({count:U().int().min(1).max(500).default(100)}),_d=T({entries:pe(g()),shell:g().optional()}),Nt=g().min(1),sn=de(["none","minimal","low","medium","high","xhigh"]),an=de(["read_only","workspace_write","full_access"]),pr=de(["default","plan"]),mr=T({type:de(["text","image"]),text:g().optional(),data:g().max(Iu).optional(),mimeType:g().optional()}),_o=T({id:g().min(1),role:de(["user","assistant","system"]),content:g(),createdAt:U(),isStreaming:he().optional()}),gr=T({id:g().min(1),name:g().min(1),input:g().optional(),output:g().optional(),createdAt:U().optional(),status:de(["pending","running","completed","failed"]).default("pending")}),Nn=T({requestId:g().min(1),toolName:g().optional(),toolInput:g().optional(),context:g().optional(),options:pe(T({id:g().min(1),label:g().min(1),kind:de(["allow","deny","other"]).default("other")})).default([])}),jd=T({id:g().min(1),label:g().min(1)}),Cd=T({id:g().min(1),name:g().min(1),title:g().min(1),description:g().optional(),provider:Nt.optional(),source:de(["built_in","custom","project","user","linkshell"]).default("built_in"),category:g().optional(),argsMode:de(["none","optional","required","raw"]).default("optional"),requiresIdle:he().optional(),destructive:he().optional(),disabledReason:g().optional(),executionKind:de(["prompt","native","local_ui"]).default("prompt")}),Nd=T({id:g().min(1),title:g().min(1),description:g().optional()}),Id=de(["pending","connecting","connected","failed","needs_auth","disabled"]),Td=T({name:g().min(1),status:Id,error:g().optional(),toolCount:U().int().optional()}),Ad=T({id:Nt,label:g().min(1),enabled:he(),reason:g().optional(),supportsImages:he().optional(),supportsPermission:he().optional(),supportsPlan:he().optional(),supportsCancel:he().optional(),models:pe(jd).optional(),defaultModel:g().min(1).optional(),reasoningEfforts:pe(sn).optional(),permissionModes:pe(an).optional(),commands:pe(Cd).optional(),modes:pe(Nd).optional(),currentMode:g().optional(),features:kt(he()).optional(),mcpServers:pe(Td).optional()}),Ui=T({enabled:he(),provider:Nt.optional(),machineId:g().min(1).optional(),providers:pe(Ad).optional(),protocolVersion:U().int().optional(),error:g().optional(),supportsSessionList:he().default(!1),supportsSessionLoad:he().default(!1),supportsImages:he().default(!1),supportsAudio:he().default(!1),supportsPermission:he().default(!1),supportsPlan:he().default(!1),supportsCancel:he().default(!1)}),Ed=T({}),Pd=T({cwd:g().optional(),provider:Nt.optional(),mcpServers:kt(hr()).optional()}),Md=T({agentSessionId:g().min(1),cwd:g().optional()}),Rd=T({}),Ld=T({agentSessionId:g().optional(),clientMessageId:g().min(1),contentBlocks:pe(mr).min(1),model:g().min(1).optional(),reasoningEffort:sn.optional(),permissionMode:an.optional()}),Dd=T({agentSessionId:g().optional()}),zd=T({agentSessionId:g().optional(),kind:de(["message","message_delta","tool_call","tool_result","plan","status","error"]),message:_o.optional(),delta:g().optional(),toolCall:gr.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:de(["pending","in_progress","completed"])})).optional(),status:de(["idle","running","waiting_permission","error"]).optional(),error:g().optional()}),Od=Nn.extend({agentSessionId:g().optional()}),Fd=T({agentSessionId:g().optional(),requestId:g().min(1),outcome:de(["allow","deny","cancelled"]),optionId:g().optional()}),$d=T({agentSessionId:g().optional(),capabilities:Ui.optional(),messages:pe(_o).default([]),toolCalls:pe(gr).default([]),pendingPermissions:pe(Nn).default([]),status:de(["unavailable","idle","running","waiting_permission","error"]).default("unavailable"),error:g().optional()}),xr=de(["unavailable","idle","running","waiting_permission","error"]),jo=de(["chat","thinking","tool_activity","command_execution","file_change","subagent_action","plan","user_input_prompt","review","context_compaction"]),Bd=T({path:g().min(1),kind:g().optional(),added:U().int().nonnegative().optional(),removed:U().int().nonnegative().optional()}),Co=T({entries:pe(Bd).default([]),diff:g().optional(),summary:g().optional(),changeSetId:g().optional(),status:de(["pending","running","completed","failed"]).optional()}),No=T({command:g().optional(),cwd:g().optional(),output:g().optional(),exitCode:U().int().nullable().optional(),status:de(["pending","running","completed","failed"]).optional()}),qd=T({id:g().min(1),label:g().min(1),description:g().optional()}),Vd=T({id:g().min(1),header:g().optional(),question:g().min(1),isOther:he().optional(),isSecret:he().optional(),selectionLimit:U().int().positive().optional(),options:pe(qd).optional()}),Io=T({requestId:g().min(1),questions:pe(Vd).default([])}),Ud=T({threadId:g().min(1),agentId:g().optional(),nickname:g().optional(),role:g().optional(),model:g().optional(),prompt:g().optional()}),Hd=T({threadId:g().min(1),status:g().min(1),message:g().optional()}),To=T({tool:g().min(1),status:g().min(1),prompt:g().optional(),model:g().optional(),receiverThreadIds:pe(g().min(1)).default([]),receiverAgents:pe(Ud).default([]),agentStates:kt(Hd).default({})}),In=T({id:g().min(1),conversationId:g().min(1),type:de(["message","tool_call","plan","permission","status","error"]),kind:jo.optional(),turnId:g().optional(),itemId:g().optional(),role:de(["user","assistant","system"]).optional(),content:pe(mr).optional(),text:g().optional(),toolCall:gr.optional(),commandExecution:No.optional(),fileChange:Co.optional(),subagent:To.optional(),structuredInput:Io.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:de(["pending","in_progress","completed"])})).optional(),permission:Nn.optional(),status:xr.optional(),error:g().optional(),metadata:kt(hr()).optional(),createdAt:U(),updatedAt:U().optional(),isStreaming:he().optional()}),Ao=T({inputTokens:U().optional(),outputTokens:U().optional(),cacheReadTokens:U().optional(),totalTokens:U().optional(),contextWindow:U().optional(),totalCostUsd:U().optional(),updatedAt:U().optional()}),yr=T({id:g().min(1),agentSessionId:g().optional(),provider:Nt.default("codex"),cwd:g(),title:g().optional(),model:g().optional(),reasoningEffort:sn.optional(),permissionMode:an.optional(),collaborationMode:pr.optional(),status:xr.default("idle"),archived:he().default(!1),lastMessagePreview:g().optional(),lastActivityAt:U(),createdAt:U(),usage:Ao.optional()}),Zd=T({}),Wd=Ui.extend({workspaceProtocolVersion:U().int().default(2)}),Qd=T({conversationId:g().optional(),agentSessionId:g().optional(),cwd:g().optional(),provider:Nt.optional(),model:g().optional(),reasoningEffort:sn.optional(),permissionMode:an.optional(),collaborationMode:pr.optional(),title:g().optional(),forkFromConversationId:g().optional(),forkFromTurnId:g().optional()}),Kd=T({conversation:yr,snapshot:pe(In).default([]),requestedConversationId:g().min(1).optional()}),Yd=T({includeArchived:he().optional().default(!1)}),Xd=T({conversations:pe(yr)}),Jd=T({conversationId:g().min(1),clientMessageId:g().min(1),contentBlocks:pe(mr).min(1),delivery:de(["auto","new_turn","steer"]).optional().default("auto"),targetTurnId:g().min(1).optional(),model:g().min(1).optional(),reasoningEffort:sn.optional(),permissionMode:an.optional(),collaborationMode:pr.optional()}),Gd=T({conversationId:g().min(1),commandId:g().min(1),rawText:g().optional(),args:g().optional(),clientMessageId:g().min(1)}),ef=T({conversationId:g().min(1)}),tf=T({conversationId:g().min(1),requestId:g().min(1),outcome:de(["allow","deny","cancelled"]),optionId:g().optional()}),nf=T({conversationId:g().min(1),requestId:g().min(1),answers:kt(pe(g()))}),rf=T({conversationId:g().optional()}),sf=T({conversations:pe(yr).default([]),activeConversationId:g().optional(),items:pe(In).default([]),machineId:g().min(1).optional()}),af=T({conversationId:g().min(1),conversation:yr.optional(),item:In.optional(),patch:T({itemId:g().min(1),kind:jo.optional(),role:de(["user","assistant","system"]).optional(),content:pe(mr).optional(),text:g().optional(),textDelta:g().optional(),status:xr.optional(),toolCall:gr.optional(),commandExecution:No.optional(),fileChange:Co.optional(),subagent:To.optional(),structuredInput:Io.optional(),plan:pe(T({id:g().min(1),text:g().min(1),status:de(["pending","in_progress","completed"])})).optional(),permission:Nn.optional(),error:g().optional(),metadata:kt(hr()).optional(),updatedAt:U().optional(),isStreaming:he().optional()}).optional()}),of=Nn.extend({conversationId:g().min(1),item:In.optional()}),lf=T({conversationId:g().optional(),kind:de(["model_changed","effort_changed","permission_changed","native_unsupported","info","warning"]),title:g().min(1),detail:g().optional(),durationMs:U().int().positive().optional()}),cf=T({conversationId:g().min(1),cursor:g().optional(),limit:U().int().positive().max(200).optional().default(50)}),uf=T({conversationId:g().min(1),items:pe(In).default([]),nextCursor:g().optional(),hasMore:he().default(!1)}),Eo=T({inputTokens:U().default(0),outputTokens:U().default(0),cacheReadTokens:U().default(0),cacheWriteTokens:U().default(0),totalTokens:U().default(0),calls:U().default(0)}),Ln=Eo.extend({key:g()}),df=T({}),ff=T({totals:Eo,sessions:U().default(0),peakDayTokens:U().default(0),longestTaskMs:U().default(0),currentStreakDays:U().default(0),longestStreakDays:U().default(0),byDay:pe(Ln).default([]),byHourWeekday:pe(T({weekday:U(),hour:U(),tokens:U()})).default([]),byTool:pe(Ln).default([]),byModel:pe(Ln).default([]),byProject:pe(Ln).default([]),generatedAt:U()}),hf=T({conversationId:g().min(1),title:g().optional(),archived:he().optional(),model:g().optional(),reasoningEffort:sn.optional(),permissionMode:an.optional(),collaborationMode:pr.optional()}),pf=T({hasHost:he(),agentStatus:xr.optional().nullable(),agentProvider:g().optional().nullable(),agentConversationId:g().optional().nullable(),agentTitle:g().optional().nullable(),agentDetail:g().optional().nullable(),agentLastActivity:U().optional().nullable(),lastActivity:U().optional(),agentUsage:Ao.optional().nullable()}),mf=T({conversationId:g().min(1)}),gf=T({conversationId:g().min(1)}),xf=T({provider:Nt.optional(),serverName:g().min(1)}),yf=T({provider:Nt.optional(),serverName:g().min(1),authorizationUrl:g().min(1).optional(),error:g().optional()}),Bs={"session.connect":Du,"session.ack":Ou,"session.resume":Fu,"session.heartbeat":$u,"session.error":yd,"terminal.output":Mu,"terminal.input":Ru,"terminal.resize":Lu,"terminal.exit":zu,"pairing.created":Bu,"pairing.claim":qu,"pairing.claimed":Vu,"control.claim":Uu,"control.grant":Hu,"control.reject":Zu,"control.release":Wu,"session.host_disconnected":Qu,"session.host_reconnected":Ku,"session.presence":pf,"screen.start":Yu,"screen.stop":Xu,"screen.frame":Ju,"screen.status":Gu,"screen.offer":ed,"screen.answer":td,"screen.ice":nd,"file.upload":md,"terminal.spawn":rd,"terminal.spawned":ad,"terminal.list":sd,"terminal.browse":cd,"terminal.browse.result":dd,"terminal.file.read":fd,"terminal.file.read.result":hd,"terminal.kill":od,"terminal.mkdir":ld,"terminal.status":pd,"permission.decision":gd,"permission.decision.result":xd,"tunnel.request":bd,"tunnel.response":kd,"tunnel.ws.data":vd,"tunnel.ws.close":wd,"terminal.history.request":Sd,"terminal.history.response":_d,"agent.initialize":Ed,"agent.capabilities":Ui,"agent.session.new":Pd,"agent.session.load":Md,"agent.session.list":Rd,"agent.prompt":Ld,"agent.cancel":Dd,"agent.update":zd,"agent.permission.request":Od,"agent.permission.response":Fd,"agent.snapshot":$d,"agent.v2.capabilities.request":Zd,"agent.v2.capabilities":Wd,"agent.v2.conversation.open":Qd,"agent.v2.conversation.opened":Kd,"agent.v2.conversation.list":Yd,"agent.v2.conversation.list.result":Xd,"agent.v2.conversation.update":hf,"agent.v2.conversation.delete":mf,"agent.v2.conversation.deleted":gf,"agent.v2.prompt":Jd,"agent.v2.command.execute":Gd,"agent.v2.cancel":ef,"agent.v2.permission.respond":tf,"agent.v2.permission.request":of,"agent.v2.structured_input.respond":nf,"agent.v2.snapshot.request":rf,"agent.v2.snapshot":sf,"agent.v2.event":af,"agent.v2.notice":lf,"agent.v2.history.request":cf,"agent.v2.history.result":uf,"agent.v2.usage.request":df,"agent.v2.usage.report":ff,"agent.v2.mcp.login":xf,"agent.v2.mcp.login.result":yf},bf=["agent.v2.capabilities","agent.v2.conversation.opened","agent.v2.conversation.list.result","agent.v2.event","agent.v2.snapshot","agent.v2.permission.request","agent.v2.notice","agent.v2.history.result","agent.v2.conversation.deleted","agent.v2.usage.report","agent.v2.mcp.login.result"],kf=["agent.v2.conversation.open","agent.v2.conversation.update","agent.v2.conversation.delete","agent.v2.prompt","agent.v2.command.execute","agent.v2.cancel","agent.v2.permission.respond","agent.v2.structured_input.respond","agent.v2.mcp.login"],vf=["agent.v2.capabilities.request","agent.v2.conversation.list","agent.v2.snapshot.request","agent.v2.history.request","agent.v2.usage.request"],wf=new Set(bf),Sf=new Set(kf),_f=new Set(vf);function jf(e){return wf.has(e)?"host_to_client":Sf.has(e)?"client_write":_f.has(e)?"client_read":null}function Cf(e){return jf(e)==="host_to_client"}function Nf(){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function dn(e){return{id:e.id??Nf(),type:e.type,sessionId:e.sessionId,terminalId:e.terminalId,deviceId:e.deviceId,timestamp:new Date().toISOString(),traceId:e.traceId,seq:e.seq,ack:e.ack,payload:e.payload}}function Po(e){return Pu.parse(JSON.parse(e))}function If(e){return JSON.stringify(e)}function Ve(e,t){if(!Object.prototype.hasOwnProperty.call(Bs,e))throw new pt([{code:z.custom,path:["type"],message:`Unknown protocol message type: ${String(e)}`}]);return Bs[e].parse(t)}function Tf(e){if(!e.deviceToken&&!e.jwt)return e.onState("poll"),()=>{};let t=!1,n=null,r,i=0;const s=()=>{if(t)return;e.onState(i===0?"connecting":"poll");const a=Xc(e.config,{deviceToken:e.deviceToken,jwt:e.jwt}),o=new WebSocket(a);n=o,o.onopen=()=>{i=0,e.onState("live")},o.onmessage=c=>{if(typeof c.data=="string")try{const u=Po(c.data);if(u.type!=="session.presence")return;const d=u.payload;e.onPresence(u.sessionId,{hasHost:d.hasHost,agentStatus:d.agentStatus??null,agentProvider:d.agentProvider??null,agentConversationId:d.agentConversationId??null,agentTitle:d.agentTitle??null,agentDetail:d.agentDetail??null,agentLastActivity:d.agentLastActivity??null,lastActivity:d.lastActivity??Date.now(),agentUsage:d.agentUsage??null})}catch{}},o.onclose=()=>{if(t)return;e.onState("poll");const c=Math.min(15e3,1e3*2**Math.min(i,4));i+=1,r=window.setTimeout(s,c)},o.onerror=()=>{o.close()}};return s(),()=>{t=!0,r&&window.clearTimeout(r),n==null||n.close()}}function qs(e){return e.agentStatus==="waiting_permission"?0:e.agentStatus==="running"?1:e.agentStatus==="error"?2:e.hasHost?10:20}function Af(e){var n;const t=(n=e.agentTitle)==null?void 0:n.trim();return t||e.projectName||e.hostname||e.id.slice(0,8)}function Ef(e){if(!e)return null;const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function Pf(e){if(!e||e<=0)return null;const t=Date.now()-e;return t<45e3?"刚刚":t<36e5?`${Math.max(1,Math.round(t/6e4))} 分钟前`:t<864e5?`${Math.max(1,Math.round(t/36e5))} 小时前`:`${Math.max(1,Math.round(t/864e5))} 天前`}function Mf(e,t){var r,i,s,a;return e.hasHost?e.agentStatus==="waiting_permission"?{text:((r=e.agentDetail)==null?void 0:r.trim())||"等你授权才能继续",tone:"warning"}:e.agentStatus==="error"?{text:((i=e.agentDetail)==null?void 0:i.trim())||"刚刚异常",tone:"danger"}:e.agentStatus==="running"&&((s=e.agentDetail)!=null&&s.trim())&&e.agentDetail.trim()!==((a=e.agentTitle)==null?void 0:a.trim())?{text:e.agentDetail.trim(),tone:"muted"}:{text:[t!=null&&t.showHost&&e.hostname?e.hostname:null,Ef(e.cwd),Pf(e.agentLastActivity??e.lastActivity)].filter(Boolean).join(" · ")||"在线",tone:"muted"}:{text:"主机离线",tone:"muted"}}function Mo(e){switch(e){case"waiting_permission":return{text:"等你授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};default:return null}}function Rf(e){const t=(e||"").toLowerCase();if(/bash|shell|command/.test(t))return"允许运行这条命令?";if(/write|edit|multiedit/.test(t))return"允许改这个文件?";if(/(^|_)read(_|$)|readfile|read_file/.test(t))return"允许读取这个文件?";if(/webfetch|web_search|websearch|fetch/.test(t))return"允许访问网络?";const n=e==null?void 0:e.split(/ · |__/).pop();return n?`允许使用 ${n}?`:"需要你的授权才能继续"}function Lf({session:e,onLogin:t,onLogout:n,onOpenSession:r}){const[i,s]=v.useState(Ga()),[a,o]=v.useState(i.httpUrl),[c,u]=v.useState(!1),[d,f]=v.useState(()=>_t()),p=D=>Math.max(D.lastActivity??0,D.agentLastActivity??0),h=d.filter(D=>D.hasHost).sort((D,x)=>{const M=qs(D)-qs(x);return M!==0?M:p(x)-p(D)}),m=d.filter(D=>!D.hasHost).sort((D,x)=>p(x)-p(D)),b=new Set(d.map(D=>D.hostname).filter(Boolean)).size>1,[S,k]=v.useState(!1),[A,I]=v.useState(!0),[W,Q]=v.useState(""),[j,Y]=v.useState(!1),[X,J]=v.useState(null),[_,$]=v.useState(!1),[B,ae]=v.useState("poll"),q=v.useCallback(async D=>{D!=null&&D.silent||I(!0);try{const[x,M]=await Promise.allSettled([Kc(i,(e==null?void 0:e.accessToken)??null),Qc(i,{deviceToken:Hn(),jwt:(e==null?void 0:e.accessToken)??null})]),Ce=x.status==="fulfilled"?x.value:[],y=M.status==="fulfilled"?M.value:[],Ne=x.status==="rejected"&&M.status==="rejected",Le=new Map;for(const Fe of[...Ce,...y])Le.set(Fe.id,Fe);const Ie=[...Le.values()];f(Ne?_t():Ie.length>0?li(Ie):bc())}catch{f(_t())}finally{I(!1)}},[i,e==null?void 0:e.accessToken]);v.useEffect(()=>{q()},[q]),v.useEffect(()=>Tf({config:i,deviceToken:Hn(),jwt:(e==null?void 0:e.accessToken)??null,onState:ae,onPresence:(D,x)=>{f(M=>M.find(y=>y.id===D)?M.map(y=>y.id===D?{...y,...x,lastActivity:x.lastActivity??y.lastActivity}:y):(q({silent:!0}),M))}}),[i,e==null?void 0:e.accessToken,q]),v.useEffect(()=>{const D=B==="live"?3e4:8e3,x=window.setInterval(()=>{document.visibilityState==="visible"&&q({silent:!0})},D);return()=>window.clearInterval(x)},[q,B]);const L=async()=>{const D=W.trim();if(!/^\d{6}$/.test(D)){J("请输入 6 位配对码");return}Y(!0),J(null);try{const{sessionId:x}=await Wc(i,D);li([{id:x,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),Q(""),$(!1),q(),r(x)}catch(x){J(x.message||"配对失败")}finally{Y(!1)}},ie=D=>{f(kc(D))},be=()=>{const D=a.trim().replace(/\/+$/,"");if(D===i.httpUrl){u(!1);return}let x=!1;try{const M=new URL(D);x=M.protocol==="http:"||M.protocol==="https:"}catch{x=!1}if(!x){u(!0);return}u(!1),o(D),eo(D),s({httpUrl:D})},le=D=>{const x=Mf(D,{showHost:b}),M=Mo(D.agentStatus),Ce=D.agentStatus==="waiting_permission"?"bg-warning":D.agentStatus==="running"?"bg-accent":D.agentStatus==="error"?"bg-danger":null,y=x.tone==="warning"?"text-warning":x.tone==="danger"?"text-danger":"text-content-muted",Ne=l.jsxs("div",{className:"min-w-0",children:[l.jsxs("p",{className:"flex items-center gap-2 text-[15px] font-medium text-content-primary",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${D.hasHost?D.agentStatus==="running"||D.agentStatus==="waiting_permission"?"bg-accent animate-pulse-dot":"bg-success":"bg-content-faint"}`}),l.jsx("span",{className:"truncate",children:Af(D)}),D.agentProvider&&l.jsx(Qt,{provider:D.agentProvider,size:12}),M&&l.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium ${M.className}`,children:[M.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),M.text]})]}),l.jsx("p",{className:`mt-1 truncate text-2xs ${y}`,children:x.text})]});return l.jsxs("div",{className:`codex-card group relative flex items-center justify-between overflow-hidden p-4 transition-colors ${D.hasHost?"hover:bg-surface-overlay":"opacity-70"} ${D.agentStatus==="running"?"border-accent/25":D.agentStatus==="waiting_permission"?"border-warning/30":D.agentStatus==="error"?"border-danger/25":""}`,children:[Ce&&l.jsx("span",{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-0.5 ${Ce}`}),D.hasHost?l.jsx("button",{onClick:()=>r(D.id),className:"flex flex-1 cursor-pointer items-center justify-between text-left",children:Ne}):l.jsx("div",{className:"flex flex-1 items-center justify-between text-left",children:Ne}),l.jsxs("div",{className:"flex items-center gap-2 pl-3",children:[l.jsx("button",{onClick:()=>ie(D.id),className:"cursor-pointer rounded-lg p-1.5 text-content-faint opacity-0 transition-colors hover:text-danger group-hover:opacity-100",title:"从列表移除","aria-label":"移除会话",children:l.jsx(ft,{size:14})}),D.hasHost&&l.jsx(et,{size:16,className:"text-content-faint"})]})]},D.id)};return l.jsxs("div",{className:"min-h-screen bg-canvas",children:[l.jsxs("header",{className:"glass-bar sticky top-0 z-10 flex min-h-14 items-center justify-between gap-3 border-b border-border px-4 sm:px-6",style:{paddingTop:"env(safe-area-inset-top)"},children:[l.jsxs("div",{className:"flex shrink-0 items-center gap-2.5",children:[l.jsx(Bi,{size:26}),l.jsx("h1",{className:"font-mono text-[15px] font-semibold text-content-primary",children:"LinkShell"})]}),l.jsxs("div",{className:"flex min-w-0 items-center gap-2 sm:gap-3",children:[Ec(e)&&l.jsx("span",{className:"shrink-0 rounded-full border border-accent/30 bg-accent/10 px-2.5 py-0.5 text-2xs font-semibold tracking-wide text-accent",children:"PRO"}),e?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"hidden min-w-0 truncate text-[13px] text-content-muted sm:inline",children:e.user.email}),l.jsx("button",{onClick:async()=>{await Rc(),n()},className:"codex-btn-ghost shrink-0 whitespace-nowrap text-2xs",children:"退出"})]}):l.jsx("button",{onClick:t,className:"codex-btn-outline shrink-0 whitespace-nowrap text-2xs",children:"登录"})]})]}),l.jsx("main",{className:"mx-auto max-w-[46rem] animate-fade-in px-4 py-6 sm:px-6 sm:py-10",children:l.jsxs("section",{className:"space-y-5",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[l.jsxs("h2",{className:"flex flex-wrap items-center gap-2 text-[15px] font-semibold text-content-primary",children:["我的会话 ",l.jsxs("span",{className:"font-normal text-content-muted",children:["(",h.length,")"]}),l.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${B==="live"?"border-success/30 bg-success/10 text-success":"border-border bg-surface-overlay text-content-muted"}`,children:[B==="live"&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),B==="live"?"实时":B==="connecting"?"连接中":"轮询"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{onClick:()=>void q(),className:"codex-btn-ghost text-2xs",children:[l.jsx(po,{size:13})," 刷新"]}),l.jsxs("button",{onClick:()=>$(D=>!D),className:"codex-btn-primary text-2xs",children:[l.jsx(dr,{size:13})," 添加连接"]})]})]}),_&&l.jsxs("section",{className:"codex-card animate-slide-in p-5",children:[l.jsx("label",{className:"mb-1.5 block text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"网关地址"}),l.jsxs("div",{className:"mb-4",children:[l.jsx("input",{value:a,onChange:D=>{o(D.target.value),u(!1)},onBlur:be,onKeyDown:D=>D.key==="Enter"&&be(),className:`codex-input font-mono text-2xs ${c?"border-danger/60":""}`,placeholder:"https://gateway.itool.tech"}),c&&l.jsx("p",{className:"mt-1.5 text-2xs text-danger",children:"请输入有效的 http(s) 地址"})]}),l.jsx("label",{className:"mb-1.5 block text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"配对码(在主机运行 linkshell 获取)"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:W,onChange:D=>Q(D.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"123456",inputMode:"numeric",autoFocus:!0,className:"codex-input flex-1 font-mono tracking-widest",onKeyDown:D=>D.key==="Enter"&&L()}),l.jsx("button",{onClick:L,disabled:j,className:"codex-btn-primary",children:j?"…":"连接"})]}),X&&l.jsx("p",{className:"mt-3 text-[13px] text-danger",children:X})]}),h.length===0&&m.length===0?l.jsx("div",{className:"codex-card flex flex-col items-center gap-3 px-6 py-20 text-center",children:A?l.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:"加载中…"}):l.jsxs("p",{className:"max-w-sm text-[15px] leading-7 text-content-muted",children:["还没有会话。在主机运行"," ",l.jsx("code",{className:"font-mono text-accent",children:"linkshell"}),",然后点「添加连接」输入配对码。"]})}):l.jsxs("div",{className:"space-y-3",children:[h.map(D=>le(D)),m.length>0&&l.jsxs("div",{className:"space-y-3 pt-2",children:[l.jsxs("button",{onClick:()=>k(D=>!D),className:"flex w-full cursor-pointer items-center gap-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint transition-colors hover:text-content-muted",children:[l.jsx(et,{size:12,className:`transition-transform ${S?"rotate-90":""}`}),"离线 (",m.length,")"]}),S&&m.map(D=>le(D))]})]})]})})]})}const Df=15e3,zf=1e3,Of=3e4,Ff=20;class $f{constructor(t){this.options=t,this.status="idle",this.deviceId=fc(),this.controllerId=null,this.epoch=0,this.reconnectAttempts=0,this.manualClose=!1,this.lastAckedSeqByTerminal=new Map,this.terminalBuffers=new Map,this.listeners=new Set}get sessionId(){return this.options.sessionId}get currentStatus(){return this.status}get isController(){return this.controllerId===this.deviceId}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(const n of this.listeners)n(t)}setStatus(t){this.status!==t&&(this.status=t,this.emit({type:"status",status:t}))}connect(){this.manualClose=!1,this.openSocket(!1)}openSocket(t){var r,i;if(this.manualClose)return;const n=++this.epoch;this.setStatus(t?"reconnecting":"connecting"),Promise.resolve(((i=(r=this.options).getJwt)==null?void 0:i.call(r))??null).then(s=>{n!==this.epoch||this.manualClose||this.openSocketWithJwt(n,t,s)})}openSocketWithJwt(t,n,r){const i=Yc(this.options.config,{sessionId:this.options.sessionId,deviceId:this.deviceId,deviceToken:dc(),jwt:r});let s;try{s=new WebSocket(i)}catch{this.scheduleReconnect(t);return}this.socket=s,s.onopen=()=>{if(t!==this.epoch){try{s.close()}catch{}return}this.reconnectAttempts=0,this.setStatus("connected"),this.startHeartbeat(),this.claimControl(),n&&this.sendResume()},s.onmessage=a=>{t===this.epoch&&this.handleMessage(typeof a.data=="string"?a.data:String(a.data))},s.onerror=()=>{this.epoch},s.onclose=()=>{if(t===this.epoch){if(this.stopHeartbeat(),this.manualClose){this.setStatus("disconnected");return}this.scheduleReconnect(t)}}}scheduleReconnect(t){if(this.manualClose||t!==this.epoch)return;const n=Math.min(this.reconnectAttempts++,Ff),i=Math.min(zf*2**n,Of)*(.5+Math.random()*.5);this.setStatus("reconnecting"),this.reconnectTimer=setTimeout(()=>this.openSocket(!0),i)}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.sendRaw(dn({type:"session.heartbeat",sessionId:this.options.sessionId,payload:{ts:Date.now()}}))},Df)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0)}sendResume(){this.sendRaw(dn({type:"session.resume",sessionId:this.options.sessionId,payload:{lastAckedSeq:-1,lastAckedSeqByTerminal:Object.fromEntries(this.lastAckedSeqByTerminal)}}))}handleMessage(t){var i;let n;try{n=Po(t)}catch{return}const r=n.type;if(r==="terminal.output"){try{const s=Ve("terminal.output",n.payload),a=n.terminalId??"default";if(n.seq!==void 0){const u=this.lastAckedSeqByTerminal.get(a)??-1;n.seq>u&&(this.lastAckedSeqByTerminal.set(a,n.seq),this.sendRaw(dn({type:"session.ack",sessionId:this.options.sessionId,terminalId:a,payload:{seq:n.seq}})))}this.emit({type:"terminal.output",terminalId:a,data:s.data,seq:n.seq,isReplay:s.isReplay});let c=(this.terminalBuffers.get(a)??"")+s.data;c.length>262144&&(c=c.slice(c.length-131072)),this.terminalBuffers.set(a,c)}catch{}return}if(r==="terminal.reset"){const s=n.terminalId??"default";this.terminalBuffers.delete(s),this.lastAckedSeqByTerminal.delete(s),this.emit({type:"terminal.reset",terminalId:s});return}if(r==="control.grant"){const s=((i=n.payload)==null?void 0:i.deviceId)??null;this.controllerId=s,this.emit({type:"control",controllerId:s});return}if(r==="control.release"){this.controllerId=null,this.emit({type:"control",controllerId:null});return}if(r==="session.error"){const s=n.payload;this.emit({type:"session.error",code:s.code??"error",message:s.message??""});return}if(r==="session.host_disconnected"){this.setStatus("host_disconnected");return}if(r==="session.host_reconnected"){this.setStatus("connected");return}if(r==="terminal.list"||r==="terminal.spawned"){this.emit({type:"terminal.list",envelope:n});return}if(Cf(r)){this.emit({type:"agent",envelope:n});return}this.emit({type:"envelope",envelope:n})}sendRaw(t){return!this.socket||this.socket.readyState!==WebSocket.OPEN?!1:(this.socket.send(If(t)),!0)}send(t,n,r){return this.sendRaw(dn({type:t,sessionId:this.options.sessionId,deviceId:this.deviceId,terminalId:r,payload:n}))}claimControl(){this.sendRaw(dn({type:"control.claim",sessionId:this.options.sessionId,deviceId:this.deviceId,payload:{deviceId:this.deviceId}}))}sendInput(t,n){this.send("terminal.input",{data:n},t)}sendResize(t,n,r){this.send("terminal.resize",{cols:n,rows:r},t)}requestTerminalList(){this.send("terminal.list",{terminals:[]})}terminalBuffer(t){return this.terminalBuffers.get(t)??""}spawnTerminal(t){this.send("terminal.spawn",{cwd:t,forceNew:!0})}killTerminal(t){this.send("terminal.kill",{terminalId:t},t),this.terminalBuffers.delete(t)}sendAgent(t,n){return this.send(t,n)}protocolVersion(){return _u}disconnect(){if(this.manualClose=!0,this.epoch++,this.stopHeartbeat(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0),this.socket){try{this.socket.close(1e3,"client disconnect")}catch{}this.socket=void 0}this.setStatus("disconnected")}}const Vs=200;function Ht(e,t){var i,s;if(t.length===0)return e;const n=new Map;for(const a of e)n.set(a.id,a);for(const a of t){const o=n.get(a.id);if(!(((i=o==null?void 0:o.metadata)==null?void 0:i.queuedDiscarded)===!0&&((s=a.metadata)==null?void 0:s.queuedDiscarded)!==!0)){if(o!=null&&o.metadata&&(o.metadata.queuedSent||o.metadata.queuedDiscarded||o.metadata.delivery)){const c=a.metadata??{};n.set(a.id,{...a,metadata:{...c,queuedSent:c.queuedSent??o.metadata.queuedSent,queuedDiscarded:c.queuedDiscarded??o.metadata.queuedDiscarded,delivery:c.delivery??o.metadata.delivery}});continue}n.set(a.id,a)}}const r=[...n.values()].sort((a,o)=>a.createdAt-o.createdAt);return r.length>Vs?r.slice(r.length-Vs):r}function Bf(e,t,n){if(t.item){const r={...t.item,metadata:{...t.item.metadata??{}}};return Ht(e,[r])}if(t.patch){const r=t.patch;let i=!1;const s=e.map(a=>a.id!==r.itemId&&a.itemId!==r.itemId?a:(i=!0,{...a,kind:r.kind??a.kind,role:r.role??a.role,content:r.content??a.content,text:r.textDelta?`${r.text??a.text??""}${r.textDelta}`:r.text??a.text,status:r.status??a.status,toolCall:r.toolCall?{...a.toolCall??{},...r.toolCall}:a.toolCall,commandExecution:r.commandExecution?{...a.commandExecution??{},...r.commandExecution}:a.commandExecution,fileChange:r.fileChange?{...a.fileChange??{},...r.fileChange}:a.fileChange,subagent:r.subagent?{...a.subagent??{},...r.subagent}:a.subagent,structuredInput:r.structuredInput??a.structuredInput,plan:r.plan??a.plan,permission:r.permission?{...a.permission??{},...r.permission}:a.permission,error:r.error??a.error,metadata:r.metadata?{...a.metadata??{},...r.metadata}:a.metadata,updatedAt:r.updatedAt??Date.now(),isStreaming:r.isStreaming??a.isStreaming}));return i?s:(n==null||n(r.itemId),e)}return e}function yi(e){return e.map(t=>({...t,metadata:{...t.metadata??{}}}))}function qf(e){const t=new Map;for(const n of yi(e)){const r=t.get(n.conversationId)??[];r.push(n),t.set(n.conversationId,r)}return t}function zr(e,t){const n=new Map;for(const r of e)n.set(r.id,r);for(const r of t){const i=n.get(r.id);if(!i){n.set(r.id,r);continue}n.set(r.id,{...i,...r,status:r.status,lastActivityAt:Math.max(i.lastActivityAt??0,r.lastActivityAt??0)})}return[...n.values()].sort((r,i)=>i.lastActivityAt-r.lastActivityAt)}function Vf(e){var t,n,r;if(e.text)return e.text.slice(0,120).replace(/\s+/g," ").trim();if((t=e.toolCall)!=null&&t.name)return`🔧 ${e.toolCall.name}`;if((n=e.commandExecution)!=null&&n.command)return`$ ${e.commandExecution.command}`;if((r=e.fileChange)!=null&&r.summary)return e.fileChange.summary;if(e.error)return`⚠ ${e.error}`}function ut(e){const t=Math.random().toString(36).slice(2,10);return`${e}-${Date.now().toString(36)}-${t}`}function Us(e,t){return`${e??"unknown"}:${t}`}function Uf(e){return/auth|unauthorized|token|subscription|version|protocol/i.test(e)}function Hf(e){switch(e){case"thinking":case"tool_use":case"outputting":return"running";case"waiting":return"waiting_permission";case"idle":return"idle";case"error":return"error";default:return null}}class Zf{constructor(t,n,r){this.listeners=new Set,this.pendingBrowse=new Map,this.pendingRead=new Map,this.openInFlight=new Set,this.openedThisSession=new Set,this.autoFlushing=new Set,this.reqCounter=0,this.outbox=[],this.snapshotRecoveryTimers=new Map,this.status="idle",this.isController=!1,this.externalAgentStatus=null,this.externalAgentTitle=null,this.externalAgentProvider=null,this.externalAgentConversationId=null,this.conversations=[],this.timelines=new Map,this.capabilities=null,this.activeConversationId=null,this.lastError=null,this.history=new Map,this.notices=[],this.usage=null,this.mcpAuthLinks={},this.lastProviderSig="",this.subscribe=s=>(this.listeners.add(s),()=>this.listeners.delete(s)),this.getSnapshot=()=>this.snapshot,this.sessionId=n,this.bridge=new $f({config:t,sessionId:n,getJwt:r}),this.conversations=ao(n);const i=_c(n);this.timelines=new Map(Object.entries(i)),this.snapshot=this.buildSnapshot(),this.unsub=this.bridge.onEvent(s=>this.handleBridgeEvent(s))}buildSnapshot(){return{status:this.status,isController:this.isController,externalAgentStatus:this.externalAgentStatus,externalAgentTitle:this.externalAgentTitle,externalAgentProvider:this.externalAgentProvider,externalAgentConversationId:this.externalAgentConversationId,conversations:this.conversations,timelines:this.timelines,capabilities:this.capabilities,activeConversationId:this.activeConversationId,lastError:this.lastError,history:this.history,notices:this.notices,usage:this.usage,mcpAuthLinks:this.mcpAuthLinks}}notify(){this.snapshot=this.buildSnapshot();for(const t of this.listeners)t();this.schedulePersist()}schedulePersist(){this.persistTimer||(this.persistTimer=setTimeout(()=>{this.persistTimer=void 0,_s(this.sessionId,this.conversations),js(this.sessionId,this.timelines)},800))}flushPersist(){this.persistTimer&&(clearTimeout(this.persistTimer),this.persistTimer=void 0),_s(this.sessionId,this.conversations),js(this.sessionId,this.timelines)}connect(){this.bridge.connect()}destroy(){this.flushPersist(),this.errorClearTimer&&clearTimeout(this.errorClearTimer);for(const t of this.snapshotRecoveryTimers.values())clearTimeout(t);this.snapshotRecoveryTimers.clear(),this.unsub(),this.bridge.disconnect(),this.listeners.clear()}get client(){return this.bridge}handleBridgeEvent(t){var n;switch(t.type){case"status":this.status=t.status,t.status==="connected"&&((n=this.lastError)!=null&&n.sticky||(this.lastError=null),this.requestCapabilities(),this.requestSnapshot(),this.requestConversationList(),this.flushOutbox()),this.notify();break;case"control":this.isController=this.bridge.isController,this.notify();break;case"session.error":{const r=Uf(t.code);this.lastError={code:t.code,message:t.message,sticky:r},this.notify(),this.errorClearTimer&&(clearTimeout(this.errorClearTimer),this.errorClearTimer=void 0),r||(this.errorClearTimer=setTimeout(()=>{this.lastError=null,this.errorClearTimer=void 0,this.notify()},6e3));break}case"agent":this.handleAgentEnvelope(t.envelope);break;case"envelope":this.handleOtherEnvelope(t.envelope);break}}handleOtherEnvelope(t){const n=t.type;if(n==="terminal.status"){try{const r=Ve("terminal.status",t.payload);this.externalAgentStatus=Hf(r.phase),this.externalAgentProvider=r.provider??null,this.externalAgentTitle=r.toolName?`外部终端 · ${r.toolName}`:r.summary?`外部终端 · ${r.summary}`:"外部终端",this.externalAgentConversationId=r.conversationId??null,this.notify()}catch{}return}if(n==="terminal.browse.result"){try{const r=Ve("terminal.browse.result",t.payload);if(r.requestId){const i=this.pendingBrowse.get(r.requestId);i&&(this.pendingBrowse.delete(r.requestId),i(r))}}catch{}return}if(n==="terminal.file.read.result"){try{const r=Ve("terminal.file.read.result",t.payload);if(r.requestId){const i=this.pendingRead.get(r.requestId);i&&(this.pendingRead.delete(r.requestId),i(r))}}catch{}return}}setTimeline(t,n){const r=new Map(this.timelines);r.set(t,n),this.timelines=r}handleAgentEnvelope(t){var r;const n=t.type;try{if(n==="agent.v2.capabilities"){this.capabilities=Ve("agent.v2.capabilities",t.payload);const i=(this.capabilities.providers??[]).filter(s=>s.enabled).map(s=>s.id).sort().join(",");i&&i!==this.lastProviderSig&&(this.lastProviderSig=i,this.requestSnapshot()),this.pruneConnectedMcpAuthLinks(),this.notify();return}if(n==="agent.v2.snapshot"){const i=Ve("agent.v2.snapshot",t.payload);this.conversations=zr(this.conversations,i.conversations),i.activeConversationId&&(this.activeConversationId=i.activeConversationId);const s=qf(i.items),a=new Map(this.timelines);for(const[o,c]of s)a.set(o,Ht(a.get(o)??[],c));this.timelines=a,this.notify();return}if(n==="agent.v2.conversation.opened"){const i=Ve("agent.v2.conversation.opened",t.payload);this.conversations=zr(this.conversations,[i.conversation]),this.activeConversationId=i.conversation.id,this.setTimeline(i.conversation.id,Ht(this.timelines.get(i.conversation.id)??[],yi(i.snapshot)));const s=a=>{const o=this.history.get(a);this.history.set(a,{loading:!1,hasMore:(o==null?void 0:o.hasMore)??!0,cursor:o==null?void 0:o.cursor,syncing:!1}),this.openedThisSession.add(a)};s(i.conversation.id),i.requestedConversationId&&i.requestedConversationId!==i.conversation.id&&s(i.requestedConversationId),this.openInFlight.delete(i.conversation.id),i.requestedConversationId&&this.openInFlight.delete(i.requestedConversationId),this.notify();return}if(n==="agent.v2.history.result"){const i=Ve("agent.v2.history.result",t.payload);this.setTimeline(i.conversationId,Ht(this.timelines.get(i.conversationId)??[],yi(i.items))),this.history.set(i.conversationId,{loading:!1,hasMore:i.hasMore,cursor:i.nextCursor}),this.notify();return}if(n==="agent.v2.conversation.list.result"){const i=Ve("agent.v2.conversation.list.result",t.payload);this.conversations=zr(this.conversations,i.conversations),this.notify();return}if(n==="agent.v2.conversation.deleted"){const i=Ve("agent.v2.conversation.deleted",t.payload);this.removeConversationLocal(i.conversationId),this.notify();return}if(n==="agent.v2.mcp.login.result"){const i=Ve("agent.v2.mcp.login.result",t.payload),s=Us(i.provider,i.serverName);if(i.error){const a={...this.mcpAuthLinks};delete a[s],this.mcpAuthLinks=a,this.pushNotice({kind:"warning",title:`MCP ${i.serverName} 授权失败`,detail:i.error});return}if(i.authorizationUrl){this.mcpAuthLinks={...this.mcpAuthLinks,[s]:i.authorizationUrl},this.notify();try{window.open(i.authorizationUrl,"_blank","noopener,noreferrer")||this.pushNotice({kind:"info",title:"请打开授权页",detail:"浏览器拦截了弹窗,请在 MCP 面板里点击「打开授权页」。"})}catch{this.pushNotice({kind:"info",title:"请打开授权页",detail:"无法自动打开授权页,请在 MCP 面板里手动打开。"})}return}this.notify();return}if(n==="agent.v2.event"){const i=Ve("agent.v2.event",t.payload);if(i.conversation){const o=i.conversation,c=this.conversations.some(u=>u.id===o.id);this.conversations=(c?this.conversations.map(u=>u.id===o.id?o:u):[o,...this.conversations]).sort((u,d)=>d.lastActivityAt-u.lastActivityAt)}else(r=i.patch)!=null&&r.status&&this.updateConversationStatus(i.conversationId,i.patch.status,i.patch.updatedAt??Date.now());const s=this.timelines.get(i.conversationId)??[],a=Bf(s,i,()=>this.scheduleSnapshotRecovery(i.conversationId));if(a!==s){this.setTimeline(i.conversationId,a);const o=a[a.length-1];o&&this.touchConversation(i.conversationId,o)}this.notify(),this.maybeFlushQueue(i.conversationId);return}if(n==="agent.v2.permission.request"){const i=Ve("agent.v2.permission.request",t.payload);if(this.updateConversationStatus(i.conversationId,"waiting_permission",Date.now()),i.item){const s={...i.item,metadata:{...i.item.metadata??{},permissionLive:!0}};this.setTimeline(i.conversationId,Ht(this.timelines.get(i.conversationId)??[],[s])),this.notify()}return}if(n==="agent.v2.notice"){const i=Ve("agent.v2.notice",t.payload),s=ut("notice");this.notices=[...this.notices,{id:s,kind:i.kind,title:i.title,detail:i.detail}].slice(-4),this.notify();const a=i.durationMs&&i.durationMs>0?i.durationMs:4e3;setTimeout(()=>this.dismissNotice(s),a);return}if(n==="agent.v2.usage.report"){this.usage=Ve("agent.v2.usage.report",t.payload),this.notify();return}}catch{}}touchConversation(t,n){const r=Vf(n);this.conversations=this.conversations.map(i=>i.id===t?{...i,lastMessagePreview:r??i.lastMessagePreview,lastActivityAt:n.updatedAt??n.createdAt??i.lastActivityAt}:i)}updateConversationStatus(t,n,r){this.conversations=this.conversations.map(i=>i.id===t?{...i,status:n,lastActivityAt:Math.max(i.lastActivityAt,r)}:i).sort((i,s)=>s.lastActivityAt-i.lastActivityAt)}sendReliable(t,n){const r=this.bridge.sendAgent(t,n);return r||this.outbox.push({type:t,payload:n,queuedAt:Date.now()}),r}flushOutbox(){if(this.outbox.length===0)return;const t=this.outbox;this.outbox=[];const n=Date.now();let r=0;for(let i=0;i<t.length;i++){const s=t[i];if(n-s.queuedAt>6e4){r+=1;continue}if(!this.sendReliable(s.type,s.payload)){this.outbox.push(...t.slice(i+1));break}}if(r>0){const i=ut("notice");this.notices=[...this.notices,{id:i,kind:"warning",title:"发送失败",detail:`${r} 条消息因连接中断超过 60 秒未能送达,已丢弃`}].slice(-4),this.notify(),setTimeout(()=>this.dismissNotice(i),6e3)}}scheduleSnapshotRecovery(t){this.snapshotRecoveryTimers.has(t)||this.snapshotRecoveryTimers.set(t,setTimeout(()=>{this.snapshotRecoveryTimers.delete(t),this.requestSnapshot(t)},1e3))}pushNotice(t){const n=ut("notice");this.notices=[...this.notices,{id:n,kind:t.kind,title:t.title,detail:t.detail}].slice(-4),this.notify(),setTimeout(()=>this.dismissNotice(n),t.durationMs&&t.durationMs>0?t.durationMs:5e3)}pruneConnectedMcpAuthLinks(){var i;const t=this.mcpAuthLinks;if(Object.keys(t).length===0)return;const r={...t};for(const s of((i=this.capabilities)==null?void 0:i.providers)??[])for(const a of s.mcpServers??[])a.status==="connected"&&delete r[Us(s.id,a.name)];this.mcpAuthLinks=r}dismissNotice(t){const n=this.notices.filter(r=>r.id!==t);n.length!==this.notices.length&&(this.notices=n,this.notify())}dismissError(){this.errorClearTimer&&(clearTimeout(this.errorClearTimer),this.errorClearTimer=void 0),this.lastError&&(this.lastError=null,this.notify())}setActiveConversation(t){this.activeConversationId=t,this.notify(),t&&this.ensureHistoryLoaded(t)}ensureHistoryLoaded(t){if(this.openInFlight.has(t))return;const r=(this.timelines.get(t)??[]).some(a=>{var o;return((o=a.metadata)==null?void 0:o.optimistic)!==!0});if(r&&this.openedThisSession.has(t)){const a=this.conversations.find(o=>o.id===t);if((a==null?void 0:a.status)!=="running"&&(a==null?void 0:a.status)!=="waiting_permission")return}const i=this.conversations.find(a=>a.id===t);if(!i)return;this.openInFlight.add(t);const s=this.history.get(t);r?this.history.set(t,{loading:(s==null?void 0:s.loading)??!1,hasMore:(s==null?void 0:s.hasMore)??!0,cursor:s==null?void 0:s.cursor,syncing:!0}):this.history.set(t,{loading:!0,hasMore:(s==null?void 0:s.hasMore)??!0,cursor:s==null?void 0:s.cursor}),this.notify(),setTimeout(()=>{if(!this.openInFlight.delete(t))return;const a=this.history.get(t);if(a&&(a.loading||a.syncing)){this.history.set(t,{loading:!1,hasMore:a.hasMore,cursor:a.cursor,syncing:!1});const o=ut("notice");this.notices=[...this.notices,{id:o,kind:"warning",title:"加载对话记录超时"}].slice(-4),setTimeout(()=>this.dismissNotice(o),6e3),this.notify()}},12e3),this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:t,agentSessionId:i.agentSessionId,provider:i.provider,cwd:i.cwd,model:i.model,reasoningEffort:i.reasoningEffort,permissionMode:i.permissionMode,collaborationMode:i.collaborationMode,title:i.title})}requestCapabilities(){this.bridge.sendAgent("agent.v2.capabilities.request",{})}requestSnapshot(t){this.bridge.sendAgent("agent.v2.snapshot.request",t?{conversationId:t}:{})}requestConversationList(t=!1){this.bridge.sendAgent("agent.v2.conversation.list",{includeArchived:t})}requestUsage(){this.bridge.sendAgent("agent.v2.usage.request",{})}loadOlderHistory(t){const n=this.history.get(t);n&&(n.loading||!n.hasMore)||(this.history.set(t,{loading:!0,hasMore:(n==null?void 0:n.hasMore)??!0,cursor:n==null?void 0:n.cursor}),this.notify(),this.bridge.sendAgent("agent.v2.history.request",{conversationId:t,cursor:n==null?void 0:n.cursor,limit:50}))}openConversation(t){const n=t.conversationId??ut("agent");return this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:n,provider:t.provider,cwd:t.cwd,model:t.model,reasoningEffort:t.reasoningEffort,permissionMode:t.permissionMode,collaborationMode:t.collaborationMode,title:t.title}),n}forkConversation(t,n){const r=this.conversations.find(s=>s.id===t);if(!r||r.provider!=="claude")return;const i=ut("agent");return this.bridge.sendAgent("agent.v2.conversation.open",{conversationId:i,provider:r.provider,cwd:r.cwd,forkFromConversationId:t,forkFromTurnId:n}),i}sendPrompt(t){const n=[];t.text.trim()&&n.push({type:"text",text:t.text});for(const c of t.images??[])n.push({type:"image",data:c.data,mimeType:c.mimeType});if(n.length===0)return;const r=this.conversations.find(c=>c.id===t.conversationId),s=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="waiting_permission"?"queued":"auto",a=ut("msg"),o={id:a,conversationId:t.conversationId,type:"message",kind:"chat",role:"user",content:n,text:t.text,createdAt:Date.now(),metadata:{optimistic:!0,delivery:s,clientMessageId:a}};this.setTimeline(t.conversationId,Ht(this.timelines.get(t.conversationId)??[],[o])),this.conversations=this.conversations.map(c=>c.id===t.conversationId?{...c,model:t.model??c.model,reasoningEffort:t.reasoningEffort??c.reasoningEffort,permissionMode:t.permissionMode??c.permissionMode,collaborationMode:t.collaborationMode??c.collaborationMode,status:s==="auto"?"running":c.status,lastActivityAt:Date.now()}:c),this.notify(),s!=="queued"&&this.sendReliable("agent.v2.prompt",{conversationId:t.conversationId,clientMessageId:a,contentBlocks:n,delivery:"auto",model:t.model,reasoningEffort:t.reasoningEffort,permissionMode:t.permissionMode,collaborationMode:t.collaborationMode})}sendQueuedFollowUp(t,n,r){var u,d,f;const s=(this.timelines.get(t)??[]).find(p=>p.id===n);if(!s||((u=s.metadata)==null?void 0:u.queuedSent)===!0||((d=s.metadata)==null?void 0:d.queuedDiscarded)===!0)return;const a=this.conversations.find(p=>p.id===t),o=s.content??(s.text?[{type:"text",text:s.text}]:[]);if(o.length===0)return;this.bridge.sendAgent("agent.v2.prompt",{conversationId:t,clientMessageId:((f=s.metadata)==null?void 0:f.clientMessageId)??ut("msg"),contentBlocks:o,delivery:r,model:a==null?void 0:a.model,reasoningEffort:a==null?void 0:a.reasoningEffort,permissionMode:a==null?void 0:a.permissionMode,collaborationMode:a==null?void 0:a.collaborationMode})&&(this.patchItem(t,n,{queuedSent:!0}),this.notify())}discardQueuedFollowUp(t,n){this.patchItem(t,n,{queuedDiscarded:!0,queuedSent:!0}),this.notify()}patchItem(t,n,r){const i=this.timelines.get(t);i&&this.setTimeline(t,i.map(s=>s.id===n?{...s,metadata:{...s.metadata??{},...r},updatedAt:Date.now()}:s))}maybeFlushQueue(t){const n=this.conversations.find(s=>s.id===t);if(!n||n.status==="running"||n.status==="waiting_permission")return;const i=(this.timelines.get(t)??[]).find(s=>{var a,o,c;return((a=s.metadata)==null?void 0:a.delivery)==="queued"&&((o=s.metadata)==null?void 0:o.queuedSent)!==!0&&((c=s.metadata)==null?void 0:c.queuedDiscarded)!==!0});!i||this.autoFlushing.has(i.id)||(this.autoFlushing.add(i.id),this.sendQueuedFollowUp(t,i.id,"new_turn"),setTimeout(()=>this.autoFlushing.delete(i.id),1500))}cancel(t){this.sendReliable("agent.v2.cancel",{conversationId:t})}respondPermission(t,n,r,i){this.patchItemByPredicate(t,s=>{var a;return((a=s.permission)==null?void 0:a.requestId)===n},{permissionPending:!0,pendingOutcome:r,optionId:i}),this.notify(),this.sendReliable("agent.v2.permission.respond",{conversationId:t,requestId:n,outcome:r,optionId:i})}respondStructuredInput(t,n,r){this.patchItemByPredicate(t,i=>{var s;return((s=i.structuredInput)==null?void 0:s.requestId)===n},{inputSubmitting:!0,answers:r}),this.notify(),this.sendReliable("agent.v2.structured_input.respond",{conversationId:t,requestId:n,answers:r})}patchItemByPredicate(t,n,r){const i=this.timelines.get(t);if(!i)return;let s=!1;this.setTimeline(t,i.map(a=>s||!n(a)?a:(s=!0,{...a,metadata:{...a.metadata??{},...r},updatedAt:Date.now()})))}executeCommand(t,n,r){this.bridge.sendAgent("agent.v2.command.execute",{conversationId:t,commandId:n,args:r,clientMessageId:ut("cmd")})}updateConversationSettings(t,n){this.conversations=this.conversations.map(r=>r.id===t?{...r,...n}:r),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,...n})}renameConversation(t,n){const r=n.trim(),i=r===""?void 0:r;this.conversations=this.conversations.map(s=>s.id===t?{...s,title:i}:s),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,title:r})}setConversationArchived(t,n){this.conversations=this.conversations.map(r=>r.id===t?{...r,archived:n}:r),this.notify(),this.bridge.sendAgent("agent.v2.conversation.update",{conversationId:t,archived:n})}deleteConversation(t){this.removeConversationLocal(t),this.notify(),this.bridge.sendAgent("agent.v2.conversation.delete",{conversationId:t})}startMcpLogin(t,n){this.bridge.sendAgent("agent.v2.mcp.login",{...t?{provider:t}:{},serverName:n})}removeConversationLocal(t){if(this.conversations=this.conversations.filter(n=>n.id!==t),this.timelines.has(t)){const n=new Map(this.timelines);n.delete(t),this.timelines=n}this.history.delete(t),this.openInFlight.delete(t),this.activeConversationId===t&&(this.activeConversationId=null)}nextRequestId(t){return this.reqCounter+=1,`${t}-${this.reqCounter}-${ut("r")}`}browse(t,n=!0){const r=this.nextRequestId("browse");return new Promise((i,s)=>{const a=setTimeout(()=>{this.pendingBrowse.delete(r),s(new Error("browse timeout"))},1e4);this.pendingBrowse.set(r,o=>{clearTimeout(a),i(o)}),this.bridge.send("terminal.browse",{path:t,includeFiles:n,requestId:r})})}readFile(t,n=256e3){const r=this.nextRequestId("read");return new Promise((i,s)=>{const a=setTimeout(()=>{this.pendingRead.delete(r),s(new Error("read timeout"))},1e4);this.pendingRead.set(r,o=>{clearTimeout(a),i(o)}),this.bridge.send("terminal.file.read",{path:t,maxBytes:n,requestId:r})})}}function Wf(e,t){const n=`${e.httpUrl}|${t}`,r=v.useRef(null),i=v.useMemo(()=>{var o;if(r.current&&r.current.key===n)return r.current.store;(o=r.current)==null||o.store.destroy();const a=new Zf(e,t,async()=>{const c=await uo();return(c==null?void 0:c.accessToken)??null});return r.current={key:n,store:a},a},[n]);v.useEffect(()=>(i.connect(),()=>{i.destroy(),r.current=null}),[i]);const s=v.useSyncExternalStore(i.subscribe,i.getSnapshot);return{store:i,snapshot:s}}const Ro=()=>typeof window<"u"&&"Notification"in window;function Qf(){Ro()&&Notification.permission==="default"&&Notification.requestPermission().catch(()=>{})}const Kf="● LinkShell";function Yf(){return document.hidden||!document.hasFocus()}function Xf(e){const t=v.useRef(new Map),n=v.useRef(null);v.useEffect(()=>{const r=()=>{n.current!=null&&!document.hidden&&(document.title=n.current,n.current=null)};return window.addEventListener("focus",r),document.addEventListener("visibilitychange",r),()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",r)}},[]),v.useEffect(()=>{const r=t.current,i=new Map;for(const s of e){if(i.set(s.id,s.status),r.get(s.id)!=="running"||s.status==="running")continue;const o=s.status==="idle",c=s.status==="waiting_permission";if(!o&&!c||!Yf())continue;const u=o?"任务完成":"等待授权",d=s.title&&s.title.trim()||s.lastMessagePreview&&s.lastMessagePreview.trim().slice(0,60)||`对话 ${s.id.slice(-6)}`;if(n.current==null&&(n.current=document.title),document.title=Kf,Ro()&&Notification.permission==="granted")try{const f=new Notification(u,{body:d,tag:`linkshell-turn-${s.id}`});f.onclick=()=>{window.focus(),f.close()}}catch{}}t.current=i},[e])}function Jf(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Gf=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eh=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,th={};function Hs(e,t){return(th.jsx?eh:Gf).test(e)}const nh=/[ \t\n\f\r]/g;function rh(e){return typeof e=="object"?e.type==="text"?Zs(e.value):!1:Zs(e)}function Zs(e){return e.replace(nh,"")===""}class Tn{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Tn.prototype.normal={};Tn.prototype.property={};Tn.prototype.space=void 0;function Lo(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Tn(n,r,t)}function bi(e){return e.toLowerCase()}class Qe{constructor(t,n){this.attribute=n,this.property=t}}Qe.prototype.attribute="";Qe.prototype.booleanish=!1;Qe.prototype.boolean=!1;Qe.prototype.commaOrSpaceSeparated=!1;Qe.prototype.commaSeparated=!1;Qe.prototype.defined=!1;Qe.prototype.mustUseProperty=!1;Qe.prototype.number=!1;Qe.prototype.overloadedBoolean=!1;Qe.prototype.property="";Qe.prototype.spaceSeparated=!1;Qe.prototype.space=void 0;let ih=0;const oe=zt(),Pe=zt(),ki=zt(),R=zt(),Ae=zt(),Kt=zt(),Xe=zt();function zt(){return 2**++ih}const vi=Object.freeze(Object.defineProperty({__proto__:null,boolean:oe,booleanish:Pe,commaOrSpaceSeparated:Xe,commaSeparated:Kt,number:R,overloadedBoolean:ki,spaceSeparated:Ae},Symbol.toStringTag,{value:"Module"})),Or=Object.keys(vi);class Hi extends Qe{constructor(t,n,r,i){let s=-1;if(super(t,n),Ws(this,"space",i),typeof r=="number")for(;++s<Or.length;){const a=Or[s];Ws(this,Or[s],(r&vi[a])===vi[a])}}}Hi.prototype.defined=!0;function Ws(e,t,n){n&&(e[t]=n)}function on(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Hi(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[bi(r)]=r,n[bi(s.attribute)]=r}return new Tn(t,n,e.space)}const Do=on({properties:{ariaActiveDescendant:null,ariaAtomic:Pe,ariaAutoComplete:null,ariaBusy:Pe,ariaChecked:Pe,ariaColCount:R,ariaColIndex:R,ariaColSpan:R,ariaControls:Ae,ariaCurrent:null,ariaDescribedBy:Ae,ariaDetails:null,ariaDisabled:Pe,ariaDropEffect:Ae,ariaErrorMessage:null,ariaExpanded:Pe,ariaFlowTo:Ae,ariaGrabbed:Pe,ariaHasPopup:null,ariaHidden:Pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ae,ariaLevel:R,ariaLive:null,ariaModal:Pe,ariaMultiLine:Pe,ariaMultiSelectable:Pe,ariaOrientation:null,ariaOwns:Ae,ariaPlaceholder:null,ariaPosInSet:R,ariaPressed:Pe,ariaReadOnly:Pe,ariaRelevant:null,ariaRequired:Pe,ariaRoleDescription:Ae,ariaRowCount:R,ariaRowIndex:R,ariaRowSpan:R,ariaSelected:Pe,ariaSetSize:R,ariaSort:null,ariaValueMax:R,ariaValueMin:R,ariaValueNow:R,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function zo(e,t){return t in e?e[t]:t}function Oo(e,t){return zo(e,t.toLowerCase())}const sh=on({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kt,acceptCharset:Ae,accessKey:Ae,action:null,allow:null,allowFullScreen:oe,allowPaymentRequest:oe,allowUserMedia:oe,alt:null,as:null,async:oe,autoCapitalize:null,autoComplete:Ae,autoFocus:oe,autoPlay:oe,blocking:Ae,capture:null,charSet:null,checked:oe,cite:null,className:Ae,cols:R,colSpan:null,content:null,contentEditable:Pe,controls:oe,controlsList:Ae,coords:R|Kt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:oe,defer:oe,dir:null,dirName:null,disabled:oe,download:ki,draggable:Pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:oe,formTarget:null,headers:Ae,height:R,hidden:ki,high:R,href:null,hrefLang:null,htmlFor:Ae,httpEquiv:Ae,id:null,imageSizes:null,imageSrcSet:null,inert:oe,inputMode:null,integrity:null,is:null,isMap:oe,itemId:null,itemProp:Ae,itemRef:Ae,itemScope:oe,itemType:Ae,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:oe,low:R,manifest:null,max:null,maxLength:R,media:null,method:null,min:null,minLength:R,multiple:oe,muted:oe,name:null,nonce:null,noModule:oe,noValidate:oe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:oe,optimum:R,pattern:null,ping:Ae,placeholder:null,playsInline:oe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:oe,referrerPolicy:null,rel:Ae,required:oe,reversed:oe,rows:R,rowSpan:R,sandbox:Ae,scope:null,scoped:oe,seamless:oe,selected:oe,shadowRootClonable:oe,shadowRootDelegatesFocus:oe,shadowRootMode:null,shape:null,size:R,sizes:null,slot:null,span:R,spellCheck:Pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:R,step:null,style:null,tabIndex:R,target:null,title:null,translate:null,type:null,typeMustMatch:oe,useMap:null,value:Pe,width:R,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ae,axis:null,background:null,bgColor:null,border:R,borderColor:null,bottomMargin:R,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:oe,declare:oe,event:null,face:null,frame:null,frameBorder:null,hSpace:R,leftMargin:R,link:null,longDesc:null,lowSrc:null,marginHeight:R,marginWidth:R,noResize:oe,noHref:oe,noShade:oe,noWrap:oe,object:null,profile:null,prompt:null,rev:null,rightMargin:R,rules:null,scheme:null,scrolling:Pe,standby:null,summary:null,text:null,topMargin:R,valueType:null,version:null,vAlign:null,vLink:null,vSpace:R,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:oe,disableRemotePlayback:oe,prefix:null,property:null,results:R,security:null,unselectable:null},space:"html",transform:Oo}),ah=on({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xe,accentHeight:R,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:R,amplitude:R,arabicForm:null,ascent:R,attributeName:null,attributeType:null,azimuth:R,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:R,by:null,calcMode:null,capHeight:R,className:Ae,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:R,diffuseConstant:R,direction:null,display:null,dur:null,divisor:R,dominantBaseline:null,download:oe,dx:null,dy:null,edgeMode:null,editable:null,elevation:R,enableBackground:null,end:null,event:null,exponent:R,externalResourcesRequired:null,fill:null,fillOpacity:R,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Kt,g2:Kt,glyphName:Kt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:R,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:R,horizOriginX:R,horizOriginY:R,id:null,ideographic:R,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:R,k:R,k1:R,k2:R,k3:R,k4:R,kernelMatrix:Xe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:R,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:R,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:R,overlineThickness:R,paintOrder:null,panose1:null,path:null,pathLength:R,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ae,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:R,pointsAtY:R,pointsAtZ:R,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xe,rev:Xe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xe,requiredFeatures:Xe,requiredFonts:Xe,requiredFormats:Xe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:R,specularExponent:R,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:R,strikethroughThickness:R,string:null,stroke:null,strokeDashArray:Xe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:R,strokeOpacity:R,strokeWidth:null,style:null,surfaceScale:R,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xe,tabIndex:R,tableValues:null,target:null,targetX:R,targetY:R,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:R,underlineThickness:R,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:R,values:null,vAlphabetic:R,vMathematical:R,vectorEffect:null,vHanging:R,vIdeographic:R,version:null,vertAdvY:R,vertOriginX:R,vertOriginY:R,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:R,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:zo}),Fo=on({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),$o=on({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Oo}),Bo=on({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),oh={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},lh=/[A-Z]/g,Qs=/-[a-z]/g,ch=/^data[-\w.:]+$/i;function uh(e,t){const n=bi(t);let r=t,i=Qe;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ch.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Qs,fh);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Qs.test(s)){let a=s.replace(lh,dh);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Hi}return new i(r,t)}function dh(e){return"-"+e.toLowerCase()}function fh(e){return e.charAt(1).toUpperCase()}const hh=Lo([Do,sh,Fo,$o,Bo],"html"),Zi=Lo([Do,ah,Fo,$o,Bo],"svg");function ph(e){return e.join(" ").trim()}var Bt={},Fr,Ks;function mh(){if(Ks)return Fr;Ks=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,c=`
|
|
3
|
-
`,u="/",d="*",f="",p="comment",h="declaration";function m(S,k){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];k=k||{};var A=1,I=1;function W(q){var L=q.match(t);L&&(A+=L.length);var ie=q.lastIndexOf(c);I=~ie?q.length-ie:I+q.length}function Q(){var q={line:A,column:I};return function(L){return L.position=new j(q),J(),L}}function j(q){this.start=q,this.end={line:A,column:I},this.source=k.source}j.prototype.content=S;function Y(q){var L=new Error(k.source+":"+A+":"+I+": "+q);if(L.reason=q,L.filename=k.source,L.line=A,L.column=I,L.source=S,!k.silent)throw L}function X(q){var L=q.exec(S);if(L){var ie=L[0];return W(ie),S=S.slice(ie.length),L}}function J(){X(n)}function _(q){var L;for(q=q||[];L=$();)L!==!1&&q.push(L);return q}function $(){var q=Q();if(!(u!=S.charAt(0)||d!=S.charAt(1))){for(var L=2;f!=S.charAt(L)&&(d!=S.charAt(L)||u!=S.charAt(L+1));)++L;if(L+=2,f===S.charAt(L-1))return Y("End of comment missing");var ie=S.slice(2,L-2);return I+=2,W(ie),S=S.slice(L),I+=2,q({type:p,comment:ie})}}function B(){var q=Q(),L=X(r);if(L){if($(),!X(i))return Y("property missing ':'");var ie=X(s),be=q({type:h,property:b(L[0].replace(e,f)),value:ie?b(ie[0].replace(e,f)):f});return X(a),be}}function ae(){var q=[];_(q);for(var L;L=B();)L!==!1&&(q.push(L),_(q));return q}return J(),ae()}function b(S){return S?S.replace(o,f):f}return Fr=m,Fr}var Ys;function gh(){if(Ys)return Bt;Ys=1;var e=Bt&&Bt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.default=n;const t=e(mh());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const a=(0,t.default)(r),o=typeof i=="function";return a.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;o?i(u,d,c):d&&(s=s||{},s[u]=d)}),s}return Bt}var fn={},Xs;function xh(){if(Xs)return fn;Xs=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},a=function(u,d){return d.toUpperCase()},o=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,o):u=u.replace(r,o),u.replace(t,a))};return fn.camelCase=c,fn}var hn,Js;function yh(){if(Js)return hn;Js=1;var e=hn&&hn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(gh()),n=xh();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,c){o&&c&&(a[(0,n.camelCase)(o,s)]=c)}),a}return r.default=r,hn=r,hn}var bh=yh();const kh=Xa(bh),qo=Vo("end"),Wi=Vo("start");function Vo(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function vh(e){const t=Wi(e),n=qo(e);if(t&&n)return{start:t,end:n}}function xn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Gs(e.position):"start"in e||"end"in e?Gs(e):"line"in e||"column"in e?wi(e):""}function wi(e){return ea(e&&e.line)+":"+ea(e&&e.column)}function Gs(e){return wi(e&&e.start)+"-"+wi(e&&e.end)}function ea(e){return e&&typeof e=="number"?e:1}class Oe extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=xn(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Oe.prototype.file="";Oe.prototype.name="";Oe.prototype.reason="";Oe.prototype.message="";Oe.prototype.stack="";Oe.prototype.column=void 0;Oe.prototype.line=void 0;Oe.prototype.ancestors=void 0;Oe.prototype.cause=void 0;Oe.prototype.fatal=void 0;Oe.prototype.place=void 0;Oe.prototype.ruleId=void 0;Oe.prototype.source=void 0;const Qi={}.hasOwnProperty,wh=new Map,Sh=/[A-Z]/g,_h=new Set(["table","tbody","thead","tfoot","tr"]),jh=new Set(["td","th"]),Uo="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ch(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Rh(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Mh(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Zi:hh,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Ho(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Ho(e,t,n){if(t.type==="element")return Nh(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ih(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Ah(e,t,n);if(t.type==="mdxjsEsm")return Th(e,t);if(t.type==="root")return Eh(e,t,n);if(t.type==="text")return Ph(e,t)}function Nh(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Zi,e.schema=i),e.ancestors.push(t);const s=Wo(e,t.tagName,!1),a=Lh(e,t);let o=Yi(e,t);return _h.has(t.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!rh(c):!0})),Zo(e,a,s,t),Ki(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Ih(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return ot(r.type==="ExpressionStatement"),e.evaluater.evaluateExpression(r.expression)}Sn(e,t.position)}function Th(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sn(e,t.position)}function Ah(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Zi,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:Wo(e,t.name,!0),a=Dh(e,t),o=Yi(e,t);return Zo(e,a,s,t),Ki(a,o),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function Eh(e,t,n){const r={};return Ki(r,Yi(e,t)),e.create(t,e.Fragment,r,n)}function Ph(e,t){return t.value}function Zo(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ki(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Mh(e,t,n){return r;function r(i,s,a,o){const u=Array.isArray(a.children)?n:t;return o?u(s,a,o):u(s,a)}}function Rh(e,t){return n;function n(r,i,s,a){const o=Array.isArray(s.children),c=Wi(r);return t(i,s,a,o,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Lh(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Qi.call(t.properties,i)){const s=zh(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&jh.has(t.tagName)?r=o:n[a]=o}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Dh(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];ot(s.type==="ExpressionStatement");const a=s.expression;ot(a.type==="ObjectExpression");const o=a.properties[0];ot(o.type==="SpreadElement"),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else Sn(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];ot(o.type==="ExpressionStatement"),s=e.evaluater.evaluateExpression(o.expression)}else Sn(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Yi(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:wh;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const u=i.get(c)||0;a=c+"-"+u,i.set(c,u+1)}}const o=Ho(e,s,a);o!==void 0&&n.push(o)}return n}function zh(e,t,n){const r=uh(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Jf(n):ph(n)),r.property==="style"){let i=typeof n=="object"?n:Oh(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Fh(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?oh[r.property]||r.property:r.attribute,n]}}function Oh(e,t){try{return kh(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Oe("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Uo+"#cannot-parse-style-attribute",i}}function Wo(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Hs(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}r=a}else r=Hs(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Qi.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Sn(e)}function Sn(e,t){const n=new Oe("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Uo+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Fh(e){const t={};let n;for(n in e)Qi.call(e,n)&&(t[$h(n)]=e[n]);return t}function $h(e){let t=e.replace(Sh,Bh);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Bh(e){return"-"+e.toLowerCase()}const $r={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},qh={};function Xi(e,t){const n=qh,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Qo(e,r,i)}function Qo(e,t,n){if(Vh(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return ta(e.children,t,n)}return Array.isArray(e)?ta(e,t,n):""}function ta(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Qo(e[i],t,n);return r.join("")}function Vh(e){return!!(e&&typeof e=="object")}const na=document.createElement("i");function Ji(e){const t="&"+e+";";na.innerHTML=t;const n=na.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Je(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Ge(e,t){return e.length>0?(Je(e,e.length,0,t),e):t}const ra={}.hasOwnProperty;function Ko(e){const t={};let n=-1;for(;++n<e.length;)Uh(t,e[n]);return t}function Uh(e,t){let n;for(n in t){const i=(ra.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){ra.call(i,a)||(i[a]=[]);const o=s[a];Hh(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Hh(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Je(e,0,0,r)}function Yo(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function lt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ue=It(/[A-Za-z]/),ze=It(/[\dA-Za-z]/),Zh=It(/[#-'*+\--9=?A-Z^-~]/);function er(e){return e!==null&&(e<32||e===127)}const Si=It(/\d/),Wh=It(/[\dA-Fa-f]/),Qh=It(/[!-/:-@[-`{-~]/);function K(e){return e!==null&&e<-2}function Te(e){return e!==null&&(e<0||e===32)}function me(e){return e===-2||e===-1||e===32}const br=It(new RegExp("\\p{P}|\\p{S}","u")),Dt=It(/\s/);function It(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ln(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&ze(e.charCodeAt(n+1))&&ze(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(n+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ye(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(c){return me(c)?(e.enter(n),o(c)):t(c)}function o(c){return me(c)&&s++<i?(e.consume(c),o):(e.exit(n),t(c))}}const Kh={tokenize:Yh};function Yh(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ye(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return K(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Xh={tokenize:Jh},ia={tokenize:Gh};function Jh(e){const t=this,n=[];let r=0,i,s,a;return o;function o(I){if(r<n.length){const W=n[r];return t.containerState=W[1],e.attempt(W[0].continuation,c,u)(I)}return u(I)}function c(I){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const W=t.events.length;let Q=W,j;for(;Q--;)if(t.events[Q][0]==="exit"&&t.events[Q][1].type==="chunkFlow"){j=t.events[Q][1].end;break}k(r);let Y=W;for(;Y<t.events.length;)t.events[Y][1].end={...j},Y++;return Je(t.events,Q+1,0,t.events.slice(W)),t.events.length=Y,u(I)}return o(I)}function u(I){if(r===n.length){if(!i)return p(I);if(i.currentConstruct&&i.currentConstruct.concrete)return m(I);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ia,d,f)(I)}function d(I){return i&&A(),k(r),p(I)}function f(I){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,m(I)}function p(I){return t.containerState={},e.attempt(ia,h,m)(I)}function h(I){return r++,n.push([t.currentConstruct,t.containerState]),p(I)}function m(I){if(I===null){i&&A(),k(0),e.consume(I);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),b(I)}function b(I){if(I===null){S(e.exit("chunkFlow"),!0),k(0),e.consume(I);return}return K(I)?(e.consume(I),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(I),b)}function S(I,W){const Q=t.sliceStream(I);if(W&&Q.push(null),I.previous=s,s&&(s.next=I),s=I,i.defineSkip(I.start),i.write(Q),t.parser.lazy[I.start.line]){let j=i.events.length;for(;j--;)if(i.events[j][1].start.offset<a&&(!i.events[j][1].end||i.events[j][1].end.offset>a))return;const Y=t.events.length;let X=Y,J,_;for(;X--;)if(t.events[X][0]==="exit"&&t.events[X][1].type==="chunkFlow"){if(J){_=t.events[X][1].end;break}J=!0}for(k(r),j=Y;j<t.events.length;)t.events[j][1].end={..._},j++;Je(t.events,X+1,0,t.events.slice(Y)),t.events.length=j}}function k(I){let W=n.length;for(;W-- >I;){const Q=n[W];t.containerState=Q[1],Q[0].exit.call(t,e)}n.length=I}function A(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Gh(e,t,n){return ye(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function nn(e){if(e===null||Te(e)||Dt(e))return 1;if(br(e))return 2}function kr(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const _i={name:"attention",resolveAll:ep,tokenize:tp};function ep(e,t){let n=-1,r,i,s,a,o,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};sa(f,-c),sa(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},e[r][1].end={...a.start},e[n][1].start={...o.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ge(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ge(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Ge(u,kr(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ge(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Ge(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Je(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function tp(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nn(r);let s;return a;function a(c){return s=c,e.enter("attentionSequence"),o(c)}function o(c){if(c===s)return e.consume(c),o;const u=e.exit("attentionSequence"),d=nn(c),f=!d||d===2&&i||n.includes(c),p=!i||i===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(i||!p)),u._close=!!(s===42?p:p&&(d||!f)),t(c)}}function sa(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const np={name:"autolink",tokenize:rp};function rp(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return Ue(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||ze(h)?(r=1,o(h)):u(h)}function o(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||ze(h))&&r++<32?(e.consume(h),o):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||er(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):Zh(h)?(e.consume(h),u):n(h)}function d(h){return ze(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||ze(h))&&r++<63){const m=h===45?p:f;return e.consume(h),m}return n(h)}}const An={partial:!0,tokenize:ip};function ip(e,t,n){return r;function r(s){return me(s)?ye(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||K(s)?t(s):n(s)}}const Xo={continuation:{tokenize:ap},exit:op,name:"blockQuote",tokenize:sp};function sp(e,t,n){const r=this;return i;function i(a){if(a===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return me(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function ap(e,t,n){const r=this;return i;function i(a){return me(a)?ye(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(Xo,t,n)(a)}}function op(e){e.exit("blockQuote")}const Jo={name:"characterEscape",tokenize:lp};function lp(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Qh(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Go={name:"characterReference",tokenize:cp};function cp(e,t,n){const r=this;let i=0,s,a;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=ze,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Wh,d):(e.enter("characterReferenceValue"),s=7,a=Si,d(f))}function d(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return a===ze&&!Ji(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&i++<s?(e.consume(f),d):n(f)}}const aa={partial:!0,tokenize:dp},oa={concrete:!0,name:"codeFenced",tokenize:up};function up(e,t,n){const r=this,i={partial:!0,tokenize:Q};let s=0,a=0,o;return c;function c(j){return u(j)}function u(j){const Y=r.events[r.events.length-1];return s=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,o=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(j)}function d(j){return j===o?(a++,e.consume(j),d):a<3?n(j):(e.exit("codeFencedFenceSequence"),me(j)?ye(e,f,"whitespace")(j):f(j))}function f(j){return j===null||K(j)?(e.exit("codeFencedFence"),r.interrupt?t(j):e.check(aa,b,W)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(j))}function p(j){return j===null||K(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(j)):me(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ye(e,h,"whitespace")(j)):j===96&&j===o?n(j):(e.consume(j),p)}function h(j){return j===null||K(j)?f(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(j))}function m(j){return j===null||K(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(j)):j===96&&j===o?n(j):(e.consume(j),m)}function b(j){return e.attempt(i,W,S)(j)}function S(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),k}function k(j){return s>0&&me(j)?ye(e,A,"linePrefix",s+1)(j):A(j)}function A(j){return j===null||K(j)?e.check(aa,b,W)(j):(e.enter("codeFlowValue"),I(j))}function I(j){return j===null||K(j)?(e.exit("codeFlowValue"),A(j)):(e.consume(j),I)}function W(j){return e.exit("codeFenced"),t(j)}function Q(j,Y,X){let J=0;return _;function _(L){return j.enter("lineEnding"),j.consume(L),j.exit("lineEnding"),$}function $(L){return j.enter("codeFencedFence"),me(L)?ye(j,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):B(L)}function B(L){return L===o?(j.enter("codeFencedFenceSequence"),ae(L)):X(L)}function ae(L){return L===o?(J++,j.consume(L),ae):J>=a?(j.exit("codeFencedFenceSequence"),me(L)?ye(j,q,"whitespace")(L):q(L)):X(L)}function q(L){return L===null||K(L)?(j.exit("codeFencedFence"),Y(L)):X(L)}}}function dp(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Br={name:"codeIndented",tokenize:hp},fp={partial:!0,tokenize:pp};function hp(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),ye(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):K(u)?e.attempt(fp,a,c)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||K(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function c(u){return e.exit("codeIndented"),t(u)}}function pp(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):K(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ye(e,s,"linePrefix",5)(a)}function s(a){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):K(a)?i(a):n(a)}}const mp={name:"codeText",previous:xp,resolve:gp,tokenize:yp};function gp(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function xp(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function yp(e,t,n){let r=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),r++,o):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),i=0,d(f)):K(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||K(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class bp{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&pn(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),pn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),pn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);pn(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);pn(this.left,n.reverse())}}}function pn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function el(e){const t={};let n=-1,r,i,s,a,o,c,u;const d=new bp(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,kp(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=d.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},o=d.slice(i,n),o.unshift(r),d.splice(i,n-i+1,o))}}return Je(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function kp(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,c=[],u={};let d,f,p=-1,h=n,m=0,b=0;const S=[b];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<o.length;)o[p][0]==="exit"&&o[p-1][0]==="enter"&&o[p][1].type===o[p-1][1].type&&o[p][1].start.line!==o[p][1].end.line&&(b=p+1,S.push(b),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const k=o.slice(S[p],S[p+1]),A=s.pop();c.push([A,A+k.length-1]),e.splice(A,2,k)}for(c.reverse(),p=-1;++p<c.length;)u[m+c[p][0]]=m+c[p][1],m+=c[p][1]-c[p][0]-1;return u}const vp={resolve:Sp,tokenize:_p},wp={partial:!0,tokenize:jp};function Sp(e){return el(e),e}function _p(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):K(o)?e.check(wp,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jp(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ye(e,s,"linePrefix")}function s(a){if(a===null||K(a))return n(a);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function tl(e,t,n,r,i,s,a,o,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(k){return k===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(k),e.exit(s),p):k===null||k===32||k===41||er(k)?n(k):(e.enter(r),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),b(k))}function p(k){return k===62?(e.enter(s),e.consume(k),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===62?(e.exit("chunkString"),e.exit(o),p(k)):k===null||k===60||K(k)?n(k):(e.consume(k),k===92?m:h)}function m(k){return k===60||k===62||k===92?(e.consume(k),h):h(k)}function b(k){return!d&&(k===null||k===41||Te(k))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(r),t(k)):d<u&&k===40?(e.consume(k),d++,b):k===41?(e.consume(k),d--,b):k===null||k===32||k===40||er(k)?n(k):(e.consume(k),k===92?S:b)}function S(k){return k===40||k===41||k===92?(e.consume(k),b):b(k)}}function nl(e,t,n,r,i,s){const a=this;let o=0,c;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return o>999||h===null||h===91||h===93&&!c||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):K(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||K(h)||o++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!me(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,f):f(h)}}function rl(e,t,n,r,i,s){let a;return o;function o(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),u(p))}function u(p){return p===a?(e.exit(s),c(a)):p===null?n(p):K(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ye(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||K(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:d)}function f(p){return p===a||p===92?(e.consume(p),d):d(p)}}function yn(e,t){let n;return r;function r(i){return K(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):me(i)?ye(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Cp={name:"definition",tokenize:Ip},Np={partial:!0,tokenize:Tp};function Ip(e,t,n){const r=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return nl.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return Te(h)?yn(e,u)(h):u(h)}function u(h){return tl(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(Np,f,f)(h)}function f(h){return me(h)?ye(e,p,"whitespace")(h):p(h)}function p(h){return h===null||K(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Tp(e,t,n){return r;function r(o){return Te(o)?yn(e,i)(o):n(o)}function i(o){return rl(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return me(o)?ye(e,a,"whitespace")(o):a(o)}function a(o){return o===null||K(o)?t(o):n(o)}}const Ap={name:"hardBreakEscape",tokenize:Ep};function Ep(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return K(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Pp={name:"headingAtx",resolve:Mp,tokenize:Rp};function Mp(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Je(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Rp(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||Te(d)?(e.exit("atxHeadingSequence"),o(d)):n(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||K(d)?(e.exit("atxHeading"),t(d)):me(d)?ye(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||Te(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const Lp=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],la=["pre","script","style","textarea"],Dp={concrete:!0,name:"htmlFlow",resolveTo:Fp,tokenize:$p},zp={partial:!0,tokenize:qp},Op={partial:!0,tokenize:Bp};function Fp(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function $p(e,t,n){const r=this;let i,s,a,o,c;return u;function u(y){return d(y)}function d(y){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(y),f}function f(y){return y===33?(e.consume(y),p):y===47?(e.consume(y),s=!0,b):y===63?(e.consume(y),i=3,r.interrupt?t:x):Ue(y)?(e.consume(y),a=String.fromCharCode(y),S):n(y)}function p(y){return y===45?(e.consume(y),i=2,h):y===91?(e.consume(y),i=5,o=0,m):Ue(y)?(e.consume(y),i=4,r.interrupt?t:x):n(y)}function h(y){return y===45?(e.consume(y),r.interrupt?t:x):n(y)}function m(y){const Ne="CDATA[";return y===Ne.charCodeAt(o++)?(e.consume(y),o===Ne.length?r.interrupt?t:B:m):n(y)}function b(y){return Ue(y)?(e.consume(y),a=String.fromCharCode(y),S):n(y)}function S(y){if(y===null||y===47||y===62||Te(y)){const Ne=y===47,Le=a.toLowerCase();return!Ne&&!s&&la.includes(Le)?(i=1,r.interrupt?t(y):B(y)):Lp.includes(a.toLowerCase())?(i=6,Ne?(e.consume(y),k):r.interrupt?t(y):B(y)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(y):s?A(y):I(y))}return y===45||ze(y)?(e.consume(y),a+=String.fromCharCode(y),S):n(y)}function k(y){return y===62?(e.consume(y),r.interrupt?t:B):n(y)}function A(y){return me(y)?(e.consume(y),A):_(y)}function I(y){return y===47?(e.consume(y),_):y===58||y===95||Ue(y)?(e.consume(y),W):me(y)?(e.consume(y),I):_(y)}function W(y){return y===45||y===46||y===58||y===95||ze(y)?(e.consume(y),W):Q(y)}function Q(y){return y===61?(e.consume(y),j):me(y)?(e.consume(y),Q):I(y)}function j(y){return y===null||y===60||y===61||y===62||y===96?n(y):y===34||y===39?(e.consume(y),c=y,Y):me(y)?(e.consume(y),j):X(y)}function Y(y){return y===c?(e.consume(y),c=null,J):y===null||K(y)?n(y):(e.consume(y),Y)}function X(y){return y===null||y===34||y===39||y===47||y===60||y===61||y===62||y===96||Te(y)?Q(y):(e.consume(y),X)}function J(y){return y===47||y===62||me(y)?I(y):n(y)}function _(y){return y===62?(e.consume(y),$):n(y)}function $(y){return y===null||K(y)?B(y):me(y)?(e.consume(y),$):n(y)}function B(y){return y===45&&i===2?(e.consume(y),ie):y===60&&i===1?(e.consume(y),be):y===62&&i===4?(e.consume(y),M):y===63&&i===3?(e.consume(y),x):y===93&&i===5?(e.consume(y),D):K(y)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(zp,Ce,ae)(y)):y===null||K(y)?(e.exit("htmlFlowData"),ae(y)):(e.consume(y),B)}function ae(y){return e.check(Op,q,Ce)(y)}function q(y){return e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),L}function L(y){return y===null||K(y)?ae(y):(e.enter("htmlFlowData"),B(y))}function ie(y){return y===45?(e.consume(y),x):B(y)}function be(y){return y===47?(e.consume(y),a="",le):B(y)}function le(y){if(y===62){const Ne=a.toLowerCase();return la.includes(Ne)?(e.consume(y),M):B(y)}return Ue(y)&&a.length<8?(e.consume(y),a+=String.fromCharCode(y),le):B(y)}function D(y){return y===93?(e.consume(y),x):B(y)}function x(y){return y===62?(e.consume(y),M):y===45&&i===2?(e.consume(y),x):B(y)}function M(y){return y===null||K(y)?(e.exit("htmlFlowData"),Ce(y)):(e.consume(y),M)}function Ce(y){return e.exit("htmlFlow"),t(y)}}function Bp(e,t,n){const r=this;return i;function i(a){return K(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function qp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(An,t,n)}}const Vp={name:"htmlText",tokenize:Up};function Up(e,t,n){const r=this;let i,s,a;return o;function o(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),c}function c(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),Q):x===63?(e.consume(x),I):Ue(x)?(e.consume(x),X):n(x)}function u(x){return x===45?(e.consume(x),d):x===91?(e.consume(x),s=0,m):Ue(x)?(e.consume(x),A):n(x)}function d(x){return x===45?(e.consume(x),h):n(x)}function f(x){return x===null?n(x):x===45?(e.consume(x),p):K(x)?(a=f,be(x)):(e.consume(x),f)}function p(x){return x===45?(e.consume(x),h):f(x)}function h(x){return x===62?ie(x):x===45?p(x):f(x)}function m(x){const M="CDATA[";return x===M.charCodeAt(s++)?(e.consume(x),s===M.length?b:m):n(x)}function b(x){return x===null?n(x):x===93?(e.consume(x),S):K(x)?(a=b,be(x)):(e.consume(x),b)}function S(x){return x===93?(e.consume(x),k):b(x)}function k(x){return x===62?ie(x):x===93?(e.consume(x),k):b(x)}function A(x){return x===null||x===62?ie(x):K(x)?(a=A,be(x)):(e.consume(x),A)}function I(x){return x===null?n(x):x===63?(e.consume(x),W):K(x)?(a=I,be(x)):(e.consume(x),I)}function W(x){return x===62?ie(x):I(x)}function Q(x){return Ue(x)?(e.consume(x),j):n(x)}function j(x){return x===45||ze(x)?(e.consume(x),j):Y(x)}function Y(x){return K(x)?(a=Y,be(x)):me(x)?(e.consume(x),Y):ie(x)}function X(x){return x===45||ze(x)?(e.consume(x),X):x===47||x===62||Te(x)?J(x):n(x)}function J(x){return x===47?(e.consume(x),ie):x===58||x===95||Ue(x)?(e.consume(x),_):K(x)?(a=J,be(x)):me(x)?(e.consume(x),J):ie(x)}function _(x){return x===45||x===46||x===58||x===95||ze(x)?(e.consume(x),_):$(x)}function $(x){return x===61?(e.consume(x),B):K(x)?(a=$,be(x)):me(x)?(e.consume(x),$):J(x)}function B(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,ae):K(x)?(a=B,be(x)):me(x)?(e.consume(x),B):(e.consume(x),q)}function ae(x){return x===i?(e.consume(x),i=void 0,L):x===null?n(x):K(x)?(a=ae,be(x)):(e.consume(x),ae)}function q(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||Te(x)?J(x):(e.consume(x),q)}function L(x){return x===47||x===62||Te(x)?J(x):n(x)}function ie(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function be(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),le}function le(x){return me(x)?ye(e,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):D(x)}function D(x){return e.enter("htmlTextData"),a(x)}}const Gi={name:"labelEnd",resolveAll:Qp,resolveTo:Kp,tokenize:Yp},Hp={tokenize:Xp},Zp={tokenize:Jp},Wp={tokenize:Gp};function Qp(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Je(e,0,e.length,n),e}function Kp(e,t){let n=e.length,r=0,i,s,a,o;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const c={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return o=[["enter",c,t],["enter",u,t]],o=Ge(o,e.slice(s+1,s+r+3)),o=Ge(o,[["enter",d,t]]),o=Ge(o,kr(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),o=Ge(o,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),o=Ge(o,e.slice(a+1)),o=Ge(o,[["exit",c,t]]),Je(e,s,e.length,o),e}function Yp(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return o;function o(p){return s?s._inactive?f(p):(a=r.parser.defined.includes(lt(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(Hp,d,a?d:f)(p):p===91?e.attempt(Zp,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(Wp,d,f)(p)}function d(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function Xp(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Te(f)?yn(e,s)(f):s(f)}function s(f){return f===41?d(f):tl(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Te(f)?yn(e,c)(f):d(f)}function o(f){return n(f)}function c(f){return f===34||f===39||f===40?rl(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Te(f)?yn(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Jp(e,t,n){const r=this;return i;function i(o){return nl.call(r,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return r.parser.defined.includes(lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function a(o){return n(o)}}function Gp(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const em={name:"labelStartImage",resolveAll:Gi.resolveAll,tokenize:tm};function tm(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):n(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const nm={name:"labelStartLink",resolveAll:Gi.resolveAll,tokenize:rm};function rm(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const qr={name:"lineEnding",tokenize:im};function im(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ye(e,t,"linePrefix")}}const Vn={name:"thematicBreak",tokenize:sm};function sm(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||K(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),me(u)?ye(e,o,"whitespace")(u):o(u))}}const We={continuation:{tokenize:cm},exit:dm,name:"list",tokenize:lm},am={partial:!0,tokenize:fm},om={partial:!0,tokenize:um};function lm(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(h){const m=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Si(h)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Vn,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Si(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(An,r.interrupt?n:d,e.attempt(am,p,f))}function d(h){return r.containerState.initialBlankLine=!0,s++,p(h)}function f(h){return me(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function cm(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(An,i,s);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ye(e,t,"listItemIndent",r.containerState.size+1)(o)}function s(o){return r.containerState.furtherBlankLines||!me(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(om,t,a)(o))}function a(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,ye(e,e.attempt(We,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function um(e,t,n){const r=this;return ye(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function dm(e){e.exit(this.containerState.type)}function fm(e,t,n){const r=this;return ye(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!me(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ca={name:"setextUnderline",resolveTo:hm,tokenize:pm};function hm(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function pm(e,t,n){const r=this;let i;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),me(u)?ye(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||K(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const mm={tokenize:gm};function gm(e){const t=this,n=e.attempt(An,r,e.attempt(this.parser.constructs.flowInitial,i,ye(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vp,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const xm={resolveAll:sl()},ym=il("string"),bm=il("text");function il(e){return{resolveAll:sl(e==="text"?km:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,o);return a;function a(d){return u(d)?s(d):o(d)}function o(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=i[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function sl(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function km(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,o=0,c;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)c=!0,o++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const u={type:n===e.length||c||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const vm={42:We,43:We,45:We,48:We,49:We,50:We,51:We,52:We,53:We,54:We,55:We,56:We,57:We,62:Xo},wm={91:Cp},Sm={[-2]:Br,[-1]:Br,32:Br},_m={35:Pp,42:Vn,45:[ca,Vn],60:Dp,61:ca,95:Vn,96:oa,126:oa},jm={38:Go,92:Jo},Cm={[-5]:qr,[-4]:qr,[-3]:qr,33:em,38:Go,42:_i,60:[np,Vp],91:nm,92:[Ap,Jo],93:Gi,95:_i,96:mp},Nm={null:[_i,xm]},Im={null:[42,95]},Tm={null:[]},Am=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Im,contentInitial:wm,disable:Tm,document:vm,flow:_m,flowInitial:Sm,insideSpan:Nm,string:jm,text:Cm},Symbol.toStringTag,{value:"Module"}));function Em(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],o=[];const c={attempt:Y(Q),check:Y(j),consume:A,enter:I,exit:W,interrupt:Y(j,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:m,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&s.push(t),u;function f($){return a=Ge(a,$),S(),a[a.length-1]!==null?[]:(X(t,0),u.events=kr(s,u.events,u),u.events)}function p($,B){return Mm(h($),B)}function h($){return Pm(a,$)}function m(){const{_bufferIndex:$,_index:B,line:ae,column:q,offset:L}=r;return{_bufferIndex:$,_index:B,line:ae,column:q,offset:L}}function b($){i[$.line]=$.column,_()}function S(){let $;for(;r._index<a.length;){const B=a[r._index];if(typeof B=="string")for($=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===$&&r._bufferIndex<B.length;)k(B.charCodeAt(r._bufferIndex));else k(B)}}function k($){d=d($)}function A($){K($)?(r.line++,r.column=1,r.offset+=$===-3?2:1,_()):$!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=$}function I($,B){const ae=B||{};return ae.type=$,ae.start=m(),u.events.push(["enter",ae,u]),o.push(ae),ae}function W($){const B=o.pop();return B.end=m(),u.events.push(["exit",B,u]),B}function Q($,B){X($,B.from)}function j($,B){B.restore()}function Y($,B){return ae;function ae(q,L,ie){let be,le,D,x;return Array.isArray(q)?Ce(q):"tokenize"in q?Ce([q]):M(q);function M(Ie){return Fe;function Fe(ce){const Ke=ce!==null&&Ie[ce],$e=ce!==null&&Ie.null,C=[...Array.isArray(Ke)?Ke:Ke?[Ke]:[],...Array.isArray($e)?$e:$e?[$e]:[]];return Ce(C)(ce)}}function Ce(Ie){return be=Ie,le=0,Ie.length===0?ie:y(Ie[le])}function y(Ie){return Fe;function Fe(ce){return x=J(),D=Ie,Ie.partial||(u.currentConstruct=Ie),Ie.name&&u.parser.constructs.disable.null.includes(Ie.name)?Le():Ie.tokenize.call(B?Object.assign(Object.create(u),B):u,c,Ne,Le)(ce)}}function Ne(Ie){return $(D,x),L}function Le(Ie){return x.restore(),++le<be.length?y(be[le]):ie}}}function X($,B){$.resolveAll&&!s.includes($)&&s.push($),$.resolve&&Je(u.events,B,u.events.length-B,$.resolve(u.events.slice(B),u)),$.resolveTo&&(u.events=$.resolveTo(u.events,u))}function J(){const $=m(),B=u.previous,ae=u.currentConstruct,q=u.events.length,L=Array.from(o);return{from:q,restore:ie};function ie(){r=$,u.previous=B,u.currentConstruct=ae,u.events.length=q,o=L,_()}}function _(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Pm(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Mm(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
|
|
4
|
-
`;break}case-3:{a=`\r
|
|
5
|
-
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Rm(e){const r={constructs:Ko([Am,...(e||{}).extensions||[]]),content:i(Kh),defined:[],document:i(Xh),flow:i(mm),lazy:{},string:i(ym),text:i(bm)};return r;function i(s){return a;function a(o){return Em(r,s,o)}}}function Lm(e){for(;!el(e););return e}const ua=/[\0\t\n\r]/g;function Dm(){let e=1,t="",n=!0,r;return i;function i(s,a,o){const c=[];let u,d,f,p,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(ua.lastIndex=f,u=ua.exec(s),p=u&&u.index!==void 0?u.index:s.length,h=s.charCodeAt(p),!u){t=s.slice(f);break}if(h===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(s.slice(f,p)),e+=p-f),h){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return o&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const zm=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Om(e){return e.replace(zm,Fm)}function Fm(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Yo(n.slice(s?2:1),s?16:10)}return Ji(n)||e}const al={}.hasOwnProperty;function $m(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Bm(n)(Lm(Rm(n).document().write(Dm()(e,t,!0))))}function Bm(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(se),autolinkProtocol:J,autolinkEmail:J,atxHeading:s(we),blockQuote:s($e),characterEscape:J,characterReference:J,codeFenced:s(C),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(C,a),codeText:s(F,a),codeTextData:J,data:J,codeFlowValue:J,definition:s(te),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(_e),hardBreakEscape:s(De),hardBreakTrailing:s(De),htmlFlow:s(Tt,a),htmlFlowData:J,htmlText:s(Tt,a),htmlTextData:J,image:s(Nr),label:a,link:s(se),listItem:s(P),listItemValue:p,listOrdered:s(Ze,f),listUnordered:s(Ze),paragraph:s(Ft),reference:y,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(we),strong:s(Be),thematicBreak:s(qe)},exit:{atxHeading:c(),atxHeadingSequence:Q,autolink:c(),autolinkEmail:Ke,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:Le,characterReferenceMarkerNumeric:Le,characterReferenceValue:Ie,characterReference:Fe,codeFenced:c(S),codeFencedFence:b,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:_,codeIndented:c(k),codeText:c(L),codeTextData:_,data:_,definition:c(),definitionDestinationString:W,definitionLabelString:A,definitionTitleString:I,emphasis:c(),hardBreakEscape:c(B),hardBreakTrailing:c(B),htmlFlow:c(ae),htmlFlowData:_,htmlText:c(q),htmlTextData:_,image:c(be),label:D,labelText:le,lineEnding:$,link:c(ie),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Ne,resourceDestinationString:x,resourceTitleString:M,resource:Ce,setextHeading:c(X),setextHeadingLineSequence:Y,setextHeadingText:j,strong:c(),thematicBreak:c()}};ol(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(N){let O={type:"root",children:[]};const G={stack:[O],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:d,data:n},fe=[];let je=-1;for(;++je<N.length;)if(N[je][1].type==="listOrdered"||N[je][1].type==="listUnordered")if(N[je][0]==="enter")fe.push(je);else{const Ye=fe.pop();je=i(N,Ye,je)}for(je=-1;++je<N.length;){const Ye=t[N[je][0]];al.call(Ye,N[je][1].type)&&Ye[N[je][1].type].call(Object.assign({sliceSerialize:N[je][2].sliceSerialize},G),N[je][1])}if(G.tokenStack.length>0){const Ye=G.tokenStack[G.tokenStack.length-1];(Ye[1]||da).call(G,void 0,Ye[0])}for(O.position={start:wt(N.length>0?N[0][1].start:{line:1,column:1,offset:0}),end:wt(N.length>0?N[N.length-2][1].end:{line:1,column:1,offset:0})},je=-1;++je<t.transforms.length;)O=t.transforms[je](O)||O;return O}function i(N,O,G){let fe=O-1,je=-1,Ye=!1,ct,rt,At,it;for(;++fe<=G;){const Re=N[fe];switch(Re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Re[0]==="enter"?je++:je--,it=void 0;break}case"lineEndingBlank":{Re[0]==="enter"&&(ct&&!it&&!je&&!At&&(At=fe),it=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:it=void 0}if(!je&&Re[0]==="enter"&&Re[1].type==="listItemPrefix"||je===-1&&Re[0]==="exit"&&(Re[1].type==="listUnordered"||Re[1].type==="listOrdered")){if(ct){let xt=fe;for(rt=void 0;xt--;){const st=N[xt];if(st[1].type==="lineEnding"||st[1].type==="lineEndingBlank"){if(st[0]==="exit")continue;rt&&(N[rt][1].type="lineEndingBlank",Ye=!0),st[1].type="lineEnding",rt=xt}else if(!(st[1].type==="linePrefix"||st[1].type==="blockQuotePrefix"||st[1].type==="blockQuotePrefixWhitespace"||st[1].type==="blockQuoteMarker"||st[1].type==="listItemIndent"))break}At&&(!rt||At<rt)&&(ct._spread=!0),ct.end=Object.assign({},rt?N[rt][1].start:Re[1].end),N.splice(rt||fe,0,["exit",ct,Re[2]]),fe++,G++}if(Re[1].type==="listItemPrefix"){const xt={type:"listItem",_spread:!1,start:Object.assign({},Re[1].start),end:void 0};ct=xt,N.splice(fe,0,["enter",xt,Re[2]]),fe++,G++,At=void 0,it=!0}}}return N[O][1]._spread=Ye,G}function s(N,O){return G;function G(fe){o.call(this,N(fe),fe),O&&O.call(this,fe)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(N,O,G){this.stack[this.stack.length-1].children.push(N),this.stack.push(N),this.tokenStack.push([O,G||void 0]),N.position={start:wt(O.start),end:void 0}}function c(N){return O;function O(G){N&&N.call(this,G),u.call(this,G)}}function u(N,O){const G=this.stack.pop(),fe=this.tokenStack.pop();if(fe)fe[0].type!==N.type&&(O?O.call(this,N,fe[0]):(fe[1]||da).call(this,N,fe[0]));else throw new Error("Cannot close `"+N.type+"` ("+xn({start:N.start,end:N.end})+"): it’s not open");G.position.end=wt(N.end)}function d(){return Xi(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(N){if(this.data.expectingFirstListItemValue){const O=this.stack[this.stack.length-2];O.start=Number.parseInt(this.sliceSerialize(N),10),this.data.expectingFirstListItemValue=void 0}}function h(){const N=this.resume(),O=this.stack[this.stack.length-1];O.lang=N}function m(){const N=this.resume(),O=this.stack[this.stack.length-1];O.meta=N}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N.replace(/(\r?\n|\r)$/g,"")}function A(N){const O=this.resume(),G=this.stack[this.stack.length-1];G.label=O,G.identifier=lt(this.sliceSerialize(N)).toLowerCase()}function I(){const N=this.resume(),O=this.stack[this.stack.length-1];O.title=N}function W(){const N=this.resume(),O=this.stack[this.stack.length-1];O.url=N}function Q(N){const O=this.stack[this.stack.length-1];if(!O.depth){const G=this.sliceSerialize(N).length;O.depth=G}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function Y(N){const O=this.stack[this.stack.length-1];O.depth=this.sliceSerialize(N).codePointAt(0)===61?1:2}function X(){this.data.setextHeadingSlurpLineEnding=void 0}function J(N){const G=this.stack[this.stack.length-1].children;let fe=G[G.length-1];(!fe||fe.type!=="text")&&(fe=nt(),fe.position={start:wt(N.start),end:void 0},G.push(fe)),this.stack.push(fe)}function _(N){const O=this.stack.pop();O.value+=this.sliceSerialize(N),O.position.end=wt(N.end)}function $(N){const O=this.stack[this.stack.length-1];if(this.data.atHardBreak){const G=O.children[O.children.length-1];G.position.end=wt(N.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(O.type)&&(J.call(this,N),_.call(this,N))}function B(){this.data.atHardBreak=!0}function ae(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function q(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function L(){const N=this.resume(),O=this.stack[this.stack.length-1];O.value=N}function ie(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=O,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function be(){const N=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";N.type+="Reference",N.referenceType=O,delete N.url,delete N.title}else delete N.identifier,delete N.label;this.data.referenceType=void 0}function le(N){const O=this.sliceSerialize(N),G=this.stack[this.stack.length-2];G.label=Om(O),G.identifier=lt(O).toLowerCase()}function D(){const N=this.stack[this.stack.length-1],O=this.resume(),G=this.stack[this.stack.length-1];if(this.data.inReference=!0,G.type==="link"){const fe=N.children;G.children=fe}else G.alt=O}function x(){const N=this.resume(),O=this.stack[this.stack.length-1];O.url=N}function M(){const N=this.resume(),O=this.stack[this.stack.length-1];O.title=N}function Ce(){this.data.inReference=void 0}function y(){this.data.referenceType="collapsed"}function Ne(N){const O=this.resume(),G=this.stack[this.stack.length-1];G.label=O,G.identifier=lt(this.sliceSerialize(N)).toLowerCase(),this.data.referenceType="full"}function Le(N){this.data.characterReferenceType=N.type}function Ie(N){const O=this.sliceSerialize(N),G=this.data.characterReferenceType;let fe;G?(fe=Yo(O,G==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):fe=Ji(O);const je=this.stack[this.stack.length-1];je.value+=fe}function Fe(N){const O=this.stack.pop();O.position.end=wt(N.end)}function ce(N){_.call(this,N);const O=this.stack[this.stack.length-1];O.url=this.sliceSerialize(N)}function Ke(N){_.call(this,N);const O=this.stack[this.stack.length-1];O.url="mailto:"+this.sliceSerialize(N)}function $e(){return{type:"blockquote",children:[]}}function C(){return{type:"code",lang:null,meta:null,value:""}}function F(){return{type:"inlineCode",value:""}}function te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function _e(){return{type:"emphasis",children:[]}}function we(){return{type:"heading",depth:0,children:[]}}function De(){return{type:"break"}}function Tt(){return{type:"html",value:""}}function Nr(){return{type:"image",title:null,url:"",alt:null}}function se(){return{type:"link",title:null,url:"",children:[]}}function Ze(N){return{type:"list",ordered:N.type==="listOrdered",start:null,spread:N._spread,children:[]}}function P(N){return{type:"listItem",spread:N._spread,checked:null,children:[]}}function Ft(){return{type:"paragraph",children:[]}}function Be(){return{type:"strong",children:[]}}function nt(){return{type:"text",value:""}}function qe(){return{type:"thematicBreak"}}}function wt(e){return{line:e.line,column:e.column,offset:e.offset}}function ol(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ol(e,r):qm(e,r)}}function qm(e,t){let n;for(n in t)if(al.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function da(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+xn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+xn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+xn({start:t.start,end:t.end})+") is still open")}function Vm(e){const t=this;t.parser=n;function n(r){return $m(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Um(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Hm(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
6
|
-
`}]}function Zm(e,t){const n=t.value?t.value+`
|
|
7
|
-
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function Wm(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Qm(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Km(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ln(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let a,o=e.footnoteCounts.get(r);o===void 0?(o=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(r,o);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function Ym(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Xm(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ll(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function Jm(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ll(e,t);const i={src:ln(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Gm(e,t){const n={src:ln(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function eg(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function tg(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ll(e,t);const i={href:ln(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function ng(e,t){const n={href:ln(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function rg(e,t,n){const r=e.all(t),i=n?ig(n):cl(t),s={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const d=r[o];(i||o!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
|
|
8
|
-
`}),d.type==="element"&&d.tagName==="p"&&!i?a.push(...d.children):a.push(d)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
|
|
9
|
-
`});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function ig(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=cl(n[r])}return t}function cl(e){const t=e.spread;return t??e.children.length>1}function sg(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function ag(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function og(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function lg(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cg(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=Wi(t.children[1]),c=qo(t.children[t.children.length-1]);o&&c&&(a.position={start:o,end:c}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function ug(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,o=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<o;){const f=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let m={type:"element",tagName:s,properties:p,children:[]};f&&(m.children=e.all(f),e.patch(f,m),m=e.applyData(f,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function dg(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const fa=9,ha=32;function fg(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(pa(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(pa(t.slice(i),i>0,!1)),s.join("")}function pa(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===fa||s===ha;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===fa||s===ha;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function hg(e,t){const n={type:"text",value:fg(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function pg(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const mg={blockquote:Um,break:Hm,code:Zm,delete:Wm,emphasis:Qm,footnoteReference:Km,heading:Ym,html:Xm,imageReference:Jm,image:Gm,inlineCode:eg,linkReference:tg,link:ng,listItem:rg,list:sg,paragraph:ag,root:og,strong:lg,table:cg,tableCell:dg,tableRow:ug,text:hg,thematicBreak:pg,toml:Dn,yaml:Dn,definition:Dn,footnoteDefinition:Dn};function Dn(){}const ul=-1,vr=0,bn=1,tr=2,es=3,ts=4,ns=5,rs=6,dl=7,fl=8,ma=typeof self=="object"?self:globalThis,gg=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case vr:case ul:return n(a,i);case bn:{const o=n([],i);for(const c of a)o.push(r(c));return o}case tr:{const o=n({},i);for(const[c,u]of a)o[r(c)]=r(u);return o}case es:return n(new Date(a),i);case ts:{const{source:o,flags:c}=a;return n(new RegExp(o,c),i)}case ns:{const o=n(new Map,i);for(const[c,u]of a)o.set(r(c),r(u));return o}case rs:{const o=n(new Set,i);for(const c of a)o.add(r(c));return o}case dl:{const{name:o,message:c}=a;return n(new ma[o](c),i)}case fl:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return n(new DataView(o),a)}}return n(new ma[s](a),i)};return r},ga=e=>gg(new Map,e)(0),qt="",{toString:xg}={},{keys:yg}=Object,mn=e=>{const t=typeof e;if(t!=="object"||!e)return[vr,t];const n=xg.call(e).slice(8,-1);switch(n){case"Array":return[bn,qt];case"Object":return[tr,qt];case"Date":return[es,qt];case"RegExp":return[ts,qt];case"Map":return[ns,qt];case"Set":return[rs,qt];case"DataView":return[bn,n]}return n.includes("Array")?[bn,n]:n.includes("Error")?[dl,n]:[tr,n]},zn=([e,t])=>e===vr&&(t==="function"||t==="symbol"),bg=(e,t,n,r)=>{const i=(a,o)=>{const c=r.push(a)-1;return n.set(o,c),c},s=a=>{if(n.has(a))return n.get(a);let[o,c]=mn(a);switch(o){case vr:{let d=a;switch(c){case"bigint":o=fl,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return i([ul],a)}return i([o,d],a)}case bn:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),i([c,[...p]],a)}const d=[],f=i([o,d],a);for(const p of a)d.push(s(p));return f}case tr:{if(c)switch(c){case"BigInt":return i([c,a.toString()],a);case"Boolean":case"Number":case"String":return i([c,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],f=i([o,d],a);for(const p of yg(a))(e||!zn(mn(a[p])))&&d.push([s(p),s(a[p])]);return f}case es:return i([o,a.toISOString()],a);case ts:{const{source:d,flags:f}=a;return i([o,{source:d,flags:f}],a)}case ns:{const d=[],f=i([o,d],a);for(const[p,h]of a)(e||!(zn(mn(p))||zn(mn(h))))&&d.push([s(p),s(h)]);return f}case rs:{const d=[],f=i([o,d],a);for(const p of a)(e||!zn(mn(p)))&&d.push(s(p));return f}}const{message:u}=a;return i([o,{name:c,message:u}],a)};return s},xa=(e,{json:t,lossy:n}={})=>{const r=[];return bg(!(t||n),!!t,new Map,r)(e),r},nr=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?ga(xa(e,t)):structuredClone(e):(e,t)=>ga(xa(e,t));function kg(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function vg(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function wg(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||kg,r=e.options.footnoteBackLabel||vg,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),f=String(u.identifier).toUpperCase(),p=ln(f.toLowerCase());let h=0;const m=[],b=e.footnoteCounts.get(f);for(;b!==void 0&&++h<=b;){m.length>0&&m.push({type:"text",value:" "});let A=typeof n=="string"?n:n(c,h);typeof A=="string"&&(A={type:"text",value:A}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const S=d[d.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const A=S.children[S.children.length-1];A&&A.type==="text"?A.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...m)}else d.push(...m);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,k),o.push(k)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...nr(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
10
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
|
|
11
|
-
`}]}}const En=(function(e){if(e==null)return Cg;if(typeof e=="function")return wr(e);if(typeof e=="object")return Array.isArray(e)?Sg(e):_g(e);if(typeof e=="string")return jg(e);throw new Error("Expected function, string, or object as test")});function Sg(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=En(e[n]);return wr(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function _g(e){const t=e;return wr(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function jg(e){return wr(t);function t(n){return n&&n.type===e}}function wr(e){return t;function t(n,r,i){return!!(Ng(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Cg(){return!0}function Ng(e){return e!==null&&typeof e=="object"&&"type"in e}const hl=[],Ig=!0,ji=!1,Tg="skip";function pl(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=En(i),a=r?-1:1;o(e,void 0,[])();function o(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=hl,m,b,S;if((!t||s(c,u,d[d.length-1]||void 0))&&(h=Ag(n(c,d)),h[0]===ji))return h;if("children"in c&&c.children){const k=c;if(k.children&&h[0]!==Tg)for(b=(r?k.children.length:-1)+a,S=d.concat(k);b>-1&&b<k.children.length;){const A=k.children[b];if(m=o(A,b,S)(),m[0]===ji)return m;b=typeof m[1]=="number"?m[1]:b+a}}return h}}}function Ag(e){return Array.isArray(e)?e:typeof e=="number"?[Ig,e]:e==null?hl:[e]}function Sr(e,t,n,r){let i,s,a;typeof t=="function"&&typeof n!="function"?(s=void 0,a=t,i=n):(s=t,a=n,i=r),pl(e,s,o,i);function o(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return a(c,f,d)}}const Ci={}.hasOwnProperty,Eg={};function Pg(e,t){const n=t||Eg,r=new Map,i=new Map,s=new Map,a={...mg,...n.handlers},o={all:u,applyData:Rg,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:c,options:n,patch:Mg,wrap:Dg};return Sr(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:i,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),o;function c(d,f){const p=d.type,h=o.handlers[p];if(Ci.call(o.handlers,p)&&h)return h(o,d,f);if(o.options.passThrough&&o.options.passThrough.includes(p)){if("children"in d){const{children:b,...S}=d,k=nr(S);return k.children=o.all(d),k}return nr(d)}return(o.options.unknownHandler||Lg)(o,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const m=o.one(p[h],d);if(m){if(h&&p[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=ya(m.value)),!Array.isArray(m)&&m.type==="element")){const b=m.children[0];b&&b.type==="text"&&(b.value=ya(b.value))}Array.isArray(m)?f.push(...m):f.push(m)}}}return f}}function Mg(e,t){e.position&&(t.position=vh(e))}function Rg(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&s&&Object.assign(n.properties,nr(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Lg(e,t){const n=t.data||{},r="value"in t&&!(Ci.call(n,"hProperties")||Ci.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Dg(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
12
|
-
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
13
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
14
|
-
`}),n}function ya(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ba(e,t){const n=Pg(e,t),r=n.one(e,void 0),i=wg(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
15
|
-
`},i),s}function zg(e,t){return e&&"run"in e?async function(n,r){const i=ba(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ba(n,{file:r,...e||t})}}function ka(e){if(e)throw e}var Vr,va;function Og(){if(va)return Vr;va=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!f)return!1;var p;for(p in u);return typeof p>"u"||e.call(u,p)},a=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},o=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return Vr=function c(){var u,d,f,p,h,m,b=arguments[0],S=1,k=arguments.length,A=!1;for(typeof b=="boolean"&&(A=b,b=arguments[1]||{},S=2),(b==null||typeof b!="object"&&typeof b!="function")&&(b={});S<k;++S)if(u=arguments[S],u!=null)for(d in u)f=o(b,d),p=o(u,d),b!==p&&(A&&p&&(s(p)||(h=i(p)))?(h?(h=!1,m=f&&i(f)?f:[]):m=f&&s(f)?f:{},a(b,{name:d,newValue:c(A,m,p)})):typeof p<"u"&&a(b,{name:d,newValue:p}));return b},Vr}var Fg=Og();const Ur=Xa(Fg);function Ni(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function $g(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(c,...u){const d=e[++s];let f=-1;if(c){a(c);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,d?Bg(d,o)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Bg(e,t){let n;return r;function r(...a){const o=e.length>a.length;let c;o&&a.push(i);try{c=e.apply(this,a)}catch(u){const d=u;if(o&&n)throw d;return i(d)}o||(c&&c.then&&typeof c.then=="function"?c.then(s,i):c instanceof Error?i(c):s(c))}function i(a,...o){n||(n=!0,t(a,...o))}function s(a){i(null,a)}}const dt={basename:qg,dirname:Vg,extname:Ug,join:Hg,sep:"/"};function qg(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Pn(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(r=i):(o=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function Vg(e){if(Pn(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Ug(e){Pn(e);let t=e.length,n=-1,r=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Hg(...e){let t=-1,n;for(;++t<e.length;)Pn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Zg(n)}function Zg(e){Pn(e);const t=e.codePointAt(0)===47;let n=Wg(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Wg(e,t){let n="",r=0,i=-1,s=0,a=-1,o,c;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=a,s=0;continue}}else if(n.length>0){n="",r=0,i=a,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return n}function Pn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Qg={cwd:Kg};function Kg(){return"/"}function Ii(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Yg(e){if(typeof e=="string")e=new URL(e);else if(!Ii(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Xg(e)}function Xg(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Hr=["history","path","basename","stem","extname","dirname"];class ml{constructor(t){let n;t?Ii(t)?n={path:t}:typeof t=="string"||Jg(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Qg.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Hr.length;){const s=Hr[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Hr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?dt.basename(this.path):void 0}set basename(t){Wr(t,"basename"),Zr(t,"basename"),this.path=dt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?dt.dirname(this.path):void 0}set dirname(t){wa(this.basename,"dirname"),this.path=dt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?dt.extname(this.path):void 0}set extname(t){if(Zr(t,"extname"),wa(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=dt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ii(t)&&(t=Yg(t)),Wr(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?dt.basename(this.path,this.extname):void 0}set stem(t){Wr(t,"stem"),Zr(t,"stem"),this.path=dt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Oe(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Zr(e,t){if(e&&e.includes(dt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+dt.sep+"`")}function Wr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function wa(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Jg(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Gg=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),ex={}.hasOwnProperty;class is extends Gg{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=$g()}copy(){const t=new is;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ur(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Yr("data",this.frozen),this.namespace[t]=n,this):ex.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Yr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=On(t),r=this.parser||this.Parser;return Qr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Qr("process",this.parser||this.Parser),Kr("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,a){const o=On(t),c=r.parse(o);r.run(c,o,function(d,f,p){if(d||!f||!p)return u(d);const h=f,m=r.stringify(h,p);rx(m)?p.value=m:p.result=m,u(d,p)});function u(d,f){d||!f?a(d):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Qr("processSync",this.parser||this.Parser),Kr("processSync",this.compiler||this.Compiler),this.process(t,i),_a("processSync","process",n),r;function i(s,a){n=!0,ka(s),r=a}}run(t,n,r){Sa(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(a,o){const c=On(n);i.run(t,c,u);function u(d,f,p){const h=f||t;d?o(d):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),_a("runSync","run",r),i;function s(a,o){ka(a),i=o,r=!0}}stringify(t,n){this.freeze();const r=On(n),i=this.compiler||this.Compiler;return Kr("stringify",i),Sa(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Yr("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;c(d,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(u.plugins),u.settings&&(i.settings=Ur(!0,i.settings,u.settings))}function o(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[h,...m]=d;const b=r[p][1];Ni(b)&&Ni(h)&&(h=Ur(!0,b,h)),r[p]=[u,h,...m]}}}}const tx=new is().freeze();function Qr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Kr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Yr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Sa(e){if(!Ni(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function _a(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function On(e){return nx(e)?e:new ml(e)}function nx(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function rx(e){return typeof e=="string"||ix(e)}function ix(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const sx="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ja=[],Ca={allowDangerousHtml:!0},ax=/^(https?|ircs?|mailto|xmpp)$/i,ox=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function lx(e){const t=cx(e),n=ux(e);return dx(t.runSync(t.parse(n),n),e)}function cx(e){const t=e.rehypePlugins||ja,n=e.remarkPlugins||ja,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ca}:Ca;return tx().use(Vm).use(n).use(zg,r).use(t)}function ux(e){const t=e.children||"",n=new ml;return typeof t=="string"&&(n.value=t),n}function dx(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,c=t.urlTransform||fx;for(const d of ox)Object.hasOwn(t,d.from)&&ac("Unexpected `"+d.from+"` prop, "+(d.to?"use `"+d.to+"` instead":"remove it")+" (see <"+sx+"#"+d.id+"> for more info)");return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),Sr(e,u),Ch(e,{Fragment:l.Fragment,components:i,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in $r)if(Object.hasOwn($r,h)&&Object.hasOwn(d.properties,h)){const m=d.properties[h],b=$r[h];(b===null||b.includes(d.tagName))&&(d.properties[h]=c(String(m||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):s?s.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return o&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function fx(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||ax.test(e.slice(0,t))?e:""}function Na(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function hx(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function px(e,t,n){const i=En((n||{}).ignore||[]),s=mx(t);let a=-1;for(;++a<s.length;)pl(e,"text",o);function o(u,d){let f=-1,p;for(;++f<d.length;){const h=d[f],m=p?p.children:void 0;if(i(h,m?m.indexOf(h):void 0,p))return;p=h}if(p)return c(u,d)}function c(u,d){const f=d[d.length-1],p=s[a][0],h=s[a][1];let m=0;const S=f.children.indexOf(u);let k=!1,A=[];p.lastIndex=0;let I=p.exec(u.value);for(;I;){const W=I.index,Q={index:I.index,input:I.input,stack:[...d,u]};let j=h(...I,Q);if(typeof j=="string"&&(j=j.length>0?{type:"text",value:j}:void 0),j===!1?p.lastIndex=W+1:(m!==W&&A.push({type:"text",value:u.value.slice(m,W)}),Array.isArray(j)?A.push(...j):j&&A.push(j),m=W+I[0].length,k=!0),!p.global)break;I=p.exec(u.value)}return k?(m<u.value.length&&A.push({type:"text",value:u.value.slice(m)}),f.children.splice(S,1,...A)):A=[u],S+A.length}}function mx(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([gx(i[0]),xx(i[1])])}return t}function gx(e){return typeof e=="string"?new RegExp(hx(e),"g"):e}function xx(e){return typeof e=="function"?e:function(){return e}}const Xr="phrasing",Jr=["autolink","link","image","label"];function yx(){return{transforms:[jx],enter:{literalAutolink:kx,literalAutolinkEmail:Gr,literalAutolinkHttp:Gr,literalAutolinkWww:Gr},exit:{literalAutolink:_x,literalAutolinkEmail:Sx,literalAutolinkHttp:vx,literalAutolinkWww:wx}}}function bx(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Xr,notInConstruct:Jr},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Xr,notInConstruct:Jr},{character:":",before:"[ps]",after:"\\/",inConstruct:Xr,notInConstruct:Jr}]}}function kx(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Gr(e){this.config.enter.autolinkProtocol.call(this,e)}function vx(e){this.config.exit.autolinkProtocol.call(this,e)}function wx(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];ot(t.type==="link"),t.url="http://"+this.sliceSerialize(e)}function Sx(e){this.config.exit.autolinkEmail.call(this,e)}function _x(e){this.exit(e)}function jx(e){px(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Cx],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Nx]],{ignore:["link","linkReference"]})}function Cx(e,t,n,r,i){let s="";if(!gl(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Ix(n)))return!1;const a=Tx(n+r);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function Nx(e,t,n,r){return!gl(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Ix(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Tx(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Na(e,"(");let s=Na(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function gl(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Dt(n)||br(n))&&(!t||n!==47)}xl.peek=Ox;function Ax(){this.buffer()}function Ex(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Px(){this.buffer()}function Mx(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Rx(e){const t=this.resume(),n=this.stack[this.stack.length-1];ot(n.type==="footnoteReference"),n.identifier=lt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Lx(e){this.exit(e)}function Dx(e){const t=this.resume(),n=this.stack[this.stack.length-1];ot(n.type==="footnoteDefinition"),n.identifier=lt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zx(e){this.exit(e)}function Ox(){return"["}function xl(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const a=n.enter("footnoteReference"),o=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function Fx(){return{enter:{gfmFootnoteCallString:Ax,gfmFootnoteCall:Ex,gfmFootnoteDefinitionLabelString:Px,gfmFootnoteDefinition:Mx},exit:{gfmFootnoteCallString:Rx,gfmFootnoteCall:Lx,gfmFootnoteDefinitionLabelString:Dx,gfmFootnoteDefinition:zx}}}function $x(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:xl},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,a){const o=s.createTracker(a);let c=o.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return c+=o.move(s.safe(s.associationId(r),{before:c,after:"]"})),d(),c+=o.move("]:"),r.children&&r.children.length>0&&(o.shift(4),c+=o.move((t?`
|
|
16
|
-
`:" ")+s.indentLines(s.containerFlow(r,o.current()),t?yl:Bx))),u(),c}}function Bx(e,t,n){return t===0?e:yl(e,t,n)}function yl(e,t,n){return(n?"":" ")+e}const qx=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bl.peek=Wx;function Vx(){return{canContainEols:["delete"],enter:{strikethrough:Hx},exit:{strikethrough:Zx}}}function Ux(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:qx}],handlers:{delete:bl}}}function Hx(e){this.enter({type:"delete",children:[]},e)}function Zx(e){this.exit(e)}function bl(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),s(),a}function Wx(){return"~"}function Qx(e){return e.length}function Kx(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Qx,s=[],a=[],o=[],c=[];let u=0,d=-1;for(;++d<e.length;){const b=[],S=[];let k=-1;for(e[d].length>u&&(u=e[d].length);++k<e[d].length;){const A=Yx(e[d][k]);if(n.alignDelimiters!==!1){const I=i(A);S[k]=I,(c[k]===void 0||I>c[k])&&(c[k]=I)}b.push(A)}a[d]=b,o[d]=S}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<u;)s[f]=Ia(r[f]);else{const b=Ia(r);for(;++f<u;)s[f]=b}f=-1;const p=[],h=[];for(;++f<u;){const b=s[f];let S="",k="";b===99?(S=":",k=":"):b===108?S=":":b===114&&(k=":");let A=n.alignDelimiters===!1?1:Math.max(1,c[f]-S.length-k.length);const I=S+"-".repeat(A)+k;n.alignDelimiters!==!1&&(A=S.length+A+k.length,A>c[f]&&(c[f]=A),h[f]=A),p[f]=I}a.splice(1,0,p),o.splice(1,0,h),d=-1;const m=[];for(;++d<a.length;){const b=a[d],S=o[d];f=-1;const k=[];for(;++f<u;){const A=b[f]||"";let I="",W="";if(n.alignDelimiters!==!1){const Q=c[f]-(S[f]||0),j=s[f];j===114?I=" ".repeat(Q):j===99?Q%2?(I=" ".repeat(Q/2+.5),W=" ".repeat(Q/2-.5)):(I=" ".repeat(Q/2),W=I):W=" ".repeat(Q)}n.delimiterStart!==!1&&!f&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||f)&&k.push(" "),n.alignDelimiters!==!1&&k.push(I),k.push(A),n.alignDelimiters!==!1&&k.push(W),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||f!==u-1)&&k.push("|")}m.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return m.join(`
|
|
17
|
-
`)}function Yx(e){return e==null?"":String(e)}function Ia(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Xx(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const a=n.indentLines(n.containerFlow(e,s.current()),Jx);return i(),a}function Jx(e,t,n){return">"+(n?"":" ")+e}function Gx(e,t){return Ta(e,t.inConstruct,!0)&&!Ta(e,t.notInConstruct,!1)}function Ta(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Aa(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
18
|
-
`&&Gx(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
19
|
-
`}function ey(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>a&&(a=s):s=1,i=r+t.length,r=n.indexOf(t,i);return a}function ty(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function ny(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ry(e,t,n,r){const i=ny(n),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(ty(e,n)){const f=n.enter("codeIndented"),p=n.indentLines(s,iy);return f(),p}const o=n.createTracker(r),c=i.repeat(Math.max(ey(s,i)+1,3)),u=n.enter("codeFenced");let d=o.move(c);if(e.lang){const f=n.enter(`codeFencedLang${a}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:`
|
|
20
|
-
`,encode:["`"],...o.current()})),f()}return d+=o.move(`
|
|
21
|
-
`),s&&(d+=o.move(s+`
|
|
22
|
-
`)),d+=o.move(c),u(),d}function iy(e,t,n){return(n?"":" ")+e}function ss(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function sy(e,t,n,r){const i=ss(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("definition");let o=n.enter("label");const c=n.createTracker(r);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
23
|
-
`,...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),o()),a(),u}function ay(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function _n(e){return"&#x"+e.toString(16).toUpperCase()+";"}function rr(e,t,n){const r=nn(e),i=nn(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}kl.peek=oy;function kl(e,t,n,r){const i=ay(n),s=n.enter("emphasis"),a=n.createTracker(r),o=a.move(i);let c=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=c.charCodeAt(0),d=rr(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(c=_n(u)+c.slice(1));const f=c.charCodeAt(c.length-1),p=rr(r.after.charCodeAt(0),f,i);p.inside&&(c=c.slice(0,-1)+_n(f));const h=a.move(i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},o+c+h}function oy(e,t,n){return n.options.emphasis||"*"}function ly(e,t){let n=!1;return Sr(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,ji}),!!((!e.depth||e.depth<3)&&Xi(e)&&(t.options.setext||n))}function cy(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(ly(e,n)){const d=n.enter("headingSetext"),f=n.enter("phrasing"),p=n.containerPhrasing(e,{...s.current(),before:`
|
|
24
|
-
`,after:`
|
|
25
|
-
`});return f(),d(),p+`
|
|
26
|
-
`+(i===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
|
|
27
|
-
`))+1))}const a="#".repeat(i),o=n.enter("headingAtx"),c=n.enter("phrasing");s.move(a+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
28
|
-
`,...s.current()});return/^[\t ]/.test(u)&&(u=_n(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,n.options.closeAtx&&(u+=" "+a),c(),o(),u}vl.peek=uy;function vl(e){return e.value||""}function uy(){return"<"}wl.peek=dy;function wl(e,t,n,r){const i=ss(n),s=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let o=n.enter("label");const c=n.createTracker(r);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),o(),e.title&&(o=n.enter(`title${s}`),u+=c.move(" "+i),u+=c.move(n.safe(e.title,{before:u,after:i,...c.current()})),u+=c.move(i),o()),u+=c.move(")"),a(),u}function dy(){return"!"}Sl.peek=fy;function Sl(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let a=n.enter("label");const o=n.createTracker(r);let c=o.move("![");const u=n.safe(e.alt,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==f?c+=o.move(f+"]"):i==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function fy(){return"!"}_l.peek=hy;function _l(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const a=n.unsafe[s],o=n.compilePattern(a);let c;if(a.atBreak)for(;c=o.exec(r);){let u=c.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(c.index+1)}}return i+r+i}function hy(){return"`"}function jl(e,t){const n=Xi(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Cl.peek=py;function Cl(e,t,n,r){const i=ss(n),s=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let o,c;if(jl(e,n)){const d=n.stack;n.stack=[],o=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),o(),n.stack=d,f}o=n.enter("link"),c=n.enter("label");let u=a.move("[");return u+=a.move(n.containerPhrasing(e,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(n.safe(e.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=n.enter("destinationRaw"),u+=a.move(n.safe(e.url,{before:u,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(n.safe(e.title,{before:u,after:i,...a.current()})),u+=a.move(i),c()),u+=a.move(")"),o(),u}function py(e,t,n){return jl(e,n)?"<":"["}Nl.peek=my;function Nl(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let a=n.enter("label");const o=n.createTracker(r);let c=o.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...o.current()});return a(),n.stack=d,s(),i==="full"||!u||u!==f?c+=o.move(f+"]"):i==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function my(){return"["}function as(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function gy(e){const t=as(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function xy(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Il(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function yy(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let a=e.ordered?xy(n):as(n);const o=e.ordered?a==="."?")":".":gy(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Il(n)===a&&d){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=o),n.bulletCurrent=a;const u=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=s,i(),u}function by(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ky(e,t,n,r){const i=by(n);let s=n.bulletCurrent||as(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=n.createTracker(r);o.move(s+" ".repeat(a-s.length)),o.shift(a);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,o.current()),d);return c(),u;function d(f,p,h){return p?(h?"":" ".repeat(a))+f:(h?s:s+" ".repeat(a-s.length))+f}}function vy(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),a=n.containerPhrasing(e,r);return s(),i(),a}const wy=En(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Sy(e,t,n,r){return(e.children.some(function(a){return wy(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function _y(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tl.peek=jy;function Tl(e,t,n,r){const i=_y(n),s=n.enter("strong"),a=n.createTracker(r),o=a.move(i+i);let c=a.move(n.containerPhrasing(e,{after:i,before:o,...a.current()}));const u=c.charCodeAt(0),d=rr(r.before.charCodeAt(r.before.length-1),u,i);d.inside&&(c=_n(u)+c.slice(1));const f=c.charCodeAt(c.length-1),p=rr(r.after.charCodeAt(0),f,i);p.inside&&(c=c.slice(0,-1)+_n(f));const h=a.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:d.outside},o+c+h}function jy(e,t,n){return n.options.strong||"*"}function Cy(e,t,n,r){return n.safe(e.value,r)}function Ny(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Iy(e,t,n){const r=(Il(n)+(n.options.ruleSpaces?" ":"")).repeat(Ny(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Al={blockquote:Xx,break:Aa,code:ry,definition:sy,emphasis:kl,hardBreak:Aa,heading:cy,html:vl,image:wl,imageReference:Sl,inlineCode:_l,link:Cl,linkReference:Nl,list:yy,listItem:ky,paragraph:vy,root:Sy,strong:Tl,text:Cy,thematicBreak:Iy};function Ty(){return{enter:{table:Ay,tableData:Ea,tableHeader:Ea,tableRow:Py},exit:{codeText:My,table:Ey,tableData:ei,tableHeader:ei,tableRow:ei}}}function Ay(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Ey(e){this.exit(e),this.data.inTable=void 0}function Py(e){this.enter({type:"tableRow",children:[]},e)}function ei(e){this.exit(e)}function Ea(e){this.enter({type:"tableCell",children:[]},e)}function My(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ry));const n=this.stack[this.stack.length-1];ot(n.type==="inlineCode"),n.value=t,this.exit(e)}function Ry(e,t){return t==="|"?t:e}function Ly(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
29
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:a,tableCell:c,tableRow:o}};function a(h,m,b,S){return u(d(h,b,S),h.align)}function o(h,m,b,S){const k=f(h,b,S),A=u([k]);return A.slice(0,A.indexOf(`
|
|
30
|
-
`))}function c(h,m,b,S){const k=b.enter("tableCell"),A=b.enter("phrasing"),I=b.containerPhrasing(h,{...S,before:s,after:s});return A(),k(),I}function u(h,m){return Kx(h,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function d(h,m,b){const S=h.children;let k=-1;const A=[],I=m.enter("table");for(;++k<S.length;)A[k]=f(S[k],m,b);return I(),A}function f(h,m,b){const S=h.children;let k=-1;const A=[],I=m.enter("tableRow");for(;++k<S.length;)A[k]=c(S[k],h,m,b);return I(),A}function p(h,m,b){let S=Al.inlineCode(h,m,b);return b.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Dy(){return{exit:{taskListCheckValueChecked:Pa,taskListCheckValueUnchecked:Pa,paragraph:Oy}}}function zy(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Fy}}}function Pa(e){const t=this.stack[this.stack.length-2];ot(t.type==="listItem"),t.checked=e.type==="taskListCheckValueChecked"}function Oy(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];ot(n.type==="paragraph");const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Fy(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(a);let c=Al.listItem(e,t,n,{...r,...o.current()});return s&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+a}}function $y(){return[yx(),Fx(),Vx(),Ty(),Dy()]}function By(e){return{extensions:[bx(),$x(e),Ux(),Ly(e),zy()]}}const qy={tokenize:Qy,partial:!0},El={tokenize:Ky,partial:!0},Pl={tokenize:Yy,partial:!0},Ml={tokenize:Xy,partial:!0},Vy={tokenize:Jy,partial:!0},Rl={name:"wwwAutolink",tokenize:Zy,previous:Dl},Ll={name:"protocolAutolink",tokenize:Wy,previous:zl},vt={name:"emailAutolink",tokenize:Hy,previous:Ol},gt={};function Uy(){return{text:gt}}let Et=48;for(;Et<123;)gt[Et]=vt,Et++,Et===58?Et=65:Et===91&&(Et=97);gt[43]=vt;gt[45]=vt;gt[46]=vt;gt[95]=vt;gt[72]=[vt,Ll];gt[104]=[vt,Ll];gt[87]=[vt,Rl];gt[119]=[vt,Rl];function Hy(e,t,n){const r=this;let i,s;return a;function a(f){return!Ti(f)||!Ol.call(r,r.previous)||os(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(f))}function o(f){return Ti(f)?(e.consume(f),o):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(Vy,d,u)(f):f===45||f===95||ze(f)?(s=!0,e.consume(f),c):d(f)}function u(f){return e.consume(f),i=!0,c}function d(f){return s&&i&&Ue(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function Zy(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!Dl.call(r,r.previous)||os(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(qy,e.attempt(El,e.attempt(Pl,s),n),n)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Wy(e,t,n){const r=this;let i="",s=!1;return a;function a(f){return(f===72||f===104)&&zl.call(r,r.previous)&&!os(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),o):n(f)}function o(f){if(Ue(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),o;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),s?u:(s=!0,c)):n(f)}function u(f){return f===null||er(f)||Te(f)||Dt(f)||br(f)?n(f):e.attempt(El,e.attempt(Pl,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Qy(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),s):n(a)}function s(a){return a===null?n(a):t(a)}}function Ky(e,t,n){let r,i,s;return a;function a(u){return u===46||u===95?e.check(Ml,c,o)(u):u===null||Te(u)||Dt(u)||u!==45&&br(u)?c(u):(s=!0,e.consume(u),a)}function o(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),a}function c(u){return i||r||!s?n(u):t(u)}}function Yy(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Ml,t,s)(a):a===null||Te(a)||Dt(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&r++,e.consume(a),i}}function Xy(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||Te(o)||Dt(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||Te(o)||Dt(o)?t(o):r(o)}function s(o){return Ue(o)?a(o):n(o)}function a(o){return o===59?(e.consume(o),r):Ue(o)?(e.consume(o),a):n(o)}}function Jy(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return ze(s)?n(s):t(s)}}function Dl(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Te(e)}function zl(e){return!Ue(e)}function Ol(e){return!(e===47||Ti(e))}function Ti(e){return e===43||e===45||e===46||e===95||ze(e)}function os(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Gy={tokenize:ob,partial:!0};function eb(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ib,continuation:{tokenize:sb},exit:ab}},text:{91:{name:"gfmFootnoteCall",tokenize:rb},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:tb,resolveTo:nb}}}}function tb(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const c=r.events[i][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!a||!a._balanced)return n(c);const u=lt(r.sliceSerialize({start:a.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function nb(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function rb(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,a;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!a||f===null||f===91||Te(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(lt(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Te(f)||(a=!0),s++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function ib(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,a=0,o;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(a>999||m===93&&!o||m===null||m===91||Te(m))return n(m);if(m===93){e.exit("chunkString");const b=e.exit("gfmFootnoteDefinitionLabelString");return s=lt(r.sliceSerialize(b)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Te(m)||(o=!0),a++,e.consume(m),m===92?f:d}function f(m){return m===91||m===92||m===93?(e.consume(m),a++,d):d(m)}function p(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),ye(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function sb(e,t,n){return e.check(An,t,e.attempt(Gy,t,n))}function ab(e){e.exit("gfmFootnoteDefinition")}function ob(e,t,n){const r=this;return ye(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):n(s)}}function lb(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,o){let c=-1;for(;++c<a.length;)if(a[c][0]==="enter"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._close){let u=c;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[c][1].end.offset-a[c][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[c][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[c][1].end)},f={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[c][1].start)},p=[["enter",d,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",f,o]],h=o.parser.constructs.insideSpan.null;h&&Je(p,p.length,0,kr(h,a.slice(u+1,c),o)),Je(p,p.length,0,[["exit",f,o],["enter",a[c][1],o],["exit",a[c][1],o],["exit",d,o]]),Je(a,u-1,c-u+3,p),c=u+p.length-2;break}}for(c=-1;++c<a.length;)a[c][1].type==="strikethroughSequenceTemporary"&&(a[c][1].type="data");return a}function s(a,o,c){const u=this.previous,d=this.events;let f=0;return p;function p(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?c(m):(a.enter("strikethroughSequenceTemporary"),h(m))}function h(m){const b=nn(u);if(m===126)return f>1?c(m):(a.consume(m),f++,h);if(f<2&&!n)return c(m);const S=a.exit("strikethroughSequenceTemporary"),k=nn(m);return S._open=!k||k===2&&!!b,S._close=!b||b===2&&!!k,o(m)}}}class cb{constructor(){this.map=[]}add(t,n,r){ub(this,t,n,r)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function ub(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function db(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function fb(){return{flow:{null:{name:"table",tokenize:hb,resolveAll:pb}}}}function hb(e,t,n){const r=this;let i=0,s=0,a;return o;function o(_){let $=r.events.length-1;for(;$>-1;){const q=r.events[$][1].type;if(q==="lineEnding"||q==="linePrefix")$--;else break}const B=$>-1?r.events[$][1].type:null,ae=B==="tableHead"||B==="tableRow"?j:c;return ae===j&&r.parser.lazy[r.now().line]?n(_):ae(_)}function c(_){return e.enter("tableHead"),e.enter("tableRow"),u(_)}function u(_){return _===124||(a=!0,s+=1),d(_)}function d(_){return _===null?n(_):K(_)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),h):n(_):me(_)?ye(e,d,"whitespace")(_):(s+=1,a&&(a=!1,i+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(_)))}function f(_){return _===null||_===124||Te(_)?(e.exit("data"),d(_)):(e.consume(_),_===92?p:f)}function p(_){return _===92||_===124?(e.consume(_),f):f(_)}function h(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),a=!1,me(_)?ye(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):m(_))}function m(_){return _===45||_===58?S(_):_===124?(a=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),b):Q(_)}function b(_){return me(_)?ye(e,S,"whitespace")(_):S(_)}function S(_){return _===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),k):_===45?(s+=1,k(_)):_===null||K(_)?W(_):Q(_)}function k(_){return _===45?(e.enter("tableDelimiterFiller"),A(_)):Q(_)}function A(_){return _===45?(e.consume(_),A):_===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),I):(e.exit("tableDelimiterFiller"),I(_))}function I(_){return me(_)?ye(e,W,"whitespace")(_):W(_)}function W(_){return _===124?m(_):_===null||K(_)?!a||i!==s?Q(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):Q(_)}function Q(_){return n(_)}function j(_){return e.enter("tableRow"),Y(_)}function Y(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),Y):_===null||K(_)?(e.exit("tableRow"),t(_)):me(_)?ye(e,Y,"whitespace")(_):(e.enter("data"),X(_))}function X(_){return _===null||_===124||Te(_)?(e.exit("data"),Y(_)):(e.consume(_),_===92?J:X)}function J(_){return _===92||_===124?(e.consume(_),X):X(_)}}function pb(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,c=0,u,d,f;const p=new cb;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(o=!1,c!==0&&(Ma(p,t,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],a=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},p.add(n,0,[["enter",d,t]])),i=m.type==="tableDelimiterRow"?2:d?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],f=Fn(p,t,s,i,void 0,f),s=[0,0,0,0]),a[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(a[0]=a[1],f=Fn(p,t,s,i,void 0,f)),s=a,a=[s[1],n,0,0])):m.type==="tableHead"?(o=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,s[1]!==0?(a[0]=a[1],f=Fn(p,t,s,i,n,f)):a[1]!==0&&(f=Fn(p,t,a,i,n,f)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&Ma(p,t,c,u,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=db(t.events,n))}return e}function Fn(e,t,n,r,i,s){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(s.end=Object.assign({},Zt(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const c=Zt(t.events,n[1]);if(s={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Zt(t.events,n[2]),d=Zt(t.events,n[3]),f={type:o,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,b=n[3]-n[2]-1;e.add(m,b,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Zt(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ma(e,t,n,r,i){const s=[],a=Zt(t.events,n);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),r.end=Object.assign({},a),s.push(["exit",r,t]),e.add(n+1,0,s)}function Zt(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const mb={name:"tasklistCheck",tokenize:xb};function gb(){return{text:{91:mb}}}function xb(e,t,n){const r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),s)}function s(c){return Te(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):n(c)}function o(c){return K(c)?t(c):me(c)?e.check({tokenize:yb},t,n)(c):n(c)}}function yb(e,t,n){return ye(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function bb(e){return Ko([Uy(),eb(),lb(e),fb(),gb()])}const kb={};function vb(e){const t=this,n=e||kb,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(bb(n)),s.push($y()),a.push(By(n))}const Ra=(function(e,t,n){const r=En(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Ot=(function(e){if(e==null)return _b;if(typeof e=="string")return Sb(e);if(typeof e=="object")return wb(e);if(typeof e=="function")return ls(e);throw new Error("Expected function, string, or array as `test`")});function wb(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ot(e[n]);return ls(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Sb(e){return ls(t);function t(n){return n.tagName===e}}function ls(e){return t;function t(n,r,i){return!!(jb(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function _b(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function jb(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const La=/\n/g,Da=/[\t ]+/g,Ai=Ot("br"),za=Ot(Mb),Cb=Ot("p"),Oa=Ot("tr"),Nb=Ot(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",Pb,Rb]),Fl=Ot(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function Ib(e,t){const n=t||{},r="children"in e?e.children:[],i=Fl(e),s=ql(e,{whitespace:n.whitespace||"normal"}),a=[];(e.type==="text"||e.type==="comment")&&a.push(...Bl(e,{breakBefore:!0,breakAfter:!0}));let o=-1;for(;++o<r.length;)a.push(...$l(r[o],e,{whitespace:s,breakBefore:o?void 0:i,breakAfter:o<r.length-1?Ai(r[o+1]):i}));const c=[];let u;for(o=-1;++o<a.length;){const d=a[o];typeof d=="number"?u!==void 0&&d>u&&(u=d):d&&(u!==void 0&&u>-1&&c.push(`
|
|
31
|
-
`.repeat(u)||" "),u=-1,c.push(d))}return c.join("")}function $l(e,t,n){return e.type==="element"?Tb(e,t,n):e.type==="text"?n.whitespace==="normal"?Bl(e,n):Ab(e):[]}function Tb(e,t,n){const r=ql(e,n),i=e.children||[];let s=-1,a=[];if(Nb(e))return a;let o,c;for(Ai(e)||Oa(e)&&Ra(t,e,Oa)?c=`
|
|
32
|
-
`:Cb(e)?(o=2,c=2):Fl(e)&&(o=1,c=1);++s<i.length;)a=a.concat($l(i[s],e,{whitespace:r,breakBefore:s?void 0:o,breakAfter:s<i.length-1?Ai(i[s+1]):c}));return za(e)&&Ra(t,e,za)&&a.push(" "),o&&a.unshift(o),c&&a.push(c),a}function Bl(e,t){const n=String(e.value),r=[],i=[];let s=0;for(;s<=n.length;){La.lastIndex=s;const c=La.exec(n),u=c&&"index"in c?c.index:n.length;r.push(Eb(n.slice(s,u).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),s===0?t.breakBefore:!0,u===n.length?t.breakAfter:!0)),s=u+1}let a=-1,o;for(;++a<r.length;)r[a].charCodeAt(r[a].length-1)===8203||a<r.length-1&&r[a+1].charCodeAt(0)===8203?(i.push(r[a]),o=void 0):r[a]?(typeof o=="number"&&i.push(o),i.push(r[a]),o=0):(a===0||a===r.length-1)&&i.push(0);return i}function Ab(e){return[String(e.value)]}function Eb(e,t,n){const r=[];let i=0,s;for(;i<e.length;){Da.lastIndex=i;const a=Da.exec(e);s=a?a.index:e.length,!i&&!s&&a&&!t&&r.push(""),i!==s&&r.push(e.slice(i,s)),i=a?s+a[0].length:s}return i!==s&&!n&&r.push(""),r.join(" ")}function ql(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function Pb(e){return!!(e.properties||{}).hidden}function Mb(e){return e.tagName==="td"||e.tagName==="th"}function Rb(e){return e.tagName==="dialog"&&!(e.properties||{}).open}const Lb={};function Fa(e){const t=e||Lb,n=t.aliases,r=t.detect||!1,i=t.languages||oc,s=t.plainText,a=t.prefix,o=t.subset;let c="hljs";const u=lc(i);if(n&&u.registerAlias(n),a){const d=a.indexOf("-");c=d===-1?a:a.slice(0,d)}return function(d,f){Sr(d,"element",function(p,h,m){if(p.tagName!=="code"||!m||m.type!=="element"||m.tagName!=="pre")return;const b=Db(p);if(b===!1||!b&&!r||b&&s&&s.includes(b))return;Array.isArray(p.properties.className)||(p.properties.className=[]),p.properties.className.includes(c)||p.properties.className.unshift(c);const S=Ib(p,{whitespace:"pre"});let k;try{k=b?u.highlight(b,S,{prefix:a}):u.highlightAuto(S,{prefix:a,subset:o})}catch(A){const I=A;if(b&&/Unknown language/.test(I.message)){f.message("Cannot highlight as `"+b+"`, it’s not registered",{ancestors:[m,p],cause:I,place:p.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw I}!b&&k.data&&k.data.language&&p.properties.className.push("language-"+k.data.language),k.children.length>0&&(p.children=k.children)})}}function Db(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}function Vl(e){const t=e.split(`
|
|
33
|
-
`),n=[];for(const r of t)r.startsWith("@@")?n.push({kind:"hunk",text:r}):r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("--- ")||r.startsWith("+++ ")?n.push({kind:"meta",text:r}):r.startsWith("+")?n.push({kind:"add",text:r.slice(1)}):r.startsWith("-")?n.push({kind:"remove",text:r.slice(1)}):n.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r});return n}function Ul(e){let t=0,n=0;for(const r of e)r.kind==="add"?t++:r.kind==="remove"&&n++;return{added:t,removed:n}}function Ei(e){var t;return e==null||e===!1||e===!0?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ei).join(""):typeof e=="object"&&"props"in e?Ei((t=e.props)==null?void 0:t.children):""}function _r({text:e,className:t,label:n="复制"}){const[r,i]=v.useState(!1),s=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return l.jsx("button",{onClick:s,title:r?"已复制":n,"aria-label":n,className:t??"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:r?l.jsx(Rt,{size:13,className:"text-success"}):l.jsx(Bc,{size:13})})}function zb(e){const t=e.toLowerCase(),n=r=>{if(!r||!Array.isArray(r.children)||r.type==="element"&&(r.tagName==="code"||r.tagName==="pre"))return;const i=[];for(const s of r.children)if(s.type==="text"&&typeof s.value=="string"){const a=s.value,o=a.toLowerCase();let c=o.indexOf(t);if(c===-1){i.push(s);continue}let u=0;for(;c!==-1;)c>u&&i.push({type:"text",value:a.slice(u,c)}),i.push({type:"element",tagName:"mark",properties:{},children:[{type:"text",value:a.slice(c,c+t.length)}]}),u=c+t.length,c=o.indexOf(t,u);u<a.length&&i.push({type:"text",value:a.slice(u)})}else n(s),i.push(s);r.children=i};return()=>r=>{t&&n(r)}}const Hl=v.memo(function({text:t,highlight:n}){return l.jsx("div",{className:"prose-codex break-words text-[15px] leading-7 text-content-primary",children:l.jsx(lx,{remarkPlugins:[vb],rehypePlugins:n?[[Fa,{detect:!0,ignoreMissing:!0}],zb(n)]:[[Fa,{detect:!0,ignoreMissing:!0}]],components:{mark({children:r}){return l.jsx("mark",{className:"rounded bg-warning/30 px-0.5 text-content-primary",children:r})},pre({children:r}){return l.jsx(l.Fragment,{children:r})},code({className:r,children:i,...s}){if(/language-|hljs/.test(r??"")){const o=Ei(i);return l.jsxs("div",{className:"group/code relative my-3",children:[l.jsx("pre",{className:"max-w-full overflow-x-auto rounded-lg border border-border bg-surface-raised p-3 font-mono text-[13px] leading-relaxed",children:l.jsx("code",{className:r,...s,children:i})}),l.jsx(_r,{text:o,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/code:opacity-100"})]})}return l.jsx("code",{className:"break-all rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[13px] text-accent",...s,children:i})},a({children:r,...i}){return l.jsx("a",{className:"text-accent underline underline-offset-2",target:"_blank",rel:"noreferrer",...i,children:r})},p({children:r}){return l.jsx("p",{className:"my-2",children:r})},ul({children:r}){return l.jsx("ul",{className:"my-2 list-disc space-y-1 pl-5",children:r})},ol({children:r}){return l.jsx("ol",{className:"my-2 list-decimal space-y-1 pl-5",children:r})}},children:t})})});function Zl({item:e,onOpen:t}){const n=e.fileChange,r=n.diff?Vl(n.diff):[],i=Ul(r),s=n.entries.length>0?n.entries.map(u=>u.path):[],a=s[0]||n.summary||"文件变更",o=s.length>1?` +${s.length-1}`:"",c=!!(n.diff&&t);return l.jsxs("button",{onClick:()=>c&&(t==null?void 0:t(e)),className:`flex w-full items-center gap-2 rounded-xl border border-border bg-surface px-3.5 py-2.5 text-left transition-colors ${c?"cursor-pointer hover:border-border-strong hover:bg-surface-overlay":"cursor-default"}`,children:[l.jsx(kn,{size:14,className:"shrink-0 text-content-faint"}),l.jsxs("span",{className:"truncate font-mono text-[13px] text-content-primary",title:s.join(", ")||a,children:[a,o&&l.jsx("span",{className:"text-content-muted",children:o})]}),l.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[i.added>0&&l.jsxs("span",{className:"text-diff-addText",children:["+",i.added]}),i.removed>0&&l.jsxs("span",{className:"text-diff-removeText",children:["−",i.removed]}),c&&l.jsx(et,{size:13,className:"text-content-faint"})]})]})}function Ob(e){const t=/@@\s*-(\d+)(?:,\d+)?\s*\+(\d+)(?:,\d+)?\s*@@/.exec(e);return t?[Number(t[1]),Number(t[2])]:null}function Fb({item:e}){const t=e.fileChange,n=t!=null&&t.diff?Vl(t.diff):[],r=Ul(n),i=(t==null?void 0:t.entries.map(o=>o.path).join(", "))||(t==null?void 0:t.summary)||"文件变更";let s=0,a=0;return l.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-2.5",children:[l.jsx(kn,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",title:i,children:i}),l.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[r.added>0&&l.jsxs("span",{className:"text-diff-addText",children:["+",r.added]}),r.removed>0&&l.jsxs("span",{className:"text-diff-removeText",children:["−",r.removed]})]}),(t==null?void 0:t.diff)&&l.jsx(_r,{text:t.diff,label:"复制差异"})]}),l.jsx("div",{className:"min-h-0 flex-1 overflow-auto font-mono text-[13px] leading-[1.6]",children:n.length===0?l.jsx("p",{className:"px-3 py-2 text-content-muted",children:(t==null?void 0:t.summary)||"无差异内容"}):n.map((o,c)=>{if(o.kind==="hunk"){const h=Ob(o.text);return h&&(s=h[0],a=h[1]),l.jsxs("div",{className:"flex bg-surface-raised/60 text-accent-dim",children:[l.jsx("span",{className:"w-14 shrink-0 border-r border-border"}),l.jsx("span",{className:"px-3 py-0.5",children:o.text})]},c)}if(o.kind==="meta")return null;const u=o.kind==="add",d=o.kind==="remove",f=u?"":String(s),p=d?"":String(a);return u||(s+=1),d||(a+=1),l.jsxs("div",{className:`flex ${u?"bg-diff-add":d?"bg-diff-remove":""}`,children:[l.jsxs("span",{className:"flex w-14 shrink-0 select-none justify-end gap-1.5 border-r border-border px-1.5 py-0.5 text-[10px] text-content-faint",children:[l.jsx("span",{className:"w-5 text-right",children:f}),l.jsx("span",{className:"w-5 text-right",children:p})]}),l.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${u?"text-diff-addText":d?"text-diff-removeText":"text-content-secondary"}`,children:[l.jsx("span",{className:"mr-2 select-none opacity-60",children:u?"+":d?"−":" "}),o.text||" "]})]},c)})})]})}function Yt({oldText:e,newText:t}){const n=e?e.split(`
|
|
34
|
-
`):[],r=t?t.split(`
|
|
35
|
-
`):[];if(n.length===0&&r.length===0)return null;const i=(s,a,o)=>l.jsx("div",{className:`flex ${a?"bg-diff-add":"bg-diff-remove"}`,children:l.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${a?"text-diff-addText":"text-diff-removeText"}`,children:[l.jsx("span",{className:"mr-2 select-none opacity-60",children:a?"+":"−"}),s||" "]})},o);return l.jsxs("div",{className:"max-h-72 overflow-auto rounded-lg border border-border bg-surface-raised font-mono text-[13px] leading-[1.6]",children:[n.map((s,a)=>i(s,!1,`r${a}`)),r.map((s,a)=>i(s,!0,`a${a}`))]})}function ti(e){if(!e)return;const t=e.split("/").filter(Boolean);return t.length>2?t.slice(-2).join("/"):e}function ir(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.old_string=="string"||typeof t.new_string=="string"}function $b(e){if(!Array.isArray(e))return null;const t=[];for(const n of e){if(!n||typeof n!="object")return null;const r=n;if(typeof r.content!="string"||typeof r.status!="string")return null;t.push({content:r.content,status:r.status,activeForm:typeof r.activeForm=="string"?r.activeForm:void 0})}return t}function Bb({todos:e}){return l.jsx("ul",{className:"space-y-1.5",children:e.map((t,n)=>l.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[l.jsx("span",{className:"mt-1 shrink-0",children:t.status==="completed"?l.jsx(Rt,{size:12,className:"text-success"}):t.status==="in_progress"?l.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):l.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),l.jsx("span",{className:`min-w-0 flex-1 ${t.status==="completed"?"text-content-muted line-through":t.status==="in_progress"?"font-semibold text-content-primary":"text-content-secondary"}`,children:t.status==="in_progress"&&t.activeForm?t.activeForm:t.content})]},n))})}function qb(e,t=120){const n=e.replace(/\s+/g," ").trim();return n.length>t?n.slice(0,t-1)+"…":n}function Vb(e,t){let n={};if(t)try{const s=JSON.parse(t);s&&typeof s=="object"&&(n=s)}catch{}const r=s=>typeof n[s]=="string"?n[s]:void 0;switch(e.split(/ · |__/).pop()??e){case"WebSearch":return{Icon:Mt,label:"网络搜索",summary:r("query")};case"WebFetch":return{Icon:qn,label:"获取网页",summary:r("url")};case"Grep":{const s=r("pattern"),a=r("path");return{Icon:Mt,label:"搜索代码",summary:a?`${s??""} · ${a}`:s}}case"Glob":return{Icon:Mt,label:"查找文件",summary:r("pattern")};case"Read":return{Icon:kn,label:"读取文件",summary:r("file_path")??r("path")};case"LS":case"List":return{Icon:Pt,label:"列出目录",summary:r("path")};case"Task":return{Icon:$i,label:"子任务",summary:r("description")??r("prompt")};case"Edit":{const s=r("file_path"),a=ir(n)?l.jsx(Yt,{oldText:n.old_string,newText:n.new_string}):void 0;return{Icon:Wt,label:"编辑文件",summary:ti(s),body:a}}case"MultiEdit":{const s=r("file_path"),a=Array.isArray(n.edits)?n.edits.filter(ir):[],o=a.length>0?l.jsx("div",{className:"space-y-2",children:a.map((c,u)=>l.jsx(Yt,{oldText:c.old_string,newText:c.new_string},u))}):void 0;return{Icon:Wt,label:"编辑文件",summary:ti(s),body:o}}case"Write":{const s=r("file_path"),a=r("content"),o=a!=null?l.jsx(Yt,{newText:a}):void 0;return{Icon:Wt,label:"写入文件",summary:ti(s),body:o}}case"TodoWrite":{const s=$b(n.todos);if(!s)return{Icon:Rt,label:"更新任务列表"};const a=s.filter(o=>o.status==="completed").length;return{Icon:Rt,label:"更新任务列表",summary:`${a}/${s.length}`,body:l.jsx(Bb,{todos:s})}}case"NotebookEdit":return{Icon:Wt,label:"编辑 Notebook",summary:r("notebook_path")};default:return{Icon:Fi,label:e}}}function Ub({status:e}){const t=e==="completed"?"bg-success":e==="failed"?"bg-danger":e==="running"?"bg-accent animate-pulse-dot":"bg-content-faint";return l.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${t}`})}function Wl({item:e}){const t=e.toolCall,n=e.commandExecution,r=(n==null?void 0:n.status)??(t==null?void 0:t.status),i=!!(n!=null&&n.output||t!=null&&t.input||t!=null&&t.output),[s,a]=v.useState(r==="running"||r==="failed"),o=!n&&t?Vb(t.name,t.input):null,c=(o==null?void 0:o.Icon)??Fi;return l.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-surface",children:[l.jsxs("button",{onClick:()=>i&&a(u=>!u),className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors ${i?"cursor-pointer hover:bg-surface-overlay":"cursor-default"} ${n?"border-b border-border bg-surface-raised":""}`,children:[i?s?l.jsx(bt,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(et,{size:12,className:"shrink-0 text-content-faint"}):l.jsx("span",{className:"w-3 shrink-0"}),l.jsx(Ub,{status:r}),n?l.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",children:`$ ${n.command??"命令"}`}):l.jsxs(l.Fragment,{children:[l.jsx(c,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"shrink-0 text-[13px] font-medium text-content-secondary",children:(o==null?void 0:o.label)??(t==null?void 0:t.name)??"工具调用"}),(o==null?void 0:o.summary)&&l.jsx("span",{className:"truncate font-mono text-[13px] text-content-faint",children:qb(o.summary)})]}),n&&typeof n.exitCode=="number"&&l.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[13px] ${n.exitCode===0?"text-success":"text-danger"}`,children:["exit ",n.exitCode]})]}),s&&i&&l.jsxs("div",{className:n?"":"px-3.5 pb-3 pt-2",children:[(n==null?void 0:n.output)&&l.jsxs("div",{className:"group/out relative",children:[l.jsx("pre",{className:"max-h-72 overflow-auto px-3.5 py-2.5 font-mono text-[13px] leading-relaxed text-content-secondary",children:n.output}),l.jsx(_r,{text:n.output,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/out:opacity-100"})]}),o!=null&&o.body?o.body:(t==null?void 0:t.input)&&l.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:t.input}),(t==null?void 0:t.output)&&l.jsx("pre",{className:"mt-2 max-h-60 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:t.output})]})]})}function Hb(e,t){if(!e||!t)return null;let n;try{const i=JSON.parse(t);if(!i||typeof i!="object")return null;n=i}catch{return null}const r=(e.split(/ · |__/).pop()??e).toLowerCase();if(r==="edit")return ir(n)?l.jsx(Yt,{oldText:n.old_string,newText:n.new_string}):typeof n.path=="string"?l.jsx("pre",{className:"max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:n.path}):null;if(r==="multiedit"){const i=Array.isArray(n.edits)?n.edits.filter(ir):[];return i.length>0?l.jsx("div",{className:"space-y-2",children:i.map((s,a)=>l.jsx(Yt,{oldText:s.old_string,newText:s.new_string},a))}):null}return r==="write"?typeof n.content=="string"?l.jsx(Yt,{newText:n.content}):null:r==="bash"||r==="shell"||r==="command"||r==="commandexecution"?typeof n.command!="string"?null:l.jsxs("div",{children:[l.jsx("pre",{className:"max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:`$ ${n.command}`}),typeof n.cwd=="string"&&n.cwd&&l.jsx("p",{className:"mt-1.5 font-mono text-xs text-content-faint",children:n.cwd}),typeof n.description=="string"&&n.description&&l.jsx("p",{className:"mt-1.5 text-xs text-content-muted",children:n.description})]}):null}function Zb(e){if(!e)return!1;const t=e.tagName;return t==="TEXTAREA"||t==="INPUT"||t==="SELECT"?!0:e.isContentEditable===!0}function Wb({item:e,onRespond:t}){var p;const[n,r]=v.useState(!1),i=e.permission,s=n||((p=e.metadata)==null?void 0:p.permissionPending)===!0,a=[...i&&i.options.length>0?i.options:[{id:"allow",label:"允许一次",kind:"allow"},{id:"deny",label:"拒绝",kind:"deny"}]].sort((h,m)=>h.kind===m.kind?0:h.kind==="allow"?-1:1),o=(h,m)=>{!i||s||(r(!0),t(i.requestId,h,m))},c=a.find(h=>h.kind==="allow"),u=c==null?void 0:c.id;if(v.useEffect(()=>{if(!i||s||!u)return;const h=m=>{m.key!=="Enter"||m.metaKey||m.ctrlKey||m.altKey||m.shiftKey||m.isComposing||Zb(document.activeElement)||(m.preventDefault(),o("allow",u))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s,u,i==null?void 0:i.requestId]),!i)return null;const d=Hb(i.toolName,i.toolInput),f=a.filter(h=>h.kind==="allow").length;return l.jsxs("div",{className:"rounded-xl border border-warning/40 bg-surface p-4",children:[l.jsx("p",{className:"text-sm font-medium text-content-primary",children:Rf(i.toolName)}),i.context&&l.jsx("p",{className:"mt-1.5 text-sm text-content-secondary",children:i.context}),d?l.jsx("div",{className:"mt-2",children:d}):i.toolInput&&l.jsx("pre",{className:"mt-2 max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:i.toolInput}),l.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:a.map(h=>{const m=h.kind==="allow"?a.filter(S=>S.kind==="allow").findIndex(S=>S.id===h.id):-1,b=h.kind==="allow"?m===0||f===1?"codex-btn-primary min-h-11 px-4 text-sm":"codex-btn-outline min-h-11 px-4 text-sm":"codex-btn-ghost min-h-11 px-4 text-sm";return l.jsx("button",{disabled:s,onClick:()=>o(h.kind==="allow"?"allow":"deny",h.id),className:b,children:h.label},h.id)})}),s&&l.jsx("p",{className:"mt-2 text-xs text-content-muted",children:"已发送…"})]})}function Qb({item:e}){var t;return(t=e.plan)!=null&&t.length?l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4",children:[l.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"计划"}),l.jsx("ul",{className:"space-y-1.5",children:e.plan.map(n=>l.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[l.jsx("span",{className:"mt-1 shrink-0",children:n.status==="completed"?l.jsx(Rt,{size:12,className:"text-success"}):n.status==="in_progress"?l.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):l.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),l.jsx("div",{className:`min-w-0 flex-1 ${n.status==="completed"?"text-content-muted line-through":"text-content-secondary"}`,children:l.jsx(Hl,{text:n.text})})]},n.id))})]}):null}function Kb({item:e,onSubmit:t}){var f,p,h;const n=e.structuredInput,[r,i]=v.useState({});if(!n)return null;const s=((f=e.metadata)==null?void 0:f.inputSubmitting)===!0,a=((p=e.metadata)==null?void 0:p.inputSubmitted)===!0,o=typeof((h=e.metadata)==null?void 0:h.inputError)=="string"?e.metadata.inputError:void 0,c=(m,b,S)=>{i(k=>{const A=k[m]??[];if(A.includes(b))return{...k,[m]:A.filter(W=>W!==b)};if(!S||S<=1)return{...k,[m]:[b]};const I=[...A,b];return{...k,[m]:I.slice(-S)}})},u=(m,b)=>{i(S=>({...S,[m]:b?[b]:[]}))},d=n.questions.every(m=>{var b;return(((b=r[m.id])==null?void 0:b.length)??0)>0});return l.jsxs("div",{className:"rounded-xl border border-accent-dim/40 bg-surface p-4",children:[l.jsx("p",{className:"text-sm font-medium text-accent",children:"需要你的输入"}),l.jsx("div",{className:"mt-3 space-y-4",children:n.questions.map(m=>l.jsxs("div",{children:[m.header&&l.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:m.header}),l.jsx("p",{className:"mb-2 text-sm text-content-secondary",children:m.question}),m.options&&m.options.length>0&&m.selectionLimit&&m.selectionLimit>1&&l.jsxs("p",{className:"mb-2 text-2xs text-content-faint",children:["可多选",m.selectionLimit<m.options.length?`(最多 ${m.selectionLimit} 项)`:""]}),m.options&&m.options.length>0?l.jsx("div",{className:"flex flex-wrap gap-2",children:m.options.map(b=>{const S=(r[m.id]??[]).includes(b.id);return l.jsx("button",{disabled:a||s,onClick:()=>c(m.id,b.id,m.selectionLimit),title:b.description,className:S?"codex-btn-primary text-xs":"codex-btn-outline text-xs",children:b.label},b.id)})}):l.jsx("input",{type:m.isSecret?"password":"text",disabled:a||s,onChange:b=>u(m.id,b.target.value),className:"codex-input text-sm",placeholder:"输入答案…"})]},m.id))}),o&&l.jsx("p",{className:"mt-3 text-xs text-danger",children:o}),l.jsx("div",{className:"mt-3",children:a?l.jsx("span",{className:"text-xs text-content-muted",children:"已提交"}):l.jsx("button",{disabled:!d||s,onClick:()=>t(n.requestId,r),className:"codex-btn-primary text-xs",children:s?"提交中…":"提交"})})]})}function cs(){return l.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-2xs text-accent",children:[l.jsx("span",{className:"h-1 w-1 animate-pulse-dot rounded-full bg-accent"}),"正在生成"]})}function Ql({item:e}){const[t,n]=v.useState(!!e.isStreaming);return l.jsxs("div",{className:"rounded-xl border border-border bg-surface px-3.5 py-2.5",children:[l.jsxs("button",{onClick:()=>n(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[t?l.jsx(bt,{size:11,className:"shrink-0 text-content-faint"}):l.jsx(et,{size:11,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:"思考过程"}),e.isStreaming&&l.jsx(cs,{})]}),t&&e.text&&l.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words pl-4 text-sm italic leading-relaxed text-content-muted",children:e.text})]})}function $a({item:e,label:t}){const[n,r]=v.useState(!1),i=e.text!=null&&e.text.trim()!=="";return l.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-2xs text-content-faint",children:[l.jsx("span",{className:"h-px flex-1 bg-border"}),l.jsxs("button",{onClick:()=>i&&r(s=>!s),className:`flex shrink-0 items-center gap-1 rounded-full border border-border bg-surface px-2.5 py-1 ${i?"cursor-pointer transition-colors hover:text-content-secondary":"cursor-default"}`,title:i?n?"收起":"展开":void 0,children:[l.jsx("span",{className:"font-medium",children:t}),e.isStreaming&&l.jsx(cs,{}),i&&(n?l.jsx(bt,{size:10}):l.jsx(et,{size:10}))]}),l.jsx("span",{className:"h-px flex-1 bg-border"}),n&&i&&l.jsx("p",{className:"basis-full whitespace-pre-wrap break-words pt-1.5 text-xs italic leading-relaxed text-content-muted",children:e.text})]})}function Yb(e){const t=Math.max(1,e.receiverThreadIds.length,e.receiverAgents.length),n=(e.tool||"").toLowerCase();return n.includes("spawn")?`启动 ${t} 个子 Agent`:n.includes("wait")?`等待 ${t} 个子 Agent`:n.includes("resume")?`恢复 ${t} 个子 Agent`:n.includes("close")?`关闭 ${t} 个子 Agent`:n.includes("sendinput")||n.includes("send_input")?`更新 ${t} 个子 Agent`:t===1?"子 Agent 活动":`${t} 个子 Agent 活动`}function Xb(e){const t=(e||"").toLowerCase().replace(/[\s_-]/g,"");return t==="completed"||t==="done"||t==="success"?"完成":t==="failed"||t==="error"?"失败":t==="stopped"||t==="cancelled"?"已停止":t==="queued"||t==="pending"?"排队中":t==="running"||t==="inprogress"?"运行中":e||"未知"}function Kl({item:e,onOpenAgent:t}){const n=e.subagent,[r,i]=v.useState(!0),s=[...new Set(n.receiverThreadIds.length>0?n.receiverThreadIds:n.receiverAgents.map(a=>a.threadId))];return l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-3.5",children:[l.jsxs("button",{onClick:()=>i(a=>!a),className:"flex w-full cursor-pointer items-center gap-2 text-left",children:[l.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-accent/10 text-accent",children:l.jsx($i,{size:13})}),l.jsx("span",{className:"flex-1 truncate text-sm font-medium text-content-primary",children:Yb(n)}),e.isStreaming&&l.jsx("span",{className:"h-1.5 w-1.5 animate-pulse-dot rounded-full bg-accent"}),r?l.jsx(bt,{size:13,className:"shrink-0 text-content-faint"}):l.jsx(et,{size:13,className:"shrink-0 text-content-faint"})]}),n.prompt&&l.jsx("p",{className:`mt-2 text-xs leading-relaxed text-content-muted ${r?"":"line-clamp-1"}`,children:n.prompt}),r&&s.length>0&&l.jsx("div",{className:"mt-2.5 space-y-0.5",children:s.map(a=>{const o=n.receiverAgents.find(p=>p.threadId===a),c=n.agentStates[a],u=Xb((c==null?void 0:c.status)??n.status),d=o!=null&&o.nickname&&(o!=null&&o.role)?`${o.nickname} [${o.role}]`:(o==null?void 0:o.nickname)||(o==null?void 0:o.role)||(a.length>14?`Agent ${a.slice(-8)}`:a||"Agent"),f=u==="失败"?"bg-danger":u==="完成"?"bg-success":"bg-accent";return l.jsxs("button",{onClick:()=>t==null?void 0:t({threadId:a,name:d,role:o==null?void 0:o.role,model:o==null?void 0:o.model,prompt:(o==null?void 0:o.prompt)??n.prompt,status:u,message:c==null?void 0:c.message,tool:n.tool}),className:"flex w-full cursor-pointer items-center gap-2 rounded-lg px-1.5 py-1 text-left transition-colors hover:bg-surface-overlay",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${f}`}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-content-secondary",children:d}),(o==null?void 0:o.model)&&l.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:o.model}),l.jsx("span",{className:"shrink-0 text-2xs font-medium text-content-muted",children:u}),l.jsx(et,{size:12,className:"shrink-0 text-content-faint"})]},a)})})]})}function Jb({detail:e}){const t=e.status==="失败"?"bg-danger":e.status==="完成"?"bg-success":"bg-accent";return l.jsxs("div",{className:"flex h-full flex-col overflow-y-auto bg-surface",children:[l.jsxs("div",{className:"border-b border-border px-4 py-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent/10 text-accent",children:l.jsx($i,{size:15})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-semibold text-content-primary",children:e.name}),l.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",children:e.threadId})]}),l.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-xs text-content-secondary",children:[l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${t}`}),e.status]})]}),l.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.role&&l.jsx("span",{className:"codex-chip",children:e.role}),e.model&&l.jsx("span",{className:"codex-chip",children:e.model}),e.tool&&l.jsx("span",{className:"codex-chip",children:e.tool})]})]}),l.jsxs("div",{className:"space-y-4 px-4 py-4",children:[e.prompt&&l.jsxs("section",{children:[l.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"委派指令"}),l.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.prompt})]}),e.message&&l.jsxs("section",{children:[l.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"状态消息"}),l.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.message})]}),l.jsx("p",{className:"pt-2 text-2xs leading-relaxed text-content-faint",children:"子 Agent 由主 Agent 内部派生,其完整对话记录不经网关透出,因此此处仅展示主 Agent 报告的状态信息。"})]})]})}const Gb=new Set(["tool_activity","command_execution","file_change","subagent_action","thinking"]);function ek(e){return!!(e.kind&&Gb.has(e.kind)||e.fileChange||e.commandExecution||e.toolCall||e.subagent||e.type==="tool_call")}function $n(e){var t,n,r;return e.role==="user"&&((t=e.metadata)==null?void 0:t.delivery)==="queued"&&((n=e.metadata)==null?void 0:n.queuedSent)!==!0&&((r=e.metadata)==null?void 0:r.queuedDiscarded)!==!0}function tk({items:e,canSteer:t,onSend:n,onSteer:r,onDiscard:i}){return e.length===0?null:l.jsx("div",{className:"mb-2 flex flex-col gap-1.5",children:e.map(s=>l.jsxs("div",{className:"group flex animate-slide-in items-center gap-2 rounded-xl border border-border bg-surface-raised px-3.5 py-2.5 shadow-sm",children:[l.jsx("span",{className:"shrink-0 rounded-full bg-surface-overlay px-2 py-0.5 text-2xs font-medium text-content-muted",children:"已排队"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-secondary",children:s.text}),l.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[l.jsx("button",{onClick:()=>n(s.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"立即发送",children:"立即发送"}),t&&l.jsx("button",{onClick:()=>r(s.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"引导当前轮",children:"引导"}),l.jsx("button",{onClick:()=>i(s.id),className:"cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:text-danger",title:"丢弃","aria-label":"丢弃排队消息",children:l.jsx(ft,{size:14})})]})]},s.id))})}function Ba(e,t,n){return e.kind==="thinking"?l.jsx(Ql,{item:e}):e.kind==="subagent_action"||e.subagent?l.jsx(Kl,{item:e,onOpenAgent:n}):e.kind==="file_change"||e.fileChange?l.jsx(Zl,{item:e,onOpen:t}):l.jsx(Wl,{item:e})}function nk(e){let t=1/0,n=0;for(const c of e){typeof c.createdAt=="number"&&(t=Math.min(t,c.createdAt));const u=typeof c.updatedAt=="number"?c.updatedAt:c.createdAt;typeof u=="number"&&(n=Math.max(n,u))}if(!Number.isFinite(t)||n<=t)return;const r=n-t;if(r<1e3)return;const i=Math.round(r/1e3);if(i<60)return`${(r/1e3).toFixed(1)}s`;const s=Math.floor(i/60),a=i%60;return s<60?`${s}m ${String(a).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m ${String(a).padStart(2,"0")}s`}function rk({items:e,live:t,onOpenDiff:n,onOpenAgent:r}){const[i,s]=v.useState(!1);if(t)return l.jsx("div",{className:"space-y-2",children:e.map(m=>l.jsx("div",{children:Ba(m,n,r)},m.id))});const a=e.filter(m=>m.kind==="file_change"||m.fileChange).length,o=e.filter(m=>m.kind==="command_execution"||m.commandExecution).length,c=e.filter(m=>(m.toolCall||m.type==="tool_call")&&!m.subagent).length,u=e.filter(m=>m.kind==="subagent_action"||m.subagent).length,d=e.filter(m=>m.kind==="thinking").length,f=[];a&&f.push(`编辑 ${a} 个文件`),o&&f.push(`运行 ${o} 条命令`),c&&f.push(`调用 ${c} 个工具`),u&&f.push(`${u} 次子 Agent`),!a&&!o&&!c&&!u&&d&&f.push("思考");const p=f.join(" · ")||`${e.length} 项活动`,h=nk(e);return i?l.jsxs("div",{className:"rounded-xl border border-border bg-surface p-2",children:[l.jsxs("button",{onClick:()=>s(!1),className:"mb-2 flex w-full cursor-pointer items-center gap-1.5 px-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[l.jsx(bt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:p}),h&&l.jsxs("span",{className:"text-content-faint",children:["· ",h]})]}),l.jsx("div",{className:"space-y-2",children:e.map(m=>l.jsx("div",{children:Ba(m,n,r)},m.id))})]}):l.jsxs("button",{onClick:()=>s(!0),className:"flex w-full cursor-pointer items-center gap-1.5 rounded-full border border-border bg-surface px-3.5 py-2 text-left text-xs text-content-muted transition-colors hover:border-border-strong hover:text-content-secondary",children:[l.jsx(et,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{children:p}),h&&l.jsxs("span",{className:"text-content-faint",children:["· ",h]}),l.jsx("span",{className:"ml-auto text-content-faint",children:"展开"})]})}const qa=v.memo(function({item:t,canSteer:n,onPermission:r,onStructuredInput:i,onSendQueued:s,onSteerQueued:a,onDiscardQueued:o,onOpenDiff:c,onOpenAgent:u,onEditMessage:d,onFork:f,highlightQuery:p}){var S;if(t.kind==="user_input_prompt"||t.structuredInput)return l.jsx(Kb,{item:t,onSubmit:i});if(t.kind==="subagent_action"||t.subagent)return l.jsx(Kl,{item:t,onOpenAgent:u});if(t.kind==="file_change"||t.fileChange)return l.jsx(Zl,{item:t,onOpen:c});if(t.kind==="command_execution"||t.commandExecution||t.type==="tool_call"||t.toolCall)return l.jsx(Wl,{item:t});if(t.type==="permission"||t.permission)return l.jsx(Wb,{item:t,onRespond:r});if(t.type==="plan"||t.plan)return l.jsx(Qb,{item:t});if(t.type==="error"||t.error)return l.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-danger/40 bg-surface px-3.5 py-2.5 text-sm text-danger",children:[l.jsx("span",{className:"mt-1.5 block h-1.5 w-1.5 shrink-0 rounded-full bg-danger"}),l.jsx("span",{children:t.error??"发生错误"})]});if(t.kind==="thinking")return l.jsx(Ql,{item:t});if(t.kind==="context_compaction")return l.jsx($a,{item:t,label:"上下文压缩"});if(t.kind==="review")return l.jsx($a,{item:t,label:"审查"});const h=t.role==="user",m=((S=t.metadata)==null?void 0:S.queuedDiscarded)===!0,b=t.text!=null&&t.text!=="";return l.jsxs("div",{className:h?"group flex flex-col items-end":"group min-w-0",children:[l.jsxs("div",{className:h?`max-w-[85%] break-words rounded-2xl px-4 py-2.5 text-[15px] leading-7 ${m?"bg-surface-raised text-content-secondary line-through opacity-50":"bg-surface-raised text-content-primary"}`:"w-full min-w-0",children:[Array.isArray(t.content)&&t.content.some(k=>k.type==="image")&&l.jsx("div",{className:"mb-1.5 flex flex-wrap gap-2",children:t.content.filter(k=>k.type==="image"&&k.data).map((k,A)=>l.jsx("img",{src:k.data,alt:"附件",className:"max-h-48 rounded-lg border border-border object-contain"},A))}),b&&l.jsx(Hl,{text:t.text,highlight:p}),t.isStreaming&&l.jsx(cs,{})]}),m&&l.jsx("span",{className:"mt-1 text-2xs text-content-faint",children:"已丢弃"}),b&&!t.isStreaming&&!m&&l.jsxs("div",{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 ${h?"justify-end":""}`,children:[h&&d&&l.jsx("button",{onClick:()=>d(t.text),title:"编辑并重新发送","aria-label":"编辑并重新发送",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:l.jsx(Wt,{size:13})}),f&&l.jsx("button",{onClick:()=>f(t.itemId??t.id),title:"从此处分叉出新会话","aria-label":"从此处分叉",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:l.jsx(Vc,{size:13})}),l.jsx(_r,{text:t.text})]})]})},(e,t)=>e.item===t.item&&e.canSteer===t.canSteer&&e.onPermission===t.onPermission&&e.onStructuredInput===t.onStructuredInput&&e.onSendQueued===t.onSendQueued&&e.onSteerQueued===t.onSteerQueued&&e.onDiscardQueued===t.onDiscardQueued&&e.onOpenDiff===t.onOpenDiff&&e.onOpenAgent===t.onOpenAgent&&e.onEditMessage===t.onEditMessage&&e.onFork===t.onFork&&e.highlightQuery===t.highlightQuery);function ik(e){const[t,n]=v.useState(()=>typeof window<"u"&&"matchMedia"in window?window.matchMedia(e).matches:!1);return v.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const r=window.matchMedia(e),i=()=>n(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),t}function Yl(){return ik("(max-width: 767px)")}function sk({disabled:e,running:t,supportsImages:n,commands:r=[],conversationId:i,lastUserText:s,cwd:a,onBrowse:o,seedText:c,controls:u,onSend:d,onCancel:f,onExecuteCommand:p}){const[h,m]=v.useState(""),[b,S]=v.useState([]),[k,A]=v.useState(0),[I,W]=v.useState(!1),[Q,j]=v.useState([]),[Y,X]=v.useState([]),[J,_]=v.useState(null),$=v.useRef(null),B=v.useRef(null),ae=Yl();v.useEffect(()=>{if(!i)return;const C=wc(i);m(C),j([]),requestAnimationFrame(()=>x())},[i]),v.useEffect(()=>{!c||c.nonce===0||(m(c.text),requestAnimationFrame(()=>{const C=$.current;C&&(C.focus(),C.setSelectionRange(C.value.length,C.value.length),x())}))},[c==null?void 0:c.nonce]);const q=v.useMemo(()=>{const C=/^\/(\S*)$/.exec(h);if(!C||r.length===0)return null;const F=C[1].toLowerCase(),_e=r.map(we=>{const De=we.name.toLowerCase(),Tt=we.title.toLowerCase();return F?De.startsWith(F)||Tt.startsWith(`/${F}`)?{c:we,rank:0}:De.includes(F)||Tt.includes(F)?{c:we,rank:1}:null:{c:we,rank:2}}).filter(we=>we!==null).sort((we,De)=>we.rank-De.rank).slice(0,8).map(we=>we.c);return _e.length>0?_e:null},[h,r]),L=v.useMemo(()=>{if(!o)return null;const C=/(?:^|\s)@(\S*)$/.exec(h);if(!C)return null;const F=C[1],te=F.lastIndexOf("/"),_e=te>=0?F.slice(0,te):"",we=te>=0?F.slice(te+1):F;return{token:`@${F}`,query:F,dir:_e,filter:we}},[h,o]),ie=v.useMemo(()=>{if(!L)return null;const C=(a||".").replace(/\/+$/,"")||"/";return L.dir?`${C}/${L.dir}`:C},[L,a]);v.useEffect(()=>{if(!ie||!o||ie===J)return;let C=!1;return o(ie).then(F=>{C||(X(F.error?[]:F.entries),_(ie))}).catch(()=>{C||X([])}),()=>{C=!0}},[ie,J,o]);const be=v.useMemo(()=>{if(!L||J!==ie)return null;const C=L.filter.toLowerCase(),F=Y.filter(te=>te.name.toLowerCase().includes(C)).sort((te,_e)=>te.isDirectory!==_e.isDirectory?te.isDirectory?-1:1:te.name.localeCompare(_e.name)).slice(0,50);return F.length>0?F:null},[L,Y,J,ie]),le=q?{kind:"slash",items:q}:be?{kind:"mention",items:be}:null,D=()=>{$.current&&($.current.style.height="auto")},x=()=>{const C=$.current;C&&(C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,200)}px`)},M=C=>{m(C),A(0),i&&Sc(i,C),x()},Ce=C=>{var F;C.argsMode==="none"?(p==null||p(C.id),M(""),D()):(M(`/${C.name} `),(F=$.current)==null||F.focus())},y=C=>{var we;if(!L)return;const F=(a||".").replace(/\/+$/,""),te=F&&C.path.startsWith(F)?C.path.slice(F.length).replace(/^\/+/,""):C.name,_e=h.slice(0,h.length-L.token.length);C.isDirectory?M(`${_e}@${te}/`):(M(_e),j(De=>De.includes(te)?De:[...De,te])),(we=$.current)==null||we.focus()},Ne=()=>{if(e)return;const C=h.trim(),F=/^\/(\S+)\s*(.*)$/s.exec(C);if(F&&p){const we=r.find(De=>De.name.toLowerCase()===F[1].toLowerCase());if(we){p(we.id,F[2]||void 0),M(""),j([]),D();return}}const _e=[Q.map(we=>`@${we}`).join(" "),C].filter(Boolean).join(" ");!_e&&b.length===0||(d(_e,b),M(""),S([]),j([]),D())},Le=C=>{if(le){const F=le.items.length;if(C.key==="ArrowDown"){C.preventDefault(),A(_e=>Math.min(_e+1,F-1));return}if(C.key==="ArrowUp"){C.preventDefault(),A(_e=>Math.max(_e-1,0));return}const te=()=>{const _e=Math.min(k,F-1);le.kind==="slash"?Ce(le.items[_e]):y(le.items[_e])};if(C.key==="Tab"){C.preventDefault(),te();return}if(C.key==="Enter"&&!C.metaKey&&!C.ctrlKey&&!C.shiftKey&&le.kind==="mention"){C.preventDefault(),te();return}if(C.key==="Enter"&&(C.metaKey||C.ctrlKey)){C.preventDefault(),te();return}if(C.key==="Escape"){C.preventDefault(),le.kind==="slash"?M(""):L&&M(h.slice(0,h.length-L.token.length));return}}if(C.key==="ArrowUp"&&!le&&h===""&&s){C.preventDefault(),M(s),requestAnimationFrame(()=>{const F=$.current;F&&F.setSelectionRange(F.value.length,F.value.length)});return}C.key==="Enter"&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),Ne())},Ie=C=>{for(const F of C){if(!F.type.startsWith("image/"))continue;const te=new FileReader;te.onload=()=>{const _e=String(te.result);S(we=>[...we,{data:_e,mimeType:F.type||"image/png",name:F.name||"粘贴图片"}])},te.readAsDataURL(F)}},Fe=C=>{Ie(Array.from(C.target.files??[])),C.target.value=""},ce=C=>{if(!n)return;const F=Array.from(C.clipboardData.items).filter(te=>te.kind==="file"&&te.type.startsWith("image/")).map(te=>te.getAsFile()).filter(te=>te!=null);F.length>0&&(C.preventDefault(),Ie(F))},Ke=C=>{if(W(!1),!n)return;const F=Array.from(C.dataTransfer.files).filter(te=>te.type.startsWith("image/"));F.length>0&&(C.preventDefault(),Ie(F))},$e=C=>{n&&Array.from(C.dataTransfer.items).some(F=>F.kind==="file")&&(C.preventDefault(),W(!0))};return l.jsxs("div",{className:"relative",children:[le&&l.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 mb-2 max-h-72 w-[min(20rem,calc(100vw-2rem))] overflow-y-auto p-1",children:le.kind==="slash"?le.items.map((C,F)=>{const te=C.description&&C.description!==C.title?C.description:void 0,_e=C.argsMode==="required"?"需要参数":C.argsMode==="optional"?"可选参数":void 0;return l.jsxs("button",{onMouseEnter:()=>A(F),onClick:()=>Ce(C),className:`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left transition-colors ${F===k?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[l.jsxs("span",{className:"flex w-full items-center",children:[l.jsxs("span",{className:"font-mono text-xs text-accent",children:["/",C.name]}),l.jsx("span",{className:"ml-2 flex-1 truncate text-xs text-content-muted",children:C.title}),_e&&l.jsx("span",{className:"ml-2 shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-content-faint",children:_e}),C.destructive&&l.jsx("span",{className:"ml-2 h-1.5 w-1.5 shrink-0 rounded-full bg-danger",title:"破坏性操作"})]}),te&&l.jsx("span",{className:"mt-0.5 truncate text-[11px] text-content-faint",children:te})]},C.id)}):le.items.map((C,F)=>l.jsxs("button",{onMouseEnter:()=>A(F),onClick:()=>y(C),className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors ${F===k?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[C.isDirectory?l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}):l.jsx(kn,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-xs text-content-secondary",children:C.name}),C.isDirectory&&l.jsx("span",{className:"text-content-faint",children:"/"})]},C.path))}),b.length>0&&l.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:b.map((C,F)=>l.jsxs("div",{className:"group relative",children:[l.jsx("img",{src:C.data,alt:C.name,className:"h-14 w-14 rounded-lg border border-border object-cover"}),l.jsx("button",{onClick:()=>S(te=>te.filter((_e,we)=>we!==F)),className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-danger text-white","aria-label":"移除图片",children:l.jsx(ft,{size:10})})]},F))}),Q.length>0&&l.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:Q.map(C=>l.jsxs("span",{className:"flex items-center gap-1 rounded-lg border border-border bg-surface-overlay py-1 pl-2 pr-1 font-mono text-xs text-content-secondary",children:[l.jsx(kn,{size:12,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"max-w-[200px] truncate",title:C,children:C}),l.jsx("button",{onClick:()=>j(F=>F.filter(te=>te!==C)),className:"flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-content-faint transition-colors hover:text-danger","aria-label":`移除 ${C}`,children:l.jsx(ft,{size:11})})]},C))}),l.jsxs("div",{onDrop:Ke,onDragOver:$e,onDragLeave:()=>W(!1),className:`codex-card-raised flex flex-col gap-1 px-3 pt-2.5 pb-2 transition-colors focus-within:border-border-strong ${I?"border-border-strong":""}`,children:[n&&l.jsx("input",{ref:B,type:"file",accept:"image/*",multiple:!0,onChange:Fe,className:"hidden"}),l.jsx("textarea",{ref:$,value:h,rows:1,disabled:e,placeholder:ae?r.length>0?"发送指令,或输入 / 调用命令…":"向 agent 发送指令…":r.length>0?"发送指令,/ 调用命令,@ 引用文件 (⌘/Ctrl+Enter 发送)":"向 agent 发送指令,@ 引用文件 (⌘/Ctrl+Enter 发送,Enter 换行)",onChange:C=>M(C.target.value),onKeyDown:Le,onPaste:ce,className:"min-w-0 resize-none bg-transparent px-0 py-1 text-base leading-6 text-content-primary placeholder-content-muted outline-none md:text-[15px]"}),l.jsxs("div",{className:"flex items-center gap-1",children:[n&&l.jsx("button",{onClick:()=>{var C;return(C=B.current)==null?void 0:C.click()},disabled:e,className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary disabled:opacity-40",title:"附加图片","aria-label":"附加图片",children:l.jsx(dr,{size:17})}),l.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:u}),t&&f?l.jsx("button",{onClick:f,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface-overlay text-content-secondary transition-colors hover:bg-surface-raised hover:text-content-primary","aria-label":"停止",title:"停止",children:l.jsx(fo,{size:14})}):l.jsx("button",{onClick:Ne,disabled:e||!h.trim()&&b.length===0&&Q.length===0,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-accent-dim text-white transition-colors hover:bg-accent disabled:cursor-default disabled:bg-surface-overlay disabled:text-content-faint","aria-label":"发送",title:"发送",children:l.jsx(ho,{size:16})})]})]})]})}const ak="modulepreload",ok=function(e){return"/"+e},Va={},jr=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let a=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),c=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=a(n.map(u=>{if(u=ok(u),u in Va)return;Va[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":ak,d||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((h,m)=>{p.addEventListener("load",h),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${u}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})},lk=v.lazy(()=>jr(()=>import("./TerminalPanel-BjxX8Jui.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.TerminalPanel}))),ck=v.lazy(()=>jr(()=>import("./UsageDashboard-cYiZs8c8.js"),__vite__mapDeps([4,1,3])).then(e=>({default:e.UsageDashboard}))),uk=v.lazy(()=>jr(()=>import("./PortPreview-KYkYV_-p.js"),__vite__mapDeps([5,1,3])).then(e=>({default:e.PortPreview}))),dk=v.lazy(()=>jr(()=>import("./FileBrowser-Dn_avjeH.js"),__vite__mapDeps([6,1,3])).then(e=>({default:e.FileBrowser})));function fk(){return l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"})})}function Cr(e){return function(n){return l.jsx(v.Suspense,{fallback:l.jsx(fk,{}),children:l.jsx(e,{...n})})}}const Ua=Cr(lk),hk=Cr(ck),pk=Cr(uk),mk=Cr(dk);function Xl(e){if(!e||e==="—")return"(未知目录)";const t=e.replace(/\/+$/,"").split("/");return t[t.length-1]||e}function Ha(e,t){return e.status==="waiting_permission"?0:e.status==="running"?1:e.status==="error"?2:e.id===t?3:4}function gk(e){return(t,n)=>{const r=Ha(t,e)-Ha(n,e);return r!==0?r:n.lastActivityAt-t.lastActivityAt}}function xk(e){return e.status==="waiting_permission"||e.status==="running"||e.status==="error"}function yk(e){const t=new Map;for(const r of e){const i=r.cwd||"—";let s=t.get(i);s||(s={cwd:i,label:Xl(i),providers:new Map},t.set(i,s));const a=s.providers.get(r.provider)??[];a.push(r),s.providers.set(r.provider,a)}for(const r of t.values())for(const i of r.providers.values())i.sort((s,a)=>a.lastActivityAt-s.lastActivityAt);const n=r=>{let i=0;for(const s of r.providers.values())for(const a of s)i=Math.max(i,a.lastActivityAt);return i};return[...t.values()].sort((r,i)=>n(i)-n(r))}function bk(e){return[...e.providers.entries()].map(([t,n])=>({provider:t,conversations:n})).sort((t,n)=>Pi(t.provider).localeCompare(Pi(n.provider)))}function Pi(e){switch(e){case"claude":return"Claude";case"codex":return"Codex";case"gemini":return"Gemini";case"copilot":return"Copilot";case"opencode":return"OpenCode";case"cursor":return"Cursor";case"kimi":return"Kimi";default:return e}}function ni({status:e}){const t=e==="unavailable"?{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"}:Mo(e);return t?l.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${t.className}`,children:[t.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),t.text]}):null}function Za({deviceLabel:e,conversations:t,capabilities:n,activeConversationId:r,externalAgentStatus:i,externalAgentTitle:s,externalAgentProvider:a,store:o,onSelect:c,onNewConversation:u,onOpenExternalTerminal:d}){const p=((n==null?void 0:n.providers)??[]).filter(M=>M.enabled),[h,m]=v.useState(!1),b=v.useMemo(()=>t.filter(M=>M.archived).length,[t]),S=v.useCallback(M=>!(M.archived&&!h||M.model==="<synthetic>"),[h]),k=v.useMemo(()=>t.filter(S),[t,S]),A=v.useMemo(()=>k.filter(xk).sort(gk(r)),[k,r]),I=i==="running"||i==="waiting_permission"||i==="error",W=I||A.length>0,Q=v.useMemo(()=>yk(k),[k]),[j,Y]=v.useState(new Set),X=M=>Y(Ce=>{const y=new Set(Ce);return y.has(M)?y.delete(M):y.add(M),y}),[J,_]=v.useState(null),[$,B]=v.useState(null),[ae,q]=v.useState(null),[L,ie]=v.useState(""),be=v.useRef(!1),le=()=>{_(null),B(null)},D=M=>{le(),q(M.id),ie(M.title&&M.title.trim()||"")},x=M=>{o.renameConversation(M.id,L),q(null)};return l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-3",children:[l.jsx(Dc,{size:14,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-[13px] font-semibold text-content-secondary",children:e})]}),l.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[l.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"新建对话"}),p.length===0?l.jsx("span",{className:"text-2xs text-content-faint",children:"等待能力…"}):l.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(M=>l.jsxs("button",{onClick:()=>u(M.id),className:"codex-btn-outline text-2xs","aria-label":`新建 ${M.label} 对话`,children:[l.jsx(Qt,{provider:M.id,size:13})," ",M.label]},M.id))})]}),W&&l.jsxs("div",{className:"border-b border-border px-3 py-3",children:[l.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"活跃会话"}),l.jsxs("div",{className:"space-y-1",children:[I&&i&&l.jsxs("button",{onClick:d,className:"flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay",title:"打开终端面板",children:[l.jsx(Qt,{provider:a??"custom",size:14}),l.jsxs("span",{className:"min-w-0 flex-1",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:s??"外部终端"}),l.jsx(ni,{status:i})]}),l.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:e})]})]},"active:external-terminal"),A.map(M=>{const Ce=M.title&&M.title.trim()||M.lastMessagePreview&&M.lastMessagePreview.trim().slice(0,40)||`对话 ${M.id.slice(-6)}`;return l.jsxs("button",{onClick:()=>c(M.id),className:`flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay ${M.id===r?"tree-row-active":""}`,title:M.cwd,children:[l.jsx(Qt,{provider:M.provider,size:14}),l.jsxs("span",{className:"min-w-0 flex-1",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:Ce}),l.jsx(ni,{status:M.status})]}),l.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:Xl(M.cwd)})]})]},`active:${M.id}`)})]})]}),l.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:Q.length===0?l.jsx("p",{className:"px-3 py-2 text-2xs text-content-faint",children:h||b===0?"还没有对话":"没有未归档的对话"}):Q.map(M=>{const Ce=`folder:${M.cwd}`,y=j.has(Ce);return l.jsxs("div",{className:"py-1",children:[l.jsxs("button",{onClick:()=>X(Ce),className:"tree-row",title:M.cwd,children:[y?l.jsx(et,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(bt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-content-faint",children:M.label})]}),!y&&bk(M).map(({provider:Ne,conversations:Le})=>{const Ie=`prov:${M.cwd}:${Ne}`,Fe=j.has(Ie);return l.jsxs("div",{className:"pl-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>X(Ie),className:"tree-row flex-1",children:[Fe?l.jsx(et,{size:12,className:"shrink-0 text-content-faint"}):l.jsx(bt,{size:12,className:"shrink-0 text-content-faint"}),l.jsx(Qt,{provider:Ne,size:13}),l.jsx("span",{className:"text-[13px] font-medium text-content-secondary",children:Pi(Ne)}),l.jsxs("span",{className:"text-2xs text-content-faint",children:["(",Le.length,")"]})]}),l.jsx("button",{onClick:()=>u(Ne,M.cwd==="—"?void 0:M.cwd),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:"在此目录新建对话","aria-label":"新建对话",children:l.jsx(dr,{size:13})})]}),!Fe&&Le.map(ce=>{const Ke=ce.title&&ce.title.trim()||ce.lastMessagePreview&&ce.lastMessagePreview.trim().slice(0,40)||`对话 ${ce.id.slice(-6)}`,$e=ae===ce.id,C=J===ce.id;return l.jsxs("div",{className:"group relative",children:[$e?l.jsx("input",{autoFocus:!0,value:L,onChange:F=>ie(F.target.value),onKeyDown:F=>{F.key==="Enter"?(F.preventDefault(),F.currentTarget.blur()):F.key==="Escape"&&(be.current=!0,F.currentTarget.blur())},onBlur:()=>{if(be.current){be.current=!1,q(null);return}x(ce)},placeholder:"对话名称",className:"block w-full rounded-lg border border-accent bg-surface py-2 pl-7 pr-3 text-[13px] text-content-primary outline-none"}):l.jsxs("button",{onClick:()=>c(ce.id),className:`block w-full cursor-pointer rounded-lg py-2 pl-7 pr-9 text-left transition-colors duration-150 hover:bg-surface-overlay ${ce.id===r?"tree-row-active":""}`,children:[l.jsxs("p",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"truncate text-[13px] text-content-primary",children:Ke}),l.jsx(ni,{status:ce.status}),ce.archived&&l.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-2xs text-content-faint",children:"已归档"})]}),ce.lastMessagePreview&&ce.lastMessagePreview.trim()!==Ke&&l.jsx("p",{className:"mt-0.5 truncate text-2xs text-content-muted",children:ce.lastMessagePreview})]}),!$e&&l.jsx("button",{onClick:F=>{F.stopPropagation(),B(null),_(C?null:ce.id)},className:`absolute right-1.5 top-1.5 cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-primary ${C?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"更多操作","aria-label":"更多操作",children:l.jsx(go,{size:14})}),C&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"fixed inset-0 z-10 cursor-default",onClick:le,"aria-label":"关闭菜单"}),l.jsxs("div",{className:"absolute right-1.5 top-9 z-20 w-40 overflow-hidden rounded-lg border border-border bg-surface py-1 shadow-xl",children:[l.jsxs("button",{onClick:()=>D(ce),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[l.jsx(Wt,{size:13})," 改名"]}),l.jsxs("button",{onClick:()=>{o.setConversationArchived(ce.id,!ce.archived),le()},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[l.jsx(Ns,{size:13})," ",ce.archived?"取消归档":"归档"]}),l.jsxs("button",{onClick:()=>{$===ce.id?(o.deleteConversation(ce.id),le()):B(ce.id)},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-danger transition-colors hover:bg-danger/10",children:[l.jsx(qc,{size:13})," ",$===ce.id?"确认从列表移除?":"从列表移除"]})]})]})]},ce.id)})]},Ne)})]},M.cwd)})}),b>0&&l.jsxs("button",{onClick:()=>m(M=>!M),className:"flex items-center gap-2 border-t border-border px-3 py-2.5 text-left text-2xs text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-secondary",children:[l.jsx(Ns,{size:13,className:"shrink-0"}),h?"隐藏已归档":`显示已归档 (${b})`]})]})}const kk={none:"无",minimal:"极简",low:"低",medium:"中",high:"高",xhigh:"极高"},vk={read_only:"只读",workspace_write:"工作区写",full_access:"完全访问"};function ri({icon:e,value:t,options:n,render:r,onChange:i,title:s,placeholder:a}){const[o,c]=v.useState(!1),u=v.useRef(null);if(v.useEffect(()=>{if(!o)return;const p=h=>{u.current&&!u.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]),n.length===0)return null;const d=t!==void 0&&n.includes(t),f=d?r(t):a??r(n[0]);return l.jsxs("div",{ref:u,className:"relative shrink-0",children:[l.jsxs("button",{type:"button",onClick:()=>c(p=>!p),title:s,className:"flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium text-content-secondary transition-colors hover:bg-surface-overlay hover:text-content-primary",children:[e,l.jsx("span",{className:"max-w-[7rem] truncate",children:f}),l.jsx(bt,{size:11,className:"text-content-faint"})]}),o&&l.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 z-20 mb-1.5 min-w-[8rem] max-w-[calc(100vw-2rem)] overflow-hidden p-1 animate-fade-in",children:n.map(p=>l.jsxs("button",{type:"button",onClick:()=>{i(p),c(!1)},className:`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-surface-overlay ${d&&p===t?"text-content-primary":"text-content-secondary"}`,children:[l.jsx("span",{className:"truncate",children:r(p)}),d&&p===t&&l.jsx(Rt,{size:13,className:"shrink-0 text-accent"})]},p))})]})}function wk({conversation:e,capability:t,onChange:n}){var u;const i=((t==null?void 0:t.models)??[]).filter(d=>d.id!=="default"),s=(t==null?void 0:t.reasoningEfforts)??[],a=(t==null?void 0:t.permissionModes)??[],o=(t==null?void 0:t.supportsPlan)??!1,c=e.collaborationMode==="plan";return l.jsxs(l.Fragment,{children:[i.length>0&&l.jsx(ri,{title:"模型",value:e.model??(t==null?void 0:t.defaultModel)??((u=i[0])==null?void 0:u.id),options:i.map(d=>d.id),render:d=>{var f;return((f=i.find(p=>p.id===d))==null?void 0:f.label)??d},onChange:d=>n({model:d})}),l.jsx(ri,{title:"推理强度",value:e.reasoningEffort,options:s,render:d=>kk[d]??d,onChange:d=>n({reasoningEffort:d}),placeholder:"默认"}),l.jsx(ri,{title:"权限",value:e.permissionMode,options:a,render:d=>vk[d]??d,onChange:d=>n({permissionMode:d}),placeholder:"默认"}),o&&l.jsxs("button",{type:"button",onClick:()=>n({collaborationMode:c?"default":"plan"}),className:`inline-flex shrink-0 cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium transition-colors ${c?"bg-accent-dim text-white":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,title:"计划模式",children:[c&&l.jsx(Rt,{size:11}),"计划"]})]})}function Sk({store:e,initialPath:t,providerLabel:n,onCancel:r,onConfirm:i}){const[s,a]=v.useState(t||"."),[o,c]=v.useState([]),[u,d]=v.useState(!1),[f,p]=v.useState(null),h=v.useCallback(async b=>{d(!0),p(null);try{const S=await e.browse(b,!1);S.error?p(S.error):(a(S.path),c(S.entries.filter(k=>k.isDirectory).sort((k,A)=>k.name.localeCompare(A.name))))}catch(S){p(S.message||"无法读取目录")}finally{d(!1)}},[e]);v.useEffect(()=>{h(t||".")},[h,t]);const m=s.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return l.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/60 sm:items-center sm:p-4",onClick:r,children:l.jsxs("div",{className:"codex-card flex max-h-[85dvh] w-full max-w-lg flex-col overflow-hidden rounded-t-2xl sm:rounded-xl",onClick:b=>b.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[l.jsxs("h3",{className:"text-sm font-semibold",children:["选择工作目录 · ",n]}),l.jsx("button",{onClick:r,className:"codex-btn-ghost px-2 py-1.5","aria-label":"取消",children:l.jsx(ft,{size:15})})]}),l.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-3 py-2",children:[l.jsx("button",{onClick:()=>h(m),disabled:u,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:l.jsx(ho,{size:14})}),l.jsx("input",{value:s,onChange:b=>a(b.target.value),onKeyDown:b=>b.key==="Enter"&&h(s),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),l.jsx("button",{onClick:()=>h(s),disabled:u,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:l.jsx(po,{size:14})})]}),f&&l.jsx("p",{className:"px-4 py-2 text-2xs text-danger",children:f}),l.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:u?l.jsx("p",{className:"px-4 py-3 text-2xs text-content-muted",children:"加载中…"}):o.length===0?l.jsx("p",{className:"px-4 py-3 text-2xs text-content-faint",children:"(无子目录)"}):o.map(b=>l.jsxs("button",{onClick:()=>h(b.path),className:"flex w-full cursor-pointer items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[l.jsx(Pt,{size:13,className:"shrink-0 text-content-faint"}),l.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:b.name})]},b.path))}),l.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:pb-3",children:[l.jsxs("span",{className:"truncate font-mono text-2xs text-content-muted",title:s,children:["将在此创建:",s]}),l.jsx("button",{onClick:()=>i(s),disabled:u,className:"codex-btn-primary text-2xs",children:"在此新建"})]})]})})}const ii=["light","dark","system"],Wa={light:"浅色",dark:"深色",system:"跟随系统"};function Qa(){const e=v.useSyncExternalStore(gc,ws,ws),t=()=>Ri(ii[(ii.indexOf(e)+1)%ii.length]),n=e==="light"?Oc:e==="dark"?Fc:$c;return l.jsx("button",{onClick:t,className:"codex-btn-ghost px-2 py-1.5",title:`主题:${Wa[e]}(点击切换)`,"aria-label":`主题:${Wa[e]}`,children:l.jsx(n,{size:15})})}function _k(e,t){if(!e)return 0;const n=e.toLowerCase(),r=t.toLowerCase();let i=0,s=0,a=-1;for(let o=0;o<n.length;o++){const c=n[o],u=r.indexOf(c,i);if(u===-1)return null;a>=0?s+=u-a-1:s+=u,a=u,i=u+1}return s}function jk({open:e,onClose:t,actions:n,placeholder:r="搜索命令、对话…"}){const[i,s]=v.useState(""),[a,o]=v.useState(0),c=v.useRef(null);v.useEffect(()=>{e&&(s(""),o(0),requestAnimationFrame(()=>{var m;return(m=c.current)==null?void 0:m.focus()}))},[e]);const u=v.useMemo(()=>n.map(b=>({a:b,score:_k(i,`${b.label} ${b.hint??""} ${b.keywords??""}`)})).filter(b=>b.score!==null).sort((b,S)=>b.score-S.score).map(b=>b.a),[n,i]);if(v.useEffect(()=>{o(m=>Math.min(m,Math.max(0,u.length-1)))},[u.length]),!e)return null;const d=m=>{const b=u[m];b&&(t(),b.run())},f=m=>{m.key==="ArrowDown"?(m.preventDefault(),o(b=>Math.min(b+1,u.length-1))):m.key==="ArrowUp"?(m.preventDefault(),o(b=>Math.max(b-1,0))):m.key==="Enter"?(m.preventDefault(),d(a)):m.key==="Escape"&&(m.preventDefault(),t())};let p=-1;const h=new Map;for(const m of u){const b=m.group??"",S=h.get(b)??[];S.push(m),h.set(b,S)}return l.jsx("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-canvas/60 px-3 pt-[8vh] backdrop-blur-sm animate-fade-in sm:px-4 sm:pt-[12vh]",onClick:t,children:l.jsxs("div",{className:"codex-card-raised w-full max-w-xl overflow-hidden",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-3",children:[l.jsx(Mt,{size:16,className:"shrink-0 text-content-faint"}),l.jsx("input",{ref:c,value:i,onChange:m=>s(m.target.value),onKeyDown:f,placeholder:r,className:"min-w-0 flex-1 bg-transparent text-[15px] text-content-primary placeholder-content-muted outline-none"}),l.jsx("kbd",{className:"hidden shrink-0 rounded border border-border px-1.5 py-0.5 font-mono text-2xs text-content-faint sm:inline",children:"esc"})]}),l.jsx("div",{className:"max-h-[50vh] overflow-y-auto p-1.5",children:u.length===0?l.jsx("p",{className:"px-3 py-6 text-center text-sm text-content-muted",children:"没有匹配项"}):[...h.entries()].map(([m,b])=>l.jsxs("div",{className:"mb-1",children:[m&&l.jsx("p",{className:"px-2.5 pb-1 pt-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:m}),b.map(S=>{p+=1;const k=p;return l.jsxs("button",{onMouseEnter:()=>o(k),onClick:()=>d(k),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${k===a?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[S.icon&&l.jsx("span",{className:"shrink-0 text-content-muted",children:S.icon}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-primary",children:S.label}),S.hint&&l.jsx("span",{className:"shrink-0 text-2xs text-content-faint",children:S.hint})]},S.id)})]},m||"_"))})]})})}const Ka={pending:"等待中",connecting:"连接中",connected:"已连接",failed:"连接失败",needs_auth:"需要授权",disabled:"已禁用"},Ck={pending:"bg-content-faint",connecting:"bg-warning",connected:"bg-success",failed:"bg-danger",needs_auth:"bg-warning",disabled:"bg-content-faint"};function Nk(e){return e.some(t=>t.status==="failed")?"bg-danger":e.some(t=>t.status==="pending"||t.status==="connecting"||t.status==="needs_auth")?"bg-warning":e.every(t=>t.status==="disabled")?"bg-content-faint":"bg-success"}function Ik(e,t){return`${e??"unknown"}:${t}`}function Ya({mcpServers:e,provider:t,authLinks:n,onLogin:r}){const[i,s]=v.useState(!1),a=v.useRef(null);if(v.useEffect(()=>{if(!i)return;const c=u=>{a.current&&!a.current.contains(u.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]),!e||e.length===0)return null;const o=e.filter(c=>c.status==="connected").length;return l.jsxs("div",{ref:a,className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>s(c=>!c),title:`MCP 服务器(${o}/${e.length} 已连接)`,"aria-label":"MCP 服务器状态",className:`flex cursor-pointer items-center gap-1 rounded-md p-1.5 transition-colors ${i?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,children:[l.jsx(mo,{size:16}),l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Nk(e)}`})]}),i&&l.jsxs("div",{className:"codex-card-raised absolute right-0 top-full z-20 mt-1.5 min-w-[13rem] max-w-[calc(100vw-1.5rem)] overflow-hidden p-1 animate-fade-in",children:[l.jsx("div",{className:"px-2 py-1 text-2xs font-medium uppercase tracking-wide text-content-faint",children:"MCP 服务器"}),e.map(c=>{const u=n==null?void 0:n[Ik(t,c.name)];return l.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1.5 text-xs",title:c.error??Ka[c.status],children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Ck[c.status]}`}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-content-primary",children:c.name}),typeof c.toolCount=="number"&&c.status==="connected"&&l.jsxs("span",{className:"text-2xs text-content-faint",children:[c.toolCount," 个工具"]}),c.status==="needs_auth"&&r&&l.jsx("button",{type:"button",onClick:()=>r(t,c.name),className:"cursor-pointer rounded px-1.5 py-0.5 text-2xs text-accent hover:bg-accent/10",children:"授权"}),u&&l.jsx("a",{href:u,target:"_blank",rel:"noreferrer",className:"text-2xs text-accent hover:underline",children:"打开授权页"}),c.status!=="needs_auth"&&l.jsx("span",{className:"text-2xs text-content-muted",children:Ka[c.status]})]},c.name)})]})]})}function Tk(e){return e==="connected"?{text:"已连接",color:"text-success"}:e==="connecting"||e==="reconnecting"||e==="claiming"?{text:"连接中",color:"text-warning"}:e==="host_disconnected"?{text:"主机离线",color:"text-warning"}:e.startsWith("error")?{text:"错误",color:"text-danger"}:{text:"未连接",color:"text-content-muted"}}function Ak({children:e}){const[t,n]=v.useState(!1),r=v.useRef(null);return v.useEffect(()=>{if(!t)return;const i=s=>{r.current&&!r.current.contains(s.target)&&n(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[t]),l.jsxs("div",{ref:r,className:"relative",children:[l.jsx("button",{type:"button",onClick:()=>n(i=>!i),className:`cursor-pointer rounded-md p-1.5 transition-colors ${t?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"更多","aria-label":"更多","aria-expanded":t,children:l.jsx(go,{size:16})}),t&&l.jsx("div",{className:"codex-card-raised absolute right-0 top-full z-30 mt-1.5 min-w-[11rem] overflow-hidden p-1 animate-fade-in",children:e(()=>n(!1))})]})}function Bn({icon:e,label:t,active:n,onClick:r}){return l.jsxs("button",{type:"button",onClick:r,className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-2 text-left text-xs transition-colors ${n?"bg-accent-dim/20 text-content-primary":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,children:[e,t]})}function si(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"idle":return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};default:return null}}function Un(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ek(e){if(!e)return null;const t=e.inputTokens!=null||e.cacheReadTokens!=null?(e.inputTokens??0)+(e.cacheReadTokens??0):null,n=[];let r="";if(t!=null&&e.contextWindow&&e.contextWindow>0){const i=Math.min(100,Math.round(t/e.contextWindow*100));n.push(`${i}%`),r=`上下文 ${Un(t)} / ${Un(e.contextWindow)} tokens`}else{const i=e.totalTokens??t??e.outputTokens??null;i!=null&&(n.push(Un(i)),r=`${i.toLocaleString()} tokens`)}return typeof e.totalCostUsd=="number"&&e.totalCostUsd>0&&(n.push(`$${e.totalCostUsd.toFixed(e.totalCostUsd<1?3:2)}`),r=r?`${r} · $${e.totalCostUsd.toFixed(4)}`:`$${e.totalCostUsd.toFixed(4)}`),n.length===0?null:{text:n.join(" · "),title:r}}function Pk(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${String(r).padStart(2,"0")}m ${String(i).padStart(2,"0")}s`:r>0?`${r}m ${String(i).padStart(2,"0")}s`:`${i}s`}function Mk(e){const[t,n]=v.useState(0),r=v.useRef(null);return v.useEffect(()=>{if(!e){r.current=null,n(0);return}r.current=Date.now(),n(0);const i=setInterval(()=>{r.current!=null&&n(Math.floor((Date.now()-r.current)/1e3))},1e3);return()=>clearInterval(i)},[e]),t}function Rk(e,t,n){const[r,i]=v.useState(()=>({render:e,className:e?t:""})),s=v.useRef(e);v.useEffect(()=>{e&&!s.current?i({render:!0,className:t}):!e&&s.current&&i({render:!0,className:n}),s.current=e},[e,t,n]);const a=v.useCallback(()=>{s.current||i({render:!1,className:""})},[]);return{render:r.render,className:r.className,onAnimationEnd:a}}function Lk(e,t){var i,s,a,o,c,u,d,f;const n=t.toLowerCase();return[e.text,(i=e.commandExecution)==null?void 0:i.command,(s=e.commandExecution)==null?void 0:s.output,(a=e.toolCall)==null?void 0:a.name,(o=e.toolCall)==null?void 0:o.input,(c=e.toolCall)==null?void 0:c.output,(u=e.fileChange)==null?void 0:u.summary,...((f=(d=e.fileChange)==null?void 0:d.entries)==null?void 0:f.map(p=>p.path))??[],e.error].some(p=>typeof p=="string"&&p.toLowerCase().includes(n))}function Dk({sessionId:e,session:t,onBack:n}){var ys,bs,ks;const r=v.useMemo(()=>Ga(),[]),i=v.useMemo(()=>Li(),[]),{store:s,snapshot:a}=Wf(r,e),o=Yl(),[c,u]=v.useState("none"),[d,f]=v.useState(!1),[p,h]=v.useState(!1),[m,b]=v.useState(()=>{const w=Number(localStorage.getItem("linkshell_terminal_h"));return w>=120&&w<=600?w:320}),S=v.useRef(!1),k=v.useRef(m);k.current=m;const A=v.useRef(d);A.current=d;const I=v.useCallback(()=>{A.current?h(!0):f(!0)},[]),W=v.useCallback(()=>{h(!1),f(!0)},[]),[Q,j]=v.useState(!1),[Y,X]=v.useState(null),[J,_]=v.useState(null),[$,B]=v.useState(!1),[ae,q]=v.useState(null),[L,ie]=v.useState({text:"",nonce:0}),[be,le]=v.useState(!1),[D,x]=v.useState(""),[M,Ce]=v.useState(!1),y=v.useRef(null),[Ne,Le]=v.useState(()=>{const w=Number(localStorage.getItem("linkshell_sidebar_w"));return w>=180&&w<=520?w:256}),[Ie,Fe]=v.useState(()=>localStorage.getItem("linkshell_sidebar_collapsed")==="1"),[ce,Ke]=v.useState(()=>{const w=Number(localStorage.getItem("linkshell_rightpanel_w"));return w>=320&&w<=1100?w:560}),$e=v.useRef(!1),C=v.useRef(!1),F=v.useRef(null),te=()=>{Fe(w=>(localStorage.setItem("linkshell_sidebar_collapsed",w?"0":"1"),!w))},_e=w=>{w.preventDefault(),$e.current=!0;const E=ge=>{if(!$e.current)return;const Se=Math.min(520,Math.max(180,ge.clientX));Le(Se)},ne=()=>{$e.current=!1,localStorage.setItem("linkshell_sidebar_w",String(we.current)),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",ne)},we=v.useRef(Ne);we.current=Ne;const De=v.useRef(ce);De.current=ce;const Tt=w=>{w.preventDefault(),C.current=!0;const E=ge=>{if(!C.current)return;const Se=Math.min(1100,Math.max(320,window.innerWidth-ge.clientX));Ke(Se)},ne=()=>{C.current=!1,localStorage.setItem("linkshell_rightpanel_w",String(De.current)),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",ne)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",ne)},Nr=w=>{w.preventDefault(),S.current=!0;const E=w.clientY,ne=k.current,ge=at=>{if(!S.current)return;const Ee=Math.min(600,Math.max(120,ne+(E-at.clientY)));b(Ee)},Se=()=>{S.current=!1,localStorage.setItem("linkshell_terminal_h",String(k.current)),window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",Se)};window.addEventListener("pointermove",ge),window.addEventListener("pointerup",Se)},se=a.activeConversationId,Ze=se?a.timelines.get(se)??[]:[],P=a.conversations.find(w=>w.id===se),Ft=((ys=a.capabilities)==null?void 0:ys.providers)??[],Be=P?Ft.find(w=>w.id===P.provider):void 0,nt=(P==null?void 0:P.status)==="running",qe=se?a.history.get(se):void 0;Xf(a.conversations);const N=v.useRef(!1);N.current=nt;const O=v.useRef(s);O.current=s;const G=v.useRef(null);G.current=se??null;const fe=v.useRef(!1);fe.current=M||$||Q||ae!=null||Y!=null||J!=null;const je=v.useRef(!1);je.current=be;const Ye=v.useMemo(()=>{for(let w=Ze.length-1;w>=0;w--){const E=Ze[w];if(E.role==="user"&&E.text)return E.text}},[Ze]),ct=w=>{ie(E=>({text:w,nonce:E.nonce+1}))},rt=v.useMemo(()=>{if((P==null?void 0:P.collaborationMode)!=="plan"||nt||(P==null?void 0:P.status)==="waiting_permission")return!1;const w=[...Ze].reverse().find(E=>!$n(E));return w!=null&&w.role!=="user"},[P==null?void 0:P.collaborationMode,P==null?void 0:P.status,nt,Ze]),At=()=>{se&&s.sendPrompt({conversationId:se,text:"请按上面的计划开始执行。",collaborationMode:"default",model:P==null?void 0:P.model,reasoningEffort:P==null?void 0:P.reasoningEffort,permissionMode:P==null?void 0:P.permissionMode})};v.useEffect(()=>{const w=E=>{const ne=E.metaKey||E.ctrlKey;ne&&E.shiftKey&&E.key.toLowerCase()==="p"?(E.preventDefault(),Ce(ge=>!ge)):ne&&!E.shiftKey&&E.key.toLowerCase()==="k"?(E.preventDefault(),Ce(ge=>!ge)):ne&&!E.shiftKey&&E.key.toLowerCase()==="j"?(E.preventDefault(),I()):ne&&!E.shiftKey&&E.key.toLowerCase()==="f"?(E.preventDefault(),le(!0),requestAnimationFrame(()=>{var ge;return(ge=y.current)==null?void 0:ge.focus()})):E.key==="Escape"&&(je.current?le(!1):N.current&&G.current&&!fe.current&&O.current.cancel(G.current))};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[]),v.useEffect(()=>{le(!1),x("")},[se]);const it=v.useRef(0),Re=v.useRef(!0),xt=v.useRef(null),[st,Ir]=v.useState(!0),[Jl,Mn]=v.useState(!1),Gl=()=>{const w=F.current;if(!w)return;const E=w.scrollHeight-w.scrollTop-w.clientHeight<80;Re.current=E,Ir(E),E&&Mn(!1),w.scrollTop<60&&se&&(qe!=null&&qe.hasMore)&&!qe.loading&&(it.current=w.scrollHeight,s.loadOlderHistory(se))},ec=v.useCallback(()=>{const w=F.current;w&&(Re.current=!0,Ir(!0),Mn(!1),w.scrollTop=w.scrollHeight)},[]);v.useEffect(()=>{const w=xt.current,E=F.current;if(!w||!E)return;let ne=w.getBoundingClientRect().height;const ge=new ResizeObserver(()=>{const Se=w.getBoundingClientRect().height,at=Se>ne;ne=Se,Re.current?E.scrollTop=E.scrollHeight:at&&!it.current&&Mn(!0)});return ge.observe(w),()=>ge.disconnect()},[se]);const us=v.useRef(void 0);v.useLayoutEffect(()=>{const w=F.current;if(w){if(us.current!==se){us.current=se,Re.current=!0,Ir(!0),Mn(!1),w.scrollTop=w.scrollHeight;return}it.current>0?(w.scrollTop=w.scrollHeight-it.current,it.current=0):Re.current&&(w.scrollTop=w.scrollHeight)}},[Ze.length,se]);const Tr=(w,E)=>{E?ds(w,E):q(w)},ds=(w,E)=>{const ne=Ft.find(Se=>Se.id===w),ge=s.openConversation({provider:w,cwd:E,model:ne==null?void 0:ne.defaultModel});s.setActiveConversation(ge),q(null)},tc=(w,E)=>{se&&(Qf(),s.sendPrompt({conversationId:se,text:w,images:E.map(ne=>({data:ne.data,mimeType:ne.mimeType})),model:P==null?void 0:P.model,reasoningEffort:P==null?void 0:P.reasoningEffort,permissionMode:P==null?void 0:P.permissionMode,collaborationMode:P==null?void 0:P.collaborationMode}))},fs=Tk(a.status),Ar=(P==null?void 0:P.status)==="running"||(P==null?void 0:P.status)==="waiting_permission"||(P==null?void 0:P.status)==="error",$t=!Ar&&(a.externalAgentStatus==="running"||a.externalAgentStatus==="waiting_permission"||a.externalAgentStatus==="error"),Rn=si(Ar?P==null?void 0:P.status:$t?a.externalAgentStatus??void 0:P==null?void 0:P.status),Er=Ar?P==null?void 0:P.provider:$t?a.externalAgentTitle??"外部终端":P==null?void 0:P.provider,hs=$t?a.externalAgentStatus==="running":(P==null?void 0:P.status)==="running",nc=Mk(hs),Pr=$t?null:Ek(P==null?void 0:P.usage),ps=`CLI 设备 · ${e.slice(0,8)}`,ms=P==null?void 0:P.cwd,gs=v.useCallback(()=>{s.client.spawnTerminal(ms||".")},[s,ms]),xs=Ft.filter(w=>w.enabled),rc=v.useMemo(()=>{const w=[];for(const E of xs)w.push({id:`new-${E.id}`,label:`新建 ${E.label} 对话`,group:"新建",keywords:`new conversation ${E.id}`,icon:l.jsx(dr,{size:15}),run:()=>Tr(E.id)});for(const E of a.conversations.filter(ne=>!ne.archived)){const ne=E.title&&E.title.trim()||E.lastMessagePreview&&E.lastMessagePreview.trim().slice(0,40)||`对话 ${E.id.slice(-6)}`;w.push({id:`conv-${E.id}`,label:ne,group:"对话",hint:E.cwd?E.cwd.split("/").slice(-1)[0]:void 0,keywords:`${E.provider} ${E.cwd??""}`,icon:l.jsx(Qt,{provider:E.provider,size:15}),run:()=>s.setActiveConversation(E.id)})}return se&&nt&&w.push({id:"cancel",label:"停止当前回合",group:"操作",keywords:"cancel stop interrupt",icon:l.jsx(fo,{size:15}),run:()=>s.cancel(se)}),se&&w.push({id:"search",label:"在对话中搜索",group:"操作",hint:"⌘F",keywords:"search find filter",icon:l.jsx(Mt,{size:15}),run:()=>{le(!0),requestAnimationFrame(()=>{var E;return(E=y.current)==null?void 0:E.focus()})}}),w.push({id:"panel-terminal",label:"切换终端",group:"操作",hint:"⌘J",keywords:"terminal shell",icon:l.jsx(Rr,{size:15}),run:I},{id:"panel-files",label:"打开文件浏览器",group:"操作",keywords:"files browse",icon:l.jsx(Pt,{size:15}),run:()=>u(E=>E==="files"?"none":"files")},{id:"panel-preview",label:"打开端口预览",group:"操作",keywords:"preview port browser localhost tunnel",icon:l.jsx(qn,{size:15}),run:()=>u(E=>E==="preview"?"none":"preview")}),w},[xs,a.conversations,se,nt]);return l.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[l.jsxs("header",{className:"flex items-center justify-between gap-2 overflow-hidden border-b border-border px-3 py-1.5 md:px-4 md:py-2",style:{paddingTop:"max(0.375rem, env(safe-area-inset-top))"},children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[o&&l.jsx("button",{onClick:()=>j(!0),className:"codex-btn-ghost shrink-0 px-2 py-1.5","aria-label":"打开会话列表",children:l.jsx(zc,{size:17})}),l.jsx("button",{onClick:n,className:"codex-btn-ghost shrink-0 px-2 py-1.5 text-2xs","aria-label":"返回会话列表",children:o?l.jsx(Cs,{size:17}):"← 会话"}),l.jsxs("span",{className:`flex shrink-0 items-center gap-1 text-2xs ${fs.color}`,children:[l.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),!o&&fs.text]}),Rn&&!(o&&!$t&&(P==null?void 0:P.status)==="idle")&&l.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${Rn.className}`,title:$t?"外部终端状态":"当前对话状态",children:[Rn.pulsing&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current animate-pulse-dot"}),!o&&Er&&l.jsx("span",{className:"min-w-0 truncate",children:Er}),l.jsxs("span",{className:"shrink-0",children:[!o&&Er?"· ":"",Rn.text]}),hs&&l.jsx("span",{className:"shrink-0 font-mono tabular-nums opacity-70",children:Pk(nc)})]}),Pr&&!o&&l.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:Pr.title,children:Pr.text}),((bs=a.usage)==null?void 0:bs.totals)&&!o&&l.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:"全机用量",children:[l.jsx(Lr,{size:12}),Un(a.usage.totals.totalTokens)]}),a.lastError&&l.jsx("button",{onClick:()=>s.dismissError(),className:"min-w-0 truncate rounded-full border border-danger/30 bg-danger/10 px-2 py-0.5 text-2xs text-danger",title:`${a.lastError.message}(点击关闭)`,children:a.lastError.code})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[l.jsx("button",{onClick:()=>{se&&(le(!0),requestAnimationFrame(()=>{var w;return(w=y.current)==null?void 0:w.focus()}))},disabled:!se,className:"codex-btn-ghost px-2 py-1.5 disabled:opacity-40",title:"在对话中搜索 (⌘/Ctrl+F)","aria-label":"在对话中搜索",children:l.jsx(Mt,{size:16})}),o?l.jsxs(l.Fragment,{children:[l.jsx(Ya,{mcpServers:Be==null?void 0:Be.mcpServers,provider:P==null?void 0:P.provider,authLinks:a.mcpAuthLinks,onLogin:(w,E)=>s.startMcpLogin(w,E)}),l.jsx(Ak,{children:w=>l.jsxs(l.Fragment,{children:[!i&&l.jsxs("div",{className:"flex items-center justify-between rounded-lg px-2.5 py-1.5",children:[l.jsx("span",{className:"text-xs text-content-secondary",children:"主题"}),l.jsx(Qa,{})]}),l.jsx(Bn,{icon:l.jsx(Pt,{size:15}),label:"文件",active:c==="files",onClick:()=>{u(E=>E==="files"?"none":"files"),w()}}),l.jsx(Bn,{icon:l.jsx(Rr,{size:15}),label:"终端",active:d,onClick:()=>{I(),w()}}),l.jsx(Bn,{icon:l.jsx(qn,{size:15}),label:"端口预览",active:c==="preview",onClick:()=>{u(E=>E==="preview"?"none":"preview"),w()}}),l.jsx(Bn,{icon:l.jsx(Lr,{size:15}),label:"用量统计",active:$,onClick:()=>{s.requestUsage(),B(!0),w()}})]})})]}):l.jsxs(l.Fragment,{children:[!i&&l.jsx(Qa,{}),l.jsx("button",{onClick:()=>u(w=>w==="preview"?"none":"preview"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${c==="preview"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"端口预览","aria-label":"端口预览",children:l.jsx(qn,{size:16})}),l.jsx("button",{onClick:()=>u(w=>w==="files"?"none":"files"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${c==="files"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"文件","aria-label":"文件",children:l.jsx(Pt,{size:16})}),l.jsx("button",{onClick:I,className:`cursor-pointer rounded-md p-1.5 transition-colors ${d?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"终端 (⌘J)","aria-label":"终端",children:l.jsx(Rr,{size:16})}),l.jsx("button",{onClick:()=>{s.requestUsage(),B(!0)},className:`cursor-pointer rounded-md p-1.5 transition-colors ${$?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"用量统计","aria-label":"用量统计",children:l.jsx(Lr,{size:16})}),l.jsx(Ya,{mcpServers:Be==null?void 0:Be.mcpServers,provider:P==null?void 0:P.provider,authLinks:a.mcpAuthLinks,onLogin:(w,E)=>s.startMcpLogin(w,E)})]})]})]}),l.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[a.status==="host_disconnected"&&l.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-canvas/80 backdrop-blur-sm",children:l.jsxs("div",{className:"codex-card-raised mx-4 flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center animate-fade-in",children:[l.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-warning/15 text-warning",children:l.jsx(mo,{size:24})}),l.jsx("h2",{className:"text-base font-semibold text-content-primary",children:"主机已离线"}),l.jsxs("p",{className:"text-sm leading-relaxed text-content-muted",children:["与该会话的主机连接已断开。请确认主机上的"," ",l.jsx("code",{className:"font-mono text-accent",children:"linkshell"})," 仍在运行。正在自动尝试重新连接…"]}),l.jsx("button",{onClick:n,className:"codex-btn-outline mt-1 text-2xs",children:"返回会话列表"})]})}),o?Q&&l.jsxs("div",{className:"absolute inset-0 z-30 flex animate-fade-in",children:[l.jsxs("aside",{className:"flex w-[82%] max-w-xs flex-col border-r border-border bg-surface shadow-2xl animate-drawer-in",children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),l.jsx("button",{type:"button",onClick:()=>j(!1),className:"codex-btn-ghost px-2 py-1","aria-label":"关闭会话列表",children:l.jsx(ft,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Za,{deviceLabel:ps,conversations:a.conversations,capabilities:a.capabilities,activeConversationId:se,externalAgentStatus:a.externalAgentStatus,externalAgentTitle:a.externalAgentTitle,externalAgentProvider:a.externalAgentProvider,store:s,onSelect:w=>{s.setActiveConversation(w),j(!1)},onNewConversation:(w,E)=>{j(!1),Tr(w,E)},onOpenExternalTerminal:()=>{var E;const w=a.externalAgentConversationId||((E=a.conversations.find(ne=>ne.status==="running"||ne.status==="waiting_permission"))==null?void 0:E.id);w?(s.setActiveConversation(w),j(!1)):(j(!1),W())}})})]}),l.jsx("button",{className:"flex-1 bg-canvas/60 backdrop-blur-sm",onClick:()=>j(!1),"aria-label":"关闭"})]}):Ie?l.jsx("div",{className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-surface py-2",children:l.jsx("button",{onClick:te,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"展开侧边栏","aria-label":"展开侧边栏",children:l.jsx(et,{size:16})})}):l.jsxs("aside",{className:"relative flex shrink-0 flex-col border-r border-border bg-surface",style:{width:Ne},children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[l.jsx("span",{className:"pl-1 text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),l.jsx("button",{onClick:te,className:"cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"收起侧边栏","aria-label":"收起侧边栏",children:l.jsx(Cs,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Za,{deviceLabel:ps,conversations:a.conversations,capabilities:a.capabilities,activeConversationId:se,externalAgentStatus:a.externalAgentStatus,externalAgentTitle:a.externalAgentTitle,externalAgentProvider:a.externalAgentProvider,store:s,onSelect:w=>s.setActiveConversation(w),onNewConversation:Tr,onOpenExternalTerminal:()=>{var E;const w=a.externalAgentConversationId||((E=a.conversations.find(ne=>ne.status==="running"||ne.status==="waiting_permission"))==null?void 0:E.id);w?s.setActiveConversation(w):W()}})}),l.jsx("div",{onPointerDown:_e,className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"})]}),l.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:!se||!P?l.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[l.jsx(Bi,{size:44,className:"opacity-40"}),l.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:o?"点击左上角菜单选择对话,或新建一个开始":"从左侧选择一个对话,或新建一个开始"})]}):l.jsxs(l.Fragment,{children:[be&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[l.jsx(Mt,{size:15,className:"shrink-0 text-content-faint"}),l.jsx("input",{ref:y,value:D,onChange:w=>x(w.target.value),onKeyDown:w=>w.key==="Escape"&&(le(!1),x("")),placeholder:"在此对话中搜索…",className:"min-w-0 flex-1 bg-transparent text-sm text-content-primary placeholder-content-muted outline-none"}),l.jsx("button",{onClick:()=>{le(!1),x("")},className:"codex-btn-ghost px-2 py-1","aria-label":"关闭搜索",children:l.jsx(ft,{size:14})})]}),l.jsx("div",{ref:F,onScroll:Gl,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-3 py-5 md:px-4 md:py-8",children:l.jsxs("div",{ref:xt,className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-6",children:[(qe==null?void 0:qe.loading)&&l.jsx("p",{className:"text-center text-2xs text-content-muted",children:"加载更早的消息…"}),(qe==null?void 0:qe.syncing)&&Ze.length>0&&l.jsx("div",{className:"flex justify-center",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 text-2xs text-content-muted",children:[l.jsx("span",{className:"h-2.5 w-2.5 animate-spin rounded-full border border-content-faint border-t-accent"}),"正在同步…"]})}),be&&D.trim()?(()=>{const w=D.trim(),E=Ze.filter(ne=>!$n(ne)&&Lk(ne,w));return E.length===0?l.jsxs("p",{className:"py-12 text-center text-sm text-content-muted",children:["没有匹配「",w,"」的消息"]}):l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-center text-2xs text-content-faint",children:[E.length," 条匹配"]}),E.map(ne=>l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(qa,{item:ne,canSteer:!1,onPermission:(ge,Se,at)=>s.respondPermission(se,ge,Se,at),onStructuredInput:(ge,Se)=>s.respondStructuredInput(se,ge,Se),onOpenDiff:ge=>{X(ge),u("none")},onOpenAgent:ge=>{_(ge),X(null),u("none")},onEditMessage:ct,highlightQuery:w})},ne.id))]})})():(()=>{const w=[];let E=[];const ne=()=>{E.length&&(w.push({k:"group",key:`grp-${E[0].id}`,items:E}),E=[])};for(const Se of Ze)$n(Se)||(ek(Se)?E.push(Se):(ne(),w.push({k:"item",item:Se})));ne();let ge=-1;return w.forEach((Se,at)=>{Se.k==="group"&&(ge=at)}),w.map((Se,at)=>Se.k==="item"?l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(qa,{item:Se.item,canSteer:P.provider==="codex"&&nt,onPermission:(Ee,Mr,ic)=>s.respondPermission(se,Ee,Mr,ic),onStructuredInput:(Ee,Mr)=>s.respondStructuredInput(se,Ee,Mr),onSendQueued:Ee=>s.sendQueuedFollowUp(se,Ee,"new_turn"),onSteerQueued:Ee=>s.sendQueuedFollowUp(se,Ee,"steer"),onDiscardQueued:Ee=>s.discardQueuedFollowUp(se,Ee),onOpenDiff:Ee=>{X(Ee),u("none")},onOpenAgent:Ee=>{_(Ee),X(null),u("none")},onEditMessage:ct,onFork:P.provider==="claude"?Ee=>s.forkConversation(se,Ee):void 0})},Se.item.id):l.jsx("div",{className:"min-w-0 animate-fade-in",children:l.jsx(rk,{items:Se.items,live:nt&&at===ge,onOpenDiff:Ee=>{X(Ee),u("none")},onOpenAgent:Ee=>{_(Ee),X(null),u("none")}})},Se.key))})(),Ze.length===0&&(P!=null&&P.lastMessagePreview||qe!=null&&qe.loading?l.jsxs("div",{className:"flex flex-col items-center gap-2 py-16 text-content-muted",children:[l.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"}),l.jsx("p",{className:"text-sm",children:"加载对话记录…"})]}):l.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"发送第一条指令…"}))]})}),!st&&l.jsx("div",{className:"pointer-events-none relative z-10 h-0",children:l.jsxs("button",{onClick:ec,className:"codex-card-raised pointer-events-auto absolute bottom-2 right-3 flex cursor-pointer items-center gap-1.5 rounded-full px-3 py-1.5 text-2xs text-content-secondary transition-colors animate-fade-in hover:text-content-primary md:right-4","aria-label":"回到底部",title:"回到底部",children:[Jl&&l.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-accent"}),l.jsx(bt,{size:14}),"回到底部"]})}),l.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-3xl px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:[rt&&l.jsxs("div",{className:"mb-2 flex items-center gap-3 rounded-xl border border-accent-dim/40 bg-surface px-3.5 py-2.5 animate-slide-in",children:[l.jsx("span",{className:"min-w-0 flex-1 text-sm text-content-secondary",children:"计划已就绪。执行它,或在下方继续补充。"}),l.jsx("button",{onClick:At,className:"codex-btn-primary shrink-0 text-xs",children:"执行计划"})]}),l.jsx(tk,{items:Ze.filter($n),canSteer:P.provider==="codex"&&nt,onSend:w=>s.sendQueuedFollowUp(se,w,"new_turn"),onSteer:w=>s.sendQueuedFollowUp(se,w,"steer"),onDiscard:w=>s.discardQueuedFollowUp(se,w)}),l.jsx(sk,{disabled:a.status!=="connected",running:nt,supportsImages:Be==null?void 0:Be.supportsImages,commands:Be==null?void 0:Be.commands,conversationId:se,lastUserText:Ye,cwd:P.cwd,onBrowse:w=>s.browse(w,!0),seedText:L,controls:l.jsx(wk,{conversation:P,capability:Be,onChange:w=>s.updateConversationSettings(se,w)}),onSend:tc,onCancel:()=>s.cancel(se),onExecuteCommand:(w,E)=>s.executeCommand(se,w,E)})]}),!o&&(d||p)&&l.jsxs("div",{className:`relative shrink-0 overflow-hidden border-t border-border bg-surface ${p?"animate-panel-out-down":"animate-panel-in-up"}`,style:{height:m},onAnimationEnd:()=>{p&&(h(!1),f(!1))},children:[l.jsx("div",{onPointerDown:Nr,className:"absolute left-0 right-0 top-0 z-10 h-1 cursor-row-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整终端高度"}),l.jsx(Ua,{bridge:s.client,onNewTerminal:gs})]})]})}),(()=>{let w=null;J?w=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"子 Agent"}),l.jsx("button",{onClick:()=>_(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭",children:l.jsx(ft,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Jb,{detail:J})})]}):Y?w=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"文件差异"}),l.jsx("button",{onClick:()=>X(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭差异",children:l.jsx(ft,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Fb,{item:Y})})]}):c==="files"?w=l.jsx(mk,{store:s,initialPath:(P==null?void 0:P.cwd)||".",onClose:()=>u("none")}):c==="preview"&&(w=l.jsx(pk,{gatewayUrl:r.httpUrl,sessionId:e,initialAuthToken:(t==null?void 0:t.accessToken)??null,isMobile:o,onClose:()=>u("none"),onAnnotate:at=>{ie(Ee=>({text:at,nonce:Ee.nonce+1})),o&&u("none")}}));const E=v.useRef(null);w!==null&&(E.current=w);const ne=w!==null,ge=Rk(ne,"animate-panel-in-right","animate-panel-out-right");if(!ge.render&&!ne)return null;const Se=ne?w:E.current;return o?l.jsx("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${ge.className||"animate-fade-in"}`,onAnimationEnd:ge.onAnimationEnd,children:Se}):l.jsxs("aside",{className:`relative flex shrink-0 flex-col border-l border-border ${ge.className}`,style:{width:ce},onAnimationEnd:ge.onAnimationEnd,children:[l.jsx("div",{onPointerDown:Tt,className:"absolute left-0 top-0 z-10 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"}),Se]})})(),o&&(d||p)&&l.jsxs("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${p?"animate-panel-out-right":"animate-fade-in"}`,onAnimationEnd:()=>{p&&(h(!1),f(!1))},children:[l.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[l.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"终端"}),l.jsx("button",{type:"button",onClick:I,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭终端",children:l.jsx(ft,{size:15})})]}),l.jsx("div",{className:"min-h-0 flex-1",children:l.jsx(Ua,{bridge:s.client,onNewTerminal:gs})})]}),a.notices.length>0&&l.jsx("div",{className:`pointer-events-none z-40 flex flex-col gap-2 ${o?"absolute left-3 right-3 top-2":"fixed right-4 top-16 w-80"}`,children:a.notices.map(w=>l.jsxs("button",{onClick:()=>s.dismissNotice(w.id),className:`codex-card-raised pointer-events-auto animate-fade-in cursor-pointer px-3 py-2 text-left ${w.kind==="warning"?"border-warning/40":""}`,children:[l.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-content-primary",children:[l.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w.kind==="warning"?"bg-warning":"bg-accent"}`}),w.title]}),w.detail&&l.jsx("p",{className:"mt-0.5 pl-3 text-2xs text-content-muted",children:w.detail})]},w.id))})]}),ae&&l.jsx(Sk,{store:s,initialPath:(P==null?void 0:P.cwd)||".",providerLabel:((ks=Ft.find(w=>w.id===ae))==null?void 0:ks.label)??ae,onCancel:()=>q(null),onConfirm:w=>ds(ae,w)}),l.jsx(jk,{open:M,onClose:()=>Ce(!1),actions:rc}),$&&l.jsx(hk,{report:a.usage,onClose:()=>B(!1)})]})}xc();function zk(){const[e,t]=v.useState(null),[n,r]=v.useState(!1),[i,s]=v.useState(!1),a=v.useMemo(()=>Cc(jc()),[]),o=v.useMemo(()=>Li(),[]),[c,u]=v.useState(()=>a??yc()),d=f=>{u(f),Ss(f)};return v.useEffect(()=>{const f=ur();f&&t(f),r(!0),f&&uo().then(p=>{p&&t(p)})},[]),v.useEffect(()=>{var f;o&&((f=document.querySelector('meta[name="viewport"]'))==null||f.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"))},[o]),v.useEffect(()=>{if(!o)return;const f=window;return f.__linkshellSetTheme=p=>{(p==="dark"||p==="light")&&Ri(p)},()=>{delete f.__linkshellSetTheme}},[o]),v.useEffect(()=>Tc(()=>{t(null),s(!1),u(f=>f.name==="list"?f:{name:"list"}),Ss({name:"list"})}),[]),n?i?l.jsx(Uc,{onLogin:f=>{t(f),s(!1)},onCancel:()=>s(!1)}):c.name==="console"?l.jsx(Dk,{sessionId:c.sessionId,session:e,onBack:o?oo:()=>d({name:"list"})}):l.jsx(Lf,{session:e,onLogin:()=>s(!0),onLogout:()=>{t(null),d({name:"list"})},onOpenSession:f=>d({name:"console",sessionId:f})}):null}sc.createRoot(document.getElementById("root")).render(l.jsx(Ic,{children:l.jsx(zk,{})}));export{Rr as I,ft as a,dr as b,qk as c,$c as d,dc as e,Bk as f,uo as g,po as h,$k as i,qn as j,Pt as k,ho as l,kn as m};
|