@vantaloom/runtime-win32-x64 0.12.65 → 0.12.66

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.
@@ -37,7 +37,7 @@ ${e}`;return`工作区 Diff 卡片:${t}(${n})
37
37
  ${function(e,t=60){if(0===e.length)return"(空表)";let n=Array.from(e.reduce((e,t)=>(Object.keys(t).forEach(t=>e.add(t)),e),new Set));if(0===n.length)return"(无列)";let r=e=>null==e?"":String(e),a=[];for(let i of(a.push(`| ${n.join(" | ")} |`),a.push(`| ${n.map(()=>"---").join(" | ")} |`),e.slice(0,t)))a.push(`| ${n.map(e=>r(i[e])).join(" | ")} |`);return e.length>t&&a.push(`| …(共 ${e.length} 行,已截断到前 ${t} 行)|`),a.join("\n")}(e)}`}case"browser-tab-viewer":{let e=r?.defaultUrl||r?.title||"";return e?`工作区浏览器卡片:${t}
38
38
  地址:${e}`:`工作区浏览器卡片:${t}(无地址)`}case"terminal-tab-group":{let e=r?.terminal?.sessionIds?.length??0;return`工作区终端卡片:${t}
39
39
  (终端实时输出不随卡片附带;会话数:${e}。如需查看请在对话中读取终端状态。)`}case"sidequery-pane":return`工作区旁问卡片:${t}
40
- (旁问的实时问答不随卡片附带;这是一个旁路只读问答区。)`;case"plan-doc-viewer":return`工作区卡片:${a}(计划文档/proposal.md 与执行树的内容随会话实时获取,请在对话中查看/读取计划。)`;case"spec-doc-viewer":return`工作区卡片:${a}(规范文档内容随会话实时获取,请在对话中查看/读取规范。)`;case"tasks-pane":return`工作区卡片:${a}(本轮任务清单随会话实时获取,请在对话中查看任务。)`;case"hooks-pane":return`工作区卡片:${a}(本会话注册的自动化 hook 随会话实时获取,请在对话中查看 hook。)`;case"status-monitor":return`工作区卡片:${a}(环境信息、子智能体状态与额度消耗随会话实时获取,请在对话中查看状态监控。)`;default:return`工作区卡片:${t}(类型 ${n})`}}(t,n);return{name:n,text:r,cardKind:t.kind}}(e)??null)}let Ui=0;function Uo(e){let t,n=e.dataTransfer?.getData(_V);if(!n)return null;try{t=JSON.parse(n)}catch{return null}return t&&t.text?(Ui+=1,{id:`card-att-${Date.now().toString(36)}-${Ui}`,kind:"card",name:t.name||"工作区卡片",mimeType:"text/vnd.vantaloom.card",text:t.text,cardKind:t.cardKind}):null}class Ul extends Error{constructor(){super("downloads endpoint not available"),this.name="DownloadsNotAvailableError"}}async function Us(e){let{signal:t,timeoutMs:n=8e3}=e??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;t&&t.addEventListener("abort",()=>r.abort(),{once:!0});try{let e=await fetch((0,H.localAPIURL)("/v1/downloads"),{cache:"no-store",signal:r.signal});if(404===e.status)throw new Ul;if(!e.ok)throw Error(`Downloads API error: ${e.status}`);let t=await e.json();return{downloads:Array.isArray(t.downloads)?t.downloads:[]}}finally{a&&clearTimeout(a)}}async function Uc(e,t){let{signal:n}=t??{},r=await fetch((0,H.localAPIURL)("/v1/downloads/stream"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:n});if(404===r.status)throw new Ul;if(!r.ok||!r.body)throw Error(`Downloads stream error: ${r.status}`);let a=r.body.getReader(),i=new TextDecoder,o="",l=t=>{let n=t.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===n.length)return;let r=n.join("\n");if(r&&"[DONE]"!==r)try{let t=JSON.parse(r);Array.isArray(t.downloads)&&e(t.downloads)}catch{}};for(;;){let{value:e,done:t}=await a.read();if(t)break;let n=(o+=i.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==n;){let e=o.slice(0,n);o=o.slice(n+2),l(e),n=o.indexOf("\n\n")}}}async function Ud(e){let t=await fetch((0,H.localAPIURL)("/v1/downloads"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(404===t.status)throw new Ul;if(!t.ok)throw Error(`Downloads enqueue error: ${t.status}`);return await t.json()}async function Uu(e,t){let n=await fetch((0,H.localAPIURL)(`/v1/downloads/${encodeURIComponent(e)}/${t}`),{method:"POST",cache:"no-store"});if(404===n.status)throw new Ul;if(!n.ok)throw Error(`Downloads action error: ${n.status}`);let r=await n.text();return r?JSON.parse(r):{ok:!0}}async function Uf(e){let{signal:t,timeoutMs:n=8e3}=e??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;t&&t.addEventListener("abort",()=>r.abort(),{once:!0});try{let e=await fetch((0,H.localAPIURL)("/v1/downloads/config"),{cache:"no-store",signal:r.signal});if(404===e.status)throw new Ul;if(!e.ok)throw Error(`Downloads config error: ${e.status}`);return await e.json()}finally{a&&clearTimeout(a)}}async function Um(e){let t=await fetch((0,H.localAPIURL)("/v1/downloads/config"),{method:"PUT",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(404===t.status)throw new Ul;if(!t.ok)throw Error(`Downloads config error: ${t.status}`);let n=await t.text();return n?JSON.parse(n):e}function Uh({conversationId:e,modelRef:t,models:n,onModelChange:r,onGoHome:a}){let[i,o]=P.useState(null),[l,s]=P.useState(""),[c,d]=P.useState(!1),[u,f]=P.useState(null),[m,h]=P.useState(!1),[p,g]=P.useState(null),[x,v]=P.useState([]),[b,y]=P.useState([]),[w,j]=P.useState(void 0),[k,N]=P.useState(!1),[C,S]=P.useState(!1),[M,I]=P.useState(!1),[O,z]=P.useState(()=>new Set),[A,T]=P.useState(void 0),[R,_]=P.useState(""),[D,L]=P.useState(!1),[$,B]=P.useState(void 0),V=P.useCallback(async()=>{try{let t=await eX(e);t&&o(t)}catch{}},[e]);P.useEffect(()=>{V();let e=!0,t=setInterval(()=>{e&&V()},1200);return()=>{e=!1,clearInterval(t)}},[V]);let U=i?.events??[],q=i?.conversation.running??!1,W=i?.conversation.planState,K=i?.conversation.ownerMachineId,G=i?.conversation.settings.folders??[],X=_D(i?.conversation.settings.engine),Y=P.useMemo(()=>U.filter(e=>{let t=e.kind;return"perm"!==t&&"add-model"!==t}),[U]),Z=U[U.length-1],J=Z?Z.kind:"",Q=Z&&"perm"===J&&Z.controlRunId!==u?Z:null,ee=Z&&"add-model"===J&&Z.controlRunId!==p?Z:null;async function et(t,n,r){if(ee&&!m){h(!0);try{let a=await tb(e,{added:t,summary:n,modelRef:r});g(ee.controlRunId??null),a&&o(a)}catch{}finally{h(!1)}}}async function en(n){if(Q&&!c){d(!0);try{let r=await tv(e,{accept:n,modelRef:t});f(Q.controlRunId??null),r&&o(r)}catch{}finally{d(!1)}}}async function er(n){let r=n.value.trim(),a=(n.attachments??[]).map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:"card"===e.kind?{kind:"card",name:e.name,mimeType:e.mimeType,text:e.text??"",cardKind:e.cardKind}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?(e.data??"")!=="":(e.text??"")!=="");if(r||0!==a.length){s(""),v([]);try{let i=await tc(e,{message:r,modelRef:n.modelId??t,mode:"agent",attachments:a.length>0?a:void 0});i&&o(i)}catch{s(r),v(n.attachments??[])}}}async function ea(){try{await tI(e)}catch{}V()}async function ei(t,n){try{await tM(e,t,n)}catch(e){RD.error(e instanceof Error?e.message:"审批操作失败")}V()}async function eo(t){return tE(e,t)}async function el(){try{let n=await tc(e,{message:"继续",modelRef:t,mode:"agent"});n&&o(n)}catch(e){RD.error(e instanceof Error?e.message:"继续失败")}}async function es(n){let r="string"==typeof n.modelRef?n.modelRef.trim():"",a="agent"===n.mode?"agent":"chat";try{let i=await td(e,{modelRef:r||t,mode:a,retryEventId:n.id});i&&o(i)}catch(e){RD.error(e instanceof Error?e.message:"对话重试失败")}}async function ec(){if(!w)return void j(void 0);N(!0);try{let t=await ty(e,w.id);o(t.detail),s(t.prompt),y([]);let n=[];t.revertedFiles>0&&n.push(`恢复 ${t.revertedFiles} 个文件`),t.deletedFiles>0&&n.push(`删除 ${t.deletedFiles} 个新增文件`),t.archivedSubagents>0&&n.push(`归档 ${t.archivedSubagents} 个子代理`),RD.success(n.length?`已回退:${n.join(",")}`:"已回退到此处"),t.skippedRemote&&t.skippedRemote.length>0&&RD.warning(`${t.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){RD.error(e instanceof Error?e.message:"回退失败")}finally{N(!1),j(void 0)}}async function ed(t){if(!C){S(!0);try{await tN(e,t.id),RD.success("已创建分支对话")}catch(e){RD.error(e instanceof Error?e.message:"创建分支失败")}finally{S(!1)}}}function eu(){q?RD.error("对话正在运行,请先停止后再编辑上下文"):I(!0)}function ef(){I(!1),z(new Set),T(void 0),_("")}function em(e){z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function eh(e,t){let n=Y.findIndex(t=>t.id===e),r=Y.findIndex(e=>e.id===t);if(n<0||r<0)return;let a=Math.min(n,r),i=Math.max(n,r);z(e=>{let t=new Set(e);for(let e=a;e<=i;e++){let n=Y[e];n&&"user"!==n.kind&&t.add(n.id)}return t})}function ep(e){q?RD.error("对话正在运行,请先停止后再删除"):0!==e.length&&B(e)}async function eg(){if(!$||0===$.length)return void B(void 0);L(!0);try{let t=await tw(e,$);o(t.detail),z(new Set),RD.success(`已从上下文删除 ${t.deletedEvents||$.length} 条`)}catch(e){RD.error(e instanceof Error?e.message:"删除失败")}finally{L(!1),B(void 0)}}function ex(e,t){T(e),_(t)}async function ev(){if(!A)return void T(void 0);L(!0);try{let t=await tj(e,A,R);o(t.detail),T(void 0),_(""),RD.success("已更新消息")}catch(e){RD.error(e instanceof Error?e.message:"保存失败")}finally{L(!1)}}function eb(){T(void 0),_("")}async function ey(t,n){L(!0);try{let r=await tk(e,[t],n);o(r.detail)}catch(e){RD.error(e instanceof Error?e.message:n?"还原失败":"翻译失败")}finally{L(!1)}}let ew=P.useMemo(()=>{if(!X)return{mode:M,selectedIds:O,onToggleSelect:em,onRangeSelect:eh,onEnterMode:eu,onExitMode:ef,onDeleteOne:e=>ep([e]),editingId:A,editDraft:R,onStartEdit:ex,onEditDraftChange:_,onSaveEdit:()=>void ev(),onCancelEdit:eb,onTranslate:e=>void ey(e,!1),onRestore:e=>void ey(e,!0)}},[X,M,O,A,R]),ej=ew&&A?(0,E.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,E.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑消息"}),(0,E.jsx)(F.Button,{type:"button",size:"sm",variant:"ghost",disabled:D,onClick:eb,children:"取消"}),(0,E.jsx)(F.Button,{type:"button",size:"sm",disabled:D,onClick:()=>void ev(),children:"保存"})]}):ew&&M?(0,E.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,E.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑上下文"}),(0,E.jsxs)(F.Button,{type:"button",size:"sm",variant:"destructive",disabled:D||0===O.size,onClick:()=>ep([...O]),children:["删除选中 (",O.size,")"]}),(0,E.jsx)(F.Button,{type:"button",size:"sm",variant:"ghost",onClick:ef,children:"退出编辑"})]}):void 0;function ek(e){return{id:e.id,ownerMachineId:e.ownerMachineId??K,name:e.name,subagentType:e.subagentType}}async function eN(e){let t=e.path?.trim()||e.name.trim();if(!t||"diff"===e.kind||"diff"===e.meta||e.meta?.toLowerCase().startsWith("depth"))return;let n=_O({machineId:e.machineId,path:t},{workspaceFolders:G,ownerMachineId:K});if((n.machineId??"local")==="local")try{let e=await fetch((0,H.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(n.path)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}}catch(e){RD.error(`打开文件失败:${e instanceof Error?e.message:String(e)}`)}}let eC=K??"local",eS=P.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch((0,H.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=(0,H.localAPIURL)(`/v1/remote/${encodeURIComponent(eC)}/files/raw?path=${encodeURIComponent(t)}`);await Ud({url:e,label:r}),RD.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){RD.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===eC?(0,H.localAPIURL)(`/v1/files/raw?${n}`):(0,H.localAPIURL)(`/v1/remote/${encodeURIComponent(eC)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===eC?"local-file":"remote-file",onOpen:e=>void t(e)}},[eC]);return(0,E.jsxs)("div",{className:"vtl-immersive-project",children:[(0,E.jsx)("button",{type:"button",className:"vtl-immersive-project__home",onClick:a,title:"返回主页","aria-label":"返回主页",children:(0,E.jsx)(AS,{size:16,"aria-hidden":!0})}),(0,E.jsx)(RY,{className:"vtl-immersive-project__panel",events:Y,running:q,models:n,modelId:t,onModelChange:r,onSubmit:er,onStop:ea,composerValue:l,onComposerValueChange:s,hidePermissionMode:!0,attachments:x,onAttachmentsChange:v,onCardDrop:Uo,deliverable:eS,onOpenFile:eN,onOpenSubagent:function(e){e.id&&y([ek(e)])},onApprovalDecision:ei,onFetchExplanation:eo,onContinue:el,onRetry:es,onRecallUserMessage:function(e){q?RD.error("对话正在运行,请先停止后再回退"):j(e)},onBranchAssistantMessage:ed,contextEdit:ew,contextEditBar:ej,planPromptBar:(0,E.jsxs)(E.Fragment,{children:[ee?(0,E.jsx)(IQ,{reason:ee.reason,pending:m,onAdded:(e,t)=>void et(!0,e,t),onDismiss:()=>void et(!1)}):null,Q?(0,E.jsx)(MW,{requestedMode:Q.requestedMode??"",reason:Q.reason,pending:c,onAccept:()=>void en(!0),onReject:()=>void en(!1)}):null,(0,E.jsx)(IK,{conversationId:e,planState:W,modelRef:t,onResolved:()=>void V()})]})}),b.length>0&&i?(0,E.jsx)(RJ,{stack:b,rootTitle:i.conversation.title,rootOwnerMachineId:i.conversation.ownerMachineId,onNavigateRoot:()=>y([]),onNavigateIndex:e=>y(b.slice(0,e+1)),onOpenSubagent:function(e){e.id&&y(t=>[...t,ek(e)])}}):null,(0,E.jsx)(Rt,{open:void 0!==w,onOpenChange:e=>{e||k||j(void 0)},children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"回退对话到此处?"}),(0,E.jsx)(Rk,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{disabled:k,children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",disabled:k,onClick:e=>{e.preventDefault(),ec()},children:k?"回退中…":"确认回退"})]})]})}),(0,E.jsx)(Rt,{open:void 0!==$,onOpenChange:e=>{e||D||B(void 0)},children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"从上下文中删除?"}),(0,E.jsx)(Rk,{children:`确认从上下文中删除选中的 ${$?.length??0} 条?此操作会同时从智能体的实际上下文中移除(不影响磁盘文件)。`})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{disabled:D,children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",disabled:D,onClick:e=>{e.preventDefault(),eg()},children:D?"删除中…":"确认删除"})]})]})}),(0,E.jsx)(RH,{})]})}function Up({openSeq:e,contextPreamble:t,models:n,modelRef:r,onModelChange:a,onClose:i,onEnterProject:o,onSplitToHome:l}){let[s,c]=P.useState(null);P.useEffect(()=>{let e=!1;return(async()=>{try{let t=await tu();e||c(t)}catch{}})(),()=>{e=!0}},[]);let d=s?.conversation.id??"";return(0,E.jsx)("div",{className:"vtl-immersive-quick",role:"dialog","aria-modal":"true","aria-label":"快捷操控",onClick:i,children:(0,E.jsx)("div",{className:"vtl-immersive-quick__panel",onClick:e=>e.stopPropagation(),children:d?(0,E.jsx)(T0,{conversationId:d,modelRef:r,initialMessage:"",contextPreamble:t,models:n,onModelChange:a,onEnterProject:(e,t)=>{i(),o?.(e,t)},onSplitToHome:e=>{i(),l?.(e)}},`${d}:${e}`):(0,E.jsx)("p",{className:"vtl-immersive-quick__loading",children:"正在唤起快捷操控…"})})})}function Ug({className:e,...t}){return(0,E.jsxs)("svg",{version:"1.1",viewBox:"0 0 1536 1024",className:(0,B.cn)("brand-mark",e),role:"img","aria-label":"Vantaloom",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[(0,E.jsx)("path",{transform:"translate(658,393)",d:"m0 0 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,E.jsx)("path",{transform:"translate(1147,452)",d:"m0 0h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,E.jsx)("path",{transform:"translate(556,449)",d:"m0 0h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,E.jsx)("path",{transform:"translate(409,450)",d:"m0 0h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,E.jsx)("path",{transform:"translate(918,450)",d:"m0 0h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,E.jsx)("path",{transform:"translate(224,442)",d:"m0 0h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,E.jsx)("path",{transform:"translate(1010,450)",d:"m0 0h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,E.jsx)("path",{transform:"translate(848,371)",d:"m0 0h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function Ux({text:e,as:t="div",typingSpeed:n=50,initialDelay:r=0,pauseDuration:a=2e3,deletingSpeed:i=30,loop:o=!0,className:l="",showCursor:s=!0,hideCursorWhileTyping:c=!1,cursorCharacter:d="|",cursorClassName:u="",cursorBlinkDuration:f=.5,textColors:m=[],variableSpeed:h,onSentenceComplete:p,startOnVisible:g=!1,reverseMode:x=!1,...v}){let[b,y]=(0,P.useState)(""),[w,j]=(0,P.useState)(0),[k,N]=(0,P.useState)(!1),[C,S]=(0,P.useState)(0),[M,I]=(0,P.useState)(!g),O=(0,P.useRef)(null),z=(0,P.useMemo)(()=>Array.isArray(e)?e:[e],[e]),A=(0,P.useCallback)(()=>{if(!h)return n;let{min:e,max:t}=h;return Math.random()*(t-e)+e},[h,n]);(0,P.useEffect)(()=>{if(!g||!O.current)return;let e=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&I(!0)})},{threshold:.1});return e.observe(O.current),()=>e.disconnect()},[g]),(0,P.useEffect)(()=>{let e;if(!M)return;let t=z[C]??"",l=x?t.split("").reverse().join(""):t,s=()=>{if(k)if(""===b){if(N(!1),C===z.length-1&&!o)return;p&&p(z[C]??"",C),S(e=>(e+1)%z.length),j(0),e=setTimeout(()=>{},a)}else e=setTimeout(()=>{y(e=>e.slice(0,-1))},i);else if(w<l.length)e=setTimeout(()=>{y(e=>e+l[w]),j(e=>e+1)},h?A():n);else if(z.length>1){if(!o&&C===z.length-1)return;e=setTimeout(()=>{N(!0)},a)}};return 0!==w||k||""!==b?s():e=setTimeout(s,r),()=>clearTimeout(e)},[w,b,k,n,i,a,z,C,o,r,M,x,h,A,p]);let T=c&&(w<(z[C]?.length??0)||k);return(0,P.createElement)(t,{ref:O,className:(0,B.cn)("vtl-text-type",l),...v},(0,E.jsx)("span",{className:"vtl-text-type__content",style:{color:(0===m.length?"inherit":m[C%m.length])||"inherit"},children:b}),s&&(0,E.jsx)("span",{className:(0,B.cn)("vtl-text-type__cursor",u,T&&"vtl-text-type__cursor--hidden"),style:{"--vtl-cursor-blink":`${2*f}s`},children:d}))}function Uv({corner:e,stageClassName:t,className:n,children:r,...a}){return(0,E.jsxs)("div",{className:["vtl-splash",n].filter(Boolean).join(" "),...a,children:[(0,E.jsx)("div",{className:"welcome-layer",children:(0,E.jsx)("div",{className:["welcome-stage",t].filter(Boolean).join(" "),children:r})}),e]})}let Ub="你现在想和谁对话?";function Uy({hasRoutes:e,existingModels:t,onHeadline:n,onComplete:r}){let[a,i]=P.useState(e?"pickModel":"route"),[o,l]=P.useState([]),[s,c]=P.useState("");return(P.useEffect(()=>{n(e?Ub:"需要先配置模型路由")},[]),"route"===a)?(0,E.jsx)(IJ,{onSaved:(e,t,r)=>{let a=r??[];l(a),c(a[0]?.value??""),n(Ub),i("pickModel")}}):(0,E.jsxs)("div",{className:"vtl-immersive-panel",children:[(0,E.jsx)("div",{className:"vtl-immersive-models",children:(0,E.jsx)(IY,{mode:"single",models:e?t:o,value:s,onChange:c,clearLabel:"不选择",emptyHint:"没有可用模型"})}),(0,E.jsx)("div",{className:"vtl-immersive-panel__actions",children:(0,E.jsx)(F.Button,{onClick:()=>r(s),disabled:!s,children:"开始"})})]})}let Uw="别来无恙,想干点什么?",Uj=e=>new Promise(t=>setTimeout(t,e));function Uk({modelRef:e,onModelRef:t,onStartChat:n,initialDraft:r}){let{models:a}=nl(),i=P.useRef(""!==(r??"").trim()).current,[o,l]=P.useState(i?"ready":"brand"),[s,c]=P.useState(i?r??"":""),[d,u]=P.useState(!1),[f,m]=P.useState(!1),[h,p]=P.useState(i?[Uw]:[]),[g,x]=P.useState(!1),[v,b]=P.useState([]),y=P.useCallback(e=>{p(t=>t[t.length-1]===e?t:[...t,e])},[]),w=P.useCallback(e=>{c(e),"brand"!==o||d||""===e.trim()||u(!0)},[o,d]),j=P.useCallback(()=>{u(!1),l(e=>"brand"===e?"greeting":e),p(e=>0===e.length?[Uw]:e)},[]),k=P.useCallback(async t=>{let r=t.value.trim();if(""===r)return;m(!0);let[a]=await Promise.all([t0().then(e=>e.models).catch(()=>[]),Uj(320)]),i=a.filter(e=>!1!==e.available),o=""!==e&&i.some(t=>t.id===e);if(i.length>0&&o){p(e=>[...e,""]),await Uj(160),n(r);return}x(i.length>0),b(i.map(e=>({value:e.id,label:e.label,contextLength:e.contextLength??0,providerName:e.providerName,available:!0}))),l("onboarding")},[e,n]),N=P.useCallback(e=>{t(e),y(Uw),m(!1),l("ready")},[t,y]),C=P.useCallback(async e=>{let t=e.value.trim();""!==t&&(p(e=>[...e,""]),m(!0),await Uj(450),n(t))},[n]),S=P.useMemo(()=>a.map(e=>({id:e.value,label:e.label})),[a]);return(0,E.jsxs)(Uv,{stageClassName:"gap-6",corner:(0,E.jsx)(T6,{}),children:[(0,E.jsxs)("div",{className:"vtl-immersive-headline-slot",children:[(0,E.jsx)("div",{className:(0,B.cn)("vtl-immersive-brand",i&&"vtl-immersive-brand--erased",!i&&(d||"brand"!==o)&&"vtl-immersive-brand--erasing"),onAnimationEnd:d?j:void 0,children:(0,E.jsx)(Ug,{})}),"brand"!==o?(0,E.jsx)(Ux,{className:"vtl-immersive-headline",text:h.length>0?h:[Uw],loop:!1,typingSpeed:48,deletingSpeed:24,pauseDuration:420,cursorCharacter:"▍"},"immersive-headline"):null]}),"onboarding"===o?(0,E.jsx)(Uy,{hasRoutes:g,existingModels:v,onHeadline:y,onComplete:N}):(0,E.jsx)("div",{className:(0,B.cn)("vtl-immersive-composer",f&&"vtl-immersive-composer--leaving"),children:(0,E.jsx)(MF,{minRows:3,value:s,onValueChange:w,onSubmit:"ready"===o?C:k,hideComposerOptions:"ready"!==o,hidePermissionMode:!0,models:"ready"===o?S:void 0,modelId:"ready"===o?e:void 0,onModelChange:"ready"===o?t:void 0,labels:{placeholder:"告诉智能体你想做什么…"}})})]})}let UN="vantaloom-immersive-model";function UC(){let{models:e}=nl(),[t,n]=P.useState("home"),[r,a]=P.useState(""),[i,o]=P.useState(""),[l,s]=P.useState(""),[c,d]=P.useState(""),[u,f]=P.useState(""),[m,h]=P.useState("chats"),[p,g]=P.useState([]),[x,v]=P.useState([]),[b,y]=P.useState(()=>window.localStorage.getItem(UN)??""),[w,j]=P.useState(!1),[k,N]=P.useState(0),C=P.useCallback(e=>{y(e),e&&window.localStorage.setItem(UN,e)},[]),S=P.useCallback(async()=>{try{g(await tf())}catch{}},[]),M=P.useCallback(async()=>{try{v(await tm())}catch{}},[]);P.useEffect(()=>{S(),M();let e=setInterval(()=>{S(),M()},3e3);return()=>clearInterval(e)},[S,M]);let I=P.useMemo(()=>e.map(e=>({id:e.value,label:e.label})),[e]),O=P.useMemo(()=>{if("project"===t&&i){let e=x.find(e=>e.id===i)?.title||"未命名项目";return`【当前上下文】用户当前打开的是项目「${e}」(id=${i})。`}if("chat"===t&&r){let e=p.find(e=>e.id===r)?.title||"新对话";return`【当前上下文】用户当前打开的是聊天「${e}」(id=${r})。`}return"【当前上下文】用户当前打开的是主页。"},[t,i,r,x,p]);P.useEffect(()=>{let e=e=>{"Space"!==e.code||!e.shiftKey||e.repeat||w?"Escape"===e.key&&w&&j(!1):(e.preventDefault(),N(e=>e+1),j(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w]);let z=P.useCallback(async e=>{try{let t=await th();a(t.conversation.id),d(e),n("chat"),S()}catch{n("home")}},[S]),A=P.useCallback(e=>{a(e),d(""),n("chat")},[]),T=P.useCallback((e,t)=>{e&&t&&(o(e),s(t),n("project"),M())},[M]),R=P.useCallback(async e=>{try{let t=(await tZ(e))[0];if(!t)return;o(e),s(t.id),n("project")}catch{}},[]),_=P.useCallback(()=>{n("home"),a(""),o(""),s(""),d(""),f(""),S(),M()},[S,M]),D=P.useCallback(e=>{n("home"),a(""),o(""),s(""),d(""),f((e??"").trim()),S(),M()},[S,M]),L=w?(0,E.jsx)(Up,{openSeq:k,contextPreamble:O,models:I,modelRef:b,onModelChange:C,onClose:()=>j(!1),onEnterProject:T,onSplitToHome:D}):null;return"project"===t&&l?(0,E.jsxs)("div",{className:"vtl-splash",children:[(0,E.jsx)(Uh,{conversationId:l,modelRef:b,models:I,onModelChange:C,onGoHome:_},l),(0,E.jsx)(T6,{}),L]}):(0,E.jsxs)(E.Fragment,{children:["chat"===t&&r?(0,E.jsxs)("div",{className:"vtl-splash",children:[(0,E.jsx)(T0,{conversationId:r,modelRef:b,initialMessage:c,models:I,onModelChange:C,onEnterProject:T,onSplitToHome:D},r),(0,E.jsx)(T6,{})]}):(0,E.jsx)(Uk,{modelRef:b,onModelRef:C,onStartChat:z,initialDraft:u}),(0,E.jsx)(US,{kind:m,onToggleKind:()=>h(e=>"chats"===e?"projects":"chats"),chats:p,projects:x,currentChatId:"chat"===t?r:"",currentProjectId:i,onOpenChat:A,onOpenProject:e=>void R(e),onGoHome:_}),L]})}function US({kind:e,onToggleKind:t,chats:n,projects:r,currentChatId:a,currentProjectId:i,onOpenChat:o,onOpenProject:l,onGoHome:s}){let c="chats"===e;return(0,E.jsxs)("div",{className:"vtl-immersive-rail",children:[(0,E.jsxs)("div",{className:"vtl-immersive-rail__head",children:[(0,E.jsx)("button",{type:"button",className:"vtl-immersive-rail__icon",onClick:s,title:"回到主页(开始新对话)","aria-label":"主页",children:(0,E.jsx)(eO,{size:16,"aria-hidden":!0})}),(0,E.jsx)("button",{type:"button",className:"vtl-immersive-rail__icon",onClick:t,title:c?"查看项目":"查看聊天","aria-label":"切换列表",children:c?(0,E.jsx)(eP,{size:16,"aria-hidden":!0}):(0,E.jsx)(eI,{size:16,"aria-hidden":!0})})]}),(0,E.jsx)("div",{className:"vtl-immersive-rail__list",children:c?0===n.length?(0,E.jsx)("p",{className:"vtl-immersive-rail__empty",children:"还没有聊天,去主页说点什么吧"}):n.slice(0,20).map(e=>(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("vtl-immersive-rail__row",e.id===a&&"vtl-immersive-rail__row--active"),onClick:()=>o(e.id),title:e.title||"新对话",children:[e.running?(0,E.jsx)("span",{className:"vtl-immersive-rail__dot","aria-hidden":!0}):null,(0,E.jsx)("span",{className:"vtl-immersive-rail__row-title",children:e.title||"新对话"})]},e.id)):0===r.length?(0,E.jsx)("p",{className:"vtl-immersive-rail__empty",children:"还没有项目(在对话里描述要在某个文件夹做的任务即可创建)"}):r.slice(0,20).map(e=>(0,E.jsx)("button",{type:"button",className:(0,B.cn)("vtl-immersive-rail__row",e.id===i&&"vtl-immersive-rail__row--active"),onClick:()=>l(e.id),title:e.title||"未命名项目",children:(0,E.jsx)("span",{className:"vtl-immersive-rail__row-title",children:e.title||"未命名项目"})},e.id))})]})}function UM(){return(0,E.jsx)(UC,{})}let UE=(0,z.default)("layout-panel-left",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]),UI=(0,z.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);function UP({conversationPanel:e,paneElements:t,panes:n,activeSlotCount:r,onOpenPalette:a,timeline:i,view:o,onPaneCountChange:l}){let[s,c]=P.useState(0),d=P.useMemo(()=>n.slice(0,r).map((e,t)=>({pane:e,index:t})).filter(e=>void 0!==e.pane),[n,r]),u=Math.min(s,Math.max(0,d.length-1));P.useEffect(()=>{s!==u&&c(u)},[s,u]),P.useEffect(()=>{l?.(d.length)},[l,d.length]);let f=n.slice(0,r).findIndex(e=>void 0===e);return(0,E.jsx)("div",{className:"vtl-app-background vtl-agent-conversation-workspace flex h-full min-h-0 flex-col",children:(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:"conversation"===o?(0,E.jsxs)("div",{className:"relative size-full min-h-0",children:[i?(0,E.jsx)("div",{className:"pointer-events-none absolute left-1 top-2 z-30 flex justify-start",children:(0,E.jsx)("div",{className:"pointer-events-auto",children:i})}):null,(0,E.jsx)("div",{className:"size-full",children:e})]}):(0,E.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,E.jsxs)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5",children:[d.map((e,t)=>(0,E.jsx)("button",{type:"button",className:(0,B.cn)("inline-flex h-9 min-w-[3rem] shrink-0 items-center justify-center rounded-md px-3 text-sm font-medium transition-colors",t===u?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"),onClick:()=>c(t),children:(0,E.jsx)("span",{className:"max-w-[8rem] truncate",children:e.pane.title})},e.pane.id)),(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"icon-sm",className:"ml-1 h-9 w-9 shrink-0",onClick:()=>{let e=f>=0?f:u;a(d[e]?.index??e)},children:(0,E.jsx)(eO,{className:"size-4"})})]}),(0,E.jsx)("div",{className:"min-h-0 flex-1",children:d.length>0?(0,E.jsx)("div",{className:"size-full",children:t[d[u]?.index??0]}):(0,E.jsx)("div",{className:"grid size-full place-items-center p-4",children:(0,E.jsxs)(F.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>a(0),children:[(0,E.jsx)(eO,{className:"size-4"}),"添加组件"]})})})]})})})}function UO({view:e,onViewChange:t,paneCount:n}){return(0,E.jsxs)("div",{className:"flex items-center rounded-lg border border-border bg-background/60 p-0.5",children:[(0,E.jsx)("button",{type:"button","aria-label":"对话","aria-pressed":"conversation"===e,onClick:()=>t("conversation"),className:(0,B.cn)("flex size-8 items-center justify-center rounded-md transition-colors [&_svg]:size-4","conversation"===e?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,E.jsx)(UI,{})}),(0,E.jsxs)("button",{type:"button","aria-label":"工作区","aria-pressed":"workspace"===e,onClick:()=>t("workspace"),className:(0,B.cn)("relative flex size-8 items-center justify-center rounded-md transition-colors [&_svg]:size-4","workspace"===e?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,E.jsx)(UE,{}),n>0?(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 grid h-3.5 min-w-3.5 place-items-center rounded-full bg-primary px-0.5 text-[0.5rem] font-semibold leading-none text-primary-foreground",children:n}):null]})]})}function Uz(e){return!e||"local"===e}async function UA(e,t){return UD(await UL(t,`/${encodeURIComponent(e)}`),t)}async function UT(e,t){return UD(await UL(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(Ut),edges:e.edges.map(Un)})}),t)}async function UR(e,t,n){return UD(await UL(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(Ut),edges:t.edges.map(Un),nodeIds:t.nodeIds})}),n)}async function U_(e,t){return UD(await UL(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}function UD(e,t){var n,r;let a;return{canvas:(n=e.canvas,a=Uz(r=t)?n.ownerMachineId??"local":r,{id:n.id,title:n.title||"新画布",ownerMachineId:a,nodeCount:n.nodeCount??0,running:n.running??!1,createdAt:n.createdAt,updatedAt:n.updatedAt,lastOpenedAt:n.lastOpenedAt}),nodes:e.nodes??[],edges:e.edges??[]}}async function UL(e,t,n,r){let a=await fetch((0,H.localAPIURL)(Uz(e)?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let U$={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题",immersiveMode:"切换到沉浸模式"},UF={search:"搜索控制台...",dashboard:"仪表盘",canvas:"工程",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近工程",canvasNew:"新建工程",canvasAll:"浏览所有画布",projectCanvas:"画布",projectKanban:"看板",projectSettings:"工程设置",projectNewConversation:"新建对话",projectEmpty:"暂无工程",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"},UB=(0,z.default)("brain-circuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]),UV=(0,z.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),UH=(0,z.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),UU=(0,z.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Uq=(0,z.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),UW=(0,z.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),UK=(0,z.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function UG(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=[];for(let a of e){let e=a.forkOriginId;if(e&&t.has(e)){let t=n.get(e)??[];t.push(a),n.set(e,t)}else r.push(a)}return{byId:t,childrenOf:n,roots:r}}function UX(e){let{childrenOf:t,roots:n}=UG(e),r=[],a=e=>{for(let n of(r.push(e),t.get(e.id)??[]))a(n)};for(let e of n)a(e);return r}function UY(e,t,n,r,a){let i=new Set(e);if("range"===n&&a){let n=r.indexOf(a),o=r.indexOf(t);if(-1!==n&&-1!==o){let[a,l]=n<o?[n,o]:[o,n],s=!e.has(t);for(let e=a;e<=l;e++){let t=r[e];t&&(s?i.add(t):i.delete(t))}return i}}return i.has(t)?i.delete(t):i.add(t),i}let UZ={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-project":"canvas","project-overview":"canvas","project-settings":"canvas","project-conversation":"canvas",kanban:"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-models":"settings","preferences-agents":"settings","system-general":"settings","network-downloads":"settings","dump-history":"settings","preferences-model-routes":"settings","preferences-model-groups":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-assets":"settings","preferences-layout":"settings","preferences-official-extensions":"settings","network-topology":"settings","network-settings":"settings","search-settings":"settings","system-downloads":"settings","check-update":"settings","balance-usage":"settings",feedback:"settings",account:"settings"},UJ=[{id:"model",title:"模型设置",icon:(0,E.jsx)(_q,{}),items:[{id:"preferences-models",label:"模型",icon:(0,E.jsx)(UB,{})},{id:"preferences-agents",label:"代理",icon:(0,E.jsx)(CB,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,E.jsx)(_q,{})}]},{id:"prefs",title:"偏好设置",icon:(0,E.jsx)(UK,{}),items:[{id:"preferences-assets",label:"扩展 / 资产",icon:(0,E.jsx)(nh,{})},{id:"preferences-layout",label:"布局排版",icon:(0,E.jsx)(UH,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,E.jsx)(UV,{})}]},{id:"system",title:"系统设置",icon:(0,E.jsx)(UW,{}),items:[{id:"system-general",label:"系统与账户",icon:(0,E.jsx)(UW,{})},{id:"network-downloads",label:"网络与下载",icon:(0,E.jsx)(UU,{})},{id:"dump-history",label:"请求历史 / 诊断",icon:(0,E.jsx)(Uq,{})},{id:"search-settings",label:"搜索设置",icon:(0,E.jsx)(IX,{})}]}],UQ=(0,z.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),U0=(0,z.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),U1=(0,z.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),U2=(0,z.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var U5=e.i(91e3);function U3(){let{user:e}=eE(),t=e?.name??U$.product,n=(e?.name??"V").slice(0,1).toUpperCase();return(0,E.jsx)("div",{className:"mt-auto pt-3",children:(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:(0,E.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,E.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,E.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:n}),(0,E.jsx)("span",{className:"truncate text-sm text-foreground",children:t})]}),(0,E.jsx)(MC,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,E.jsxs)(MM,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[e?.email&&(0,E.jsx)(MP,{className:"truncate font-normal text-muted-foreground",children:e.email}),(0,E.jsxs)(ME,{disabled:!0,children:[(0,E.jsx)(UQ,{}),(0,E.jsx)("span",{className:"flex-1",children:"语言"}),(0,E.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,E.jsxs)(ME,{disabled:!0,children:[(0,E.jsx)(Iq,{}),(0,E.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,E.jsx)(MO,{}),(0,E.jsx)(U4,{}),(0,E.jsx)(U8,{}),e&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(MO,{}),(0,E.jsx)(U7,{})]})]})]})})}function U4(){let{enterImmersive:e}=eN();return(0,E.jsxs)(ME,{onSelect:()=>e(),children:[(0,E.jsx)(nh,{}),(0,E.jsx)("span",{className:"flex-1",children:U$.immersiveMode})]})}let U6=["light","dark","jelly"];function U8(){let{resolvedTheme:e,setTheme:t}=(0,T1.useTheme)(),[n,r]=P.useState(U5.defaultAppearanceTheme);P.useEffect(()=>{let e=window.localStorage.getItem(U5.appearanceThemeStorageKey)??U5.defaultAppearanceTheme;r(e),(0,U5.applyAppearanceTheme)({theme:e})},[]);let a=n===U5.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=U6[(U6.indexOf(a)+1)%U6.length]??"light";function o(e){r(e),window.localStorage.setItem(U5.appearanceThemeStorageKey,e),(0,U5.applyAppearanceTheme)({theme:e})}let l="dark"===a?U1:U2;return(0,E.jsxs)(ME,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(U5.jellyAppearanceTheme);return}o(U5.defaultAppearanceTheme),t(i)}()},children:[(0,E.jsx)(l,{}),(0,E.jsx)("span",{className:"flex-1",children:U$.theme}),(0,E.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function U7(){let{logout:e}=eE();return(0,E.jsxs)(ME,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,E.jsx)(U0,{}),(0,E.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let U9=(0,z.default)("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]),qe="__all__",qt={status:"all",location:qe,sort:"recent"};function qn(e,t,n=!0){let r=P.useRef(e);r.current=e;let a=P.useRef(!1);P.useEffect(()=>{if(!n)return;let e=!1,i=async()=>{if(!e&&!a.current){a.current=!0;try{await r.current()}finally{a.current=!1}}};i();let o=setInterval(()=>{"visible"===document.visibilityState&&i()},t),l=()=>{"visible"===document.visibilityState&&i()};return document.addEventListener("visibilitychange",l),()=>{e=!0,clearInterval(o),document.removeEventListener("visibilitychange",l)}},[t,n])}function qr(e){let[t,n]=P.useState(0),r=P.useRef(e);return P.useEffect(()=>{e&&!r.current&&n(e=>e+1),r.current=e},[e]),t}let qa=(0,z.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),qi=P.useLayoutEffect;function qo({open:e,className:t,children:n}){let r=P.useRef(null),[a,i]=P.useState(e),[o,l]=P.useState(e?"auto":0),s=P.useRef(!0);return P.useEffect(()=>{e&&i(!0)},[e]),qi(()=>{if(s.current){s.current=!1,l(e?"auto":0);return}let t=r.current;if(!t)return;let n=t.scrollHeight;if(e){l(n);let e=window.setTimeout(()=>l("auto"),200);return()=>window.clearTimeout(e)}l(n);let a=window.requestAnimationFrame(()=>l(0));return()=>window.cancelAnimationFrame(a)},[e]),(0,E.jsx)("div",{"aria-hidden":!e,className:(0,B.cn)("overflow-hidden transition-[height] ease-out",e?"duration-200":"duration-150",t),style:{height:o},children:(0,E.jsx)("div",{ref:r,children:a?n:null})})}function ql({count:e,archived:t,onArchive:n,onDelete:r,onCancel:a}){let[i,o]=P.useState(!1);return(0,E.jsxs)("div",{className:"mb-3 flex items-center gap-1.5 rounded-lg border border-border bg-muted/60 px-2.5 py-1.5 text-[13px]",children:[(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["已选 ",e," 项"]}),(0,E.jsxs)("button",{type:"button",onClick:n,title:t?"取消归档":"归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-foreground/80 transition-colors hover:bg-background/70 hover:text-foreground [&_svg]:size-3.5",children:[t?(0,E.jsx)(qa,{}):(0,E.jsx)(Av,{}),t?"取消归档":"归档"]}),(0,E.jsxs)("button",{type:"button",onClick:()=>o(!0),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-destructive transition-colors hover:bg-destructive/10 [&_svg]:size-3.5",children:[(0,E.jsx)(ML,{}),"删除"]}),(0,E.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded-md px-2 py-1 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:"取消"}),(0,E.jsx)(Rt,{open:i,onOpenChange:o,children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"删除会话"}),(0,E.jsxs)(Rk,{children:["确认删除选中的 ",e," 个对话?此操作无法撤销。"]})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",onClick:r,children:"删除"})]})]})})]})}let qs=P.memo(function({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onRename:s,onDelete:c,onFork:d,onArchive:u,onUnarchive:f,selectionMode:m,selected:h,onToggleSelect:p,deleteLabel:g="删除"}){let[x,v]=P.useState(!1),[b,y]=P.useState(!1),[w,j]=P.useState(t),k=!!p,N=!!(l||s||c||d||u||f),C=i>0,S=()=>{j(t),y(!0)},M=(0,E.jsxs)(E.Fragment,{children:[l?(0,E.jsxs)(E5,{onSelect:()=>l(),children:[(0,E.jsx)(UK,{}),(0,E.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,s?(0,E.jsxs)(E5,{onSelect:()=>S(),children:[(0,E.jsx)(IW,{}),(0,E.jsx)("span",{className:"flex-1",children:"重命名"})]}):null,d?(0,E.jsxs)(E5,{onSelect:()=>d(),children:[(0,E.jsx)(Ef,{}),(0,E.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,u?(0,E.jsxs)(E5,{onSelect:()=>u(),children:[(0,E.jsx)(Av,{}),(0,E.jsx)("span",{className:"flex-1",children:"归档"})]}):null,f?(0,E.jsxs)(E5,{onSelect:()=>f(),children:[(0,E.jsx)(qa,{}),(0,E.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,c?(0,E.jsxs)(E5,{variant:"destructive",onSelect:()=>v(!0),children:[(0,E.jsx)(ML,{}),(0,E.jsx)("span",{className:"flex-1",children:g})]}):null]}),I=(0,E.jsxs)("div",{className:(0,B.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors animate-in fade-in-0 slide-in-from-left-1 duration-200",h?"bg-primary/10 text-foreground":r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:C?{marginLeft:14*i}:void 0,children:[m&&k?(0,E.jsx)("button",{type:"button","aria-label":h?"取消选择":"选择","aria-pressed":h,onClick:e=>{e.preventDefault(),e.stopPropagation(),p?.(e.shiftKey?"range":"toggle")},className:(0,B.cn)("ml-2 flex size-4 shrink-0 items-center justify-center rounded border",h?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/50 bg-transparent"),children:h?(0,E.jsx)(CV,{className:"size-3"}):null}):null,(0,E.jsxs)("button",{type:"button",title:e,onClick:e=>{if(k&&(m||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault(),p?.(e.shiftKey?"range":"toggle");return}o()},className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[C?(0,E.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,E.jsx)("span",{className:"size-1.5 shrink-0 animate-pulse rounded-full bg-green-500","aria-label":"运行中"}):(0,E.jsx)(qu,{active:r}),n??(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),N&&!m?(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:(0,E.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,E.jsx)(MD,{className:"size-4"})})}),(0,E.jsxs)(MM,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,E.jsxs)(ME,{onSelect:()=>l(),children:[(0,E.jsx)(UK,{}),(0,E.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,s?(0,E.jsxs)(ME,{onSelect:()=>S(),children:[(0,E.jsx)(IW,{}),(0,E.jsx)("span",{className:"flex-1",children:"重命名"})]}):null,d?(0,E.jsxs)(ME,{onSelect:()=>d(),children:[(0,E.jsx)(Ef,{}),(0,E.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,u?(0,E.jsxs)(ME,{onSelect:()=>u(),children:[(0,E.jsx)(Av,{}),(0,E.jsx)("span",{className:"flex-1",children:"归档"})]}):null,f?(0,E.jsxs)(ME,{onSelect:()=>f(),children:[(0,E.jsx)(qa,{}),(0,E.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,c?(0,E.jsxs)(ME,{variant:"destructive",onSelect:()=>v(!0),children:[(0,E.jsx)(ML,{}),(0,E.jsx)("span",{className:"flex-1",children:g})]}):null]})]}):null]});return(0,E.jsxs)(E.Fragment,{children:[N?(0,E.jsxs)(EK,{children:[(0,E.jsx)(EX,{asChild:!0,children:I}),(0,E.jsx)(E2,{className:"min-w-44",children:M})]}):I,s?(0,E.jsx)(Pe,{open:b,onOpenChange:y,children:(0,E.jsxs)(P1,{className:"sm:max-w-md",children:[(0,E.jsxs)(P2,{children:[(0,E.jsx)(P3,{children:"重命名"}),(0,E.jsx)(P4,{children:"重命名后名称将被固定,不再自动生成。留空保存可恢复自动命名。"})]}),(0,E.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s?.(w),y(!1)},children:[(0,E.jsx)(V,{autoFocus:!0,value:w,onChange:e=>j(e.target.value),placeholder:"留空以恢复自动命名",onFocus:e=>e.currentTarget.select()}),(0,E.jsxs)(P5,{className:"mt-4",children:[(0,E.jsx)(F.Button,{type:"button",variant:"ghost",onClick:()=>y(!1),children:"取消"}),(0,E.jsx)(F.Button,{type:"submit",children:"保存"})]})]})]})}):null,c?(0,E.jsx)(Rt,{open:x,onOpenChange:v,children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:g}),(0,E.jsxs)(Rk,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",onClick:()=>c(),children:"删除"})]})]})}):null]})}),qc=P.forwardRef(function({icon:e,label:t,onClick:n,...r},a){return(0,E.jsxs)("button",{ref:a,type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",...r,children:[(0,E.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})});function qd(){return(0,E.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,E.jsx)(_,{className:"size-4 animate-spin"}),(0,E.jsx)("span",{children:"加载中…"})]})}function qu({active:e}){return(0,E.jsx)("span",{className:(0,B.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}let qf={all:"全部",running:"运行中",idle:"空闲",archived:"已归档"},qm={recent:"最近活动",name:"名称"};function qh({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=zF(),o=e.location===qe?"全部":a(e.location),l=(0,E.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,B.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,E.jsx)(MB,{className:"size-4"}),n?(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]});return i?(0,E.jsxs)(zR,{direction:"bottom",children:[(0,E.jsx)(Pn,{asChild:!0,children:l}),(0,E.jsxs)(zD,{children:[(0,E.jsx)(zL,{children:(0,E.jsx)(z$,{children:"筛选与排序"})}),(0,E.jsxs)("div",{className:"max-h-[60vh] overflow-y-auto px-4 pb-6",children:[(0,E.jsx)(qp,{title:"状态",children:Object.keys(qf).map(n=>(0,E.jsx)(qg,{label:qf[n],selected:e.status===n,onSelect:()=>t({...e,status:n})},n))}),(0,E.jsxs)(qp,{title:"运行位置",children:[(0,E.jsx)(qg,{label:"全部",selected:e.location===qe,onSelect:()=>t({...e,location:qe})}),r.map(n=>(0,E.jsx)(qg,{label:a(n),selected:e.location===n,onSelect:()=>t({...e,location:n})},n))]}),(0,E.jsx)(qp,{title:"排序",children:Object.keys(qm).map(n=>(0,E.jsx)(qg,{label:qm[n],selected:e.sort===n,onSelect:()=>t({...e,sort:n})},n))}),n?(0,E.jsx)("button",{type:"button",onClick:()=>t(qt),className:"mt-4 flex h-11 w-full items-center justify-center rounded-lg border border-border text-[15px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:"重置筛选"}):null]})]})]}):(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:l}),(0,E.jsxs)(MM,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,E.jsx)(MP,{children:"筛选与排序"}),(0,E.jsxs)(MS,{children:[(0,E.jsxs)(MA,{children:[(0,E.jsx)("span",{className:"flex-1",children:"状态"}),(0,E.jsx)("span",{className:"text-xs text-muted-foreground",children:qf[e.status]})]}),(0,E.jsx)(MT,{children:(0,E.jsxs)(Mb,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,E.jsx)(MI,{value:"all",children:"全部"}),(0,E.jsx)(MI,{value:"running",children:"运行中"}),(0,E.jsx)(MI,{value:"idle",children:"空闲"}),(0,E.jsx)(MI,{value:"archived",children:"已归档"})]})})]}),(0,E.jsxs)(MS,{children:[(0,E.jsxs)(MA,{children:[(0,E.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,E.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:o})]}),(0,E.jsx)(MT,{className:"max-h-72 overflow-y-auto",children:(0,E.jsxs)(Mb,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,E.jsx)(MI,{value:qe,children:"全部"}),r.map(e=>(0,E.jsx)(MI,{value:e,children:(0,E.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,E.jsx)(MO,{}),(0,E.jsx)(MP,{children:"排序"}),(0,E.jsxs)(Mb,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,E.jsx)(MI,{value:"recent",children:qm.recent}),(0,E.jsx)(MI,{value:"name",children:qm.name})]}),n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(MO,{}),(0,E.jsx)(ME,{onSelect:()=>t(qt),children:(0,E.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function qp({title:e,children:t}){return(0,E.jsxs)("div",{className:"mb-4 last:mb-0",children:[(0,E.jsx)("p",{className:"mb-1 px-1 text-xs font-medium text-muted-foreground",children:e}),(0,E.jsx)("div",{className:"space-y-0.5",children:t})]})}function qg({label:e,selected:t,onSelect:n}){return(0,E.jsxs)("button",{type:"button",role:"radio","aria-checked":t,onClick:n,className:(0,B.cn)("flex h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-[15px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),t?(0,E.jsx)(CV,{className:"size-4 shrink-0 text-primary"}):null]})}function qx({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,E.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,B.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}let qv=P.memo(function({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onRename:i,onDelete:o,onFork:l,onArchive:s,onUnarchive:c,selectionMode:d,selected:u,onToggleSelect:f}){let m=!0===e.running,h=e.settings?.engine??"vantaloom",p=!!e.projectId,g="vantaloom"!==h?(0,E.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,E.jsx)(qx,{engine:h}),(0,E.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,E.jsx)(qs,{title:m?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:g,active:t,running:m,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a&&!p?()=>a(e.id,e.ownerMachineId):void 0,onRename:i?t=>i(e,t):void 0,onDelete:o?()=>o(e):void 0,onFork:l?()=>l(e):void 0,onArchive:s,onUnarchive:c,selectionMode:d,selected:u,onToggleSelect:f,deleteLabel:"删除会话"})});function qb(e,t){return!!(e.running||t.has(e.id))||(e.children??[]).some(e=>qb(e,t))}let qy=P.memo(function e({nodes:t,depth:n,ancestors:r,activeIds:a,activeLeafId:i,onOpen:o}){let l=t.filter(e=>qb(e,a));return 0===l.length?null:(0,E.jsx)("div",{className:"space-y-0.5",children:l.map(t=>{let l=Ij(t.subagentType),s=l.Icon,c=[...r,{id:t.id,ownerMachineId:t.ownerMachineId,name:t.subagentName,subagentType:t.subagentType}],d=t.id===i,u=t.children??[],f=u.some(e=>qb(e,a));return(0,E.jsxs)("div",{children:[(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",d?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*n},onClick:()=>o?.(c),title:t.subagentName||l.label,children:[(0,E.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,E.jsx)(s,{className:(0,B.cn)("size-3.5 shrink-0",l.color)}),(0,E.jsx)("span",{className:"truncate",children:t.subagentName||`${l.label}子代理`}),t.running?(0,E.jsx)(_,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,E.jsx)(qo,{open:f,children:(0,E.jsx)(e,{nodes:u,depth:n+1,ancestors:c,activeIds:a,activeLeafId:i,onOpen:o})})]},t.id)})})},(e,t)=>e.nodes===t.nodes&&e.activeIds===t.activeIds&&e.activeLeafId===t.activeLeafId&&e.depth===t.depth&&e.ancestors===t.ancestors&&e.onOpen===t.onOpen);function qw({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let[s,c]=P.useState(qt),d="archived"===s.status,{recents:u,refresh:f,loading:m,machineNames:h}=function(e){let[t,n]=P.useState([]),[r,a]=P.useState(!0),[i,o]=P.useState({}),l=P.useRef(!0),s=P.useCallback(async()=>{try{let{machineNames:t}=await eK({includeArchived:e,onPartial:e=>{l.current&&(n([...e].filter(e=>!e.projectId).sort((e,t)=>t.updatedAt>e.updatedAt?1:-1)),a(!1))}});if(!l.current)return;o(t)}catch{}finally{l.current&&a(!1)}},[e]);P.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);let c=P.useRef(e);return P.useEffect(()=>{c.current!==e&&(c.current=e,s())},[e,s]),qn(s,1e4),{recents:t,refresh:()=>void s(),loading:r,machineNames:i}}(d),[p,g]=P.useState(()=>new Set),x=P.useRef(null),v=P.useMemo(()=>{let e=new Set;for(let t of u)e.add(t.ownerMachineId||e$);return Array.from(e)},[u]),b=P.useCallback(e=>eF(e)?"本机":h[e]??e,[h]),y=P.useMemo(()=>{let e=u.filter(e=>{let t=!0===e.running,n=!!e.archivedAt;if("archived"===s.status){if(!n)return!1}else if(n)return!1;return("running"!==s.status||!!t)&&("idle"!==s.status||!t)&&(s.location===qe||(e.ownerMachineId||e$)===s.location)});return"name"===s.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[u,s]),w=P.useMemo(()=>y.filter(e=>!0===e.running),[y]),j=P.useMemo(()=>y.filter(e=>!0!==e.running),[y]),k=s.status!==qt.status||s.location!==qt.location||s.sort!==qt.sort,N=m&&0===u.length,C=P.useCallback(async e=>{try{await te(e.id,e.ownerMachineId)}catch{}a?.(e.id),f()},[a,f]),S=P.useCallback(async e=>{try{let t=await tN(e.id,void 0,e.ownerMachineId);await f(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[f,n]),M=P.useCallback(async e=>{try{await tn(e.id,e.ownerMachineId)}catch{}f()},[f]),I=P.useCallback(async(e,t)=>{try{await tt(e.id,t,e.ownerMachineId)}catch{}f()},[f]),O=P.useCallback(async e=>{try{await tr(e.id,e.ownerMachineId)}catch{}f()},[f]),z=P.useMemo(()=>[...UX(w),...UX(j)],[w,j]),A=P.useMemo(()=>z.map(e=>e.id),[z]),T=P.useCallback((e,t)=>{g(n=>UY(n,e,t,A,x.current)),x.current=e},[A]),R=P.useCallback(()=>{g(new Set),x.current=null},[]);P.useEffect(()=>{g(e=>{if(0===e.size)return e;let t=new Set(z.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[z]);let _=P.useMemo(()=>z.filter(e=>p.has(e.id)),[z,p]),D=P.useCallback(async()=>{await Promise.all(_.map(e=>(d?tr(e.id,e.ownerMachineId):tn(e.id,e.ownerMachineId)).catch(()=>{}))),R(),f()},[_,d,R,f]),L=P.useCallback(async()=>{for(let e of(await Promise.all(_.map(e=>te(e.id,e.ownerMachineId).catch(()=>{}))),_))a?.(e.id);R(),f()},[_,R,f,a]),$=p.size>0,F=P.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),B=o?.[o.length-1]?.id,V=P.useCallback(t=>t!==e||(i?.length??0)===0?null:(0,E.jsx)(qy,{nodes:i??[],depth:0,ancestors:[],activeIds:F,activeLeafId:B,onOpen:l}),[e,i,F,B,l]),H=P.useCallback(t=>{let{childrenOf:a,roots:i}=UG(t),o=(t,i)=>{let l=V(t.id);return(0,E.jsxs)(P.Fragment,{children:[(0,E.jsx)(qv,{conversation:t,depth:i,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onRename:I,onDelete:C,onFork:S,onArchive:t.archivedAt?void 0:()=>M(t),onUnarchive:t.archivedAt?()=>O(t):void 0,selectionMode:$,selected:p.has(t.id),onToggleSelect:e=>T(t.id,e)}),l?(0,E.jsx)("div",{style:i>0?{marginLeft:14*i}:void 0,children:l}):null,(a.get(t.id)??[]).map(e=>o(e,i+1))]},t.id)};return i.map(e=>o(e,0))},[V,e,n,r,I,C,S,M,O,$,p,T]),U=P.useMemo(()=>H(w),[H,w]),q=P.useMemo(()=>H(j),[H,j]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"vtl-stagger-item mb-6 space-y-0.5",style:{animationDelay:"0ms"},"data-tour":"new-conversation",children:(0,E.jsxs)(EK,{children:[(0,E.jsx)(EX,{asChild:!0,children:(0,E.jsx)(qc,{icon:U9,label:UF.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,E.jsx)(E2,{className:"min-w-44",children:(0,E.jsxs)(E5,{onSelect:()=>t({item:{id:"import-claude-session"}}),children:[(0,E.jsx)(Ap,{}),(0,E.jsx)("span",{className:"flex-1",children:"导入 Claude 会话"})]})})]})}),$?(0,E.jsx)(ql,{count:p.size,archived:d,onArchive:()=>void D(),onDelete:()=>void L(),onCancel:R}):null,(0,E.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[w.length>0?(0,E.jsxs)("div",{className:"vtl-stagger-item mb-4",style:{animationDelay:"25ms"},children:[(0,E.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,E.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,E.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,E.jsx)("div",{className:"space-y-0.5",children:U})]}):null,(0,E.jsxs)("div",{className:"vtl-stagger-item mb-2 flex items-center justify-between px-3",style:{animationDelay:"50ms"},children:[(0,E.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,E.jsx)(qh,{filter:s,onChange:c,active:k,locations:v,locationLabel:b})]}),(0,E.jsx)("div",{className:"space-y-0.5",children:N?(0,E.jsx)(qd,{}):0===j.length?(0,E.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:d?"暂无已归档对话":k?"没有符合筛选条件的对话":"暂无对话"}):q})]})]})}let qj=(0,z.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["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",key:"ohrbg2"}]]);var qk="Collapsible",[qN,qC]=jD(qk),[qS,qM]=qN(qk),qE=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=NO({prop:r,defaultProp:a??!1,onChange:o,caller:qk});return(0,E.jsx)(qS,{scope:n,disabled:i,contentId:ke(),open:s,onOpenToggle:P.useCallback(()=>c(e=>!e),[c]),children:(0,E.jsx)(jB.div,{"data-state":qA(s),"data-disabled":i?"":void 0,...l,ref:t})})});qE.displayName=qk;var qI="CollapsibleTrigger",qP=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=qM(qI,n);return(0,E.jsx)(jB.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":qA(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:jR(e.onClick,a.onOpenToggle)})});qP.displayName=qI;var qO="CollapsibleContent";P.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=qM(qO,e.__scopeCollapsible);return(0,E.jsx)(NE,{present:n||a.open,children:({present:e})=>(0,E.jsx)(qz,{...r,ref:t,present:e})})}).displayName=qO;var qz=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=qM(qO,n),[l,s]=P.useState(r),c=P.useRef(null),d=(0,j_.useComposedRefs)(t,c),u=P.useRef(0),f=u.current,m=P.useRef(0),h=m.current,p=o.open||l,g=P.useRef(p),x=P.useRef(void 0);return P.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),j8(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,m.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),s(r)}},[o.open,r]),(0,E.jsx)(jB.div,{"data-state":qA(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:p&&a})});function qA(e){return e?"open":"closed"}function qT(){return{kind:"human",id:"local",displayName:"我"}}async function qR(e,t){let n=t?`?status=${encodeURIComponent(t)}`:"";return(await qZ(`/api/local/projects/${encodeURIComponent(e)}/issues${n}`)).issues??[]}async function q_(e){return qZ(`/api/local/issues/${encodeURIComponent(e)}`)}async function qD(e,t){return qZ(`/api/local/projects/${encodeURIComponent(e)}/issues`,{method:"POST",body:JSON.stringify(t)})}async function qL(e,t){return qZ(`/api/local/issues/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function q$(e){await qZ(`/api/local/issues/${encodeURIComponent(e)}`,{method:"DELETE"})}async function qF(e,t){return qZ(`/api/local/issues/${encodeURIComponent(e)}/claim`,{method:"POST",body:JSON.stringify({assignee:t})})}async function qB(e,t,n=qT()){return qZ(`/api/local/issues/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify({actor:n,body:t})})}async function qV(e){return(await qZ(`/api/local/issues/${encodeURIComponent(e)}/events`)).events??[]}async function qH(e){return(await qZ(`/api/local/projects/${encodeURIComponent(e)}/links`)).links??[]}async function qU(e,t,n,r){return qZ(`/api/local/projects/${encodeURIComponent(e)}/links`,{method:"POST",body:JSON.stringify({fromIssueId:t,toIssueId:n,kind:r})})}async function qq(e){await qZ(`/api/local/links/${encodeURIComponent(e)}`,{method:"DELETE"})}let qW=new Map,qK=new Map;async function qG(e){let t=Date.now(),n=qW.get(e);if(n&&t-n.at<2500)return n.value;let r=qK.get(e);if(r)return r;let a=(async()=>{try{let t=(await qZ(`/api/local/projects/${encodeURIComponent(e)}/approvals`)).approvals??[];return qW.set(e,{value:t,at:Date.now()}),t}finally{qK.delete(e)}})();return qK.set(e,a),a}async function qX(e,t,n,r){await qZ(`/api/local/agent/conversations/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(null!=r&&""!==r?{decision:n,feedback:r}:{decision:n})})}class qY extends Error{status;constructor(e,t){super(e),this.name="KanbanAPIError",this.status=t}}async function qZ(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new qY("string"==typeof r?.error?r.error:"kanban api failed",n.status);return r}function qJ({activeProjectId:e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onNewProject:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p}){let{projects:g,loading:x,refresh:v}=function(){let[e,t]=P.useState([]),[n,r]=P.useState(!0),a=P.useRef(!0),i=P.useCallback(async()=>{try{let e=await tU();if(!a.current)return;let n=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(n)}catch{}finally{a.current&&r(!1)}},[]);return P.useEffect(()=>{a.current=!0;let e=()=>void i();return window.addEventListener(tH,e),()=>{a.current=!1,window.removeEventListener(tH,e)}},[i]),qn(i,1e4),{projects:e,loading:n,refresh:()=>void i()}}(),b=x&&0===g.length;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,E.jsx)(qc,{icon:qj,label:UF.canvasNew,onClick:()=>c?.()})})}),(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:(0,E.jsx)("div",{className:"space-y-0.5",children:b?(0,E.jsx)(qd,{}):0===g.length?(0,E.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:UF.projectEmpty}):g.map((c,g)=>(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(g+1,12)}ms`},children:(0,E.jsx)(qQ,{project:c,active:c.id===e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:v,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p})},c.id))})})]})}function qQ({project:e,active:t,activeConversationId:n,hideCanvas:r,onOpenProjectCanvas:a,onOpenProjectOverview:i,onOpenProjectKanban:o,onOpenProjectSettings:l,onNewProjectConversation:s,onOpenProjectConversation:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:m,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}){let[x,v]=P.useState(t),[b,y]=P.useState([]),[w,j]=P.useState(0),k=P.useCallback(async()=>{try{let t=await qG(e.id);j(t.length)}catch{}},[e.id]),[N,C]=P.useState(()=>new Set),S=P.useRef(null),M=N.size>0,I=P.useCallback(async()=>{try{let t=await tZ(e.id);y(t)}catch{}},[e.id]);qn(I,1e4,x),qn(k,1e4,x);let O=P.useCallback(async e=>{try{await te(e.id,e.ownerMachineId)}catch{}f?.(e.id),y(t=>t.filter(t=>t.id!==e.id)),m?.()},[f,m]),z=P.useCallback(async e=>{try{await tn(e.id,e.ownerMachineId)}catch{}y(t=>t.filter(t=>t.id!==e.id)),m?.()},[m]),A=P.useCallback(async(e,t)=>{try{let n=await tt(e.id,t,e.ownerMachineId);y(t=>t.map(t=>t.id===e.id?{...t,title:n.conversation.title,titleLocked:n.conversation.titleLocked}:t))}catch{}m?.()},[m]),T=P.useMemo(()=>UX(b),[b]),R=P.useMemo(()=>T.map(e=>e.id),[T]),_=P.useCallback((e,t)=>{C(n=>UY(n,e,t,R,S.current)),S.current=e},[R]),D=P.useCallback(()=>{C(new Set),S.current=null},[]);P.useEffect(()=>{C(e=>{if(0===e.size)return e;let t=new Set(b.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[b]);let L=P.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));await Promise.all(e.map(e=>tn(e.id,e.ownerMachineId).catch(()=>{}))),D(),await I(),m?.()},[b,N,D,I,m]),$=P.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));for(let t of(await Promise.all(e.map(e=>te(e.id,e.ownerMachineId).catch(()=>{}))),e))f?.(t.id);D(),await I(),m?.()},[b,N,D,I,f,m]),F=P.useCallback(async t=>{try{let n=await tN(t.id,void 0,t.ownerMachineId);c?c(e.id,n.conversation.id,n.conversation.ownerMachineId):d(n.conversation.id,n.conversation.ownerMachineId),m?.()}catch{}},[d,c,e.id,m]),V=P.useCallback((t,n)=>{c?c(e.id,t,n):d(t,n)},[c,d,e.id]),H=P.useMemo(()=>(function(e,t){let{childrenOf:n,roots:r}=UG(e),a=new Set((t.activeSubagentPath??[]).map(e=>e.id)),i=t.activeSubagentPath?.[t.activeSubagentPath.length-1]?.id,o=(e,r)=>{let l=e.id!==t.activeConversationId||(t.subagentTree?.length??0)===0?null:(0,E.jsx)(qy,{nodes:t.subagentTree??[],depth:0,ancestors:[],activeIds:a,activeLeafId:i,onOpen:t.onOpenSubagent});return(0,E.jsxs)(P.Fragment,{children:[(0,E.jsx)(qv,{conversation:e,depth:r,active:e.id===t.activeConversationId,onOpenConversation:t.onOpenConversation,onOpenConversationSettings:t.onOpenConversationSettings,onRename:t.onRename,onDelete:t.onDelete,onFork:t.onFork,onArchive:t.onArchive?()=>t.onArchive?.(e):void 0,selectionMode:t.selectionMode,selected:t.selectedIds?.has(e.id),onToggleSelect:t.onToggleSelect?n=>t.onToggleSelect?.(e.id,n):void 0}),l?(0,E.jsx)("div",{style:r>0?{marginLeft:14*r}:void 0,children:l}):null,(n.get(e.id)??[]).map(e=>o(e,r+1))]},e.id)};return r.map((e,t)=>(0,E.jsx)("div",{className:"vtl-stagger-item space-y-0.5",style:{animationDelay:`${25*Math.min(t+3,12)}ms`},children:o(e,0)},e.id))})(b,{activeConversationId:n,onOpenConversation:V,onOpenConversationSettings:u,onRename:A,onDelete:O,onFork:F,onArchive:z,selectionMode:M,selectedIds:N,onToggleSelect:_,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}),[b,n,V,u,A,O,F,z,M,N,_,h,p,g]),U=qr(x);return(0,E.jsxs)(qE,{open:x,onOpenChange:v,children:[(0,E.jsxs)("div",{className:(0,B.cn)("group flex items-center rounded-lg text-[13px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,E.jsx)(qP,{asChild:!0,children:(0,E.jsx)("button",{type:"button","aria-label":x?"收起工程":"展开工程",className:"shrink-0 rounded-md p-1.5 pl-2 text-muted-foreground hover:text-foreground",onClick:e=>e.stopPropagation(),children:(0,E.jsx)(nc,{className:(0,B.cn)("size-4 transition-transform",x?"rotate-0":"-rotate-90")})})}),(0,E.jsxs)("button",{type:"button",title:e.title,onClick:()=>{v(!0),i?.(e.id)},className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg py-2 pr-3 text-left",children:[(0,E.jsx)(_U,{className:"size-4 shrink-0 text-muted-foreground"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),w>0?(0,E.jsx)("span",{title:`${w} 项待审批`,className:"shrink-0 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",children:w}):null,t&&(0,E.jsx)(qu,{active:!0})]})]}),(0,E.jsx)(qo,{open:x,className:"mt-0.5",children:(0,E.jsx)("div",{className:"ml-[1.125rem] border-l border-border/60 pl-1.5",children:(0,E.jsxs)("div",{className:"space-y-0.5",children:[r?null:(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,E.jsx)(q0,{icon:(0,E.jsx)(_U,{className:"size-4"}),label:UF.projectCanvas,onClick:()=>a?.(e.id,e.canvasId)})}),(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"25ms"},children:(0,E.jsx)(q0,{icon:(0,E.jsx)(UH,{className:"size-4"}),label:UF.projectKanban,onClick:()=>o?.(e.id)})}),M?(0,E.jsx)(ql,{count:N.size,archived:!1,onArchive:()=>void L(),onDelete:()=>void $(),onCancel:D}):null,H,(0,E.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:UF.projectNewConversation,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-muted-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:[(0,E.jsx)(eO,{className:"size-4 shrink-0"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:UF.projectNewConversation})]})]},U)})})]})}function q0({icon:e,label:t,onClick:n}){return(0,E.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[e,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function q1({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,E.jsx)(Am,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,E.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,E.jsx)(q5,{activeWorkspace:t,onItemSelect:n},e.id):(0,E.jsx)(q2,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function q2({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,E.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,B.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,E.jsx)(qu,{active:!0})]})}function q5({activeWorkspace:e,onItemSelect:t}){return(0,E.jsx)(E.Fragment,{children:UJ.map((n,r)=>(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(r,12)}ms`},children:(0,E.jsx)(q3,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t})},n.id))})}function q3({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=P.useState(!0),s=qr(o);return(0,E.jsxs)(qE,{open:o,onOpenChange:l,children:[(0,E.jsx)(qP,{asChild:!0,children:(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,E.jsx)(nc,{className:(0,B.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,E.jsx)(qo,{open:o,className:"mt-0.5",children:(0,E.jsx)("div",{className:"space-y-0.5",children:n.map((e,t)=>{let n=e.id===r;return(0,E.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),style:{animationDelay:`${25*Math.min(t,12)}ms`},className:(0,B.cn)("vtl-stagger-item flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",n?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n&&(0,E.jsx)(qu,{active:!0})]},e.id)})},s)})]})}function q4({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v,hideCanvas:b,className:y}){let w=UZ[n]??(UJ.some(e=>e.items.some(e=>e.id===n))?"settings":b?"agent":"canvas"),[j,k]=P.useState(w);P.useEffect(()=>{k(w)},[w]);let N=t.find(e=>e.id===j),C=P.useRef(null),S=P.useRef(new Map),[M,I]=P.useState(null),[O,z]=P.useState(!1),A=P.useCallback(()=>{let e=C.current,t=S.current.get(j);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();I({left:r.left-n.left,top:r.top-n.top,width:r.width,height:r.height})},[j]);return P.useEffect(()=>{A();let e=window.requestAnimationFrame(()=>z(!0)),t=C.current,n=null;return t&&"u">typeof ResizeObserver&&(n=new ResizeObserver(A)).observe(t),window.addEventListener("resize",A),()=>{window.cancelAnimationFrame(e),n?.disconnect(),window.removeEventListener("resize",A)}},[A]),(0,E.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,B.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",y),children:[(0,E.jsxs)("nav",{ref:C,className:"relative mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:[M?(0,E.jsx)("span",{"aria-hidden":!0,className:(0,B.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md border border-border/50 bg-background shadow-sm",O&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${M.left}px, ${M.top}px)`,width:M.width,height:M.height}}):null,e.map(e=>{let t=e.id===j;return(0,E.jsxs)("button",{ref:t=>{t?S.current.set(e.id,t):S.current.delete(e.id)},type:"button",onClick:()=>k(e.id),className:(0,B.cn)("relative z-10 flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"text-foreground":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,E.jsx)("span",{className:"truncate",children:e.label})]},e.id)})]}),"canvas"===j?(0,E.jsx)(qJ,{activeProjectId:a,activeConversationId:r,hideCanvas:b,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v}):"agent"===j?(0,E.jsx)(qw,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v}):(0,E.jsx)(q1,{content:N,activeWorkspace:n,onItemSelect:i}),(0,E.jsx)(U3,{})]})}let q6=(0,z.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var q8=e.i(78737);function q7({className:e,orientation:t="horizontal",...n}){return(0,E.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,B.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}let q9=(0,nb.cva)("group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted",{variants:{variant:{default:"border-transparent",outline:"border-border",muted:"border-transparent bg-muted/50"},size:{default:"gap-2.5 px-3 py-2.5",sm:"gap-2.5 px-3 py-2.5",xs:"gap-2 px-2.5 py-2"}},defaultVariants:{variant:"default",size:"default"}});function We({className:e,variant:t="default",size:n="default",asChild:r=!1,...a}){let i=r?AQ.Slot:"div";return(0,E.jsx)(i,{"data-slot":"item","data-variant":t,"data-size":n,className:(0,B.cn)(q9({variant:t,size:n,className:e})),...a})}let Wt=(0,nb.cva)("flex shrink-0 items-center justify-center gap-2 [&_svg]:pointer-events-none",{variants:{variant:{default:"bg-transparent",icon:"[&_svg:not([class*='size-'])]:size-4",marker:"size-8 rounded-md border bg-background ui-text-kbd font-medium text-muted-foreground [&_svg:not([class*='size-'])]:size-4",image:"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover"},align:{auto:"group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start",start:"translate-y-0.5 self-start",center:"self-center"}},defaultVariants:{variant:"default",align:"auto"}});function Wn({className:e,variant:t="default",align:n="auto",...r}){return(0,E.jsx)("div",{"data-slot":"item-media","data-variant":t,"data-align":n,className:(0,B.cn)(Wt({variant:t,align:n,className:e})),...r})}function Wr({className:e,align:t,...n}){return(0,E.jsx)("div",{"data-slot":"item-content","data-align":t,className:(0,B.cn)("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none","start"===t&&"self-start","center"===t&&"self-center",e),...n})}function Wa({className:e,...t}){return(0,E.jsx)("div",{"data-slot":"item-title",className:(0,B.cn)("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",e),...t})}function Wi({className:e,...t}){return(0,E.jsx)("p",{"data-slot":"item-description",className:(0,B.cn)("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function Wo({className:e,...t}){return(0,E.jsx)("div",{"data-slot":"item-actions",className:(0,B.cn)("flex items-center gap-2",e),...t})}let Wl={back:"Back",search:"Search settings...",welcomeTitle:"Settings",welcomeDescription:"Search or choose a setting to continue.",recommendations:"Recommended",noResults:"No settings found."},Ws=P.createContext(null);function Wc({value:e,children:t}){return(0,E.jsx)(Ws.Provider,{value:e,children:t})}function Wd(e){return"string"==typeof e||"number"==typeof e?String(e):""}function Wu({sections:e,recommendations:t,sectionId:n,defaultSectionId:r,childId:a,defaultChildId:i,onSelectionChange:o,labels:l,welcomeContent:s,className:c,sidebarClassName:d,contentClassName:u}){let f={...Wl,...l},m=zF(),h=P.useContext(Ws),[p,g]=P.useState(r),[x,v]=P.useState(i),[b,y]=P.useState("list"),w=n??p,j=a??x,k=e.find(e=>e.id===w),N=k?.children?.find(e=>e.id===j),C=!!k?.children?.length,S=m&&"detail"===b,M=P.useMemo(()=>e.flatMap(e=>[{value:e.id,label:e.title,description:e.description,icon:e.icon,searchValue:[Wd(e.title),Wd(e.description),...e.keywords??[]].join(" "),keywords:e.keywords},...(e.children??[]).map(t=>({value:`${e.id}/${t.id}`,label:t.title,description:e.title,icon:t.icon??e.icon,disabled:t.disabled,searchValue:[Wd(t.title),Wd(t.description),Wd(e.title),...t.keywords??[]].join(" "),keywords:[Wd(e.title),...t.keywords??[]]}))]),[e]),I=t??e.flatMap(e=>(e.children??[]).slice(0,2).map(t=>({id:`${e.id}-${t.id}`,title:t.title,description:e.title,icon:t.icon,sectionId:e.id,childId:t.id})));function O(t,r){let i=e.find(e=>e.id===t),l=void 0!==r,s=!!i?.children?.length;void 0===t?y("list"):l||!s?y("detail"):y("list");let c=i?.children?.[0];void 0!==t&&!l&&c&&(r=c.id),void 0===n&&g(t),void 0===a&&v(r),o?.({sectionId:t,childId:r})}let z=N?.content??k?.content??s??(0,E.jsxs)("div",{className:"mx-auto flex min-h-[22rem] w-full max-w-2xl flex-col justify-center gap-5 py-12",children:[(0,E.jsxs)("div",{className:"space-y-2",children:[(0,E.jsx)("h3",{className:"text-xl font-semibold tracking-normal",children:f.welcomeTitle}),(0,E.jsx)("p",{className:"max-w-xl text-sm text-muted-foreground",children:f.welcomeDescription})]}),(0,E.jsx)(Wm,{labels:f,options:M,onSelect:(e,t)=>O(e,t)}),I.length>0&&(0,E.jsxs)("section",{className:"space-y-2",children:[(0,E.jsx)("div",{className:"ui-text-kbd font-medium text-muted-foreground",children:f.recommendations}),(0,E.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:I.map(e=>(0,E.jsx)(We,{asChild:!0,variant:"outline",size:"xs",className:"min-h-14 flex-nowrap bg-card text-left hover:bg-muted/60",children:(0,E.jsxs)("button",{type:"button",onClick:()=>O(e.sectionId,e.childId),children:[e.icon&&(0,E.jsx)(Wn,{variant:"marker",align:"center",children:e.icon}),(0,E.jsxs)(Wr,{className:"min-w-0 gap-0.5",children:[(0,E.jsx)(Wa,{className:"max-w-full truncate",children:e.title}),e.description&&(0,E.jsx)(Wi,{className:"line-clamp-1",children:e.description})]}),(0,E.jsx)(Wo,{className:"ml-auto",children:(0,E.jsx)(MC,{className:"size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/item:opacity-100"})})]})},e.id))})]})]});return(0,E.jsxs)("div",{"data-slot":"settings-menu-panel",className:(0,B.cn)("vtl-surface-panel grid min-h-[34rem] overflow-hidden rounded-[var(--surface-panel-radius)] border md:grid-cols-[15rem_minmax(0,1fr)]",c),children:[m&&S?null:(0,E.jsx)("aside",{"data-slot":"settings-menu-sidebar",className:(0,B.cn)("min-h-0 border-b bg-muted/20 md:border-r md:border-b-0",d),children:(0,E.jsx)(Am,{className:"h-full",children:(0,E.jsx)("div",{className:"space-y-1 p-2",children:C?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left",onClick:()=>O(void 0,void 0),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}),(k?.children??[]).map(e=>(0,E.jsx)(Wf,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===j,disabled:e.disabled,onClick:()=>O(k?.id,e.id)},e.id))]}):(0,E.jsxs)(E.Fragment,{children:[m&&h?(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>h(),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,e.map(e=>(0,E.jsx)(Wf,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===w,disabled:e.disabled,onClick:()=>O(e.id,void 0)},e.id))]})})})}),!m||S?(0,E.jsxs)("main",{"data-slot":"settings-menu-content",className:(0,B.cn)("min-w-0 bg-[var(--surface-panel)] p-4 md:p-5 animate-in fade-in-0 slide-in-from-right-1 duration-150",u),children:[S?(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-3 h-auto min-h-9 justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>y("list"),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,k?(0,E.jsx)("div",{className:"mb-4 flex min-h-8 items-center justify-between gap-4",children:(0,E.jsxs)("div",{className:"min-w-0",children:[(0,E.jsx)("h2",{className:"truncate text-lg font-semibold tracking-normal",children:N?.title??k.title}),(N?.description??k.description)&&(0,E.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:N?.description??k.description})]})}):null,z]},`${w??""}/${j??""}`):null]})}function Wf({title:e,icon:t,badge:n,active:r,disabled:a,onClick:i}){return(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",disabled:a,onClick:i,className:(0,B.cn)("h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left font-medium",r?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),children:[t&&(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:t}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e}),n&&(0,E.jsx)(nw,{variant:"outline",className:"h-5 shrink-0 px-1.5 ui-text-kbd",children:n}),(0,E.jsx)(MC,{className:"size-3.5 shrink-0 text-muted-foreground/60"})]})}function Wm({labels:e,options:t,onSelect:n}){return(0,E.jsx)(Oa,{options:t,placeholder:e.search,emptyText:e.noResults,className:"w-full",contentClassName:"rounded-lg",onValueChange:e=>{let[t,r]=e.split("/");t&&n(t,r)},renderOption:e=>(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",children:e.icon??(0,E.jsx)(IX,{})}),(0,E.jsxs)("span",{className:"grid min-w-0 flex-1 gap-0.5",children:[(0,E.jsx)("span",{className:"truncate",children:e.label}),e.description&&(0,E.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:e.description})]})]})})}function Wh({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,title:y,trailing:w,children:j}){let[k,N]=P.useState(!1),C=P.useCallback(()=>N(!1),[]),S=P.useCallback(e=>{C(),i(e)},[C,i]),M=P.useCallback((e,t)=>{C(),o(e,t)},[C,o]),I=P.useCallback(e=>{C(),b?.(e)},[C,b]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Wp,{onMenuClick:()=>N(!0),title:y,trailing:w}),(0,E.jsx)(zR,{open:k,onOpenChange:N,direction:"left",children:(0,E.jsxs)(zD,{className:"w-[85vw] max-w-xs",children:[(0,E.jsx)(z$,{className:"sr-only",children:"导航"}),(0,E.jsx)(q4,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:S,onOpenConversation:M,onOpenCanvas:()=>{},onOpenProjectCanvas:(e,t)=>{C(),l?.(e,t)},onOpenProjectOverview:e=>{C(),s?.(e)},onOpenProjectKanban:e=>{C(),c?.(e)},onOpenProjectSettings:e=>{C(),d?.(e)},onNewProjectConversation:e=>{C(),u?.(e)},onOpenProjectConversation:(e,t,n)=>{C(),f?.(e,t,n)},onNewProject:()=>{C(),m?.()},onOpenConversationSettings:(e,t)=>{C(),h?.(e,t)},onConversationDeleted:p,onAccountSettings:()=>{C(),g?.()},subagentTree:x,activeSubagentPath:v,onOpenSubagent:I,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})}),(0,E.jsx)(Wc,{value:()=>N(!0),children:j})]})}function Wp({onMenuClick:e,title:t,trailing:n,className:r}){return(0,E.jsxs)("header",{className:(0,B.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,E.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,E.jsx)(q6,{})}),t?(0,E.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,E.jsx)("div",{className:"min-w-0 flex-1"}),(0,E.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let Wg=(0,z.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),Wx=[{id:"canvas",label:UF.canvas,icon:(0,E.jsx)(_U,{})},{id:"agent",label:"智能体",icon:(0,E.jsx)(CB,{})},{id:"settings",label:UF.settings,icon:(0,E.jsx)(UK,{})}],Wv=[{id:"canvas",title:UF.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:UF.canvas,items:[{id:"open-recent-canvas",label:UF.canvasRecent,icon:(0,E.jsx)(_U,{})},{id:"new-canvas",label:UF.canvasNew,icon:(0,E.jsx)(eO,{})},{id:"all-canvases",label:UF.canvasAll,icon:(0,E.jsx)(_W,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:UF.conversationRecent,icon:(0,E.jsx)(Wg,{})},{id:"new-agent-conversation",label:UF.conversationNew,icon:(0,E.jsx)(CB,{})}]}]},{id:"settings",title:UF.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,E.jsx)(UK,{})}]}]}],Wb=["light","dark","jelly"],Wy={light:{label:"Light",icon:U2,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:U1,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,E.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,E.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,E.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,E.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,E.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,E.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function Ww(){let{resolvedTheme:e,setTheme:t}=(0,T1.useTheme)(),[n,r]=P.useState(U5.defaultAppearanceTheme);P.useEffect(()=>{let e=window.localStorage.getItem(U5.appearanceThemeStorageKey)??U5.defaultAppearanceTheme;r(e),(0,U5.applyAppearanceTheme)({theme:e})},[]);let a=n===U5.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=Wb.indexOf(a),o=Wb[(i+1)%Wb.length]??"light",{icon:l,label:s,className:c}=Wy[a];function d(e){r(e),window.localStorage.setItem(U5.appearanceThemeStorageKey,e),(0,U5.applyAppearanceTheme)({theme:e})}return(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,B.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${U$.theme}: ${s}`,title:`${U$.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(U5.jellyAppearanceTheme);return}d(U5.defaultAppearanceTheme),t(o)},children:(0,E.jsx)(l,{})})}function Wj(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function Wk(e){return"u"<typeof document?null:document.querySelector(e)}function WN(){return null!=Wk('[role="menu"]')}function WC(){return null!=Wk('[data-tour="init-wizard"]')}function WS(){let e=Wk('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}var WM=e.i(64990);let WE=(0,z.default)("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]),WI=(0,z.default)("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),WP=(0,z.default)("panel-right-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]),WO=(0,z.default)("rectangle-horizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]),Wz=(0,z.default)("shredder",[["path",{d:"M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1eob4r"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 22v-5",key:"sfixh4"}],["path",{d:"M14 19v-2",key:"pdve8j"}],["path",{d:"M18 20v-3",key:"uox2gk"}],["path",{d:"M2 13h20",key:"5evz65"}],["path",{d:"M6 20v-3",key:"c6pdcb"}]]);async function WA(){return W$("/api/local/terminals/machines")}async function WT(e){let t=new URLSearchParams;e&&t.set("scopeId",e);let n=t.toString();return W$(`/api/local/terminals/sessions${n?`?${n}`:""}`)}async function WR(e){return W$("/api/local/terminals/sessions",{method:"POST",body:JSON.stringify(e)})}async function W_(e){await W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}async function WD(e,t){await W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}/input`,{method:"POST",body:JSON.stringify({data:t})})}async function WL(e,t){return W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}/resize`,{method:"POST",body:JSON.stringify(t)})}async function W$(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"terminal api failed");return r}let WF=(0,z.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);function WB({groupSize:e,panelElement:t,styleProp:n}){let r,[a,i]=function(e){switch(typeof e){case"number":return[e,"px"];case"string":{let t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}(n);switch(i){case"%":r=a/100*e;break;case"px":r=a;break;case"rem":r=a*parseFloat(getComputedStyle(t.ownerDocument.body).fontSize);break;case"em":r=a*parseFloat(getComputedStyle(t).fontSize);break;case"vh":r=a/100*window.innerHeight;break;case"vw":r=a/100*window.innerWidth}return r}function WV(e){return parseFloat(e.toFixed(3))}function WH({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>e+="horizontal"===t?n.element.offsetWidth:n.element.offsetHeight,0)}function WU(e){let{panels:t}=e,n=WH({group:e});return 0===n?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:!0===e.panelConstraints.collapsible,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let t,{element:r,panelConstraints:a}=e,i=0;void 0!==a.collapsedSize&&(i=WV(WB({groupSize:n,panelElement:r,styleProp:a.collapsedSize})/n*100)),void 0!==a.defaultSize&&(t=WV(WB({groupSize:n,panelElement:r,styleProp:a.defaultSize})/n*100));let o=0;void 0!==a.minSize&&(o=WV(WB({groupSize:n,panelElement:r,styleProp:a.minSize})/n*100));let l=100;return void 0!==a.maxSize&&(l=WV(WB({groupSize:n,panelElement:r,styleProp:a.maxSize})/n*100)),{groupResizeBehavior:a.groupResizeBehavior,collapsedSize:i,collapsible:!0===a.collapsible,defaultSize:t,disabled:a.disabled,minSize:o,maxSize:l,panelId:e.id}})}function Wq(e,t="Assertion error"){if(!e)throw Error(t)}function WW(e,t){return Array.from(t).sort("horizontal"===e?WK:WG)}function WK(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return 0!==n?n:e.element.offsetWidth-t.element.offsetWidth}function WG(e,t){let n=e.element.offsetTop-t.element.offsetTop;return 0!==n?n:e.element.offsetHeight-t.element.offsetHeight}function WX(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function WY(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function WZ(e){let{element:t,orientation:n,panels:r,separators:i}=e,o=WW(n,Array.from(t.children).filter(WX).map(e=>({element:e}))).map(({element:e})=>e),l=[],s=!1,c=!1,d=-1,u=-1,f=0,m,h=[];{let e=-1;for(let t of o)t.hasAttribute("data-panel")&&(e++,t.hasAttribute("data-disabled")||(f++,-1===d&&(d=e),u=e))}if(f>1){let t=-1;for(let f of o)if(f.hasAttribute("data-panel")){t++;let i=r.find(e=>e.element===f);if(i){if(m){let r,o=m.element.getBoundingClientRect(),p=f.getBoundingClientRect();if(c){let e="horizontal"===n?new DOMRect(o.right,o.top,0,o.height):new DOMRect(o.left,o.bottom,o.width,0),t="horizontal"===n?new DOMRect(p.left,p.top,0,p.height):new DOMRect(p.left,p.top,p.width,0);switch(h.length){case 0:r=[e,t];break;case 1:{let a=h[0],i=function({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},a,i=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=WY(r,n),l="horizontal"===e?t:o;l<i&&(i=l,a=n)}return Wq(a,"No rect found"),a}({orientation:n,rects:[o,p],targetRect:a.element.getBoundingClientRect()});r=[a,i===o?t:e];break}default:r=h}}else r=h.length?h:["horizontal"===n?new DOMRect(o.right,p.top,p.left-o.right,p.height):new DOMRect(p.left,o.bottom,p.width,p.top-o.bottom)];for(let n of r){let r="width"in n?n:n.element.getBoundingClientRect(),o=(void 0===a&&(a="function"==typeof matchMedia&&!!matchMedia("(pointer:coarse)").matches),a)?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<o){let e=o-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<o){let e=o-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}let c=t<=d||t>u;s||c||l.push({group:e,groupSize:WH({group:e}),panels:[m,i],separator:"width"in n?void 0:n,rect:r}),s=!1}}c=!1,m=i,h=[]}}else if(f.hasAttribute("data-separator")){null!==f.ariaDisabled&&(s=!0);let e=i.find(e=>e.element===f);e?h.push(e):(m=void 0,h=[])}else c=!0}return l}class WJ{#t={};addListener(e,t){let n=this.#t[e];return void 0===n?this.#t[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#t[e];if(void 0!==n)if(1===n.length)n[0].call(null,t);else{let e=!1,r=null,a=Array.from(n);for(let n=0;n<a.length;n++){let i=a[n];try{i.call(null,t)}catch(t){null===r&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#t={}}removeListener(e,t){let n=this.#t[e];if(void 0!==n){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}}let WQ=new Map,W0=new WJ;function W1(e,t){for(let[t]of WQ)if(t.id===e)return t}function W2(e,t){for(let[t,n]of WQ)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function W5(e,t){return W0.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function W3(e,t){let n=WQ.get(e);(WQ=new Map(WQ)).set(e,t),W0.emit("groupChange",{group:e,prev:n,next:t})}let W4=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function W6(e){let t=e.length;for(;t--;){let n=e[t];if(Wq(n,"Missing node"),function(e){let t,n=getComputedStyle(e);return!!("fixed"===n.position||"auto"!==n.zIndex&&("static"!==n.position||"flex"===(t=getComputedStyle(W9(e)??e).display)||"inline-flex"===t)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||W4.test(n.willChange)||"touch"===n.webkitOverflowScrolling)}(n))return n}return null}function W8(e){return e&&Number(getComputedStyle(e).zIndex)||0}function W7(e){let t=[];for(;e;)t.push(e),e=W9(e);return t}function W9(e){let{parentNode:t}=e;return null!==t&&"object"==typeof t&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t}function Ke(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let a=WZ(r),i=function(e,t,n){let r,a={x:1/0,y:1/0};for(let i of t){let t=WY(n,i.rect);switch(e){case"horizontal":t.x<=a.x&&(r=i,a=t);break;case"vertical":t.y<=a.y&&(r=i,a=t)}}return r?{distance:a,hitRegion:r}:void 0}(r.orientation,a,{x:e.clientX,y:e.clientY});i&&i.distance.x<=0&&i.distance.y<=0&&function({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!WX(n)||n.contains(e)||e.contains(n))return!0;if(function(e,t){let n;if(e===t)throw Error("Cannot compare node with itself");let r={a:W7(e),b:W7(t)};for(;r.a.at(-1)===r.b.at(-1);)n=r.a.pop(),r.b.pop();Wq(n,"Stacking order can only be calculated for elements with a common ancestor");let a={a:W8(W6(r.a)),b:W8(W6(r.b))};if(a.a===a.b){let e=n.childNodes,t={a:r.a.at(-1),b:r.b.at(-1)},a=e.length;for(;a--;){let n=e[a];if(n===t.a)return 1;if(n===t.b)return -1}}return Math.sign(a.a-a.b)}(n,e)>0){let a=n;for(;a;){var r;if(a.contains(e))break;if(r=a.getBoundingClientRect(),r.x<t.x+t.width&&r.x+r.width>t.x&&r.y<t.y+t.height&&r.y+r.height>t.y)return!1;a=a.parentElement}}return!0}({groupElement:r.element,hitRegion:i.hitRegion.rect,pointerEventTarget:e.target})&&n.push(i.hitRegion)}),n}function Kt(e,t,n=0){return Math.abs(WV(e)-WV(t))<=n}function Kn(e,t){return Kt(e,t)?0:e>t?1:-1}function Kr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:a=0,collapsible:i,disabled:o,maxSize:l=100,minSize:s=0}=t;return o&&!e?n:(0>Kn(r,s)&&(r=i&&0>Kn(r,(a+s)/2)?a:s),WV(r=Math.min(l,r)))}function Ka({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:i}){if(Kt(e,0))return t;let o="imperative-api"===i,l=Object.values(t),s=Object.values(a),c=[...l],[d,u]=r;Wq(null!=d,"Invalid first pivot index"),Wq(null!=u,"Invalid second pivot index");let f=0;if("keyboard"===i){{let t=e<0?u:d,r=n[t];Wq(r,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(Wq(null!=n,`Previous layout not found for panel index ${t}`),Kt(n,a)){let t=o-n;Kn(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?d:u,r=n[t];Wq(r,`No panel constraints found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(Wq(null!=n,`Previous layout not found for panel index ${t}`),Kt(n,o)){let t=n-a;Kn(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}else{let t=e<0?u:d,r=n[t];Wq(r,`Panel constraints not found for index ${t}`);let a=l[t],{collapsible:i,collapsedSize:o,minSize:s}=r;if(i&&0>Kn(a,s))if(e>0){let t=s-o;0>Kn(a+e,s)&&(e=0>=Kn(e,t/2)?0:t)}else{let t=s-o;0>Kn(a-e,s)&&(e=Kn(100+e,100-t/2)>0?0:-t)}}{let t=e<0?1:-1,r=e<0?u:d,a=0;for(;;){let e=l[r];if(Wq(null!=e,`Previous layout not found for panel index ${r}`),a+=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e,(r+=t)<0||r>=n.length)break}let i=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-i:i}{let t=e<0?d:u;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),a=l[t];Wq(null!=a,`Previous layout not found for panel index ${t}`);let i=a-r,s=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:a,size:i});if(!Kt(a,s)&&(f+=a-s,c[t]=s,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}(s,c))return a;{let t=e<0?u:d,r=l[t];Wq(null!=r,`Previous layout not found for panel index ${t}`);let a=r+f,i=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:a});if(c[t]=i,!Kt(i,a)){let t=a-i,r=e<0?u:d;for(;r>=0&&r<n.length;){let a=c[r];Wq(null!=a,`Previous layout not found for panel index ${r}`);let i=a+t,l=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:a,size:i});if(Kt(a,l)||(t-=l-a,c[r]=l),Kt(t,0))break;e>0?r--:r++}}}if(!Kt(Object.values(c).reduce((e,t)=>t+e,0),100,.1))return a;let m=Object.keys(a);return c.reduce((e,t,n)=>(e[m[n]]=t,e),{})}function Ki(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(void 0===t[n]||0!==Kn(e[n],t[n]))return!1;return!0}function Ko({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],a=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(", ")}`);if(!Kt(a,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Wq(null!=t,`No layout data found for index ${e}`);let n=100/a*t;r[e]=n}let i=0;for(let e=0;e<t.length;e++){let a=n[e];Wq(null!=a,`No layout data found for index ${e}`);let o=r[e];Wq(null!=o,`No layout data found for index ${e}`);let l=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:a,size:o});o!=l&&(i+=o-l,r[e]=l)}if(!Kt(i,0))for(let e=0;e<t.length;e++){let n=r[e];Wq(null!=n,`No layout data found for index ${e}`);let a=n+i,o=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:a});if(n!==o&&(i-=o-n,r[e]=o,Kt(i,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Kl({groupId:e,panelId:t}){let n=()=>{for(let[t,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:a,groupSize:i,separatorToPanels:o}]of WQ)if(t.id===e)return{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:t,groupSize:i,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(void 0!==e)return e;throw Error(`Panel constraints not found for Panel ${t}`)},a=()=>{let e=n().group.panels.find(e=>e.id===t);if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},i=()=>{let e=n().layout[t];if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{if(e===i())return;let{defaultLayoutDeferred:r,derivedPanelConstraints:a,group:o,groupSize:l,layout:s,separatorToPanels:c}=n(),d=Ko({layout:(({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:a})=>{let o=i(),l=n.findIndex(e=>e.id===t),s=0===l,c=l===n.length-1;if(c&&e<o&&(s||n.slice(0,l).every((e,t)=>{let n=a[t];return n?.collapsible&&Kt(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,l).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:WV(100-e)}}return Ka({delta:c?o-e:e-o,initialLayout:r,panelConstraints:a,pivotIndices:c?[l-1,l]:[l,l+1],prevLayout:r,trigger:"imperative-api"})})({nextSize:e,panels:o.panels,prevLayout:s,derivedPanelConstraints:a}),panelConstraints:a});Ki(s,d)||W3(o,{defaultLayoutDeferred:r,derivedPanelConstraints:a,groupSize:l,layout:d,separatorToPanels:c})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=a(),l=i();e&&l!==t&&(n.expandToSize=l,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:l}=a(),s=i();if(e&&s===t){let e=l.expandToSize??n;0===e&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=i(),{element:r}=a();return{asPercentage:t,inPixels:"horizontal"===e.orientation?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=i();return e&&Kt(t,n)},resize:e=>{let{group:t}=n(),{element:r}=a(),i=WH({group:t});o(WV(WB({groupSize:i,panelElement:r,styleProp:e})/i*100))}}}function Ks(e){e.defaultPrevented||Ke(e,WQ).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>void 0!==e.panelConstraints.defaultSize);if(n){let r=n.panelConstraints.defaultSize,a=Kl({groupId:t.group.id,panelId:n.id});a&&void 0!==r&&(a.resize(r),e.preventDefault())}}})}function Kc(e){for(let[t]of WQ)if(t.separators.some(t=>t.element===e))return t;throw Error("Could not find parent Group for separator element")}function Kd({groupId:e}){let t=()=>{for(let[t,n]of WQ)if(t.id===e)return{group:t,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:a,groupSize:i,layout:o,separatorToPanels:l}=t(),s=Ko({layout:e,panelConstraints:r});return n?o:(Ki(o,s)||W3(a,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:i,layout:s,separatorToPanels:l}),s)}}}function Ku(e,t){let n=Kc(e),r=W2(n.id,!0),a=n.separators.find(t=>t.element===e);Wq(a,"Matching separator not found");let i=r.separatorToPanels.get(a);Wq(i,"Matching panels not found");let o=i.map(e=>n.panels.indexOf(e)),l=Kd({groupId:n.id}).getLayout(),s=Ko({layout:Ka({delta:t,initialLayout:l,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:l,trigger:"keyboard"}),panelConstraints:r.derivedPanelConstraints});Ki(l,s)||W3(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:s,separatorToPanels:r.separatorToPanels})}function Kf(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Kc(t);if(!n.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),"vertical"===n.orientation&&Ku(t,5);break;case"ArrowLeft":e.preventDefault(),"horizontal"===n.orientation&&Ku(t,-5);break;case"ArrowRight":e.preventDefault(),"horizontal"===n.orientation&&Ku(t,5);break;case"ArrowUp":e.preventDefault(),"vertical"===n.orientation&&Ku(t,-5);break;case"End":e.preventDefault(),Ku(t,100);break;case"Enter":{e.preventDefault();let n=Kc(t),{derivedPanelConstraints:r,layout:a,separatorToPanels:i}=W2(n.id,!0),o=n.separators.find(e=>e.element===t);Wq(o,"Matching separator not found");let l=i.get(o);Wq(l,"Matching panels not found");let s=l[0],c=r.find(e=>e.panelId===s.id);if(Wq(c,"Panel metadata not found"),c.collapsible){let e=a[s.id];Ku(t,(c.collapsedSize===e?n.mutableState.expandedPanelSizes[s.id]??c.minSize:c.collapsedSize)-e)}break}case"F6":{e.preventDefault();let n=Kc(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Wq(null!==r,"Index not found");let a=e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0;n[a].focus({preventScroll:!0});break}case"Home":e.preventDefault(),Ku(t,-100)}}let Km={cursorFlags:0,state:"inactive"},Kh=new WJ;function Kp(e){let t=Km;Km=e,Kh.emit("change",{prev:t,next:e})}function Kg(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=WQ,n=Ke(e,t),r=new Map,a=!1;n.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Kp({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}let Kx=e=>e,Kv=()=>{};function Kb(){return void 0===i&&(i=!1,"u">typeof window&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(i=!0)),i}let Ky=new WeakMap;function Kw(e){if(null===e.defaultView||void 0===e.defaultView)return;let{prevStyle:t,styleSheet:n}=Ky.get(e)??{};void 0===n&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=Km;switch(r.state){case"active":case"hover":{let e=function({cursorFlags:e,groups:t,state:n}){let r=0,a=0;switch(n){case"active":case"hover":t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case"horizontal":r++;break;case"vertical":a++}})}if(0!==r||0!==a){if("active"===n&&e&&Kb()){let t=(4&e)!=0,n=(8&e)!=0;if((1&e)!=0)return t?"se-resize":n?"ne-resize":"e-resize";if((2&e)!=0)return t?"sw-resize":n?"nw-resize":"w-resize";if(t)return"s-resize";if(n)return"n-resize"}return Kb()?r>0&&a>0?"move":r>0?"ew-resize":"ns-resize":r>0&&a>0?"grab":r>0?"col-resize":"row-resize"}}({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?0===n.cssRules.length?n.insertRule(a):n.replaceSync(a):1===n.cssRules.length&&n.deleteRule(0);break}case"inactive":t=void 0,1===n.cssRules.length&&n.deleteRule(0)}Ky.set(e,{prevStyle:t,styleSheet:n})}function Kj({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:a,pointerDownAtPoint:i,prevCursorFlags:o}){var l;let s,c,d=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:l,panels:s}=n,{disableCursor:c}=n.mutableState,u=0;u=i?"horizontal"===l?(t.clientX-i.x)/o*100:(t.clientY-i.y)/o*100:"horizontal"===l?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),m=a.get(n);if(!f||!m)return;let{defaultLayoutDeferred:h,derivedPanelConstraints:p,groupSize:g,layout:x,separatorToPanels:v}=m;if(p&&x&&v){let t=Ka({delta:u,initialLayout:f,panelConstraints:p,pivotIndices:e.panels.map(e=>s.indexOf(e)),prevLayout:x,trigger:"mouse-or-touch"});if(Ki(t,x)){if(0!==u&&!c)switch(l){case"horizontal":d|=u<0?1:2;break;case"vertical":d|=u<0?4:8}}else W3(e.group,{defaultLayoutDeferred:h,derivedPanelConstraints:p,groupSize:g,layout:t,separatorToPanels:v})}});let u=0;0===t.movementX?u|=3&o:u|=3&d,0===t.movementY?u|=12&o:u|=12&d,l=u,s=Km,(c={...Km}).cursorFlags=l,Km=c,Kh.emit("change",{prev:s,next:c}),Kw(e)}function Kk(e){let t=WQ,n=Km;"active"===n.state&&Kj({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}function KN(e){if(e.defaultPrevented)return;let t=Km,n=WQ;if("active"===t.state){if(0===e.buttons){Kp({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(e=>{let t=W2(e.group.id,!0);W3(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}Kj({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags})}else{let r=Ke(e,n);0===r.length?"inactive"!==t.state&&Kp({cursorFlags:0,state:"inactive"}):Kp({cursorFlags:0,hitRegions:r,state:"hover"}),Kw(e.currentTarget)}}function KC(e){e.relatedTarget instanceof HTMLIFrameElement&&"hover"===Km.state&&Kp({cursorFlags:0,state:"inactive"})}function KS(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=Km;"active"===t.state&&(Kp({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Kw(e.currentTarget),t.hitRegions.forEach(e=>{let t=W2(e.group.id,!0);W3(e.group,t)}),e.preventDefault()))}function KM(e){let t=0,n=0,r={};for(let a of e)if(void 0!==a.defaultSize){t++;let e=WV(a.defaultSize);n+=e,r[a.panelId]=e}else r[a.panelId]=void 0;let a=e.length-t;if(0!==a){let t=WV((100-n)/a);for(let n of e)void 0===n.defaultSize&&(r[n.panelId]=t)}return r}let KE=new Map;function KI(e){let t=(0,P.useId)();return`${e??t}`}let KP="u">typeof window?P.useLayoutEffect:P.useEffect;function KO(e){let t=(0,P.useRef)(e);return KP(()=>{t.current=e},[e]),(0,P.useCallback)((...e)=>t.current?.(...e),[t])}function Kz(...e){return KO(t=>{e.forEach(e=>{if(e)switch(typeof e){case"function":e(t);break;case"object":e.current=t}})})}function KA(e){let t=(0,P.useRef)({...e});return KP(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}let KT=(0,P.createContext)(null);function KR({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:a,elementRef:i,groupRef:o,id:l,onLayoutChange:s,onLayoutChanged:c,orientation:d="horizontal",resizeTargetMinimumSize:u={coarse:20,fine:10},style:f,...m}){let h,p=(0,P.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=KO(e=>{Ki(p.current.onLayoutChange,e)||(p.current.onLayoutChange=e,s?.(e))}),x=KO(e=>{Ki(p.current.onLayoutChanged,e)||(p.current.onLayoutChanged=e,c?.(e))}),v=KI(l),b=(0,P.useRef)(null),[y,w]=function(){let[e,t]=(0,P.useState)({});return[e,(0,P.useCallback)(()=>t({}),[])]}(),j=(0,P.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:u,separators:[]}),k=Kz(b,i);h=(0,P.useRef)({getLayout:()=>({}),setLayout:Kx}),(0,P.useImperativeHandle)(o,()=>h.current,[]),KP(()=>{Object.assign(h.current,Kd({groupId:v}))});let N=KO((e,t)=>{let r=Km,a=W1(e),i=W2(e);if(i){let e=!1;return"active"===r.state&&(e=r.hitRegions.some(e=>e.group===a)),{flexGrow:i.layout[t]??1,pointerEvents:e?"none":void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),C=KA({defaultLayout:n,disableCursor:r}),S=(0,P.useMemo)(()=>({get disableCursor(){return!!C.disableCursor},getPanelStyles:N,id:v,orientation:d,registerPanel:e=>{let t=j.current;return t.panels=WW(d,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerSeparator:e=>{let t=j.current;return t.separators=WW(d,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=j.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=W1(v),a=W2(v);r&&a&&W3(r,{...a,derivedPanelConstraints:WU(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=j.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[N,v,w,d,C]),M=(0,P.useRef)(null);return KP(()=>{let e,t,n,r,i,o,l,s,c,u,f,m,h,p=b.current;if(null===p)return;let y=j.current;if(void 0!==C.defaultLayout&&Object.keys(C.defaultLayout).length===y.panels.length)for(let t of(e={},y.panels)){let n=C.defaultLayout[t.id];void 0!==n&&(e[t.id]=n)}let w={disabled:!!a,element:p,id:v,mutableState:{defaultLayout:e,disableCursor:!!C.disableCursor,expandedPanelSizes:j.current.lastExpandedPanelSizes,layouts:j.current.layouts},orientation:d,panels:y.panels,resizeTargetMinimumSize:y.resizeTargetMinimumSize,separators:y.separators};M.current=w;let k=(t=!0,Wq(w.element.ownerDocument.defaultView,"Cannot register an unmounted Group"),n=w.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,(o=new n(e=>{for(let n of e){let{borderBoxSize:e,target:r}=n;if(r===w.element){if(t){let e=WH({group:w});if(0===e)return;let t=W2(w.id);if(!t)return;let n=WU(w),r=t.defaultLayoutDeferred?KM(n):t.layout,a=Ko({layout:function({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let a=0,i=0,o=!1,l=new Map,s=[];for(let c of e.panels){let e=r[c.id]??0;if("preserve-pixel-size"===c.panelConstraints.groupResizeBehavior){o=!0;let r=WV(e/100*n/t*100);l.set(c.id,r),a+=r}else s.push(c.id),i+=e}if(!o||0===s.length)return r;let c=100-a,d={...r};if(l.forEach((e,t)=>{d[t]=e}),i>0)for(let e of s){let t=r[e]??0;d[e]=WV(t/i*c)}else{let e=WV(c/s.length);for(let t of s)d[t]=e}return d}({group:w,nextGroupSize:e,prevGroupSize:t.groupSize,prevLayout:r}),panelConstraints:n});if(!t.defaultLayoutDeferred&&Ki(t.layout,a)&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}(t.derivedPanelConstraints,n)&&t.groupSize===e)return;W3(w,{defaultLayoutDeferred:!1,derivedPanelConstraints:n,groupSize:e,layout:a,separatorToPanels:t.separatorToPanels})}}else!function(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let a=WH({group:e}),i="horizontal"===e.orientation?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,l={asPercentage:WV(i/a*100),inPixels:i};r.mutableValues.prevSize=l,r.onResize(l,r.id,o)}(w,r,e)}})).observe(w.element),w.panels.forEach(e=>{Wq(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&o.observe(e.element)}),l=WH({group:w}),s=WU(w),c=w.panels.map(({id:e})=>e).join(","),(u=w.mutableState.defaultLayout)&&(function(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}(w.panels,u)||(u=void 0)),f=Ko({layout:w.mutableState.layouts[c]??u??KM(s),panelConstraints:s}),m=w.element.ownerDocument,KE.set(m,(KE.get(m)??0)+1),h=new Map,WZ(w).forEach(e=>{e.separator&&h.set(e.separator,e.panels)}),W3(w,{defaultLayoutDeferred:0===l,derivedPanelConstraints:s,groupSize:l,layout:f,separatorToPanels:h}),w.separators.forEach(e=>{Wq(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener("keydown",Kf)}),1===KE.get(m)&&(m.addEventListener("dblclick",Ks,!0),m.addEventListener("pointerdown",Kg,!0),m.addEventListener("pointerleave",Kk),m.addEventListener("pointermove",KN),m.addEventListener("pointerout",KC),m.addEventListener("pointerup",KS,!0)),function(){t=!1,KE.set(m,Math.max(0,(KE.get(m)??0)-1)),(WQ=new Map(WQ)).delete(w),w.separators.forEach(e=>{e.element.removeEventListener("keydown",Kf)}),KE.get(m)||(m.removeEventListener("dblclick",Ks,!0),m.removeEventListener("pointerdown",Kg,!0),m.removeEventListener("pointerleave",Kk),m.removeEventListener("pointermove",KN),m.removeEventListener("pointerout",KC),m.removeEventListener("pointerup",KS,!0)),o.disconnect()}),{defaultLayoutDeferred:N,derivedPanelConstraints:S,layout:E}=W2(w.id,!0);!N&&S.length>0&&(g(E),x(E));let I=W5(v,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:r}=e.next;if(t||0===n.length)return;let a=w.panels.map(({id:e})=>e).join(",");w.mutableState.layouts[a]=r,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Kt(t.collapsedSize,r[t.panelId]),a=Kt(t.collapsedSize,n[t.panelId]);e&&!a&&(w.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let i="active"!==Km.state;g(r),i&&x(r)});return()=>{M.current=null,k(),I()}},[a,v,x,g,d,y,C]),(0,P.useEffect)(()=>{let e=M.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,E.jsx)(KT.Provider,{value:S,children:(0,E.jsx)("div",{...m,className:t,"data-group":!0,"data-testid":v,id:v,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:"horizontal"===d?"row":"column",flexWrap:"nowrap",touchAction:"horizontal"===d?"pan-y":"pan-x"},children:e})})}function K_(){let e=(0,P.useContext)(KT);return Wq(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function KD({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:a,disabled:i,elementRef:o,groupResizeBehavior:l="preserve-relative-size",id:s,maxSize:c="100%",minSize:d="0%",onResize:u,panelRef:f,style:m,...h}){let p,g=!!s,x=KI(s),v=KA({disabled:i}),b=(0,P.useRef)(null),y=Kz(b,o),{getPanelStyles:w,id:j,orientation:k,registerPanel:N,updatePanelProps:C}=K_(),S=null!==u,M=KO((e,t,n)=>{u?.(e,s,n)});KP(()=>{let e=b.current;if(null!==e)return N({element:e,id:x,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:S?M:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:n,collapsible:r,defaultSize:a,disabled:v.disabled,maxSize:c,minSize:d}})},[l,n,r,a,S,x,g,c,d,M,N,v]),(0,P.useEffect)(()=>{C(x,{disabled:i})},[i,x,C]),function(e,t){let{id:n}=K_(),r=(0,P.useRef)({collapse:Kv,expand:Kv,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Kv});(0,P.useImperativeHandle)(t,()=>r.current,[]),KP(()=>{Object.assign(r.current,Kl({groupId:n,panelId:e}))})}(x,f);let I=()=>{let e=w(j,x);if(e)return JSON.stringify(e)},O=(0,P.useSyncExternalStore)(e=>W5(j,e),I,I);return p=O?JSON.parse(O):void 0!==a?{flexGrow:void 0,flexShrink:void 0,flexBasis:a}:{flexGrow:1},(0,E.jsx)("div",{...h,"data-disabled":i||void 0,"data-panel":!0,"data-testid":x,id:x,ref:y,style:{...KL,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...p},children:(0,E.jsx)("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:"horizontal"===k?"pan-y":"pan-x"},children:e})})}KR.displayName="Group",KD.displayName="Panel";let KL={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function K$({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:a,id:i,style:o,...l}){let s,c,d=KI(i),u=KA({disabled:n,disableDoubleClick:r}),[f,m]=(0,P.useState)({}),[h,p]=(0,P.useState)("inactive"),[g,x]=(0,P.useState)(!1),v=(0,P.useRef)(null),b=Kz(v,a),{disableCursor:y,id:w,orientation:j,registerSeparator:k,updateSeparatorProps:N}=K_();return KP(()=>{let e=v.current;if(null!==e){var t;let n={disabled:u.disabled,disableDoubleClick:u.disableDoubleClick,element:e,id:d},r=k(n),a=(t=e=>{p("inactive"!==e.next.state&&e.next.hitRegions.some(e=>e.separator===n)?e.next.state:"inactive")},Kh.addListener("change",t)),i=W5(w,e=>{let{derivedPanelConstraints:t,layout:r,separatorToPanels:a}=e.next,i=a.get(n);if(i){let e=i[0],n=i.indexOf(e);m(function({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let a,i,o=e[n],l=t.find(e=>e.panelId===n);if(l){let s=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,d=[r,r+1];i=Ko({layout:Ka({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n],a=Ko({layout:Ka({delta:s-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:a,valueMin:i,valueNow:o}}({layout:r,panelConstraints:t,panelId:e.id,panelIndex:n}))}});return()=>{a(),i(),r()}}},[w,d,k,u]),(0,P.useEffect)(()=>{N(d,{disabled:n,disableDoubleClick:r})},[n,r,d,N]),n&&!y&&(s="not-allowed"),c=n?"disabled":"active"===h?"active":g?"focus":h,(0,E.jsx)("div",{...l,"aria-controls":f.valueControls,"aria-disabled":n||void 0,"aria-orientation":"horizontal"===j?"vertical":"horizontal","aria-valuemax":f.valueMax,"aria-valuemin":f.valueMin,"aria-valuenow":f.valueNow,children:e,className:t,"data-separator":c,"data-testid":d,id:d,onBlur:()=>x(!1),onFocus:()=>x(!0),ref:b,role:"separator",style:{flexBasis:"auto",cursor:s,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}function KF({className:e,direction:t,orientation:n,...r}){let a=n??t;return(0,E.jsx)(KR,{"data-slot":"resizable-panel-group","data-orientation":a??"horizontal",orientation:a,className:(0,B.cn)("flex h-full w-full data-[orientation=vertical]:flex-col",e),...r})}function KB({...e}){return(0,E.jsx)(KD,{"data-slot":"resizable-panel",...e})}function KV({withHandle:e,className:t,...n}){return(0,E.jsx)(K$,{"data-slot":"resizable-handle",className:(0,B.cn)("relative flex w-px items-center justify-center bg-border outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&(0,E.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-background",children:(0,E.jsx)(WF,{className:"size-2.5"})})})}K$.displayName="Separator";let KH=(0,z.default)("folder-kanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]),KU=(0,z.default)("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]),Kq=[{id:"ui-polish",name:"UI Polish",purpose:"整理组件视觉细节、间距和状态反馈。",models:["gpt-5-codex","gpt-5-high"]},{id:"interaction-audit",name:"Interaction Audit",purpose:"检查拖拽、滚动、键盘和选择流程。",models:["gpt-5-codex"]},{id:"typescript-check",name:"TypeScript Check",purpose:"处理类型、lint 和接口兼容。",models:["gpt-5-mini"]},{id:"telemetry-reader",name:"Telemetry Reader",purpose:"读取机器状态、运行指标和队列遥测。",models:["gpt-5-mini"]},{id:"risk-summarizer",name:"Risk Summarizer",purpose:"归纳运行风险、阻塞点和维护建议。",models:["gpt-5-codex"]},{id:"changelog-writer",name:"Changelog Writer",purpose:"整理发布说明和用户可读变更。",models:["gpt-5-mini"]},{id:"default-worker",name:"Default Worker",purpose:"通用子任务执行者。",models:["gpt-5-codex"]}],KW=[{id:"agent-ui-library",title:"Vantaloom UI 库迁移",agent:"Frontend Orchestrator",status:"working",goal:"把核心标签、画布节点和管理面板统一到可复用组件层。",progress:72,taskProgress:[100,100,75,32],runtime:"2h 18m",tokens:392e3,lastOpened:"刚刚",roadmap:[{title:"整理基础组件映射",state:"done"},{title:"接入画布节点容器",state:"done"},{title:"修正拖拽与剪切板交互",state:"running"},{title:"补充管理页面",state:"queued"}],settings:{subagents:["ui-polish","interaction-audit","typescript-check"],mainModels:["gpt-5-codex","gpt-5-high"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],blockedCommands:["git reset --hard","Remove-Item -Recurse .next"],allowedTools:["shell","browser","apply_patch","node_repl"],deniedTools:["network deploy","destructive git"],plugins:["Browser","Spreadsheets"],hosts:["Studio-PC","Linux-runner-02"]}},{id:"agent-ops-review",title:"工作组运行巡检",agent:"Ops Sentinel",status:"working",goal:"检查工作组机器负载、队列阻塞和夜间维护风险。",progress:48,taskProgress:[100,64,28],runtime:"54m",tokens:184e3,lastOpened:"6 分钟前",roadmap:[{title:"读取机器状态",state:"done"},{title:"分析队列拥塞",state:"running"},{title:"生成维护建议",state:"queued"}],settings:{subagents:["telemetry-reader","risk-summarizer"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/ops"],blockedCommands:["shutdown","Restart-Service"],allowedTools:["shell","browser"],deniedTools:["write secrets"],plugins:["Browser"],hosts:["Studio-PC","MacBook-build"]}},{id:"agent-doc-sync",title:"发布说明整理",agent:"Docs Agent",status:"paused",goal:"把最近组件变更整理成可发布的文档摘要。",progress:31,taskProgress:[86,22,0],runtime:"23m",tokens:91e3,lastOpened:"22 分钟前",roadmap:[{title:"扫描组件变更",state:"running"},{title:"归纳破坏性变化",state:"queued"},{title:"输出发布草稿",state:"queued"}],settings:{subagents:["changelog-writer"],mainModels:["gpt-5-mini"],folders:["D:/Projects/Vantaloom-ui/docs"],blockedCommands:["git push"],allowedTools:["shell","apply_patch"],deniedTools:["browser credentials"],plugins:[],hosts:["Studio-PC"]}},{id:"agent-browser-lab",title:"浏览器标签适配",agent:"Preview Agent",status:"idle",goal:"验证浏览器标签页不同尺寸和 UA 的预览行为。",progress:100,taskProgress:[100,100,100],runtime:"1h 42m",tokens:246e3,lastOpened:"今天 14:20",roadmap:[{title:"补充自适应尺寸",state:"done"},{title:"加入前进后退刷新",state:"done"},{title:"验证画布节点容器",state:"done"}],settings:{subagents:["responsive-checker"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],blockedCommands:["pnpm publish"],allowedTools:["browser","shell"],deniedTools:["external network write"],plugins:["Browser"],hosts:["Studio-PC"]}},{id:"agent-data-tab",title:"数据表标签优化",agent:"Data UI Agent",status:"idle",goal:"完善 CSV / JSON 表格标签的排序、复制与列宽交互。",progress:100,taskProgress:[100,100,100,100],runtime:"38m",tokens:132e3,lastOpened:"昨天 19:04",roadmap:[{title:"列宽拖动",state:"done"},{title:"行选择",state:"done"},{title:"复制单元格",state:"done"},{title:"接入多标签页",state:"done"}],settings:{subagents:["table-a11y"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/packages/ui/src/components"],blockedCommands:["Remove-Item"],allowedTools:["shell","apply_patch"],deniedTools:["remote write"],plugins:[],hosts:["Studio-PC"]}}];function KK(e,t,n,r,a,i,o,l,s){return{id:e,title:t,agent:n,status:r,goal:a,progress:i,taskProgress:[100,i,0],runtime:o,tokens:l,lastOpened:s,roadmap:[{title:"读取上下文",state:i>20?"done":"running"},{title:"执行当前任务",state:i>20?"running":"queued"},{title:"整理结果",state:"queued"}],settings:{subagents:["default-worker"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui"],blockedCommands:["git reset --hard"],allowedTools:["shell","apply_patch"],deniedTools:["destructive git"],plugins:[],hosts:["Studio-PC"]}}}KW.push(KK("agent-terminal-polish","终端标签组打磨","Terminal Agent","working","检查终端 TUI 渲染、字体和滚动行为。",37,"41m",118e3,"9 分钟前"),KK("agent-table-review","数据表交互复核","Table Agent","working","复核排序、列宽拖动和单元格复制体验。",62,"1h 07m",211e3,"12 分钟前"),KK("agent-node-canvas-docs","节点画布文档化","Canvas Writer","paused","把节点、连线和吸附策略整理成内部说明。",18,"16m",64e3,"31 分钟前"),KK("agent-file-tree-audit","文件树交互审阅","Explorer Agent","idle","审阅框选、多选拖拽和插入线表现。",100,"52m",152e3,"今天 13:12"),KK("agent-auth-flow","登录注册流程整理","Access Agent","idle","检查本机用户与工作组接入之间的边界。",100,"44m",99e3,"今天 11:45"),KK("agent-settings-panel","设置面板导航审阅","Settings Agent","idle","检查主菜单、子菜单和搜索跳转体验。",100,"36m",87e3,"昨天 21:18"),KK("agent-diff-view","Diff 标签页复盘","Review Agent","idle","整理统一差异、分栏差异和折叠区域规则。",100,"1h 11m",176e3,"昨天 16:02"),KK("agent-clipboard-stack","剪切板堆叠交互记录","Clipboard Agent","idle","记录钥匙扣展开、拖拽排序和垃圾桶联动。",100,"1h 24m",234e3,"周五 18:33")),KW.filter(e=>"idle"!==e.status);let KG=KW.filter(e=>"idle"===e.status).sort((e,t)=>e.lastOpened.localeCompare(t.lastOpened));function KX({conversation:e,mainModels:t,onMainModelsChange:n}){let{models:r,loading:a}=nl(),[i,o]=P.useState(""),l=P.useMemo(()=>r.filter(e=>!1!==e.available),[r]),s=P.useMemo(()=>{let e=new Map;for(let t of l){let n=t.providerName?.trim()||"其他",r=e.get(n);r?r.push(t):e.set(n,[t])}return Array.from(e.entries()).map(([e,t])=>({provider:e,models:t}))},[l]),c=P.useMemo(()=>{let e=i.trim().toLowerCase();return e?s.map(t=>({provider:t.provider,models:t.models.filter(n=>n.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))})).filter(e=>e.models.length>0):s},[s,i]),d=P.useMemo(()=>new Set(t),[t]),u=e?.lastModelRef??"",f=u&&d.has(u)?u:t[0],m=P.useMemo(()=>new Set(l.map(e=>e.value)),[l]),h=P.useMemo(()=>new Map(r.map(e=>[e.value,e])),[r]),p=P.useMemo(()=>t.filter(e=>!m.has(e)).map(e=>{let t=h.get(e);return{id:e,label:t?.label??e,provider:t?.providerName?.trim()||""}}),[t,m,h]),g=P.useMemo(()=>{let e=i.trim().toLowerCase();return e?p.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):p},[p,i]),x=P.useCallback(e=>{n(d.has(e)?t.filter(t=>t!==e):[...t,e])},[t,n,d]),v=P.useCallback(e=>{let r=e.map(e=>e.value);if(r.every(e=>d.has(e))){let e=new Set(r);n(t.filter(t=>!e.has(t)))}else n([...t,...r.filter(e=>!d.has(e))])},[t,n,d]);return(0,E.jsxs)("div",{className:"grid gap-3",children:[e?.agent?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:e.agent}):null,(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"该会话可用的语言模型,按渠道分组;可选多个,作为允许使用的模型集合。主模型(标记为「主」)由实际使用动态决定,无需在此手动指定。"}),(0,E.jsxs)("div",{className:"relative",children:[(0,E.jsx)(IX,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,E.jsx)(V,{value:i,onChange:e=>o(e.target.value),placeholder:"搜索模型或渠道...",className:"h-8 pl-8"})]}),(0,E.jsx)("div",{className:"grid max-h-[min(22rem,50svh)] gap-3 overflow-auto rounded-lg border bg-card/40 p-2",children:a&&0===r.length?(0,E.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"读取模型中…"}):0===c.length&&0===g.length?(0,E.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:0===r.length?"没有可用模型":"没有匹配的模型"}):(0,E.jsxs)(E.Fragment,{children:[c.map(e=>{let t=e.models.map(e=>e.value),n=t.filter(e=>d.has(e)).length,r=n===t.length;return(0,E.jsxs)("div",{className:"grid gap-1",children:[(0,E.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,E.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,E.jsx)("span",{className:"truncate text-xs font-semibold text-foreground",children:e.provider}),(0,E.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[n,"/",t.length]})]}),(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>v(e.models),children:r?"取消全选":"全选"})]}),(0,E.jsx)("div",{className:"grid gap-0.5",children:e.models.map(e=>{let t=d.has(e.value),n=e.value===f;return(0,E.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":t,onClick:()=>x(e.value),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),x(e.value))},className:(0,B.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50",t?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,E.jsx)(EF,{checked:t,tabIndex:-1,className:"pointer-events-none"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n?(0,E.jsx)("span",{className:"shrink-0 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"主"}):null]},e.value)})})]},e.provider)}),g.length>0?(0,E.jsxs)("div",{className:"grid gap-1",children:[(0,E.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,E.jsx)("span",{className:"truncate text-xs font-semibold text-muted-foreground",children:"已禁用 / 不可用"}),(0,E.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:g.length})]}),(0,E.jsx)("div",{className:"grid gap-0.5",children:g.map(e=>(0,E.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":!0,title:"该模型所属渠道已禁用或不可用,点击可移除",onClick:()=>x(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),x(e.id))},className:(0,B.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm opacity-60 transition-colors outline-none hover:bg-muted hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50"),children:[(0,E.jsx)(EF,{checked:!0,tabIndex:-1,className:"pointer-events-none"}),(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[e.label,e.provider?(0,E.jsxs)("span",{className:"ml-1.5 text-[11px] text-muted-foreground/70",children:["· ",e.provider]}):null]}),(0,E.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"不可用"})]},e.id))})]}):null]})})]})}async function KY(e,t){let n=new URLSearchParams;e&&n.set("conversationId",e),t&&n.set("workspace",t);let r=n.toString();return Ge(`/api/local/agent/project-docs${r?`?${r}`:""}`)}async function KZ(e,t,n,r){return Ge("/api/local/agent/project-docs",{method:"PUT",body:JSON.stringify({path:e,content:t,conversationId:n,workspace:r})})}let KJ=null,KQ=null;async function K0(){let e=Date.now();return KJ&&e-KJ.at<3e4?KJ.value:KQ||(KQ=(async()=>{try{let e=await Ge("/api/local/agent-config");return KJ={value:e,at:Date.now()},e}finally{KQ=null}})())}async function K1(e){let t=await Ge("/api/local/agent-config",{method:"PUT",body:JSON.stringify(e)});return KJ={value:t,at:Date.now()},t}async function K2(e){return Ge(e&&"local"!==e?`/v1/remote/${e}/agent/engines`:"/api/local/agent/engines")}function K5(e){return"installing-node"===e||"installing-bridge"===e}async function K3(){return Ge("/api/local/agent/engines/install-adapter",{method:"POST"})}async function K4(){return Ge("/api/local/agent/engines/install-status")}async function K6(){return Ge("/api/local/agent/reclaude/status")}async function K8(){return Ge("/api/local/agent/reclaude/login/start",{method:"POST",body:"{}"})}async function K7(e){return Ge("/api/local/agent/reclaude/login/poll",{method:"POST",body:JSON.stringify({state:e})})}async function K9(){return Ge("/api/local/agent/reclaude/logout",{method:"POST",body:"{}"})}async function Ge(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"agent config api failed");return r}let Gt=[{engine:"vantaloom",available:!0}];function Gn(e){let[t,n]=P.useState([]),[r,a]=P.useState(!0),i=P.useCallback(async()=>{a(!0);try{let t=await K2(e);n(Array.isArray(t.engines)&&t.engines.length>0?t.engines:Gt)}catch{n(Gt)}finally{a(!1)}},[e]);return P.useEffect(()=>{i()},[i]),{engines:t,loading:r,refresh:i}}let Gr={folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:["local"]},Ga=["运行环境配置","选择工作目录","模型设置","确认开始"],Gi=[{value:"vantaloom",label:"Vantaloom"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}];function Go({onCreated:e,onCancel:t}){let{machines:n}=TV(),{models:r}=nl(),[a,i]=P.useState("local"),{engines:o}=Gn(a),l=P.useCallback(e=>{if("vantaloom"===e)return!0;let t=o.find(t=>t.engine===e);return t?.available??!1},[o]),s=P.useCallback(e=>o.find(t=>t.engine===e)?.reason,[o]),[c,d]=P.useState(0),[u,f]=P.useState(""),[m,h]=P.useState("vantaloom"),[p,g]=P.useState(Kq),[x,v]=P.useState([]),[b,y]=P.useState(""),[w,j]=P.useState(Gr),[k,N]=P.useState(!1),[C,S]=P.useState("");P.useEffect(()=>{"vantaloom"===m||l(m)||h("vantaloom")},[m,l]);let M=_D(m);P.useEffect(()=>{M&&j(e=>{let t=1===e.hosts.length&&"local"===e.hosts[0],n=e.folders.slice(-1),r=n.length===e.folders.length;return t&&r?e:{...e,hosts:["local"],folders:n}})},[M]);let I=P.useMemo(()=>({id:"new-agent-conversation",title:u.trim()||"新 Agent 对话",agent:"Local Agent",status:k?"working":"idle",goal:"",progress:0,taskProgress:[100,0],runtime:"0m",tokens:0,lastOpened:"刚刚",roadmap:[{title:"配置会话环境",state:"done"},{title:"等待首条消息",state:"queued"}],settings:{subagents:[],mainModels:x,...w,engine:m,ccModel:M?b:void 0}}),[b,k,m,M,x,w,u]),O="local"===a?"本机":n.find(e=>e.id===a)?.name??a,z=P.useCallback(async()=>{if(!k){N(!0),S("");try{let t=await e7({title:u.trim()||"新 Agent 对话",agent:"Local Agent",goal:"",ownerMachineId:a,settings:{subagents:[],mainModels:M?[]:x,...w,engine:m,ccModel:M?b:void 0}});e(t)}catch(t){let e="local"===a?void 0:n.find(e=>e.id===a)?.name;"local"!==a&&d(0),S(function(e,t){let n;if(n=e instanceof Error?e.message:String(e??""),/relay to .* failed/i.test(n)||n.includes("目标机器离线或未连接")||/no response from/i.test(n)||/relay timeout|request timeout/i.test(n)||/Hub connection not configured/i.test(n)){let e=t?`机器「${t}」`:"目标机器";return`${e}当前离线或无法连接,无法在其上运行 agent。请确认该机器已开启并联网,或改在本机运行。`}return e instanceof Error&&e.message?e.message:"操作失败"}(t,e))}finally{N(!1)}}},[b,k,m,M,n,x,e,a,w,u]),A=c===Ga.length-1;return(0,E.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col","data-tour":"init-wizard",children:[(0,E.jsx)("header",{className:"shrink-0 px-6 pt-8 pb-6",children:(0,E.jsx)("ol",{className:"mx-auto flex max-w-2xl items-center",children:Ga.map((e,t)=>{let n=t<c,r=t===c;return(0,E.jsxs)("li",{className:"flex min-w-0 flex-1 items-center last:flex-none",children:[(0,E.jsxs)("button",{type:"button","aria-current":r?"step":void 0,"aria-label":`第 ${t+1} 步:${e}`,onClick:()=>{t<=c&&d(t)},className:"group flex shrink-0 items-center gap-2 outline-none",children:[(0,E.jsx)("span",{className:(0,B.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border text-sm font-medium transition-colors",n?"border-primary bg-primary text-primary-foreground":r?"border-primary text-primary ring-2 ring-primary/30":"border-border bg-background text-muted-foreground"),children:n?(0,E.jsx)(CV,{className:"size-4"}):t+1}),(0,E.jsx)("span",{className:(0,B.cn)("hidden truncate text-sm font-medium transition-colors sm:inline",r?"text-foreground":n?"text-foreground/80":"text-muted-foreground"),children:e})]}),t<Ga.length-1?(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("mx-3 h-px min-w-6 flex-1 transition-colors",t<c?"bg-primary":"bg-border")}):null]},e)})})}),(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6",children:(0,E.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:[0===c?(0,E.jsxs)("div",{className:"grid gap-6",children:[(0,E.jsx)(Gs,{value:a,onChange:e=>{i(e)},machines:n}),(0,E.jsxs)("div",{className:"grid gap-2","data-tour":"wizard-engine",children:[(0,E.jsx)("label",{htmlFor:"agent-init-engine",className:"text-sm font-medium text-foreground",children:"运行哪个 Agent"}),(0,E.jsx)(zB,{id:"agent-init-engine",value:m,onValueChange:e=>h(e),placeholder:"选择运行引擎",title:"选择运行引擎",className:"w-full",options:Gi.map(e=>{let t=l(e.value);return{value:e.value,label:`${e.label}${t?"":"(不可用)"}`,disabled:!t}})}),s(m)?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:s(m)}):null,M?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code(含 reclaude)运行在所选的 owner 机器上;其工具(读/写/执行)锁定在该机本地(跨机能力待 MCP 扩展)。"}):null]}),(0,E.jsx)(TJ,{value:w.hosts,onValueChange:e=>j(t=>({...t,hosts:e})),disabled:M,hint:M?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})]}):null,1===c?(0,E.jsxs)("div",{className:"grid gap-6",children:[(0,E.jsxs)("div",{className:"grid gap-2",children:[(0,E.jsx)("label",{htmlFor:"agent-init-title",className:"text-sm font-medium text-foreground",children:"对话名称(可选)"}),(0,E.jsx)(V,{id:"agent-init-title",value:u,placeholder:"新 Agent 对话",onChange:e=>f(e.currentTarget.value)})]}),(0,E.jsx)(TW,{title:"可访问的工作区文件夹",value:w.folders,onValueChange:e=>j(t=>({...t,folders:M?e.slice(-1):e}))}),M?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,2===c?M?(0,E.jsxs)("div",{className:"grid gap-3",children:[(0,E.jsx)("label",{htmlFor:"agent-init-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,E.jsx)(zB,{id:"agent-init-cc-model",value:""===b?_R:b,onValueChange:e=>y(e===_R?"":e),placeholder:"选择 Claude Code 模型",title:"选择 Claude Code 模型",className:"w-full",options:__.map(e=>({value:e.value,label:e.label}))}),(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,E.jsx)(KX,{conversation:I,sharedSubagents:p,mainModels:x,enabledSubagentIds:[],onMainModelsChange:v,onSharedSubagentsChange:g}):null,3===c?(0,E.jsxs)("div",{className:"grid gap-4",children:[(0,E.jsxs)("div",{className:"grid gap-3 rounded-xl border bg-card p-5",children:[(0,E.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"配置摘要"}),(0,E.jsxs)("div",{className:"grid gap-2.5",children:[(0,E.jsx)(Gl,{icon:(0,E.jsx)(KH,{}),label:"工作目录",value:w.folders.length>0?`${w.folders.length} 个目录`:"未选择"}),(0,E.jsx)(Gl,{icon:(0,E.jsx)($,{}),label:"运行环境",value:O}),(0,E.jsx)(Gl,{icon:(0,E.jsx)(_q,{}),label:"运行引擎",value:Gi.find(e=>e.value===m)?.label??m}),(0,E.jsx)(Gl,{icon:(0,E.jsx)(UB,{}),label:"模型",value:M?__.find(e=>(e.value===_R?"":e.value)===b)?.label??"默认模型":x.length>0?x.map(e=>r.find(t=>t.value===e)?.label??e).join("、"):"默认模型"})]})]}),C?(0,E.jsx)("div",{className:"text-sm text-destructive",children:C}):null]}):null]})}),(0,E.jsx)("footer",{className:"flex shrink-0 items-center justify-between px-6 pb-8",children:(0,E.jsxs)("div",{className:"mx-auto flex w-full max-w-2xl items-center justify-between",children:[(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",disabled:k,onClick:()=>{0===c?t?.():d(e=>Math.max(0,e-1))},children:[(0,E.jsx)(IH,{className:"size-4"}),0===c?"取消":"上一步"]}),A?(0,E.jsxs)(F.Button,{type:"button",disabled:k,onClick:()=>void z(),children:[(0,E.jsx)(KU,{className:"size-4"}),k?"创建中…":"确认开始"]}):(0,E.jsxs)(F.Button,{type:"button",onClick:()=>d(e=>Math.min(Ga.length-1,e+1)),children:["下一步",(0,E.jsx)(MC,{className:"size-4"})]})]})})]})}function Gl({icon:e,label:t,value:n}){return(0,E.jsxs)("div",{className:"grid grid-cols-[auto_5rem_minmax(0,1fr)] items-center gap-3",children:[(0,E.jsx)("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4",children:e}),(0,E.jsx)("span",{className:"text-sm text-muted-foreground",children:t}),(0,E.jsx)("span",{className:"min-w-0 truncate text-sm font-medium text-foreground",children:n})]})}function Gs({value:e,onChange:t,machines:n}){let r=P.useMemo(()=>{let e=[],t=!1;for(let r of n)if(r.isLocal)t=!0,e.unshift({id:"local",name:"本机",online:!0,reachable:!0});else{let t="online"===r.status;e.push({id:r.id,name:r.name,online:t,reachable:r.reachable??t})}return t||e.unshift({id:"local",name:"本机",online:!0,reachable:!0}),e},[n]);return(0,E.jsxs)("div",{className:"grid gap-2",children:[(0,E.jsx)("label",{htmlFor:"agent-init-run-machine",className:"text-sm font-medium text-foreground",children:"Agent 运行位置"}),(0,E.jsx)(zB,{id:"agent-init-run-machine",value:e,onValueChange:t,placeholder:"选择运行位置",title:"选择运行位置",className:"w-full",options:r.map(e=>{let t=e.reachable?"":e.online?"(在线·不可达)":"(离线)";return{value:e.id,label:`${e.name}${t}`,disabled:!e.reachable}})}),(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"选择 agent 实际运行在工作组里的哪台机器(默认本机)。会话与历史会保存在所选机器,并可从任意端进入。"})]})}let Gc=H4.map(e=>({id:e.id,title:e.title,description:e.description,icon:e.icon,keywords:e.keywords}));function Gd(e){return Gc.find(t=>t.id===e)}function Gu(e,t){let n=Gd(e),r="file-tab-viewer"===e?{id:t,kind:e,title:"选择文件"}:H7(e)?Ue(e,t):void 0;return{id:t,kind:e,title:r?.title??n?.title??"组件",tab:r,tabs:"multi-tab-system"===e?[]:void 0,terminal:"terminal-tab-group"===e?{sessionIds:[],autoStart:!0}:void 0}}function Gf(e){return"subagent-conversation-panel"!==e.kind&&"context-breakdown"!==e.kind}let Gm="application/vnd.vantaloom.agent-panel";function Gh(e){let t=Gf(e)?Gd(e.kind):void 0,n={content:e};return{id:`agent-panel-${e.id}`,title:e.title,description:t?.description??("subagent-conversation-panel"===e.kind?"子代理运行信息流。":"来自 Agent 工作区的面板。"),meta:"Agent panel",icon:t?.icon,dragData:{"application/vnd.vantaloom.clip-kind":"agent-panel",[Gm]:JSON.stringify(n)},payloads:{[Gm]:n}}}function Gp({ownerMachineId:e,title:t,resolvedLocation:n,className:r}){let a=function(e){let{machines:t}=TV();return P.useMemo(()=>{if(eF(e))return"本机";let n=t.find(t=>t.id===e);return n?n.isLocal?"本机":n.name:e??"本机"},[t,e])}(e),i=n??a,o=t.trim()||"新 Agent 对话";return(0,E.jsxs)("div",{className:(0,B.cn)("flex h-9 shrink-0 items-center gap-1.5 border-b px-3 text-sm",r),children:[(0,E.jsx)($,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,E.jsx)("span",{className:"shrink-0 truncate text-muted-foreground",title:i,children:i}),(0,E.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"/"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",title:o,children:o})]})}function Gg({rounds:e,onJumpToRound:t,activeRunId:n,className:r}){let[a,i]=P.useState(!1),o=P.useRef(null),[l,s]=P.useState(304);if(P.useEffect(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&i(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]),P.useLayoutEffect(()=>{if(!a)return;let e=()=>{let e=o.current;if(!e)return;let t=e.getBoundingClientRect().left;s(Math.max(120,Math.min(304,window.innerWidth-t-16)))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),!e.length)return null;let c=e.length>24?e.slice(e.length-24):e;return(0,E.jsxs)("div",{ref:o,className:(0,B.cn)("relative",r),children:[(0,E.jsx)("button",{type:"button","aria-label":"轮次时间轴",title:`轮次时间轴 \xb7 共 ${e.length} 轮`,onClick:()=>i(e=>!e),className:(0,B.cn)("group flex flex-col items-start gap-[7px] rounded-md px-1.5 py-2 outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted/50",a&&"invisible"),children:c.map(e=>{let t=!!n&&e.runId===n;return(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("h-[3px] rounded-full transition-all duration-200",t?"w-5 bg-foreground/85":"w-2.5 bg-muted-foreground/30 group-hover:bg-muted-foreground/55")},e.runId)})}),a?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),(0,E.jsx)("div",{style:{width:l},className:"absolute left-0 top-0 z-50 max-h-[20rem] overflow-y-auto overflow-x-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md vtl-scrollbar-hidden",children:(0,E.jsx)("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-px",children:e.map(e=>{let r=!!n&&e.runId===n;return(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full min-w-0 items-center gap-2 rounded px-2 py-1 text-left transition-colors",r?"bg-muted":"hover:bg-muted/70"),onClick:()=>{t(e),i(!1)},children:[(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("h-[2.5px] shrink-0 rounded-full transition-all",r?"w-3.5 bg-foreground/85":"w-2.5 bg-muted-foreground/40")}),(0,E.jsx)("span",{className:(0,B.cn)("min-w-0 flex-1 truncate text-[13px] leading-snug",r?"font-medium text-foreground":"text-foreground/90"),children:e.title?.trim()||e.summary?.trim()||"未命名轮次"})]},e.runId)})})})]}):null]})}let Gx={expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"};function Gv({icon:e,title:t,role:n,running:r,status:a,active:i,onClick:o,events:l}){let s=P.useMemo(()=>(function(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.kind==="user")return e.slice(t);return e})(l),[l]);return(0,E.jsxs)("button",{type:"button",onClick:o,className:(0,B.cn)("relative flex h-48 w-full shrink-0 flex-col overflow-hidden rounded-xl border bg-card text-left shadow-md transition-all","hover:-translate-y-0.5 hover:shadow-lg",i?"border-primary/70 ring-2 ring-primary/40":r?"border-green-500/50":"border-border/70"),children:[(0,E.jsxs)("div",{className:"flex items-center gap-2 border-b bg-muted/50 px-2.5 py-1.5",children:[(0,E.jsx)("span",{className:"shrink-0",children:e}),(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium",children:[t,(0,E.jsxs)("span",{className:"ml-1 text-[10px] font-normal text-muted-foreground",children:["· ",n]})]}),(0,E.jsxs)("span",{className:(0,B.cn)("flex shrink-0 items-center gap-0.5 rounded px-1.5 py-px text-[9.5px]",r?"bg-green-500/15 text-green-600 dark:text-green-400":"failed"===a?"bg-hot-pink/15 text-hot-pink":"bg-muted text-muted-foreground"),children:[r?(0,E.jsx)(_,{className:"size-2.5 animate-spin"}):null,r?"运行中":"failed"===a?"失败":"paused"===a?"已暂停":"已完成"]})]}),(0,E.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[s.length>0?(0,E.jsx)("div",{className:"pointer-events-none absolute inset-0",children:(0,E.jsx)(IV,{events:s,bottomInset:8,contentClassName:"max-w-none px-3",labels:Gx})}):(0,E.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-muted-foreground/50",children:"暂无内容"}),(0,E.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-background to-transparent"})]})]})}function Gb({subagent:e,ownerMachineId:t,active:n,onClick:r}){let[a,i]=P.useState([]);P.useEffect(()=>{let n,r=!1,a=async()=>{try{let o=await eX(e.id,t);if(r)return;i(o.events);let l="working"===o.conversation.status||!!o.conversation.running;n=window.setTimeout(a,l?1500:6e3)}catch{if(r)return;n=window.setTimeout(a,4e3)}};return a(),()=>{r=!0,n&&window.clearTimeout(n)}},[e.id,t]);let o=Ij(e.type),l=o.Icon;return(0,E.jsx)(Gv,{icon:(0,E.jsx)(l,{className:(0,B.cn)("size-4",o.color)}),title:e.name||`${o.label}子代理`,role:o.label,running:e.running,status:e.status,active:n,onClick:r,events:a})}function Gy({conversationTitle:e,rootEvents:t,rootOwnerMachineId:n,running:r,subagentTree:a,baselineSubagentIds:i,activeSubagentPath:o,onSelectMain:l,onSelectSubagent:s}){let c=P.useMemo(()=>(function e(t,n=[]){for(let r of t)n.push({id:r.id,name:r.subagentName,type:r.subagentType,status:r.status,running:r.running,ownerMachineId:r.ownerMachineId,createdAt:r.createdAt}),e(r.children??[],n);return n})(a).filter(e=>!i.has(e.id)).sort((e,t)=>(e.createdAt??"").localeCompare(t.createdAt??"")),[a,i]),d=o[o.length-1]?.id,u=0===o.length;return(0,E.jsx)("div",{className:"h-full min-h-0 overflow-y-auto px-4 py-4 vtl-scrollbar-hidden",children:(0,E.jsxs)("div",{className:"ml-auto flex w-full max-w-[20rem] flex-col gap-4",children:[(0,E.jsx)(Gv,{icon:(0,E.jsx)(CB,{className:"size-4 text-sky-500"}),title:"主 Agent",role:e||"主对话",running:r,status:r?"working":"idle",active:u,onClick:l,events:t}),c.map(e=>(0,E.jsx)(Gb,{subagent:e,ownerMachineId:n,active:e.id===d,onClick:()=>s({id:e.id,ownerMachineId:e.ownerMachineId??n,name:e.name,subagentType:e.type})},e.id))]})})}function Gw(e){return`vtl:composer-draft:${e}`}function Gj(e){if(!e)return"";try{return window.localStorage.getItem(Gw(e))??""}catch{return""}}function Gk(e){return`vtl:agent:prompt-history:${e}`}function GN(e){if(!e)return[];try{let t=window.localStorage.getItem(Gk(e));if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];return n.filter(e=>"string"==typeof e)}catch{return[]}}let GC="__bottom__";function GS(e){return`vtl:agent-read-pos:${e}`}function GM(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(GS(e));window.localStorage.setItem(GS(e),t)}catch{}}let GE=(0,z.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),GI=(0,z.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]),GP=(0,z.default)("file-type-corner",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"15usau"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M3 16v-1.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5V16",key:"s1gz5"}],["path",{d:"M6 22h2",key:"194x9m"}],["path",{d:"M7 14v8",key:"11ixej"}]]),GO=(0,z.default)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Gz=(0,z.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),GA=(0,z.default)("panel-bottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]),GT=(0,z.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);function GR(e,t){return"function"==typeof e?e(t):e}function G_(e,t){return n=>{t.setState(t=>({...t,[e]:GR(n,t[e])}))}}function GD(e){return e instanceof Function}function GL(e,t,n){let r,a=[];return i=>{let o,l;n.key&&n.debug&&(o=Date.now());let s=e(i);if(!(s.length!==a.length||s.some((e,t)=>a[t]!==e)))return r;if(a=s,n.key&&n.debug&&(l=Date.now()),r=t(...s),null==n||null==n.onChange||n.onChange(r),n.key&&n.debug&&null!=n&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-l)*100)/100,r=t/16,a=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${a(t,5)} /${a(e,5)} ms`,`
40
+ (旁问的实时问答不随卡片附带;这是一个旁路只读问答区。)`;case"plan-doc-viewer":return`工作区卡片:${a}(计划文档/proposal.md 与执行树的内容随会话实时获取,请在对话中查看/读取计划。)`;case"spec-doc-viewer":return`工作区卡片:${a}(规范文档内容随会话实时获取,请在对话中查看/读取规范。)`;case"tasks-pane":return`工作区卡片:${a}(本轮任务清单随会话实时获取,请在对话中查看任务。)`;case"hooks-pane":return`工作区卡片:${a}(本会话注册的自动化 hook 随会话实时获取,请在对话中查看 hook。)`;case"status-monitor":return`工作区卡片:${a}(环境信息、子智能体状态与额度消耗随会话实时获取,请在对话中查看状态监控。)`;default:return`工作区卡片:${t}(类型 ${n})`}}(t,n);return{name:n,text:r,cardKind:t.kind}}(e)??null)}let Ui=0;function Uo(e){let t,n=e.dataTransfer?.getData(_V);if(!n)return null;try{t=JSON.parse(n)}catch{return null}return t&&t.text?(Ui+=1,{id:`card-att-${Date.now().toString(36)}-${Ui}`,kind:"card",name:t.name||"工作区卡片",mimeType:"text/vnd.vantaloom.card",text:t.text,cardKind:t.cardKind}):null}class Ul extends Error{constructor(){super("downloads endpoint not available"),this.name="DownloadsNotAvailableError"}}async function Us(e){let{signal:t,timeoutMs:n=8e3}=e??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;t&&t.addEventListener("abort",()=>r.abort(),{once:!0});try{let e=await fetch((0,H.localAPIURL)("/v1/downloads"),{cache:"no-store",signal:r.signal});if(404===e.status)throw new Ul;if(!e.ok)throw Error(`Downloads API error: ${e.status}`);let t=await e.json();return{downloads:Array.isArray(t.downloads)?t.downloads:[]}}finally{a&&clearTimeout(a)}}async function Uc(e,t){let{signal:n}=t??{},r=await fetch((0,H.localAPIURL)("/v1/downloads/stream"),{cache:"no-store",headers:{Accept:"text/event-stream"},signal:n});if(404===r.status)throw new Ul;if(!r.ok||!r.body)throw Error(`Downloads stream error: ${r.status}`);let a=r.body.getReader(),i=new TextDecoder,o="",l=t=>{let n=t.split("\n").filter(e=>e.startsWith("data:")).map(e=>e.slice(5).trimStart());if(0===n.length)return;let r=n.join("\n");if(r&&"[DONE]"!==r)try{let t=JSON.parse(r);Array.isArray(t.downloads)&&e(t.downloads)}catch{}};for(;;){let{value:e,done:t}=await a.read();if(t)break;let n=(o+=i.decode(e,{stream:!0})).indexOf("\n\n");for(;-1!==n;){let e=o.slice(0,n);o=o.slice(n+2),l(e),n=o.indexOf("\n\n")}}}async function Ud(e){let t=await fetch((0,H.localAPIURL)("/v1/downloads"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(404===t.status)throw new Ul;if(!t.ok)throw Error(`Downloads enqueue error: ${t.status}`);return await t.json()}async function Uu(e,t){let n=await fetch((0,H.localAPIURL)(`/v1/downloads/${encodeURIComponent(e)}/${t}`),{method:"POST",cache:"no-store"});if(404===n.status)throw new Ul;if(!n.ok)throw Error(`Downloads action error: ${n.status}`);let r=await n.text();return r?JSON.parse(r):{ok:!0}}async function Uf(e){let{signal:t,timeoutMs:n=8e3}=e??{},r=new AbortController,a=n>0?setTimeout(()=>r.abort(),n):void 0;t&&t.addEventListener("abort",()=>r.abort(),{once:!0});try{let e=await fetch((0,H.localAPIURL)("/v1/downloads/config"),{cache:"no-store",signal:r.signal});if(404===e.status)throw new Ul;if(!e.ok)throw Error(`Downloads config error: ${e.status}`);return await e.json()}finally{a&&clearTimeout(a)}}async function Um(e){let t=await fetch((0,H.localAPIURL)("/v1/downloads/config"),{method:"PUT",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(404===t.status)throw new Ul;if(!t.ok)throw Error(`Downloads config error: ${t.status}`);let n=await t.text();return n?JSON.parse(n):e}function Uh({conversationId:e,modelRef:t,models:n,onModelChange:r,onGoHome:a}){let[i,o]=P.useState(null),[l,s]=P.useState(""),[c,d]=P.useState(!1),[u,f]=P.useState(null),[m,h]=P.useState(!1),[p,g]=P.useState(null),[x,v]=P.useState([]),[b,y]=P.useState([]),[w,j]=P.useState(void 0),[k,N]=P.useState(!1),[C,S]=P.useState(!1),[M,I]=P.useState(!1),[O,z]=P.useState(()=>new Set),[A,T]=P.useState(void 0),[R,_]=P.useState(""),[D,L]=P.useState(!1),[$,B]=P.useState(void 0),V=P.useCallback(async()=>{try{let t=await eX(e);t&&o(t)}catch{}},[e]);P.useEffect(()=>{V();let e=!0,t=setInterval(()=>{e&&V()},1200);return()=>{e=!1,clearInterval(t)}},[V]);let U=i?.events??[],q=i?.conversation.running??!1,W=i?.conversation.planState,K=i?.conversation.ownerMachineId,G=i?.conversation.settings.folders??[],X=_D(i?.conversation.settings.engine),Y=P.useMemo(()=>U.filter(e=>{let t=e.kind;return"perm"!==t&&"add-model"!==t}),[U]),Z=U[U.length-1],J=Z?Z.kind:"",Q=Z&&"perm"===J&&Z.controlRunId!==u?Z:null,ee=Z&&"add-model"===J&&Z.controlRunId!==p?Z:null;async function et(t,n,r){if(ee&&!m){h(!0);try{let a=await tb(e,{added:t,summary:n,modelRef:r});g(ee.controlRunId??null),a&&o(a)}catch{}finally{h(!1)}}}async function en(n){if(Q&&!c){d(!0);try{let r=await tv(e,{accept:n,modelRef:t});f(Q.controlRunId??null),r&&o(r)}catch{}finally{d(!1)}}}async function er(n){let r=n.value.trim(),a=(n.attachments??[]).map(e=>"image"===e.kind?{kind:"image",name:e.name,mimeType:e.mimeType,data:e.dataUrl?.split(",")[1]??""}:"card"===e.kind?{kind:"card",name:e.name,mimeType:e.mimeType,text:e.text??"",cardKind:e.cardKind}:{kind:"file",name:e.name,mimeType:e.mimeType,text:e.text??""}).filter(e=>"image"===e.kind?(e.data??"")!=="":(e.text??"")!=="");if(r||0!==a.length){s(""),v([]);try{let i=await tc(e,{message:r,modelRef:n.modelId??t,mode:"agent",attachments:a.length>0?a:void 0});i&&o(i)}catch{s(r),v(n.attachments??[])}}}async function ea(){try{await tI(e)}catch{}V()}async function ei(t,n){try{await tM(e,t,n)}catch(e){RD.error(e instanceof Error?e.message:"审批操作失败")}V()}async function eo(t){return tE(e,t)}async function el(){try{let n=await tc(e,{message:"继续",modelRef:t,mode:"agent"});n&&o(n)}catch(e){RD.error(e instanceof Error?e.message:"继续失败")}}async function es(n){let r="string"==typeof n.modelRef?n.modelRef.trim():"",a="agent"===n.mode?"agent":"chat";try{let i=await td(e,{modelRef:r||t,mode:a,retryEventId:n.id});i&&o(i)}catch(e){RD.error(e instanceof Error?e.message:"对话重试失败")}}async function ec(){if(!w)return void j(void 0);N(!0);try{let t=await ty(e,w.id);o(t.detail),s(t.prompt),y([]);let n=[];t.revertedFiles>0&&n.push(`恢复 ${t.revertedFiles} 个文件`),t.deletedFiles>0&&n.push(`删除 ${t.deletedFiles} 个新增文件`),t.archivedSubagents>0&&n.push(`归档 ${t.archivedSubagents} 个子代理`),RD.success(n.length?`已回退:${n.join(",")}`:"已回退到此处"),t.skippedRemote&&t.skippedRemote.length>0&&RD.warning(`${t.skippedRemote.length} 个远程文件未自动回退,请在对应机器手动处理`)}catch(e){RD.error(e instanceof Error?e.message:"回退失败")}finally{N(!1),j(void 0)}}async function ed(t){if(!C){S(!0);try{await tN(e,t.id),RD.success("已创建分支对话")}catch(e){RD.error(e instanceof Error?e.message:"创建分支失败")}finally{S(!1)}}}function eu(){q?RD.error("对话正在运行,请先停止后再编辑上下文"):I(!0)}function ef(){I(!1),z(new Set),T(void 0),_("")}function em(e){z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function eh(e,t){let n=Y.findIndex(t=>t.id===e),r=Y.findIndex(e=>e.id===t);if(n<0||r<0)return;let a=Math.min(n,r),i=Math.max(n,r);z(e=>{let t=new Set(e);for(let e=a;e<=i;e++){let n=Y[e];n&&"user"!==n.kind&&t.add(n.id)}return t})}function ep(e){q?RD.error("对话正在运行,请先停止后再删除"):0!==e.length&&B(e)}async function eg(){if(!$||0===$.length)return void B(void 0);L(!0);try{let t=await tw(e,$);o(t.detail),z(new Set),RD.success(`已从上下文删除 ${t.deletedEvents||$.length} 条`)}catch(e){RD.error(e instanceof Error?e.message:"删除失败")}finally{L(!1),B(void 0)}}function ex(e,t){T(e),_(t)}async function ev(){if(!A)return void T(void 0);L(!0);try{let t=await tj(e,A,R);o(t.detail),T(void 0),_(""),RD.success("已更新消息")}catch(e){RD.error(e instanceof Error?e.message:"保存失败")}finally{L(!1)}}function eb(){T(void 0),_("")}async function ey(t,n){L(!0);try{let r=await tk(e,[t],n);o(r.detail)}catch(e){RD.error(e instanceof Error?e.message:n?"还原失败":"翻译失败")}finally{L(!1)}}let ew=P.useMemo(()=>{if(!X)return{mode:M,selectedIds:O,onToggleSelect:em,onRangeSelect:eh,onEnterMode:eu,onExitMode:ef,onDeleteOne:e=>ep([e]),editingId:A,editDraft:R,onStartEdit:ex,onEditDraftChange:_,onSaveEdit:()=>void ev(),onCancelEdit:eb,onTranslate:e=>void ey(e,!1),onRestore:e=>void ey(e,!0)}},[X,M,O,A,R]),ej=ew&&A?(0,E.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,E.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑消息"}),(0,E.jsx)(F.Button,{type:"button",size:"sm",variant:"ghost",disabled:D,onClick:eb,children:"取消"}),(0,E.jsx)(F.Button,{type:"button",size:"sm",disabled:D,onClick:()=>void ev(),children:"保存"})]}):ew&&M?(0,E.jsxs)("div",{className:"vtl-agent-composer-overlay mb-[-1px] flex items-center justify-end gap-2 rounded-t-xl border border-b-0 border-border bg-background px-3 py-2 text-sm",children:[(0,E.jsx)("span",{className:"mr-auto text-muted-foreground",children:"编辑上下文"}),(0,E.jsxs)(F.Button,{type:"button",size:"sm",variant:"destructive",disabled:D||0===O.size,onClick:()=>ep([...O]),children:["删除选中 (",O.size,")"]}),(0,E.jsx)(F.Button,{type:"button",size:"sm",variant:"ghost",onClick:ef,children:"退出编辑"})]}):void 0;function ek(e){return{id:e.id,ownerMachineId:e.ownerMachineId??K,name:e.name,subagentType:e.subagentType}}async function eN(e){let t=e.path?.trim()||e.name.trim();if(!t||"diff"===e.kind||"diff"===e.meta||e.meta?.toLowerCase().startsWith("depth"))return;let n=_O({machineId:e.machineId,path:t},{workspaceFolders:G,ownerMachineId:K});if((n.machineId??"local")==="local")try{let e=await fetch((0,H.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(n.path)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}}catch(e){RD.error(`打开文件失败:${e instanceof Error?e.message:String(e)}`)}}let eC=K??"local",eS=P.useMemo(()=>{let e=e=>/^https?:\/\//i.test(e)||e.startsWith("data:"),t=async e=>{let{target:t,kind:n,label:r}=e;try{if("url"===n)return void window.open(t,"_blank","noopener,noreferrer");if("local-file"===n){let e=await fetch((0,H.localAPIURL)(`/v1/files/reveal?path=${encodeURIComponent(t)}`),{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error??`reveal failed: ${e.status}`)}return}let e=(0,H.localAPIURL)(`/v1/remote/${encodeURIComponent(eC)}/files/raw?path=${encodeURIComponent(t)}`);await Ud({url:e,label:r}),RD.success(`已开始下载「${r}」,可在 系统设置 → 下载 查看进度`)}catch(e){RD.error(`打开交付物失败:${e instanceof Error?e.message:String(e)}`)}};return{resolveImageSrc:t=>{if(e(t))return t;let n=`path=${encodeURIComponent(t)}`;return"local"===eC?(0,H.localAPIURL)(`/v1/files/raw?${n}`):(0,H.localAPIURL)(`/v1/remote/${encodeURIComponent(eC)}/files/raw?${n}`)},classify:t=>e(t)?"url":"local"===eC?"local-file":"remote-file",onOpen:e=>void t(e)}},[eC]);return(0,E.jsxs)("div",{className:"vtl-immersive-project",children:[(0,E.jsx)("button",{type:"button",className:"vtl-immersive-project__home",onClick:a,title:"返回主页","aria-label":"返回主页",children:(0,E.jsx)(AS,{size:16,"aria-hidden":!0})}),(0,E.jsx)(RY,{className:"vtl-immersive-project__panel",events:Y,running:q,models:n,modelId:t,onModelChange:r,onSubmit:er,onStop:ea,composerValue:l,onComposerValueChange:s,hidePermissionMode:!0,attachments:x,onAttachmentsChange:v,onCardDrop:Uo,deliverable:eS,onOpenFile:eN,onOpenSubagent:function(e){e.id&&y([ek(e)])},onApprovalDecision:ei,onFetchExplanation:eo,onContinue:el,onRetry:es,onRecallUserMessage:function(e){q?RD.error("对话正在运行,请先停止后再回退"):j(e)},onBranchAssistantMessage:ed,contextEdit:ew,contextEditBar:ej,planPromptBar:(0,E.jsxs)(E.Fragment,{children:[ee?(0,E.jsx)(IQ,{reason:ee.reason,pending:m,onAdded:(e,t)=>void et(!0,e,t),onDismiss:()=>void et(!1)}):null,Q?(0,E.jsx)(MW,{requestedMode:Q.requestedMode??"",reason:Q.reason,pending:c,onAccept:()=>void en(!0),onReject:()=>void en(!1)}):null,(0,E.jsx)(IK,{conversationId:e,planState:W,modelRef:t,onResolved:()=>void V()})]})}),b.length>0&&i?(0,E.jsx)(RJ,{stack:b,rootTitle:i.conversation.title,rootOwnerMachineId:i.conversation.ownerMachineId,onNavigateRoot:()=>y([]),onNavigateIndex:e=>y(b.slice(0,e+1)),onOpenSubagent:function(e){e.id&&y(t=>[...t,ek(e)])}}):null,(0,E.jsx)(Rt,{open:void 0!==w,onOpenChange:e=>{e||k||j(void 0)},children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"回退对话到此处?"}),(0,E.jsx)(Rk,{children:"此操作会归档此处之后的所有对话记录,并把这期间(含子代理)对文件的修改全部还原到当前这条消息发送前的状态。该用户消息会回到输入框。回退无法撤销。"})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{disabled:k,children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",disabled:k,onClick:e=>{e.preventDefault(),ec()},children:k?"回退中…":"确认回退"})]})]})}),(0,E.jsx)(Rt,{open:void 0!==$,onOpenChange:e=>{e||D||B(void 0)},children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"从上下文中删除?"}),(0,E.jsx)(Rk,{children:`确认从上下文中删除选中的 ${$?.length??0} 条?此操作会同时从智能体的实际上下文中移除(不影响磁盘文件)。`})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{disabled:D,children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",disabled:D,onClick:e=>{e.preventDefault(),eg()},children:D?"删除中…":"确认删除"})]})]})}),(0,E.jsx)(RH,{})]})}function Up({openSeq:e,contextPreamble:t,models:n,modelRef:r,onModelChange:a,onClose:i,onEnterProject:o,onSplitToHome:l}){let[s,c]=P.useState(null);P.useEffect(()=>{let e=!1;return(async()=>{try{let t=await tu();e||c(t)}catch{}})(),()=>{e=!0}},[]);let d=s?.conversation.id??"";return(0,E.jsx)("div",{className:"vtl-immersive-quick",role:"dialog","aria-modal":"true","aria-label":"快捷操控",onClick:i,children:(0,E.jsx)("div",{className:"vtl-immersive-quick__panel",onClick:e=>e.stopPropagation(),children:d?(0,E.jsx)(T0,{conversationId:d,modelRef:r,initialMessage:"",contextPreamble:t,models:n,onModelChange:a,onEnterProject:(e,t)=>{i(),o?.(e,t)},onSplitToHome:e=>{i(),l?.(e)}},`${d}:${e}`):(0,E.jsx)("p",{className:"vtl-immersive-quick__loading",children:"正在唤起快捷操控…"})})})}function Ug({className:e,...t}){return(0,E.jsxs)("svg",{version:"1.1",viewBox:"0 0 1536 1024",className:(0,B.cn)("brand-mark",e),role:"img","aria-label":"Vantaloom",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...t,children:[(0,E.jsx)("path",{transform:"translate(658,393)",d:"m0 0 2 1v47l57 1v1l-12 2-45 5v89l2 14 4 7 6 3h12l8-2-5-10-1-4v-11l3-8 4-6 7-7 14-8 16-6 33-9h3l-1-16-4-8-6-5-10-3h-15l-13 3-16 7-7 5 1-4 8-8 14-8 12-4 7-1h23l16 4 9 6 4 5 4 9 1 5 1 69 2 11 3 5 7 5v1h-28l-6-4-4-11v-7h-2l-2 4-7 8-11 8-10 4-4 1h-21l-9-4-7-5-14 7-7 2h-18l-11-4-6-5-5-10-1-4-1-33v-61l1-4-26 3-9-7-4-3 4-1 34-2v-34l2-5zm107 104-19 6-17 8-10 9-4 8-1 4v11l3 8 8 7 7 2h8l10-3 10-7 6-7 1-2v-44z"}),(0,E.jsx)("path",{transform:"translate(1147,452)",d:"m0 0h15l11 3 10 9 5 10v3h2l2-5 10-10 12-7 11-3h18l10 3 6 4 7 8 4 12 1 9 1 62 3 12 4 5 3 3h-38l-1-86-2-9-5-7-7-3h-12l-10 3-9 6-7 8-1 88h-26l-1-88-3-9-5-6-6-2h-11l-9 3-9 7-4 6-1 89h-34l6-14 4-19 1-10v-28l-3-19-6-18-4-9h28l3 8 3 13 7-8 8-7 10-5z"}),(0,E.jsx)("path",{transform:"translate(556,449)",d:"m0 0h19l13 4 10 9 4 9 2 13 1 67 3 10 4 5 5 4h-40l-1-85-3-12-4-6-7-4-3-1h-14l-11 4-10 7-5 8-1 6-1 83h-25l-1-99-2-17 1-1h24l2 6 2 13 9-10 12-8 11-4z"}),(0,E.jsx)("path",{transform:"translate(409,450)",d:"m0 0h22l16 4 9 6 6 9 3 11 1 71 2 9 3 5 6 4v1h-27l-6-4-3-7-2-9-11 12-13 8-9 3-7 1h-13l-12-3-10-7-6-10-1-4v-13l5-12 4-5 12-9 18-8 35-10 6-2v-14l-3-8-5-5-7-3-4-1h-15l-13 3-20 10 6-9 10-7 13-5zm27 47-23 8-13 7-8 7-5 9-1 4v11l5 10 5 4 8 3h10l11-4 8-6 5-6 1-4v-43z"}),(0,E.jsx)("path",{transform:"translate(918,450)",d:"m0 0h22l15 3 16 8 12 11 7 8 7 14 3 11v21l-3 12-4 8-5-5-8-17-11-33-7-13-9-10-10-6-7-2h-12l-11 4-8 7-7 10-4 13-1 7v18l3 14 4 10 6 8 9 8 10 4 6 1h9l9-2 7-4 5 1 5 5v2l-10 5-13 3h-22l-15-4-16-8-10-9-6-7-7-14-3-14v-16l3-13 6-12 8-10 12-9 12-5z"}),(0,E.jsx)("path",{transform:"translate(224,442)",d:"m0 0h17l15 3 10 5 10 9 9 13 14 29 13 28 6 14v2h2l1-5 16-39 17-40 4-8h9l-2 6-18 42-11 26-17 40-9 21-3-1-29-58-10-19-12-23-8-11-9-10-9-7-10-4-5-1h-19l-15 3 4-4 13-6 16-4z"}),(0,E.jsx)("path",{transform:"translate(1010,450)",d:"m0 0h19l17 4 13 7 12 11 7 11 5 13 2 11v10l-3 16-4 10-9 12-8 7-12 7-13 4-7 1h-25l-16-4-13-7-11-9-7-9-7-14-2-9v-17l3-12 5-10 3-1 7 18 11 33 8 14 8 9 8 5 12 3h8l12-3 10-7 6-8 5-12 2-11v-19l-3-14-5-12-8-10-10-6-7-2h-13l-11 4-6 4-4-2-6-5 3-3 10-5z"}),(0,E.jsx)("path",{transform:"translate(848,371)",d:"m0 0h1l1 171 2 9 4 6 6 5 19 5 6 2v1h-65l-1-188z"})]})}function Ux({text:e,as:t="div",typingSpeed:n=50,initialDelay:r=0,pauseDuration:a=2e3,deletingSpeed:i=30,loop:o=!0,className:l="",showCursor:s=!0,hideCursorWhileTyping:c=!1,hideCursorOnComplete:d=!1,cursorCharacter:u="|",cursorClassName:f="",cursorBlinkDuration:m=.5,textColors:h=[],variableSpeed:p,onSentenceComplete:g,startOnVisible:x=!1,reverseMode:v=!1,...b}){let[y,w]=(0,P.useState)(""),[j,k]=(0,P.useState)(0),[N,C]=(0,P.useState)(!1),[S,M]=(0,P.useState)(0),[I,O]=(0,P.useState)(!x),z=(0,P.useRef)(null),A=(0,P.useMemo)(()=>Array.isArray(e)?e:[e],[e]),T=(0,P.useCallback)(()=>{if(!p)return n;let{min:e,max:t}=p;return Math.random()*(t-e)+e},[p,n]);(0,P.useEffect)(()=>{if(!x||!z.current)return;let e=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&O(!0)})},{threshold:.1});return e.observe(z.current),()=>e.disconnect()},[x]),(0,P.useEffect)(()=>{let e;if(!I)return;let t=A[S]??"",l=v?t.split("").reverse().join(""):t,s=()=>{if(N)if(""===y){if(C(!1),S===A.length-1&&!o)return;g&&g(A[S]??"",S),M(e=>(e+1)%A.length),k(0),e=setTimeout(()=>{},a)}else e=setTimeout(()=>{w(e=>e.slice(0,-1))},i);else if(j<l.length)e=setTimeout(()=>{w(e=>e+l[j]),k(e=>e+1)},p?T():n);else if(A.length>1){if(!o&&S===A.length-1)return;e=setTimeout(()=>{C(!0)},a)}};return 0!==j||N||""!==y?s():e=setTimeout(s,r),()=>clearTimeout(e)},[j,y,N,n,i,a,A,S,o,r,I,v,p,T,g]);let R=A[S]?.length??0,_=!o&&S===A.length-1&&j>=R&&!N,D=c&&(j<R||N)||d&&_;return(0,P.createElement)(t,{ref:z,className:(0,B.cn)("vtl-text-type",l),...b},(0,E.jsx)("span",{className:"vtl-text-type__content",style:{color:(0===h.length?"inherit":h[S%h.length])||"inherit"},children:y}),s&&(0,E.jsx)("span",{className:(0,B.cn)("vtl-text-type__cursor",f,D&&"vtl-text-type__cursor--hidden"),style:{"--vtl-cursor-blink":`${2*m}s`},children:u}))}function Uv({corner:e,stageClassName:t,className:n,children:r,...a}){return(0,E.jsxs)("div",{className:["vtl-splash",n].filter(Boolean).join(" "),...a,children:[(0,E.jsx)("div",{className:"welcome-layer",children:(0,E.jsx)("div",{className:["welcome-stage",t].filter(Boolean).join(" "),children:r})}),e]})}let Ub="你现在想和谁对话?";function Uy({hasRoutes:e,existingModels:t,onHeadline:n,onComplete:r}){let[a,i]=P.useState(e?"pickModel":"route"),[o,l]=P.useState([]),[s,c]=P.useState("");return(P.useEffect(()=>{n(e?Ub:"需要先配置模型路由")},[]),"route"===a)?(0,E.jsx)(IJ,{onSaved:(e,t,r)=>{let a=r??[];l(a),c(a[0]?.value??""),n(Ub),i("pickModel")}}):(0,E.jsxs)("div",{className:"vtl-immersive-panel",children:[(0,E.jsx)("div",{className:"vtl-immersive-models",children:(0,E.jsx)(IY,{mode:"single",models:e?t:o,value:s,onChange:c,clearLabel:"不选择",emptyHint:"没有可用模型"})}),(0,E.jsx)("div",{className:"vtl-immersive-panel__actions",children:(0,E.jsx)(F.Button,{onClick:()=>r(s),disabled:!s,children:"开始"})})]})}let Uw="别来无恙,想干点什么?",Uj=e=>new Promise(t=>setTimeout(t,e));function Uk({modelRef:e,onModelRef:t,onStartChat:n,initialDraft:r}){let{models:a}=nl(),i=P.useRef(""!==(r??"").trim()).current,[o,l]=P.useState(i?"ready":"brand"),[s,c]=P.useState(i?r??"":""),[d,u]=P.useState(!1),[f,m]=P.useState(!1),[h,p]=P.useState(i?[Uw]:[]),[g,x]=P.useState(!1),[v,b]=P.useState([]),y=P.useCallback(e=>{p(t=>t[t.length-1]===e?t:[...t,e])},[]),w=P.useCallback(e=>{c(e),"brand"!==o||d||""===e.trim()||u(!0)},[o,d]),j=P.useCallback(()=>{u(!1),l(e=>"brand"===e?"greeting":e),p(e=>0===e.length?[Uw]:e)},[]),k=P.useCallback(async t=>{let r=t.value.trim();if(""===r)return;m(!0);let[a]=await Promise.all([t0().then(e=>e.models).catch(()=>[]),Uj(320)]),i=a.filter(e=>!1!==e.available),o=""!==e&&i.some(t=>t.id===e);if(i.length>0&&o){p(e=>[...e,""]),await Uj(160),n(r);return}x(i.length>0),b(i.map(e=>({value:e.id,label:e.label,contextLength:e.contextLength??0,providerName:e.providerName,available:!0}))),l("onboarding")},[e,n]),N=P.useCallback(e=>{t(e),y(Uw),m(!1),l("ready")},[t,y]),C=P.useCallback(async e=>{let t=e.value.trim();""!==t&&(p(e=>[...e,""]),m(!0),await Uj(450),n(t))},[n]),S=P.useMemo(()=>a.map(e=>({id:e.value,label:e.label})),[a]);return(0,E.jsxs)(Uv,{stageClassName:"gap-6",corner:(0,E.jsx)(T6,{}),children:[(0,E.jsxs)("div",{className:"vtl-immersive-headline-slot",children:[(0,E.jsx)("div",{className:(0,B.cn)("vtl-immersive-brand",i&&"vtl-immersive-brand--erased",!i&&(d||"brand"!==o)&&"vtl-immersive-brand--erasing"),onAnimationEnd:d?j:void 0,children:(0,E.jsx)(Ug,{})}),"brand"!==o?(0,E.jsx)(Ux,{className:"vtl-immersive-headline",text:h.length>0?h:[Uw],loop:!1,typingSpeed:48,deletingSpeed:24,pauseDuration:420,cursorCharacter:"▍",hideCursorOnComplete:!0},"immersive-headline"):null]}),"onboarding"===o?(0,E.jsx)(Uy,{hasRoutes:g,existingModels:v,onHeadline:y,onComplete:N}):(0,E.jsx)("div",{className:(0,B.cn)("vtl-immersive-composer",f&&"vtl-immersive-composer--leaving"),children:(0,E.jsx)(MF,{minRows:3,value:s,onValueChange:w,onSubmit:"ready"===o?C:k,hideComposerOptions:"ready"!==o,hidePermissionMode:!0,models:"ready"===o?S:void 0,modelId:"ready"===o?e:void 0,onModelChange:"ready"===o?t:void 0,labels:{placeholder:"告诉智能体你想做什么…"}})})]})}let UN="vantaloom-immersive-model";function UC(){let{models:e}=nl(),[t,n]=P.useState("home"),[r,a]=P.useState(""),[i,o]=P.useState(""),[l,s]=P.useState(""),[c,d]=P.useState(""),[u,f]=P.useState(""),[m,h]=P.useState("chats"),[p,g]=P.useState([]),[x,v]=P.useState([]),[b,y]=P.useState(()=>window.localStorage.getItem(UN)??""),[w,j]=P.useState(!1),[k,N]=P.useState(0),C=P.useCallback(e=>{y(e),e&&window.localStorage.setItem(UN,e)},[]),S=P.useCallback(async()=>{try{g(await tf())}catch{}},[]),M=P.useCallback(async()=>{try{v(await tm())}catch{}},[]);P.useEffect(()=>{S(),M();let e=setInterval(()=>{S(),M()},3e3);return()=>clearInterval(e)},[S,M]);let I=P.useMemo(()=>e.map(e=>({id:e.value,label:e.label})),[e]),O=P.useMemo(()=>{if("project"===t&&i){let e=x.find(e=>e.id===i)?.title||"未命名项目";return`【当前上下文】用户当前打开的是项目「${e}」(id=${i})。`}if("chat"===t&&r){let e=p.find(e=>e.id===r)?.title||"新对话";return`【当前上下文】用户当前打开的是聊天「${e}」(id=${r})。`}return"【当前上下文】用户当前打开的是主页。"},[t,i,r,x,p]);P.useEffect(()=>{let e=e=>{"Space"!==e.code||!e.shiftKey||e.repeat||w?"Escape"===e.key&&w&&j(!1):(e.preventDefault(),N(e=>e+1),j(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w]);let z=P.useCallback(async e=>{try{let t=await th();a(t.conversation.id),d(e),n("chat"),S()}catch{n("home")}},[S]),A=P.useCallback(e=>{a(e),d(""),n("chat")},[]),T=P.useCallback((e,t)=>{e&&t&&(o(e),s(t),n("project"),M())},[M]),R=P.useCallback(async e=>{try{let t=(await tZ(e))[0];if(!t)return;o(e),s(t.id),n("project")}catch{}},[]),_=P.useCallback(()=>{n("home"),a(""),o(""),s(""),d(""),f(""),S(),M()},[S,M]),D=P.useCallback(e=>{n("home"),a(""),o(""),s(""),d(""),f((e??"").trim()),S(),M()},[S,M]),L=w?(0,E.jsx)(Up,{openSeq:k,contextPreamble:O,models:I,modelRef:b,onModelChange:C,onClose:()=>j(!1),onEnterProject:T,onSplitToHome:D}):null;return"project"===t&&l?(0,E.jsxs)("div",{className:"vtl-splash",children:[(0,E.jsx)(Uh,{conversationId:l,modelRef:b,models:I,onModelChange:C,onGoHome:_},l),(0,E.jsx)(T6,{}),L]}):(0,E.jsxs)(E.Fragment,{children:["chat"===t&&r?(0,E.jsxs)("div",{className:"vtl-splash",children:[(0,E.jsx)(T0,{conversationId:r,modelRef:b,initialMessage:c,models:I,onModelChange:C,onEnterProject:T,onSplitToHome:D},r),(0,E.jsx)(T6,{})]}):(0,E.jsx)(Uk,{modelRef:b,onModelRef:C,onStartChat:z,initialDraft:u}),(0,E.jsx)(US,{kind:m,onToggleKind:()=>h(e=>"chats"===e?"projects":"chats"),chats:p,projects:x,currentChatId:"chat"===t?r:"",currentProjectId:i,onOpenChat:A,onOpenProject:e=>void R(e),onGoHome:_}),L]})}function US({kind:e,onToggleKind:t,chats:n,projects:r,currentChatId:a,currentProjectId:i,onOpenChat:o,onOpenProject:l,onGoHome:s}){let c="chats"===e;return(0,E.jsxs)("div",{className:"vtl-immersive-rail",children:[(0,E.jsxs)("div",{className:"vtl-immersive-rail__head",children:[(0,E.jsx)("button",{type:"button",className:"vtl-immersive-rail__icon",onClick:s,title:"回到主页(开始新对话)","aria-label":"主页",children:(0,E.jsx)(eO,{size:16,"aria-hidden":!0})}),(0,E.jsx)("button",{type:"button",className:"vtl-immersive-rail__icon",onClick:t,title:c?"查看项目":"查看聊天","aria-label":"切换列表",children:c?(0,E.jsx)(eP,{size:16,"aria-hidden":!0}):(0,E.jsx)(eI,{size:16,"aria-hidden":!0})})]}),(0,E.jsx)("div",{className:"vtl-immersive-rail__list",children:c?0===n.length?(0,E.jsx)("p",{className:"vtl-immersive-rail__empty",children:"还没有聊天,去主页说点什么吧"}):n.slice(0,20).map(e=>(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("vtl-immersive-rail__row",e.id===a&&"vtl-immersive-rail__row--active"),onClick:()=>o(e.id),title:e.title||"新对话",children:[e.running?(0,E.jsx)("span",{className:"vtl-immersive-rail__dot","aria-hidden":!0}):null,(0,E.jsx)("span",{className:"vtl-immersive-rail__row-title",children:e.title||"新对话"})]},e.id)):0===r.length?(0,E.jsx)("p",{className:"vtl-immersive-rail__empty",children:"还没有项目(在对话里描述要在某个文件夹做的任务即可创建)"}):r.slice(0,20).map(e=>(0,E.jsx)("button",{type:"button",className:(0,B.cn)("vtl-immersive-rail__row",e.id===i&&"vtl-immersive-rail__row--active"),onClick:()=>l(e.id),title:e.title||"未命名项目",children:(0,E.jsx)("span",{className:"vtl-immersive-rail__row-title",children:e.title||"未命名项目"})},e.id))})]})}function UM(){return(0,E.jsx)(UC,{})}let UE=(0,z.default)("layout-panel-left",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]),UI=(0,z.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);function UP({conversationPanel:e,paneElements:t,panes:n,activeSlotCount:r,onOpenPalette:a,timeline:i,view:o,onPaneCountChange:l}){let[s,c]=P.useState(0),d=P.useMemo(()=>n.slice(0,r).map((e,t)=>({pane:e,index:t})).filter(e=>void 0!==e.pane),[n,r]),u=Math.min(s,Math.max(0,d.length-1));P.useEffect(()=>{s!==u&&c(u)},[s,u]),P.useEffect(()=>{l?.(d.length)},[l,d.length]);let f=n.slice(0,r).findIndex(e=>void 0===e);return(0,E.jsx)("div",{className:"vtl-app-background vtl-agent-conversation-workspace flex h-full min-h-0 flex-col",children:(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden",children:"conversation"===o?(0,E.jsxs)("div",{className:"relative size-full min-h-0",children:[i?(0,E.jsx)("div",{className:"pointer-events-none absolute left-1 top-2 z-30 flex justify-start",children:(0,E.jsx)("div",{className:"pointer-events-auto",children:i})}):null,(0,E.jsx)("div",{className:"size-full",children:e})]}):(0,E.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,E.jsxs)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 py-1.5",children:[d.map((e,t)=>(0,E.jsx)("button",{type:"button",className:(0,B.cn)("inline-flex h-9 min-w-[3rem] shrink-0 items-center justify-center rounded-md px-3 text-sm font-medium transition-colors",t===u?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/50"),onClick:()=>c(t),children:(0,E.jsx)("span",{className:"max-w-[8rem] truncate",children:e.pane.title})},e.pane.id)),(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"icon-sm",className:"ml-1 h-9 w-9 shrink-0",onClick:()=>{let e=f>=0?f:u;a(d[e]?.index??e)},children:(0,E.jsx)(eO,{className:"size-4"})})]}),(0,E.jsx)("div",{className:"min-h-0 flex-1",children:d.length>0?(0,E.jsx)("div",{className:"size-full",children:t[d[u]?.index??0]}):(0,E.jsx)("div",{className:"grid size-full place-items-center p-4",children:(0,E.jsxs)(F.Button,{type:"button",variant:"outline",size:"sm",className:"rounded-full",onClick:()=>a(0),children:[(0,E.jsx)(eO,{className:"size-4"}),"添加组件"]})})})]})})})}function UO({view:e,onViewChange:t,paneCount:n}){return(0,E.jsxs)("div",{className:"flex items-center rounded-lg border border-border bg-background/60 p-0.5",children:[(0,E.jsx)("button",{type:"button","aria-label":"对话","aria-pressed":"conversation"===e,onClick:()=>t("conversation"),className:(0,B.cn)("flex size-8 items-center justify-center rounded-md transition-colors [&_svg]:size-4","conversation"===e?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,E.jsx)(UI,{})}),(0,E.jsxs)("button",{type:"button","aria-label":"工作区","aria-pressed":"workspace"===e,onClick:()=>t("workspace"),className:(0,B.cn)("relative flex size-8 items-center justify-center rounded-md transition-colors [&_svg]:size-4","workspace"===e?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,E.jsx)(UE,{}),n>0?(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 grid h-3.5 min-w-3.5 place-items-center rounded-full bg-primary px-0.5 text-[0.5rem] font-semibold leading-none text-primary-foreground",children:n}):null]})]})}function Uz(e){return!e||"local"===e}async function UA(e,t){return UD(await UL(t,`/${encodeURIComponent(e)}`),t)}async function UT(e,t){return UD(await UL(t,"",{method:"POST",body:JSON.stringify({title:e.title,nodes:e.nodes.map(Ut),edges:e.edges.map(Un)})}),t)}async function UR(e,t,n){return UD(await UL(n,`/${encodeURIComponent(e)}/save`,{method:"PUT",body:JSON.stringify({nodes:t.nodes.map(Ut),edges:t.edges.map(Un),nodeIds:t.nodeIds})}),n)}async function U_(e,t){return UD(await UL(t,`/${encodeURIComponent(e)}/open`,{method:"POST"}),t)}function UD(e,t){var n,r;let a;return{canvas:(n=e.canvas,a=Uz(r=t)?n.ownerMachineId??"local":r,{id:n.id,title:n.title||"新画布",ownerMachineId:a,nodeCount:n.nodeCount??0,running:n.running??!1,createdAt:n.createdAt,updatedAt:n.updatedAt,lastOpenedAt:n.lastOpenedAt}),nodes:e.nodes??[],edges:e.edges??[]}}async function UL(e,t,n,r){let a=await fetch((0,H.localAPIURL)(Uz(e)?`/api/local/canvas${t}`:`/v1/remote/${e}/canvas${t}`),{cache:"no-store",...n,headers:{...n?.body?{"Content-Type":"application/json"}:{},...n?.headers}});if(r?.allowNotFound&&404===a.status)return;let i=await a.json().catch(()=>({}));if(!a.ok)throw Error("string"==typeof i?.error?i.error:"canvas api failed");return i}let U$={product:"Vantaloom",overview:"运维总览",subtitle:"本机服务、工作组机器和 Agent 运行状态。",workgroup:"工作组",health:"系统健康",cost:"今日消耗",activeRuns:"运行中",queue:"排队任务",machineStatus:"机器状态",resourceTrend:"资源趋势",runMix:"运行构成",schedule:"日程提醒",incidents:"关注事项",online:"在线",local:"本机",p2p:"P2P",direct:"直连",sleeping:"休眠",memory:"内存",cpu:"CPU",gpu:"GPU",disk:"磁盘",theme:"主题",immersiveMode:"切换到沉浸模式"},UF={search:"搜索控制台...",dashboard:"仪表盘",canvas:"工程",machines:"机器",schedules:"日程",settings:"设置",overview:"总览",runs:"运行",telemetry:"遥测",canvasRecent:"打开最近工程",canvasNew:"新建工程",canvasAll:"浏览所有画布",projectCanvas:"画布",projectKanban:"看板",projectSettings:"工程设置",projectNewConversation:"新建对话",projectEmpty:"暂无工程",conversationRecent:"打开最近对话",conversationNew:"新建 Agent 对话",conversationAll:"浏览所有对话",fleet:"机器组",access:"访问控制",calendar:"计划任务",billing:"用量与账单"},UB=(0,z.default)("brain-circuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]),UV=(0,z.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),UH=(0,z.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),UU=(0,z.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Uq=(0,z.default)("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),UW=(0,z.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),UK=(0,z.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function UG(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map,r=[];for(let a of e){let e=a.forkOriginId;if(e&&t.has(e)){let t=n.get(e)??[];t.push(a),n.set(e,t)}else r.push(a)}return{byId:t,childrenOf:n,roots:r}}function UX(e){let{childrenOf:t,roots:n}=UG(e),r=[],a=e=>{for(let n of(r.push(e),t.get(e.id)??[]))a(n)};for(let e of n)a(e);return r}function UY(e,t,n,r,a){let i=new Set(e);if("range"===n&&a){let n=r.indexOf(a),o=r.indexOf(t);if(-1!==n&&-1!==o){let[a,l]=n<o?[n,o]:[o,n],s=!e.has(t);for(let e=a;e<=l;e++){let t=r[e];t&&(s?i.add(t):i.delete(t))}return i}}return i.has(t)?i.delete(t):i.add(t),i}let UZ={"new-canvas":"canvas","all-canvases":"canvas","open-recent-canvas":"canvas","new-project":"canvas","project-overview":"canvas","project-settings":"canvas","project-conversation":"canvas",kanban:"canvas","new-agent-conversation":"agent","open-recent-conversation":"agent",preferences:"settings","preferences-models":"settings","preferences-agents":"settings","system-general":"settings","network-downloads":"settings","dump-history":"settings","preferences-model-routes":"settings","preferences-model-groups":"settings","preferences-agent-config":"settings","preferences-subagent-config":"settings","preferences-cc-engine-config":"settings","preferences-assets":"settings","preferences-layout":"settings","preferences-official-extensions":"settings","network-topology":"settings","network-settings":"settings","search-settings":"settings","system-downloads":"settings","check-update":"settings","balance-usage":"settings",feedback:"settings",account:"settings"},UJ=[{id:"model",title:"模型设置",icon:(0,E.jsx)(_q,{}),items:[{id:"preferences-models",label:"模型",icon:(0,E.jsx)(UB,{})},{id:"preferences-agents",label:"代理",icon:(0,E.jsx)(CB,{})},{id:"preferences-cc-engine-config",label:"CC 引擎",icon:(0,E.jsx)(_q,{})}]},{id:"prefs",title:"偏好设置",icon:(0,E.jsx)(UK,{}),items:[{id:"preferences-assets",label:"扩展 / 资产",icon:(0,E.jsx)(nh,{})},{id:"preferences-layout",label:"布局排版",icon:(0,E.jsx)(UH,{})},{id:"preferences-official-extensions",label:"官方扩展",icon:(0,E.jsx)(UV,{})}]},{id:"system",title:"系统设置",icon:(0,E.jsx)(UW,{}),items:[{id:"system-general",label:"系统与账户",icon:(0,E.jsx)(UW,{})},{id:"network-downloads",label:"网络与下载",icon:(0,E.jsx)(UU,{})},{id:"dump-history",label:"请求历史 / 诊断",icon:(0,E.jsx)(Uq,{})},{id:"search-settings",label:"搜索设置",icon:(0,E.jsx)(IX,{})}]}],UQ=(0,z.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),U0=(0,z.default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),U1=(0,z.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),U2=(0,z.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var U5=e.i(91e3);function U3(){let{user:e}=eE(),t=e?.name??U$.product,n=(e?.name??"V").slice(0,1).toUpperCase();return(0,E.jsx)("div",{className:"mt-auto pt-3",children:(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:(0,E.jsxs)("button",{type:"button","data-tour":"account-button",className:"flex w-full items-center justify-between rounded-xl p-2 transition-colors hover:bg-muted",children:[(0,E.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,E.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border/60 bg-muted text-[10px] font-semibold text-foreground",children:n}),(0,E.jsx)("span",{className:"truncate text-sm text-foreground",children:t})]}),(0,E.jsx)(MC,{className:"size-4 shrink-0 -rotate-90 text-muted-foreground"})]})}),(0,E.jsxs)(MM,{side:"top",align:"start",sideOffset:8,className:"w-[var(--radix-dropdown-menu-trigger-width)] min-w-60",children:[e?.email&&(0,E.jsx)(MP,{className:"truncate font-normal text-muted-foreground",children:e.email}),(0,E.jsxs)(ME,{disabled:!0,children:[(0,E.jsx)(UQ,{}),(0,E.jsx)("span",{className:"flex-1",children:"语言"}),(0,E.jsx)("span",{className:"text-xs text-muted-foreground",children:"中文"})]}),(0,E.jsxs)(ME,{disabled:!0,children:[(0,E.jsx)(Iq,{}),(0,E.jsx)("span",{className:"flex-1",children:"获取帮助"})]}),(0,E.jsx)(MO,{}),(0,E.jsx)(U4,{}),(0,E.jsx)(U8,{}),e&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(MO,{}),(0,E.jsx)(U7,{})]})]})]})})}function U4(){let{enterImmersive:e}=eN();return(0,E.jsxs)(ME,{onSelect:()=>e(),children:[(0,E.jsx)(nh,{}),(0,E.jsx)("span",{className:"flex-1",children:U$.immersiveMode})]})}let U6=["light","dark","jelly"];function U8(){let{resolvedTheme:e,setTheme:t}=(0,T1.useTheme)(),[n,r]=P.useState(U5.defaultAppearanceTheme);P.useEffect(()=>{let e=window.localStorage.getItem(U5.appearanceThemeStorageKey)??U5.defaultAppearanceTheme;r(e),(0,U5.applyAppearanceTheme)({theme:e})},[]);let a=n===U5.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=U6[(U6.indexOf(a)+1)%U6.length]??"light";function o(e){r(e),window.localStorage.setItem(U5.appearanceThemeStorageKey,e),(0,U5.applyAppearanceTheme)({theme:e})}let l="dark"===a?U1:U2;return(0,E.jsxs)(ME,{onSelect:e=>{e.preventDefault(),function(){if("jelly"===i){t("dark"),o(U5.jellyAppearanceTheme);return}o(U5.defaultAppearanceTheme),t(i)}()},children:[(0,E.jsx)(l,{}),(0,E.jsx)("span",{className:"flex-1",children:U$.theme}),(0,E.jsx)("span",{className:"text-xs capitalize text-muted-foreground",children:a})]})}function U7(){let{logout:e}=eE();return(0,E.jsxs)(ME,{variant:"destructive",onSelect:()=>{e().then(()=>{window.location.reload()})},children:[(0,E.jsx)(U0,{}),(0,E.jsx)("span",{className:"flex-1",children:"退出登录"})]})}let U9=(0,z.default)("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]),qe="__all__",qt={status:"all",location:qe,sort:"recent"};function qn(e,t,n=!0){let r=P.useRef(e);r.current=e;let a=P.useRef(!1);P.useEffect(()=>{if(!n)return;let e=!1,i=async()=>{if(!e&&!a.current){a.current=!0;try{await r.current()}finally{a.current=!1}}};i();let o=setInterval(()=>{"visible"===document.visibilityState&&i()},t),l=()=>{"visible"===document.visibilityState&&i()};return document.addEventListener("visibilitychange",l),()=>{e=!0,clearInterval(o),document.removeEventListener("visibilitychange",l)}},[t,n])}function qr(e){let[t,n]=P.useState(0),r=P.useRef(e);return P.useEffect(()=>{e&&!r.current&&n(e=>e+1),r.current=e},[e]),t}let qa=(0,z.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),qi=P.useLayoutEffect;function qo({open:e,className:t,children:n}){let r=P.useRef(null),[a,i]=P.useState(e),[o,l]=P.useState(e?"auto":0),s=P.useRef(!0);return P.useEffect(()=>{e&&i(!0)},[e]),qi(()=>{if(s.current){s.current=!1,l(e?"auto":0);return}let t=r.current;if(!t)return;let n=t.scrollHeight;if(e){l(n);let e=window.setTimeout(()=>l("auto"),200);return()=>window.clearTimeout(e)}l(n);let a=window.requestAnimationFrame(()=>l(0));return()=>window.cancelAnimationFrame(a)},[e]),(0,E.jsx)("div",{"aria-hidden":!e,className:(0,B.cn)("overflow-hidden transition-[height] ease-out",e?"duration-200":"duration-150",t),style:{height:o},children:(0,E.jsx)("div",{ref:r,children:a?n:null})})}function ql({count:e,archived:t,onArchive:n,onDelete:r,onCancel:a}){let[i,o]=P.useState(!1);return(0,E.jsxs)("div",{className:"mb-3 flex items-center gap-1.5 rounded-lg border border-border bg-muted/60 px-2.5 py-1.5 text-[13px]",children:[(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["已选 ",e," 项"]}),(0,E.jsxs)("button",{type:"button",onClick:n,title:t?"取消归档":"归档",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-foreground/80 transition-colors hover:bg-background/70 hover:text-foreground [&_svg]:size-3.5",children:[t?(0,E.jsx)(qa,{}):(0,E.jsx)(Av,{}),t?"取消归档":"归档"]}),(0,E.jsxs)("button",{type:"button",onClick:()=>o(!0),title:"删除",className:"flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-destructive transition-colors hover:bg-destructive/10 [&_svg]:size-3.5",children:[(0,E.jsx)(ML,{}),"删除"]}),(0,E.jsx)("button",{type:"button",onClick:a,className:"shrink-0 rounded-md px-2 py-1 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:"取消"}),(0,E.jsx)(Rt,{open:i,onOpenChange:o,children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:"删除会话"}),(0,E.jsxs)(Rk,{children:["确认删除选中的 ",e," 个对话?此操作无法撤销。"]})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",onClick:r,children:"删除"})]})]})})]})}let qs=P.memo(function({title:e,label:t,labelNode:n,active:r,running:a,depth:i=0,onOpen:o,onOpenSettings:l,onRename:s,onDelete:c,onFork:d,onArchive:u,onUnarchive:f,selectionMode:m,selected:h,onToggleSelect:p,deleteLabel:g="删除"}){let[x,v]=P.useState(!1),[b,y]=P.useState(!1),[w,j]=P.useState(t),k=!!p,N=!!(l||s||c||d||u||f),C=i>0,S=()=>{j(t),y(!0)},M=(0,E.jsxs)(E.Fragment,{children:[l?(0,E.jsxs)(E5,{onSelect:()=>l(),children:[(0,E.jsx)(UK,{}),(0,E.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,s?(0,E.jsxs)(E5,{onSelect:()=>S(),children:[(0,E.jsx)(IW,{}),(0,E.jsx)("span",{className:"flex-1",children:"重命名"})]}):null,d?(0,E.jsxs)(E5,{onSelect:()=>d(),children:[(0,E.jsx)(Ef,{}),(0,E.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,u?(0,E.jsxs)(E5,{onSelect:()=>u(),children:[(0,E.jsx)(Av,{}),(0,E.jsx)("span",{className:"flex-1",children:"归档"})]}):null,f?(0,E.jsxs)(E5,{onSelect:()=>f(),children:[(0,E.jsx)(qa,{}),(0,E.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,c?(0,E.jsxs)(E5,{variant:"destructive",onSelect:()=>v(!0),children:[(0,E.jsx)(ML,{}),(0,E.jsx)("span",{className:"flex-1",children:g})]}):null]}),I=(0,E.jsxs)("div",{className:(0,B.cn)("group relative flex items-center rounded-lg text-[13px] transition-colors animate-in fade-in-0 slide-in-from-left-1 duration-200",h?"bg-primary/10 text-foreground":r?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),style:C?{marginLeft:14*i}:void 0,children:[m&&k?(0,E.jsx)("button",{type:"button","aria-label":h?"取消选择":"选择","aria-pressed":h,onClick:e=>{e.preventDefault(),e.stopPropagation(),p?.(e.shiftKey?"range":"toggle")},className:(0,B.cn)("ml-2 flex size-4 shrink-0 items-center justify-center rounded border",h?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/50 bg-transparent"),children:h?(0,E.jsx)(CV,{className:"size-3"}):null}):null,(0,E.jsxs)("button",{type:"button",title:e,onClick:e=>{if(k&&(m||e.metaKey||e.ctrlKey||e.shiftKey)){e.preventDefault(),p?.(e.shiftKey?"range":"toggle");return}o()},className:"flex min-w-0 flex-1 items-center gap-3 rounded-lg px-3 py-2 text-left",children:[C?(0,E.jsx)("span",{"aria-hidden":!0,className:"h-4 w-0.5 shrink-0 rounded-full bg-primary/40"}):null,a?(0,E.jsx)("span",{className:"size-1.5 shrink-0 animate-pulse rounded-full bg-green-500","aria-label":"运行中"}):(0,E.jsx)(qu,{active:r}),n??(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]}),N&&!m?(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:(0,E.jsx)("button",{type:"button","aria-label":"更多操作",className:"mr-1 shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-background/70 hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 aria-expanded:opacity-100",children:(0,E.jsx)(MD,{className:"size-4"})})}),(0,E.jsxs)(MM,{align:"end",sideOffset:4,className:"min-w-44",children:[l?(0,E.jsxs)(ME,{onSelect:()=>l(),children:[(0,E.jsx)(UK,{}),(0,E.jsx)("span",{className:"flex-1",children:"打开设置界面"})]}):null,s?(0,E.jsxs)(ME,{onSelect:()=>S(),children:[(0,E.jsx)(IW,{}),(0,E.jsx)("span",{className:"flex-1",children:"重命名"})]}):null,d?(0,E.jsxs)(ME,{onSelect:()=>d(),children:[(0,E.jsx)(Ef,{}),(0,E.jsx)("span",{className:"flex-1",children:"分支对话"})]}):null,u?(0,E.jsxs)(ME,{onSelect:()=>u(),children:[(0,E.jsx)(Av,{}),(0,E.jsx)("span",{className:"flex-1",children:"归档"})]}):null,f?(0,E.jsxs)(ME,{onSelect:()=>f(),children:[(0,E.jsx)(qa,{}),(0,E.jsx)("span",{className:"flex-1",children:"取消归档"})]}):null,c?(0,E.jsxs)(ME,{variant:"destructive",onSelect:()=>v(!0),children:[(0,E.jsx)(ML,{}),(0,E.jsx)("span",{className:"flex-1",children:g})]}):null]})]}):null]});return(0,E.jsxs)(E.Fragment,{children:[N?(0,E.jsxs)(EK,{children:[(0,E.jsx)(EX,{asChild:!0,children:I}),(0,E.jsx)(E2,{className:"min-w-44",children:M})]}):I,s?(0,E.jsx)(Pe,{open:b,onOpenChange:y,children:(0,E.jsxs)(P1,{className:"sm:max-w-md",children:[(0,E.jsxs)(P2,{children:[(0,E.jsx)(P3,{children:"重命名"}),(0,E.jsx)(P4,{children:"重命名后名称将被固定,不再自动生成。留空保存可恢复自动命名。"})]}),(0,E.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s?.(w),y(!1)},children:[(0,E.jsx)(V,{autoFocus:!0,value:w,onChange:e=>j(e.target.value),placeholder:"留空以恢复自动命名",onFocus:e=>e.currentTarget.select()}),(0,E.jsxs)(P5,{className:"mt-4",children:[(0,E.jsx)(F.Button,{type:"button",variant:"ghost",onClick:()=>y(!1),children:"取消"}),(0,E.jsx)(F.Button,{type:"submit",children:"保存"})]})]})]})}):null,c?(0,E.jsx)(Rt,{open:x,onOpenChange:v,children:(0,E.jsxs)(Rb,{children:[(0,E.jsxs)(Ry,{children:[(0,E.jsx)(Rj,{children:g}),(0,E.jsxs)(Rk,{children:["确认删除「",t,"」?此操作无法撤销。"]})]}),(0,E.jsxs)(Rw,{children:[(0,E.jsx)(RC,{children:"取消"}),(0,E.jsx)(RN,{variant:"destructive",onClick:()=>c(),children:"删除"})]})]})}):null]})}),qc=P.forwardRef(function({icon:e,label:t,onClick:n,...r},a){return(0,E.jsxs)("button",{ref:a,type:"button",onClick:n,className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted",...r,children:[(0,E.jsx)(e,{className:"size-4 shrink-0 text-muted-foreground"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})});function qd(){return(0,E.jsxs)("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-[13px] text-muted-foreground/70",role:"status","aria-live":"polite",children:[(0,E.jsx)(_,{className:"size-4 animate-spin"}),(0,E.jsx)("span",{children:"加载中…"})]})}function qu({active:e}){return(0,E.jsx)("span",{className:(0,B.cn)("size-1.5 shrink-0 rounded-full",e?"bg-primary":"border border-muted-foreground/50 bg-transparent")})}let qf={all:"全部",running:"运行中",idle:"空闲",archived:"已归档"},qm={recent:"最近活动",name:"名称"};function qh({filter:e,onChange:t,active:n,locations:r,locationLabel:a}){let i=zF(),o=e.location===qe?"全部":a(e.location),l=(0,E.jsxs)("button",{type:"button",title:"筛选","aria-label":"筛选",className:(0,B.cn)("relative rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",n&&"text-foreground"),children:[(0,E.jsx)(MB,{className:"size-4"}),n?(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full border border-sidebar bg-primary"}):null]});return i?(0,E.jsxs)(zR,{direction:"bottom",children:[(0,E.jsx)(Pn,{asChild:!0,children:l}),(0,E.jsxs)(zD,{children:[(0,E.jsx)(zL,{children:(0,E.jsx)(z$,{children:"筛选与排序"})}),(0,E.jsxs)("div",{className:"max-h-[60vh] overflow-y-auto px-4 pb-6",children:[(0,E.jsx)(qp,{title:"状态",children:Object.keys(qf).map(n=>(0,E.jsx)(qg,{label:qf[n],selected:e.status===n,onSelect:()=>t({...e,status:n})},n))}),(0,E.jsxs)(qp,{title:"运行位置",children:[(0,E.jsx)(qg,{label:"全部",selected:e.location===qe,onSelect:()=>t({...e,location:qe})}),r.map(n=>(0,E.jsx)(qg,{label:a(n),selected:e.location===n,onSelect:()=>t({...e,location:n})},n))]}),(0,E.jsx)(qp,{title:"排序",children:Object.keys(qm).map(n=>(0,E.jsx)(qg,{label:qm[n],selected:e.sort===n,onSelect:()=>t({...e,sort:n})},n))}),n?(0,E.jsx)("button",{type:"button",onClick:()=>t(qt),className:"mt-4 flex h-11 w-full items-center justify-center rounded-lg border border-border text-[15px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:"重置筛选"}):null]})]})]}):(0,E.jsxs)(Mu,{children:[(0,E.jsx)(Mm,{asChild:!0,children:l}),(0,E.jsxs)(MM,{align:"end",sideOffset:4,className:"min-w-56",children:[(0,E.jsx)(MP,{children:"筛选与排序"}),(0,E.jsxs)(MS,{children:[(0,E.jsxs)(MA,{children:[(0,E.jsx)("span",{className:"flex-1",children:"状态"}),(0,E.jsx)("span",{className:"text-xs text-muted-foreground",children:qf[e.status]})]}),(0,E.jsx)(MT,{children:(0,E.jsxs)(Mb,{value:e.status,onValueChange:n=>t({...e,status:n}),children:[(0,E.jsx)(MI,{value:"all",children:"全部"}),(0,E.jsx)(MI,{value:"running",children:"运行中"}),(0,E.jsx)(MI,{value:"idle",children:"空闲"}),(0,E.jsx)(MI,{value:"archived",children:"已归档"})]})})]}),(0,E.jsxs)(MS,{children:[(0,E.jsxs)(MA,{children:[(0,E.jsx)("span",{className:"flex-1",children:"运行位置"}),(0,E.jsx)("span",{className:"max-w-24 truncate text-xs text-muted-foreground",children:o})]}),(0,E.jsx)(MT,{className:"max-h-72 overflow-y-auto",children:(0,E.jsxs)(Mb,{value:e.location,onValueChange:n=>t({...e,location:n}),children:[(0,E.jsx)(MI,{value:qe,children:"全部"}),r.map(e=>(0,E.jsx)(MI,{value:e,children:(0,E.jsx)("span",{className:"truncate",children:a(e)})},e))]})})]}),(0,E.jsx)(MO,{}),(0,E.jsx)(MP,{children:"排序"}),(0,E.jsxs)(Mb,{value:e.sort,onValueChange:n=>t({...e,sort:n}),children:[(0,E.jsx)(MI,{value:"recent",children:qm.recent}),(0,E.jsx)(MI,{value:"name",children:qm.name})]}),n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(MO,{}),(0,E.jsx)(ME,{onSelect:()=>t(qt),children:(0,E.jsx)("span",{className:"flex-1",children:"重置筛选"})})]}):null]})]})}function qp({title:e,children:t}){return(0,E.jsxs)("div",{className:"mb-4 last:mb-0",children:[(0,E.jsx)("p",{className:"mb-1 px-1 text-xs font-medium text-muted-foreground",children:e}),(0,E.jsx)("div",{className:"space-y-0.5",children:t})]})}function qg({label:e,selected:t,onSelect:n}){return(0,E.jsxs)("button",{type:"button",role:"radio","aria-checked":t,onClick:n,className:(0,B.cn)("flex h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-[15px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),t?(0,E.jsx)(CV,{className:"size-4 shrink-0 text-primary"}):null]})}function qx({engine:e}){if("vantaloom"===e)return null;let t="claude-code"===e;return(0,E.jsxs)("span",{title:t?"Claude Code":"reclaude",className:(0,B.cn)("relative inline-flex shrink-0 select-none items-center justify-center rounded px-1 py-px text-[9px] font-semibold leading-none tracking-wide",t?"bg-violet-500/15 text-violet-600 dark:bg-violet-400/20 dark:text-violet-300":"bg-sky-500/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300"),children:[t?"CC":"RC",!t&&(0,E.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-sky-400 dark:bg-sky-300"})]})}let qv=P.memo(function({conversation:e,active:t,depth:n=0,onOpenConversation:r,onOpenConversationSettings:a,onRename:i,onDelete:o,onFork:l,onArchive:s,onUnarchive:c,selectionMode:d,selected:u,onToggleSelect:f}){let m=!0===e.running,h=e.settings?.engine??"vantaloom",p=!!e.projectId,g="vantaloom"!==h?(0,E.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:[(0,E.jsx)(qx,{engine:h}),(0,E.jsx)("span",{className:"truncate",children:e.title})]}):void 0;return(0,E.jsx)(qs,{title:m?`${e.title} \xb7 运行中`:e.title,label:e.title,labelNode:g,active:t,running:m,depth:n,onOpen:()=>r(e.id,e.ownerMachineId),onOpenSettings:a&&!p?()=>a(e.id,e.ownerMachineId):void 0,onRename:i?t=>i(e,t):void 0,onDelete:o?()=>o(e):void 0,onFork:l?()=>l(e):void 0,onArchive:s,onUnarchive:c,selectionMode:d,selected:u,onToggleSelect:f,deleteLabel:"删除会话"})});function qb(e,t){return!!(e.running||t.has(e.id))||(e.children??[]).some(e=>qb(e,t))}let qy=P.memo(function e({nodes:t,depth:n,ancestors:r,activeIds:a,activeLeafId:i,onOpen:o}){let l=t.filter(e=>qb(e,a));return 0===l.length?null:(0,E.jsx)("div",{className:"space-y-0.5",children:l.map(t=>{let l=Ij(t.subagentType),s=l.Icon,c=[...r,{id:t.id,ownerMachineId:t.ownerMachineId,name:t.subagentName,subagentType:t.subagentType}],d=t.id===i,u=t.children??[],f=u.some(e=>qb(e,a));return(0,E.jsxs)("div",{children:[(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-xs transition-colors",d?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),style:{paddingLeft:18+14*n},onClick:()=>o?.(c),title:t.subagentName||l.label,children:[(0,E.jsx)("span",{className:"shrink-0 text-muted-foreground/40",children:"└"}),(0,E.jsx)(s,{className:(0,B.cn)("size-3.5 shrink-0",l.color)}),(0,E.jsx)("span",{className:"truncate",children:t.subagentName||`${l.label}子代理`}),t.running?(0,E.jsx)(_,{className:"ml-auto size-3 shrink-0 animate-spin text-muted-foreground"}):null]}),(0,E.jsx)(qo,{open:f,children:(0,E.jsx)(e,{nodes:u,depth:n+1,ancestors:c,activeIds:a,activeLeafId:i,onOpen:o})})]},t.id)})})},(e,t)=>e.nodes===t.nodes&&e.activeIds===t.activeIds&&e.activeLeafId===t.activeLeafId&&e.depth===t.depth&&e.ancestors===t.ancestors&&e.onOpen===t.onOpen);function qw({activeConversationId:e,onItemSelect:t,onOpenConversation:n,onOpenConversationSettings:r,onConversationDeleted:a,subagentTree:i,activeSubagentPath:o,onOpenSubagent:l}){let[s,c]=P.useState(qt),d="archived"===s.status,{recents:u,refresh:f,loading:m,machineNames:h}=function(e){let[t,n]=P.useState([]),[r,a]=P.useState(!0),[i,o]=P.useState({}),l=P.useRef(!0),s=P.useCallback(async()=>{try{let{machineNames:t}=await eK({includeArchived:e,onPartial:e=>{l.current&&(n([...e].filter(e=>!e.projectId).sort((e,t)=>t.updatedAt>e.updatedAt?1:-1)),a(!1))}});if(!l.current)return;o(t)}catch{}finally{l.current&&a(!1)}},[e]);P.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);let c=P.useRef(e);return P.useEffect(()=>{c.current!==e&&(c.current=e,s())},[e,s]),qn(s,1e4),{recents:t,refresh:()=>void s(),loading:r,machineNames:i}}(d),[p,g]=P.useState(()=>new Set),x=P.useRef(null),v=P.useMemo(()=>{let e=new Set;for(let t of u)e.add(t.ownerMachineId||e$);return Array.from(e)},[u]),b=P.useCallback(e=>eF(e)?"本机":h[e]??e,[h]),y=P.useMemo(()=>{let e=u.filter(e=>{let t=!0===e.running,n=!!e.archivedAt;if("archived"===s.status){if(!n)return!1}else if(n)return!1;return("running"!==s.status||!!t)&&("idle"!==s.status||!t)&&(s.location===qe||(e.ownerMachineId||e$)===s.location)});return"name"===s.sort?e.sort((e,t)=>e.title.localeCompare(t.title,"zh-CN",{sensitivity:"base"})):e.sort((e,t)=>t.updatedAt>e.updatedAt?1:-1),e},[u,s]),w=P.useMemo(()=>y.filter(e=>!0===e.running),[y]),j=P.useMemo(()=>y.filter(e=>!0!==e.running),[y]),k=s.status!==qt.status||s.location!==qt.location||s.sort!==qt.sort,N=m&&0===u.length,C=P.useCallback(async e=>{try{await te(e.id,e.ownerMachineId)}catch{}a?.(e.id),f()},[a,f]),S=P.useCallback(async e=>{try{let t=await tN(e.id,void 0,e.ownerMachineId);await f(),n(t.conversation.id,t.conversation.ownerMachineId)}catch{}},[f,n]),M=P.useCallback(async e=>{try{await tn(e.id,e.ownerMachineId)}catch{}f()},[f]),I=P.useCallback(async(e,t)=>{try{await tt(e.id,t,e.ownerMachineId)}catch{}f()},[f]),O=P.useCallback(async e=>{try{await tr(e.id,e.ownerMachineId)}catch{}f()},[f]),z=P.useMemo(()=>[...UX(w),...UX(j)],[w,j]),A=P.useMemo(()=>z.map(e=>e.id),[z]),T=P.useCallback((e,t)=>{g(n=>UY(n,e,t,A,x.current)),x.current=e},[A]),R=P.useCallback(()=>{g(new Set),x.current=null},[]);P.useEffect(()=>{g(e=>{if(0===e.size)return e;let t=new Set(z.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[z]);let _=P.useMemo(()=>z.filter(e=>p.has(e.id)),[z,p]),D=P.useCallback(async()=>{await Promise.all(_.map(e=>(d?tr(e.id,e.ownerMachineId):tn(e.id,e.ownerMachineId)).catch(()=>{}))),R(),f()},[_,d,R,f]),L=P.useCallback(async()=>{for(let e of(await Promise.all(_.map(e=>te(e.id,e.ownerMachineId).catch(()=>{}))),_))a?.(e.id);R(),f()},[_,R,f,a]),$=p.size>0,F=P.useMemo(()=>new Set((o??[]).map(e=>e.id)),[o]),B=o?.[o.length-1]?.id,V=P.useCallback(t=>t!==e||(i?.length??0)===0?null:(0,E.jsx)(qy,{nodes:i??[],depth:0,ancestors:[],activeIds:F,activeLeafId:B,onOpen:l}),[e,i,F,B,l]),H=P.useCallback(t=>{let{childrenOf:a,roots:i}=UG(t),o=(t,i)=>{let l=V(t.id);return(0,E.jsxs)(P.Fragment,{children:[(0,E.jsx)(qv,{conversation:t,depth:i,active:t.id===e,onOpenConversation:n,onOpenConversationSettings:r,onRename:I,onDelete:C,onFork:S,onArchive:t.archivedAt?void 0:()=>M(t),onUnarchive:t.archivedAt?()=>O(t):void 0,selectionMode:$,selected:p.has(t.id),onToggleSelect:e=>T(t.id,e)}),l?(0,E.jsx)("div",{style:i>0?{marginLeft:14*i}:void 0,children:l}):null,(a.get(t.id)??[]).map(e=>o(e,i+1))]},t.id)};return i.map(e=>o(e,0))},[V,e,n,r,I,C,S,M,O,$,p,T]),U=P.useMemo(()=>H(w),[H,w]),q=P.useMemo(()=>H(j),[H,j]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"vtl-stagger-item mb-6 space-y-0.5",style:{animationDelay:"0ms"},"data-tour":"new-conversation",children:(0,E.jsxs)(EK,{children:[(0,E.jsx)(EX,{asChild:!0,children:(0,E.jsx)(qc,{icon:U9,label:UF.conversationNew,onClick:()=>t({item:{id:"new-agent-conversation"}})})}),(0,E.jsx)(E2,{className:"min-w-44",children:(0,E.jsxs)(E5,{onSelect:()=>t({item:{id:"import-claude-session"}}),children:[(0,E.jsx)(Ap,{}),(0,E.jsx)("span",{className:"flex-1",children:"导入 Claude 会话"})]})})]})}),$?(0,E.jsx)(ql,{count:p.size,archived:d,onArchive:()=>void D(),onDelete:()=>void L(),onCancel:R}):null,(0,E.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:[w.length>0?(0,E.jsxs)("div",{className:"vtl-stagger-item mb-4",style:{animationDelay:"25ms"},children:[(0,E.jsxs)("div",{className:"mb-2 flex items-center gap-2 px-3",children:[(0,E.jsx)("span",{className:"size-1.5 shrink-0 rounded-full bg-green-500"}),(0,E.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"正在运行"})]}),(0,E.jsx)("div",{className:"space-y-0.5",children:U})]}):null,(0,E.jsxs)("div",{className:"vtl-stagger-item mb-2 flex items-center justify-between px-3",style:{animationDelay:"50ms"},children:[(0,E.jsx)("span",{className:"text-[13px] text-muted-foreground",children:"最近"}),(0,E.jsx)(qh,{filter:s,onChange:c,active:k,locations:v,locationLabel:b})]}),(0,E.jsx)("div",{className:"space-y-0.5",children:N?(0,E.jsx)(qd,{}):0===j.length?(0,E.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:d?"暂无已归档对话":k?"没有符合筛选条件的对话":"暂无对话"}):q})]})]})}let qj=(0,z.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["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",key:"ohrbg2"}]]);var qk="Collapsible",[qN,qC]=jD(qk),[qS,qM]=qN(qk),qE=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[s,c]=NO({prop:r,defaultProp:a??!1,onChange:o,caller:qk});return(0,E.jsx)(qS,{scope:n,disabled:i,contentId:ke(),open:s,onOpenToggle:P.useCallback(()=>c(e=>!e),[c]),children:(0,E.jsx)(jB.div,{"data-state":qA(s),"data-disabled":i?"":void 0,...l,ref:t})})});qE.displayName=qk;var qI="CollapsibleTrigger",qP=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=qM(qI,n);return(0,E.jsx)(jB.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":qA(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:jR(e.onClick,a.onOpenToggle)})});qP.displayName=qI;var qO="CollapsibleContent";P.forwardRef((e,t)=>{let{forceMount:n,...r}=e,a=qM(qO,e.__scopeCollapsible);return(0,E.jsx)(NE,{present:n||a.open,children:({present:e})=>(0,E.jsx)(qz,{...r,ref:t,present:e})})}).displayName=qO;var qz=P.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...i}=e,o=qM(qO,n),[l,s]=P.useState(r),c=P.useRef(null),d=(0,j_.useComposedRefs)(t,c),u=P.useRef(0),f=u.current,m=P.useRef(0),h=m.current,p=o.open||l,g=P.useRef(p),x=P.useRef(void 0);return P.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),j8(()=>{let e=c.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();u.current=t.height,m.current=t.width,g.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),s(r)}},[o.open,r]),(0,E.jsx)(jB.div,{"data-state":qA(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:p&&a})});function qA(e){return e?"open":"closed"}function qT(){return{kind:"human",id:"local",displayName:"我"}}async function qR(e,t){let n=t?`?status=${encodeURIComponent(t)}`:"";return(await qZ(`/api/local/projects/${encodeURIComponent(e)}/issues${n}`)).issues??[]}async function q_(e){return qZ(`/api/local/issues/${encodeURIComponent(e)}`)}async function qD(e,t){return qZ(`/api/local/projects/${encodeURIComponent(e)}/issues`,{method:"POST",body:JSON.stringify(t)})}async function qL(e,t){return qZ(`/api/local/issues/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}async function q$(e){await qZ(`/api/local/issues/${encodeURIComponent(e)}`,{method:"DELETE"})}async function qF(e,t){return qZ(`/api/local/issues/${encodeURIComponent(e)}/claim`,{method:"POST",body:JSON.stringify({assignee:t})})}async function qB(e,t,n=qT()){return qZ(`/api/local/issues/${encodeURIComponent(e)}/comments`,{method:"POST",body:JSON.stringify({actor:n,body:t})})}async function qV(e){return(await qZ(`/api/local/issues/${encodeURIComponent(e)}/events`)).events??[]}async function qH(e){return(await qZ(`/api/local/projects/${encodeURIComponent(e)}/links`)).links??[]}async function qU(e,t,n,r){return qZ(`/api/local/projects/${encodeURIComponent(e)}/links`,{method:"POST",body:JSON.stringify({fromIssueId:t,toIssueId:n,kind:r})})}async function qq(e){await qZ(`/api/local/links/${encodeURIComponent(e)}`,{method:"DELETE"})}let qW=new Map,qK=new Map;async function qG(e){let t=Date.now(),n=qW.get(e);if(n&&t-n.at<2500)return n.value;let r=qK.get(e);if(r)return r;let a=(async()=>{try{let t=(await qZ(`/api/local/projects/${encodeURIComponent(e)}/approvals`)).approvals??[];return qW.set(e,{value:t,at:Date.now()}),t}finally{qK.delete(e)}})();return qK.set(e,a),a}async function qX(e,t,n,r){await qZ(`/api/local/agent/conversations/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:JSON.stringify(null!=r&&""!==r?{decision:n,feedback:r}:{decision:n})})}class qY extends Error{status;constructor(e,t){super(e),this.name="KanbanAPIError",this.status=t}}async function qZ(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw new qY("string"==typeof r?.error?r.error:"kanban api failed",n.status);return r}function qJ({activeProjectId:e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onNewProject:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p}){let{projects:g,loading:x,refresh:v}=function(){let[e,t]=P.useState([]),[n,r]=P.useState(!0),a=P.useRef(!0),i=P.useCallback(async()=>{try{let e=await tU();if(!a.current)return;let n=[...e].sort((e,t)=>t.updatedAt>e.updatedAt?1:-1);t(n)}catch{}finally{a.current&&r(!1)}},[]);return P.useEffect(()=>{a.current=!0;let e=()=>void i();return window.addEventListener(tH,e),()=>{a.current=!1,window.removeEventListener(tH,e)}},[i]),qn(i,1e4),{projects:e,loading:n,refresh:()=>void i()}}(),b=x&&0===g.length;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"mb-6 space-y-0.5",children:(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,E.jsx)(qc,{icon:qj,label:UF.canvasNew,onClick:()=>c?.()})})}),(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto vtl-scrollbar-hidden pr-1",children:(0,E.jsx)("div",{className:"space-y-0.5",children:b?(0,E.jsx)(qd,{}):0===g.length?(0,E.jsx)("p",{className:"px-3 py-1.5 text-[13px] text-muted-foreground/60",children:UF.projectEmpty}):g.map((c,g)=>(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(g+1,12)}ms`},children:(0,E.jsx)(qQ,{project:c,active:c.id===e,activeConversationId:t,hideCanvas:n,onOpenProjectCanvas:r,onOpenProjectOverview:a,onOpenProjectKanban:i,onOpenProjectSettings:o,onNewProjectConversation:l,onOpenProjectConversation:s,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:v,subagentTree:m,activeSubagentPath:h,onOpenSubagent:p})},c.id))})})]})}function qQ({project:e,active:t,activeConversationId:n,hideCanvas:r,onOpenProjectCanvas:a,onOpenProjectOverview:i,onOpenProjectKanban:o,onOpenProjectSettings:l,onNewProjectConversation:s,onOpenProjectConversation:c,onOpenConversation:d,onOpenConversationSettings:u,onConversationDeleted:f,onConversationsChanged:m,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}){let[x,v]=P.useState(t),[b,y]=P.useState([]),[w,j]=P.useState(0),k=P.useCallback(async()=>{try{let t=await qG(e.id);j(t.length)}catch{}},[e.id]),[N,C]=P.useState(()=>new Set),S=P.useRef(null),M=N.size>0,I=P.useCallback(async()=>{try{let t=await tZ(e.id);y(t)}catch{}},[e.id]);qn(I,1e4,x),qn(k,1e4,x);let O=P.useCallback(async e=>{try{await te(e.id,e.ownerMachineId)}catch{}f?.(e.id),y(t=>t.filter(t=>t.id!==e.id)),m?.()},[f,m]),z=P.useCallback(async e=>{try{await tn(e.id,e.ownerMachineId)}catch{}y(t=>t.filter(t=>t.id!==e.id)),m?.()},[m]),A=P.useCallback(async(e,t)=>{try{let n=await tt(e.id,t,e.ownerMachineId);y(t=>t.map(t=>t.id===e.id?{...t,title:n.conversation.title,titleLocked:n.conversation.titleLocked}:t))}catch{}m?.()},[m]),T=P.useMemo(()=>UX(b),[b]),R=P.useMemo(()=>T.map(e=>e.id),[T]),_=P.useCallback((e,t)=>{C(n=>UY(n,e,t,R,S.current)),S.current=e},[R]),D=P.useCallback(()=>{C(new Set),S.current=null},[]);P.useEffect(()=>{C(e=>{if(0===e.size)return e;let t=new Set(b.map(e=>e.id)),n=!1,r=new Set;for(let a of e)t.has(a)?r.add(a):n=!0;return n?r:e})},[b]);let L=P.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));await Promise.all(e.map(e=>tn(e.id,e.ownerMachineId).catch(()=>{}))),D(),await I(),m?.()},[b,N,D,I,m]),$=P.useCallback(async()=>{let e=b.filter(e=>N.has(e.id));for(let t of(await Promise.all(e.map(e=>te(e.id,e.ownerMachineId).catch(()=>{}))),e))f?.(t.id);D(),await I(),m?.()},[b,N,D,I,f,m]),F=P.useCallback(async t=>{try{let n=await tN(t.id,void 0,t.ownerMachineId);c?c(e.id,n.conversation.id,n.conversation.ownerMachineId):d(n.conversation.id,n.conversation.ownerMachineId),m?.()}catch{}},[d,c,e.id,m]),V=P.useCallback((t,n)=>{c?c(e.id,t,n):d(t,n)},[c,d,e.id]),H=P.useMemo(()=>(function(e,t){let{childrenOf:n,roots:r}=UG(e),a=new Set((t.activeSubagentPath??[]).map(e=>e.id)),i=t.activeSubagentPath?.[t.activeSubagentPath.length-1]?.id,o=(e,r)=>{let l=e.id!==t.activeConversationId||(t.subagentTree?.length??0)===0?null:(0,E.jsx)(qy,{nodes:t.subagentTree??[],depth:0,ancestors:[],activeIds:a,activeLeafId:i,onOpen:t.onOpenSubagent});return(0,E.jsxs)(P.Fragment,{children:[(0,E.jsx)(qv,{conversation:e,depth:r,active:e.id===t.activeConversationId,onOpenConversation:t.onOpenConversation,onOpenConversationSettings:t.onOpenConversationSettings,onRename:t.onRename,onDelete:t.onDelete,onFork:t.onFork,onArchive:t.onArchive?()=>t.onArchive?.(e):void 0,selectionMode:t.selectionMode,selected:t.selectedIds?.has(e.id),onToggleSelect:t.onToggleSelect?n=>t.onToggleSelect?.(e.id,n):void 0}),l?(0,E.jsx)("div",{style:r>0?{marginLeft:14*r}:void 0,children:l}):null,(n.get(e.id)??[]).map(e=>o(e,r+1))]},e.id)};return r.map((e,t)=>(0,E.jsx)("div",{className:"vtl-stagger-item space-y-0.5",style:{animationDelay:`${25*Math.min(t+3,12)}ms`},children:o(e,0)},e.id))})(b,{activeConversationId:n,onOpenConversation:V,onOpenConversationSettings:u,onRename:A,onDelete:O,onFork:F,onArchive:z,selectionMode:M,selectedIds:N,onToggleSelect:_,subagentTree:h,activeSubagentPath:p,onOpenSubagent:g}),[b,n,V,u,A,O,F,z,M,N,_,h,p,g]),U=qr(x);return(0,E.jsxs)(qE,{open:x,onOpenChange:v,children:[(0,E.jsxs)("div",{className:(0,B.cn)("group flex items-center rounded-lg text-[13px] transition-colors",t?"bg-muted text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground"),children:[(0,E.jsx)(qP,{asChild:!0,children:(0,E.jsx)("button",{type:"button","aria-label":x?"收起工程":"展开工程",className:"shrink-0 rounded-md p-1.5 pl-2 text-muted-foreground hover:text-foreground",onClick:e=>e.stopPropagation(),children:(0,E.jsx)(nc,{className:(0,B.cn)("size-4 transition-transform",x?"rotate-0":"-rotate-90")})})}),(0,E.jsxs)("button",{type:"button",title:e.title,onClick:()=>{v(!0),i?.(e.id)},className:"flex min-w-0 flex-1 items-center gap-2 rounded-lg py-2 pr-3 text-left",children:[(0,E.jsx)(_U,{className:"size-4 shrink-0 text-muted-foreground"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.title}),w>0?(0,E.jsx)("span",{title:`${w} 项待审批`,className:"shrink-0 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold leading-none text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",children:w}):null,t&&(0,E.jsx)(qu,{active:!0})]})]}),(0,E.jsx)(qo,{open:x,className:"mt-0.5",children:(0,E.jsx)("div",{className:"ml-[1.125rem] border-l border-border/60 pl-1.5",children:(0,E.jsxs)("div",{className:"space-y-0.5",children:[r?null:(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"0ms"},children:(0,E.jsx)(q0,{icon:(0,E.jsx)(_U,{className:"size-4"}),label:UF.projectCanvas,onClick:()=>a?.(e.id,e.canvasId)})}),(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:"25ms"},children:(0,E.jsx)(q0,{icon:(0,E.jsx)(UH,{className:"size-4"}),label:UF.projectKanban,onClick:()=>o?.(e.id)})}),M?(0,E.jsx)(ql,{count:N.size,archived:!1,onArchive:()=>void L(),onDelete:()=>void $(),onCancel:D}):null,H,(0,E.jsxs)("button",{type:"button",onClick:()=>s?.(e.id),title:UF.projectNewConversation,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-muted-foreground/80 transition-colors hover:bg-muted hover:text-foreground",children:[(0,E.jsx)(eO,{className:"size-4 shrink-0"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:UF.projectNewConversation})]})]},U)})})]})}function q0({icon:e,label:t,onClick:n}){return(0,E.jsxs)("button",{type:"button",onClick:n,className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",children:[e,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:t})]})}function q1({content:e,activeWorkspace:t,onItemSelect:n}){let r=(e?.sections??[]).flatMap(e=>e.items);return(0,E.jsx)(Am,{className:"min-h-0 flex-1",viewportClassName:"pr-1",children:(0,E.jsx)("div",{className:"space-y-0.5",children:r.map(e=>"preferences"===e.id?(0,E.jsx)(q5,{activeWorkspace:t,onItemSelect:n},e.id):(0,E.jsx)(q2,{id:e.id,icon:e.icon,label:e.label,active:e.id===t,onItemSelect:n},e.id))})})}function q2({id:e,icon:t,label:n,active:r,onItemSelect:a}){return(0,E.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e}}),className:(0,B.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[t,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:n}),r&&(0,E.jsx)(qu,{active:!0})]})}function q5({activeWorkspace:e,onItemSelect:t}){return(0,E.jsx)(E.Fragment,{children:UJ.map((n,r)=>(0,E.jsx)("div",{className:"vtl-stagger-item",style:{animationDelay:`${25*Math.min(r,12)}ms`},children:(0,E.jsx)(q3,{title:n.title,icon:n.icon,items:n.items,activeWorkspace:e,onItemSelect:t})},n.id))})}function q3({title:e,icon:t,items:n,activeWorkspace:r,onItemSelect:a}){let i=n.some(e=>e.id===r),[o,l]=P.useState(!0),s=qr(o);return(0,E.jsxs)(qE,{open:o,onOpenChange:l,children:[(0,E.jsx)(qP,{asChild:!0,children:(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",i?"text-foreground [&>svg:first-child]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&>svg:first-child]:text-muted-foreground"),children:[t,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e}),(0,E.jsx)(nc,{className:(0,B.cn)("text-muted-foreground transition-transform",o?"rotate-0":"-rotate-90")})]})}),(0,E.jsx)(qo,{open:o,className:"mt-0.5",children:(0,E.jsx)("div",{className:"space-y-0.5",children:n.map((e,t)=>{let n=e.id===r;return(0,E.jsxs)("button",{type:"button",onClick:()=>a({item:{id:e.id}}),style:{animationDelay:`${25*Math.min(t,12)}ms`},className:(0,B.cn)("vtl-stagger-item flex w-full items-center gap-3 rounded-lg py-2 pl-9 pr-3 text-left text-[13px] transition-colors [&_svg]:size-4 [&_svg]:shrink-0",n?"bg-muted text-foreground [&_svg]:text-foreground":"text-foreground/80 hover:bg-muted hover:text-foreground [&_svg]:text-muted-foreground"),children:[e.icon,(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n&&(0,E.jsx)(qu,{active:!0})]},e.id)})},s)})]})}function q4({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v,hideCanvas:b,className:y}){let w=UZ[n]??(UJ.some(e=>e.items.some(e=>e.id===n))?"settings":b?"agent":"canvas"),[j,k]=P.useState(w);P.useEffect(()=>{k(w)},[w]);let N=t.find(e=>e.id===j),C=P.useRef(null),S=P.useRef(new Map),[M,I]=P.useState(null),[O,z]=P.useState(!1),A=P.useCallback(()=>{let e=C.current,t=S.current.get(j);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();I({left:r.left-n.left,top:r.top-n.top,width:r.width,height:r.height})},[j]);return P.useEffect(()=>{A();let e=window.requestAnimationFrame(()=>z(!0)),t=C.current,n=null;return t&&"u">typeof ResizeObserver&&(n=new ResizeObserver(A)).observe(t),window.addEventListener("resize",A),()=>{window.cancelAnimationFrame(e),n?.disconnect(),window.removeEventListener("resize",A)}},[A]),(0,E.jsxs)("aside",{"data-slot":"flat-sidebar",className:(0,B.cn)("flex h-full w-72 flex-col rounded-xl border border-border bg-sidebar p-3 text-sidebar-foreground shadow-sm",y),children:[(0,E.jsxs)("nav",{ref:C,className:"relative mb-5 flex gap-1 rounded-lg bg-muted/70 p-1",children:[M?(0,E.jsx)("span",{"aria-hidden":!0,className:(0,B.cn)("pointer-events-none absolute top-0 left-0 z-0 rounded-md border border-border/50 bg-background shadow-sm",O&&"transition-[transform,width,height] duration-200 ease-out"),style:{transform:`translate(${M.left}px, ${M.top}px)`,width:M.width,height:M.height}}):null,e.map(e=>{let t=e.id===j;return(0,E.jsxs)("button",{ref:t=>{t?S.current.set(e.id,t):S.current.delete(e.id)},type:"button",onClick:()=>k(e.id),className:(0,B.cn)("relative z-10 flex flex-1 items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] font-medium transition-colors [&_svg]:size-4",t?"text-foreground":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,E.jsx)("span",{className:"truncate",children:e.label})]},e.id)})]}),"canvas"===j?(0,E.jsx)(qJ,{activeProjectId:a,activeConversationId:r,hideCanvas:b,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v}):"agent"===j?(0,E.jsx)(qw,{activeConversationId:r,onItemSelect:i,onOpenConversation:o,onOpenConversationSettings:h,onConversationDeleted:p,subagentTree:g,activeSubagentPath:x,onOpenSubagent:v}):(0,E.jsx)(q1,{content:N,activeWorkspace:n,onItemSelect:i}),(0,E.jsx)(U3,{})]})}let q6=(0,z.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var q8=e.i(78737);function q7({className:e,orientation:t="horizontal",...n}){return(0,E.jsx)("div",{role:"separator","aria-orientation":t,"data-slot":"separator","data-orientation":t,className:(0,B.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",e),...n})}let q9=(0,nb.cva)("group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted",{variants:{variant:{default:"border-transparent",outline:"border-border",muted:"border-transparent bg-muted/50"},size:{default:"gap-2.5 px-3 py-2.5",sm:"gap-2.5 px-3 py-2.5",xs:"gap-2 px-2.5 py-2"}},defaultVariants:{variant:"default",size:"default"}});function We({className:e,variant:t="default",size:n="default",asChild:r=!1,...a}){let i=r?AQ.Slot:"div";return(0,E.jsx)(i,{"data-slot":"item","data-variant":t,"data-size":n,className:(0,B.cn)(q9({variant:t,size:n,className:e})),...a})}let Wt=(0,nb.cva)("flex shrink-0 items-center justify-center gap-2 [&_svg]:pointer-events-none",{variants:{variant:{default:"bg-transparent",icon:"[&_svg:not([class*='size-'])]:size-4",marker:"size-8 rounded-md border bg-background ui-text-kbd font-medium text-muted-foreground [&_svg:not([class*='size-'])]:size-4",image:"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover"},align:{auto:"group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start",start:"translate-y-0.5 self-start",center:"self-center"}},defaultVariants:{variant:"default",align:"auto"}});function Wn({className:e,variant:t="default",align:n="auto",...r}){return(0,E.jsx)("div",{"data-slot":"item-media","data-variant":t,"data-align":n,className:(0,B.cn)(Wt({variant:t,align:n,className:e})),...r})}function Wr({className:e,align:t,...n}){return(0,E.jsx)("div",{"data-slot":"item-content","data-align":t,className:(0,B.cn)("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none","start"===t&&"self-start","center"===t&&"self-center",e),...n})}function Wa({className:e,...t}){return(0,E.jsx)("div",{"data-slot":"item-title",className:(0,B.cn)("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",e),...t})}function Wi({className:e,...t}){return(0,E.jsx)("p",{"data-slot":"item-description",className:(0,B.cn)("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function Wo({className:e,...t}){return(0,E.jsx)("div",{"data-slot":"item-actions",className:(0,B.cn)("flex items-center gap-2",e),...t})}let Wl={back:"Back",search:"Search settings...",welcomeTitle:"Settings",welcomeDescription:"Search or choose a setting to continue.",recommendations:"Recommended",noResults:"No settings found."},Ws=P.createContext(null);function Wc({value:e,children:t}){return(0,E.jsx)(Ws.Provider,{value:e,children:t})}function Wd(e){return"string"==typeof e||"number"==typeof e?String(e):""}function Wu({sections:e,recommendations:t,sectionId:n,defaultSectionId:r,childId:a,defaultChildId:i,onSelectionChange:o,labels:l,welcomeContent:s,className:c,sidebarClassName:d,contentClassName:u}){let f={...Wl,...l},m=zF(),h=P.useContext(Ws),[p,g]=P.useState(r),[x,v]=P.useState(i),[b,y]=P.useState("list"),w=n??p,j=a??x,k=e.find(e=>e.id===w),N=k?.children?.find(e=>e.id===j),C=!!k?.children?.length,S=m&&"detail"===b,M=P.useMemo(()=>e.flatMap(e=>[{value:e.id,label:e.title,description:e.description,icon:e.icon,searchValue:[Wd(e.title),Wd(e.description),...e.keywords??[]].join(" "),keywords:e.keywords},...(e.children??[]).map(t=>({value:`${e.id}/${t.id}`,label:t.title,description:e.title,icon:t.icon??e.icon,disabled:t.disabled,searchValue:[Wd(t.title),Wd(t.description),Wd(e.title),...t.keywords??[]].join(" "),keywords:[Wd(e.title),...t.keywords??[]]}))]),[e]),I=t??e.flatMap(e=>(e.children??[]).slice(0,2).map(t=>({id:`${e.id}-${t.id}`,title:t.title,description:e.title,icon:t.icon,sectionId:e.id,childId:t.id})));function O(t,r){let i=e.find(e=>e.id===t),l=void 0!==r,s=!!i?.children?.length;void 0===t?y("list"):l||!s?y("detail"):y("list");let c=i?.children?.[0];void 0!==t&&!l&&c&&(r=c.id),void 0===n&&g(t),void 0===a&&v(r),o?.({sectionId:t,childId:r})}let z=N?.content??k?.content??s??(0,E.jsxs)("div",{className:"mx-auto flex min-h-[22rem] w-full max-w-2xl flex-col justify-center gap-5 py-12",children:[(0,E.jsxs)("div",{className:"space-y-2",children:[(0,E.jsx)("h3",{className:"text-xl font-semibold tracking-normal",children:f.welcomeTitle}),(0,E.jsx)("p",{className:"max-w-xl text-sm text-muted-foreground",children:f.welcomeDescription})]}),(0,E.jsx)(Wm,{labels:f,options:M,onSelect:(e,t)=>O(e,t)}),I.length>0&&(0,E.jsxs)("section",{className:"space-y-2",children:[(0,E.jsx)("div",{className:"ui-text-kbd font-medium text-muted-foreground",children:f.recommendations}),(0,E.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:I.map(e=>(0,E.jsx)(We,{asChild:!0,variant:"outline",size:"xs",className:"min-h-14 flex-nowrap bg-card text-left hover:bg-muted/60",children:(0,E.jsxs)("button",{type:"button",onClick:()=>O(e.sectionId,e.childId),children:[e.icon&&(0,E.jsx)(Wn,{variant:"marker",align:"center",children:e.icon}),(0,E.jsxs)(Wr,{className:"min-w-0 gap-0.5",children:[(0,E.jsx)(Wa,{className:"max-w-full truncate",children:e.title}),e.description&&(0,E.jsx)(Wi,{className:"line-clamp-1",children:e.description})]}),(0,E.jsx)(Wo,{className:"ml-auto",children:(0,E.jsx)(MC,{className:"size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/item:opacity-100"})})]})},e.id))})]})]});return(0,E.jsxs)("div",{"data-slot":"settings-menu-panel",className:(0,B.cn)("vtl-surface-panel grid min-h-[34rem] overflow-hidden rounded-[var(--surface-panel-radius)] border md:grid-cols-[15rem_minmax(0,1fr)]",c),children:[m&&S?null:(0,E.jsx)("aside",{"data-slot":"settings-menu-sidebar",className:(0,B.cn)("min-h-0 border-b bg-muted/20 md:border-r md:border-b-0",d),children:(0,E.jsx)(Am,{className:"h-full",children:(0,E.jsx)("div",{className:"space-y-1 p-2",children:C?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left",onClick:()=>O(void 0,void 0),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}),(k?.children??[]).map(e=>(0,E.jsx)(Wf,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===j,disabled:e.disabled,onClick:()=>O(k?.id,e.id)},e.id))]}):(0,E.jsxs)(E.Fragment,{children:[m&&h?(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-1 h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>h(),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,e.map(e=>(0,E.jsx)(Wf,{title:e.title,icon:e.icon,badge:e.badge,active:e.id===w,disabled:e.disabled,onClick:()=>O(e.id,void 0)},e.id))]})})})}),!m||S?(0,E.jsxs)("main",{"data-slot":"settings-menu-content",className:(0,B.cn)("min-w-0 bg-[var(--surface-panel)] p-4 md:p-5 animate-in fade-in-0 slide-in-from-right-1 duration-150",u),children:[S?(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",className:"mb-3 h-auto min-h-9 justify-start px-2.5 py-1.5 text-left md:hidden",onClick:()=>y("list"),children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:(0,E.jsx)(q8.ArrowLeftIcon,{})}),(0,E.jsx)("span",{className:"min-w-0 truncate",children:f.back})]}):null,k?(0,E.jsx)("div",{className:"mb-4 flex min-h-8 items-center justify-between gap-4",children:(0,E.jsxs)("div",{className:"min-w-0",children:[(0,E.jsx)("h2",{className:"truncate text-lg font-semibold tracking-normal",children:N?.title??k.title}),(N?.description??k.description)&&(0,E.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:N?.description??k.description})]})}):null,z]},`${w??""}/${j??""}`):null]})}function Wf({title:e,icon:t,badge:n,active:r,disabled:a,onClick:i}){return(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",disabled:a,onClick:i,className:(0,B.cn)("h-auto min-h-9 w-full justify-start px-2.5 py-1.5 text-left font-medium",r?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"),children:[t&&(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center [&_svg]:size-4",children:t}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e}),n&&(0,E.jsx)(nw,{variant:"outline",className:"h-5 shrink-0 px-1.5 ui-text-kbd",children:n}),(0,E.jsx)(MC,{className:"size-3.5 shrink-0 text-muted-foreground/60"})]})}function Wm({labels:e,options:t,onSelect:n}){return(0,E.jsx)(Oa,{options:t,placeholder:e.search,emptyText:e.noResults,className:"w-full",contentClassName:"rounded-lg",onValueChange:e=>{let[t,r]=e.split("/");t&&n(t,r)},renderOption:e=>(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",children:e.icon??(0,E.jsx)(IX,{})}),(0,E.jsxs)("span",{className:"grid min-w-0 flex-1 gap-0.5",children:[(0,E.jsx)("span",{className:"truncate",children:e.label}),e.description&&(0,E.jsx)("span",{className:"truncate text-sm text-muted-foreground",children:e.description})]})]})})}function Wh({navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:i,onOpenConversation:o,onOpenProjectCanvas:l,onOpenProjectOverview:s,onOpenProjectKanban:c,onOpenProjectSettings:d,onNewProjectConversation:u,onOpenProjectConversation:f,onNewProject:m,onOpenConversationSettings:h,onConversationDeleted:p,onAccountSettings:g,subagentTree:x,activeSubagentPath:v,onOpenSubagent:b,title:y,trailing:w,children:j}){let[k,N]=P.useState(!1),C=P.useCallback(()=>N(!1),[]),S=P.useCallback(e=>{C(),i(e)},[C,i]),M=P.useCallback((e,t)=>{C(),o(e,t)},[C,o]),I=P.useCallback(e=>{C(),b?.(e)},[C,b]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Wp,{onMenuClick:()=>N(!0),title:y,trailing:w}),(0,E.jsx)(zR,{open:k,onOpenChange:N,direction:"left",children:(0,E.jsxs)(zD,{className:"w-[85vw] max-w-xs",children:[(0,E.jsx)(z$,{className:"sr-only",children:"导航"}),(0,E.jsx)(q4,{hideCanvas:!0,navItems:e,contents:t,activeWorkspace:n,activeConversationId:r,activeProjectId:a,onItemSelect:S,onOpenConversation:M,onOpenCanvas:()=>{},onOpenProjectCanvas:(e,t)=>{C(),l?.(e,t)},onOpenProjectOverview:e=>{C(),s?.(e)},onOpenProjectKanban:e=>{C(),c?.(e)},onOpenProjectSettings:e=>{C(),d?.(e)},onNewProjectConversation:e=>{C(),u?.(e)},onOpenProjectConversation:(e,t,n)=>{C(),f?.(e,t,n)},onNewProject:()=>{C(),m?.()},onOpenConversationSettings:(e,t)=>{C(),h?.(e,t)},onConversationDeleted:p,onAccountSettings:()=>{C(),g?.()},subagentTree:x,activeSubagentPath:v,onOpenSubagent:I,className:"h-full w-full rounded-none border-0 p-3 pt-[max(0.75rem,env(safe-area-inset-top))] shadow-none"})]})}),(0,E.jsx)(Wc,{value:()=>N(!0),children:j})]})}function Wp({onMenuClick:e,title:t,trailing:n,className:r}){return(0,E.jsxs)("header",{className:(0,B.cn)("fixed inset-x-0 top-0 z-40 flex h-12 items-center gap-1 border-b border-border bg-sidebar/95 px-1.5 pt-[env(safe-area-inset-top)] backdrop-blur",r),style:{height:"calc(3rem + env(safe-area-inset-top))"},children:[(0,E.jsx)("button",{type:"button","aria-label":"展开导航",onClick:e,className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-foreground/80 transition-colors hover:bg-muted hover:text-foreground [&_svg]:size-5",children:(0,E.jsx)(q6,{})}),t?(0,E.jsx)("div",{className:"min-w-0 flex-1 truncate text-center text-sm font-medium text-foreground",children:t}):(0,E.jsx)("div",{className:"min-w-0 flex-1"}),(0,E.jsx)("div",{className:"flex shrink-0 items-center",children:n})]})}let Wg=(0,z.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]),Wx=[{id:"canvas",label:UF.canvas,icon:(0,E.jsx)(_U,{})},{id:"agent",label:"智能体",icon:(0,E.jsx)(CB,{})},{id:"settings",label:UF.settings,icon:(0,E.jsx)(UK,{})}],Wv=[{id:"canvas",title:UF.canvas,description:"节点画布工作区。",sections:[{id:"canvases",title:UF.canvas,items:[{id:"open-recent-canvas",label:UF.canvasRecent,icon:(0,E.jsx)(_U,{})},{id:"new-canvas",label:UF.canvasNew,icon:(0,E.jsx)(eO,{})},{id:"all-canvases",label:UF.canvasAll,icon:(0,E.jsx)(_W,{})}]}]},{id:"agent",title:"智能体",description:"Agent 对话工作区。",sections:[{id:"conversations",title:"Agent 对话",items:[{id:"open-recent-conversation",label:UF.conversationRecent,icon:(0,E.jsx)(Wg,{})},{id:"new-agent-conversation",label:UF.conversationNew,icon:(0,E.jsx)(CB,{})}]}]},{id:"settings",title:UF.settings,description:"系统、工作组和用量配置。",sections:[{id:"settings",items:[{id:"preferences",label:"设置",icon:(0,E.jsx)(UK,{})}]}]}],Wb=["light","dark","jelly"],Wy={light:{label:"Light",icon:U2,className:"text-sidebar-foreground/60"},dark:{label:"Dark",icon:U1,className:"text-sidebar-foreground/60"},jelly:{label:"Jelly",icon:function(e){return(0,E.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[(0,E.jsx)("path",{d:"M6.5 11.5C6.5 8 8.7 5.5 12 5.5s5.5 2.5 5.5 6v.6c0 .8-.6 1.4-1.4 1.4H7.9c-.8 0-1.4-.6-1.4-1.4v-.6Z"}),(0,E.jsx)("path",{d:"M7.8 13.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5c.4 1 1.1 1.5 2 1.5s1.6-.5 2-1.5"}),(0,E.jsx)("path",{d:"M9 15.5c0 1.4-1.2 1.4-1.2 2.8 0 .7.3 1.2.8 1.7"}),(0,E.jsx)("path",{d:"M12 15.5c0 1.6-1.4 1.6-1.4 3.2 0 .7.3 1.2.8 1.8"}),(0,E.jsx)("path",{d:"M15 15.5c0 1.4 1.2 1.4 1.2 2.8 0 .7-.3 1.2-.8 1.7"})]})},className:"text-primary"}};function Ww(){let{resolvedTheme:e,setTheme:t}=(0,T1.useTheme)(),[n,r]=P.useState(U5.defaultAppearanceTheme);P.useEffect(()=>{let e=window.localStorage.getItem(U5.appearanceThemeStorageKey)??U5.defaultAppearanceTheme;r(e),(0,U5.applyAppearanceTheme)({theme:e})},[]);let a=n===U5.jellyAppearanceTheme?"jelly":"dark"===e?"dark":"light",i=Wb.indexOf(a),o=Wb[(i+1)%Wb.length]??"light",{icon:l,label:s,className:c}=Wy[a];function d(e){r(e),window.localStorage.setItem(U5.appearanceThemeStorageKey,e),(0,U5.applyAppearanceTheme)({theme:e})}return(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"icon-sm",className:(0,B.cn)("size-10 hover:bg-muted hover:text-sidebar-foreground",c),"aria-label":`${U$.theme}: ${s}`,title:`${U$.theme}: ${s}`,onClick:function(){if("jelly"===o){t("dark"),d(U5.jellyAppearanceTheme);return}d(U5.defaultAppearanceTheme),t(o)},children:(0,E.jsx)(l,{})})}function Wj(e){return()=>new Promise(t=>{e(),window.setTimeout(t,60)})}function Wk(e){return"u"<typeof document?null:document.querySelector(e)}function WN(){return null!=Wk('[role="menu"]')}function WC(){return null!=Wk('[data-tour="init-wizard"]')}function WS(){let e=Wk('[data-tour="init-wizard"] [aria-current="step"]'),t=e?.getAttribute("aria-label")?.match(/第\s*(\d+)/);return t?Number(t[1]):0}var WM=e.i(64990);let WE=(0,z.default)("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]),WI=(0,z.default)("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),WP=(0,z.default)("panel-right-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]),WO=(0,z.default)("rectangle-horizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]),Wz=(0,z.default)("shredder",[["path",{d:"M4 13V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5",key:"1eob4r"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 22v-5",key:"sfixh4"}],["path",{d:"M14 19v-2",key:"pdve8j"}],["path",{d:"M18 20v-3",key:"uox2gk"}],["path",{d:"M2 13h20",key:"5evz65"}],["path",{d:"M6 20v-3",key:"c6pdcb"}]]);async function WA(){return W$("/api/local/terminals/machines")}async function WT(e){let t=new URLSearchParams;e&&t.set("scopeId",e);let n=t.toString();return W$(`/api/local/terminals/sessions${n?`?${n}`:""}`)}async function WR(e){return W$("/api/local/terminals/sessions",{method:"POST",body:JSON.stringify(e)})}async function W_(e){await W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}async function WD(e,t){await W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}/input`,{method:"POST",body:JSON.stringify({data:t})})}async function WL(e,t){return W$(`/api/local/terminals/sessions/${encodeURIComponent(e)}/resize`,{method:"POST",body:JSON.stringify(t)})}async function W$(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"terminal api failed");return r}let WF=(0,z.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);function WB({groupSize:e,panelElement:t,styleProp:n}){let r,[a,i]=function(e){switch(typeof e){case"number":return[e,"px"];case"string":{let t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}(n);switch(i){case"%":r=a/100*e;break;case"px":r=a;break;case"rem":r=a*parseFloat(getComputedStyle(t.ownerDocument.body).fontSize);break;case"em":r=a*parseFloat(getComputedStyle(t).fontSize);break;case"vh":r=a/100*window.innerHeight;break;case"vw":r=a/100*window.innerWidth}return r}function WV(e){return parseFloat(e.toFixed(3))}function WH({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>e+="horizontal"===t?n.element.offsetWidth:n.element.offsetHeight,0)}function WU(e){let{panels:t}=e,n=WH({group:e});return 0===n?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:!0===e.panelConstraints.collapsible,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let t,{element:r,panelConstraints:a}=e,i=0;void 0!==a.collapsedSize&&(i=WV(WB({groupSize:n,panelElement:r,styleProp:a.collapsedSize})/n*100)),void 0!==a.defaultSize&&(t=WV(WB({groupSize:n,panelElement:r,styleProp:a.defaultSize})/n*100));let o=0;void 0!==a.minSize&&(o=WV(WB({groupSize:n,panelElement:r,styleProp:a.minSize})/n*100));let l=100;return void 0!==a.maxSize&&(l=WV(WB({groupSize:n,panelElement:r,styleProp:a.maxSize})/n*100)),{groupResizeBehavior:a.groupResizeBehavior,collapsedSize:i,collapsible:!0===a.collapsible,defaultSize:t,disabled:a.disabled,minSize:o,maxSize:l,panelId:e.id}})}function Wq(e,t="Assertion error"){if(!e)throw Error(t)}function WW(e,t){return Array.from(t).sort("horizontal"===e?WK:WG)}function WK(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return 0!==n?n:e.element.offsetWidth-t.element.offsetWidth}function WG(e,t){let n=e.element.offsetTop-t.element.offsetTop;return 0!==n?n:e.element.offsetHeight-t.element.offsetHeight}function WX(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function WY(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function WZ(e){let{element:t,orientation:n,panels:r,separators:i}=e,o=WW(n,Array.from(t.children).filter(WX).map(e=>({element:e}))).map(({element:e})=>e),l=[],s=!1,c=!1,d=-1,u=-1,f=0,m,h=[];{let e=-1;for(let t of o)t.hasAttribute("data-panel")&&(e++,t.hasAttribute("data-disabled")||(f++,-1===d&&(d=e),u=e))}if(f>1){let t=-1;for(let f of o)if(f.hasAttribute("data-panel")){t++;let i=r.find(e=>e.element===f);if(i){if(m){let r,o=m.element.getBoundingClientRect(),p=f.getBoundingClientRect();if(c){let e="horizontal"===n?new DOMRect(o.right,o.top,0,o.height):new DOMRect(o.left,o.bottom,o.width,0),t="horizontal"===n?new DOMRect(p.left,p.top,0,p.height):new DOMRect(p.left,p.top,p.width,0);switch(h.length){case 0:r=[e,t];break;case 1:{let a=h[0],i=function({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},a,i=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=WY(r,n),l="horizontal"===e?t:o;l<i&&(i=l,a=n)}return Wq(a,"No rect found"),a}({orientation:n,rects:[o,p],targetRect:a.element.getBoundingClientRect()});r=[a,i===o?t:e];break}default:r=h}}else r=h.length?h:["horizontal"===n?new DOMRect(o.right,p.top,p.left-o.right,p.height):new DOMRect(p.left,o.bottom,p.width,p.top-o.bottom)];for(let n of r){let r="width"in n?n:n.element.getBoundingClientRect(),o=(void 0===a&&(a="function"==typeof matchMedia&&!!matchMedia("(pointer:coarse)").matches),a)?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<o){let e=o-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<o){let e=o-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}let c=t<=d||t>u;s||c||l.push({group:e,groupSize:WH({group:e}),panels:[m,i],separator:"width"in n?void 0:n,rect:r}),s=!1}}c=!1,m=i,h=[]}}else if(f.hasAttribute("data-separator")){null!==f.ariaDisabled&&(s=!0);let e=i.find(e=>e.element===f);e?h.push(e):(m=void 0,h=[])}else c=!0}return l}class WJ{#t={};addListener(e,t){let n=this.#t[e];return void 0===n?this.#t[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#t[e];if(void 0!==n)if(1===n.length)n[0].call(null,t);else{let e=!1,r=null,a=Array.from(n);for(let n=0;n<a.length;n++){let i=a[n];try{i.call(null,t)}catch(t){null===r&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#t={}}removeListener(e,t){let n=this.#t[e];if(void 0!==n){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}}let WQ=new Map,W0=new WJ;function W1(e,t){for(let[t]of WQ)if(t.id===e)return t}function W2(e,t){for(let[t,n]of WQ)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function W5(e,t){return W0.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function W3(e,t){let n=WQ.get(e);(WQ=new Map(WQ)).set(e,t),W0.emit("groupChange",{group:e,prev:n,next:t})}let W4=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function W6(e){let t=e.length;for(;t--;){let n=e[t];if(Wq(n,"Missing node"),function(e){let t,n=getComputedStyle(e);return!!("fixed"===n.position||"auto"!==n.zIndex&&("static"!==n.position||"flex"===(t=getComputedStyle(W9(e)??e).display)||"inline-flex"===t)||1>+n.opacity||"transform"in n&&"none"!==n.transform||"webkitTransform"in n&&"none"!==n.webkitTransform||"mixBlendMode"in n&&"normal"!==n.mixBlendMode||"filter"in n&&"none"!==n.filter||"webkitFilter"in n&&"none"!==n.webkitFilter||"isolation"in n&&"isolate"===n.isolation||W4.test(n.willChange)||"touch"===n.webkitOverflowScrolling)}(n))return n}return null}function W8(e){return e&&Number(getComputedStyle(e).zIndex)||0}function W7(e){let t=[];for(;e;)t.push(e),e=W9(e);return t}function W9(e){let{parentNode:t}=e;return null!==t&&"object"==typeof t&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t}function Ke(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let a=WZ(r),i=function(e,t,n){let r,a={x:1/0,y:1/0};for(let i of t){let t=WY(n,i.rect);switch(e){case"horizontal":t.x<=a.x&&(r=i,a=t);break;case"vertical":t.y<=a.y&&(r=i,a=t)}}return r?{distance:a,hitRegion:r}:void 0}(r.orientation,a,{x:e.clientX,y:e.clientY});i&&i.distance.x<=0&&i.distance.y<=0&&function({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!WX(n)||n.contains(e)||e.contains(n))return!0;if(function(e,t){let n;if(e===t)throw Error("Cannot compare node with itself");let r={a:W7(e),b:W7(t)};for(;r.a.at(-1)===r.b.at(-1);)n=r.a.pop(),r.b.pop();Wq(n,"Stacking order can only be calculated for elements with a common ancestor");let a={a:W8(W6(r.a)),b:W8(W6(r.b))};if(a.a===a.b){let e=n.childNodes,t={a:r.a.at(-1),b:r.b.at(-1)},a=e.length;for(;a--;){let n=e[a];if(n===t.a)return 1;if(n===t.b)return -1}}return Math.sign(a.a-a.b)}(n,e)>0){let a=n;for(;a;){var r;if(a.contains(e))break;if(r=a.getBoundingClientRect(),r.x<t.x+t.width&&r.x+r.width>t.x&&r.y<t.y+t.height&&r.y+r.height>t.y)return!1;a=a.parentElement}}return!0}({groupElement:r.element,hitRegion:i.hitRegion.rect,pointerEventTarget:e.target})&&n.push(i.hitRegion)}),n}function Kt(e,t,n=0){return Math.abs(WV(e)-WV(t))<=n}function Kn(e,t){return Kt(e,t)?0:e>t?1:-1}function Kr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:a=0,collapsible:i,disabled:o,maxSize:l=100,minSize:s=0}=t;return o&&!e?n:(0>Kn(r,s)&&(r=i&&0>Kn(r,(a+s)/2)?a:s),WV(r=Math.min(l,r)))}function Ka({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:i}){if(Kt(e,0))return t;let o="imperative-api"===i,l=Object.values(t),s=Object.values(a),c=[...l],[d,u]=r;Wq(null!=d,"Invalid first pivot index"),Wq(null!=u,"Invalid second pivot index");let f=0;if("keyboard"===i){{let t=e<0?u:d,r=n[t];Wq(r,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(Wq(null!=n,`Previous layout not found for panel index ${t}`),Kt(n,a)){let t=o-n;Kn(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?d:u,r=n[t];Wq(r,`No panel constraints found for index ${t}`);let{collapsedSize:a=0,collapsible:i,minSize:o=0}=r;if(i){let n=l[t];if(Wq(null!=n,`Previous layout not found for panel index ${t}`),Kt(n,o)){let t=n-a;Kn(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}else{let t=e<0?u:d,r=n[t];Wq(r,`Panel constraints not found for index ${t}`);let a=l[t],{collapsible:i,collapsedSize:o,minSize:s}=r;if(i&&0>Kn(a,s))if(e>0){let t=s-o;0>Kn(a+e,s)&&(e=0>=Kn(e,t/2)?0:t)}else{let t=s-o;0>Kn(a-e,s)&&(e=Kn(100+e,100-t/2)>0?0:-t)}}{let t=e<0?1:-1,r=e<0?u:d,a=0;for(;;){let e=l[r];if(Wq(null!=e,`Previous layout not found for panel index ${r}`),a+=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e,(r+=t)<0||r>=n.length)break}let i=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-i:i}{let t=e<0?d:u;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),a=l[t];Wq(null!=a,`Previous layout not found for panel index ${t}`);let i=a-r,s=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:a,size:i});if(!Kt(a,s)&&(f+=a-s,c[t]=s,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}(s,c))return a;{let t=e<0?u:d,r=l[t];Wq(null!=r,`Previous layout not found for panel index ${t}`);let a=r+f,i=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:a});if(c[t]=i,!Kt(i,a)){let t=a-i,r=e<0?u:d;for(;r>=0&&r<n.length;){let a=c[r];Wq(null!=a,`Previous layout not found for panel index ${r}`);let i=a+t,l=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:a,size:i});if(Kt(a,l)||(t-=l-a,c[r]=l),Kt(t,0))break;e>0?r--:r++}}}if(!Kt(Object.values(c).reduce((e,t)=>t+e,0),100,.1))return a;let m=Object.keys(a);return c.reduce((e,t,n)=>(e[m[n]]=t,e),{})}function Ki(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(void 0===t[n]||0!==Kn(e[n],t[n]))return!1;return!0}function Ko({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],a=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(", ")}`);if(!Kt(a,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Wq(null!=t,`No layout data found for index ${e}`);let n=100/a*t;r[e]=n}let i=0;for(let e=0;e<t.length;e++){let a=n[e];Wq(null!=a,`No layout data found for index ${e}`);let o=r[e];Wq(null!=o,`No layout data found for index ${e}`);let l=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:a,size:o});o!=l&&(i+=o-l,r[e]=l)}if(!Kt(i,0))for(let e=0;e<t.length;e++){let n=r[e];Wq(null!=n,`No layout data found for index ${e}`);let a=n+i,o=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:a});if(n!==o&&(i-=o-n,r[e]=o,Kt(i,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Kl({groupId:e,panelId:t}){let n=()=>{for(let[t,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:a,groupSize:i,separatorToPanels:o}]of WQ)if(t.id===e)return{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:t,groupSize:i,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(void 0!==e)return e;throw Error(`Panel constraints not found for Panel ${t}`)},a=()=>{let e=n().group.panels.find(e=>e.id===t);if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},i=()=>{let e=n().layout[t];if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{if(e===i())return;let{defaultLayoutDeferred:r,derivedPanelConstraints:a,group:o,groupSize:l,layout:s,separatorToPanels:c}=n(),d=Ko({layout:(({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:a})=>{let o=i(),l=n.findIndex(e=>e.id===t),s=0===l,c=l===n.length-1;if(c&&e<o&&(s||n.slice(0,l).every((e,t)=>{let n=a[t];return n?.collapsible&&Kt(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,l).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:WV(100-e)}}return Ka({delta:c?o-e:e-o,initialLayout:r,panelConstraints:a,pivotIndices:c?[l-1,l]:[l,l+1],prevLayout:r,trigger:"imperative-api"})})({nextSize:e,panels:o.panels,prevLayout:s,derivedPanelConstraints:a}),panelConstraints:a});Ki(s,d)||W3(o,{defaultLayoutDeferred:r,derivedPanelConstraints:a,groupSize:l,layout:d,separatorToPanels:c})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=a(),l=i();e&&l!==t&&(n.expandToSize=l,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:l}=a(),s=i();if(e&&s===t){let e=l.expandToSize??n;0===e&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=i(),{element:r}=a();return{asPercentage:t,inPixels:"horizontal"===e.orientation?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=i();return e&&Kt(t,n)},resize:e=>{let{group:t}=n(),{element:r}=a(),i=WH({group:t});o(WV(WB({groupSize:i,panelElement:r,styleProp:e})/i*100))}}}function Ks(e){e.defaultPrevented||Ke(e,WQ).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>void 0!==e.panelConstraints.defaultSize);if(n){let r=n.panelConstraints.defaultSize,a=Kl({groupId:t.group.id,panelId:n.id});a&&void 0!==r&&(a.resize(r),e.preventDefault())}}})}function Kc(e){for(let[t]of WQ)if(t.separators.some(t=>t.element===e))return t;throw Error("Could not find parent Group for separator element")}function Kd({groupId:e}){let t=()=>{for(let[t,n]of WQ)if(t.id===e)return{group:t,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:a,groupSize:i,layout:o,separatorToPanels:l}=t(),s=Ko({layout:e,panelConstraints:r});return n?o:(Ki(o,s)||W3(a,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:i,layout:s,separatorToPanels:l}),s)}}}function Ku(e,t){let n=Kc(e),r=W2(n.id,!0),a=n.separators.find(t=>t.element===e);Wq(a,"Matching separator not found");let i=r.separatorToPanels.get(a);Wq(i,"Matching panels not found");let o=i.map(e=>n.panels.indexOf(e)),l=Kd({groupId:n.id}).getLayout(),s=Ko({layout:Ka({delta:t,initialLayout:l,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:l,trigger:"keyboard"}),panelConstraints:r.derivedPanelConstraints});Ki(l,s)||W3(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:s,separatorToPanels:r.separatorToPanels})}function Kf(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Kc(t);if(!n.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),"vertical"===n.orientation&&Ku(t,5);break;case"ArrowLeft":e.preventDefault(),"horizontal"===n.orientation&&Ku(t,-5);break;case"ArrowRight":e.preventDefault(),"horizontal"===n.orientation&&Ku(t,5);break;case"ArrowUp":e.preventDefault(),"vertical"===n.orientation&&Ku(t,-5);break;case"End":e.preventDefault(),Ku(t,100);break;case"Enter":{e.preventDefault();let n=Kc(t),{derivedPanelConstraints:r,layout:a,separatorToPanels:i}=W2(n.id,!0),o=n.separators.find(e=>e.element===t);Wq(o,"Matching separator not found");let l=i.get(o);Wq(l,"Matching panels not found");let s=l[0],c=r.find(e=>e.panelId===s.id);if(Wq(c,"Panel metadata not found"),c.collapsible){let e=a[s.id];Ku(t,(c.collapsedSize===e?n.mutableState.expandedPanelSizes[s.id]??c.minSize:c.collapsedSize)-e)}break}case"F6":{e.preventDefault();let n=Kc(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Wq(null!==r,"Index not found");let a=e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0;n[a].focus({preventScroll:!0});break}case"Home":e.preventDefault(),Ku(t,-100)}}let Km={cursorFlags:0,state:"inactive"},Kh=new WJ;function Kp(e){let t=Km;Km=e,Kh.emit("change",{prev:t,next:e})}function Kg(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=WQ,n=Ke(e,t),r=new Map,a=!1;n.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Kp({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}let Kx=e=>e,Kv=()=>{};function Kb(){return void 0===i&&(i=!1,"u">typeof window&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(i=!0)),i}let Ky=new WeakMap;function Kw(e){if(null===e.defaultView||void 0===e.defaultView)return;let{prevStyle:t,styleSheet:n}=Ky.get(e)??{};void 0===n&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=Km;switch(r.state){case"active":case"hover":{let e=function({cursorFlags:e,groups:t,state:n}){let r=0,a=0;switch(n){case"active":case"hover":t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case"horizontal":r++;break;case"vertical":a++}})}if(0!==r||0!==a){if("active"===n&&e&&Kb()){let t=(4&e)!=0,n=(8&e)!=0;if((1&e)!=0)return t?"se-resize":n?"ne-resize":"e-resize";if((2&e)!=0)return t?"sw-resize":n?"nw-resize":"w-resize";if(t)return"s-resize";if(n)return"n-resize"}return Kb()?r>0&&a>0?"move":r>0?"ew-resize":"ns-resize":r>0&&a>0?"grab":r>0?"col-resize":"row-resize"}}({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?0===n.cssRules.length?n.insertRule(a):n.replaceSync(a):1===n.cssRules.length&&n.deleteRule(0);break}case"inactive":t=void 0,1===n.cssRules.length&&n.deleteRule(0)}Ky.set(e,{prevStyle:t,styleSheet:n})}function Kj({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:a,pointerDownAtPoint:i,prevCursorFlags:o}){var l;let s,c,d=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:l,panels:s}=n,{disableCursor:c}=n.mutableState,u=0;u=i?"horizontal"===l?(t.clientX-i.x)/o*100:(t.clientY-i.y)/o*100:"horizontal"===l?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),m=a.get(n);if(!f||!m)return;let{defaultLayoutDeferred:h,derivedPanelConstraints:p,groupSize:g,layout:x,separatorToPanels:v}=m;if(p&&x&&v){let t=Ka({delta:u,initialLayout:f,panelConstraints:p,pivotIndices:e.panels.map(e=>s.indexOf(e)),prevLayout:x,trigger:"mouse-or-touch"});if(Ki(t,x)){if(0!==u&&!c)switch(l){case"horizontal":d|=u<0?1:2;break;case"vertical":d|=u<0?4:8}}else W3(e.group,{defaultLayoutDeferred:h,derivedPanelConstraints:p,groupSize:g,layout:t,separatorToPanels:v})}});let u=0;0===t.movementX?u|=3&o:u|=3&d,0===t.movementY?u|=12&o:u|=12&d,l=u,s=Km,(c={...Km}).cursorFlags=l,Km=c,Kh.emit("change",{prev:s,next:c}),Kw(e)}function Kk(e){let t=WQ,n=Km;"active"===n.state&&Kj({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}function KN(e){if(e.defaultPrevented)return;let t=Km,n=WQ;if("active"===t.state){if(0===e.buttons){Kp({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(e=>{let t=W2(e.group.id,!0);W3(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}Kj({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags})}else{let r=Ke(e,n);0===r.length?"inactive"!==t.state&&Kp({cursorFlags:0,state:"inactive"}):Kp({cursorFlags:0,hitRegions:r,state:"hover"}),Kw(e.currentTarget)}}function KC(e){e.relatedTarget instanceof HTMLIFrameElement&&"hover"===Km.state&&Kp({cursorFlags:0,state:"inactive"})}function KS(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=Km;"active"===t.state&&(Kp({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Kw(e.currentTarget),t.hitRegions.forEach(e=>{let t=W2(e.group.id,!0);W3(e.group,t)}),e.preventDefault()))}function KM(e){let t=0,n=0,r={};for(let a of e)if(void 0!==a.defaultSize){t++;let e=WV(a.defaultSize);n+=e,r[a.panelId]=e}else r[a.panelId]=void 0;let a=e.length-t;if(0!==a){let t=WV((100-n)/a);for(let n of e)void 0===n.defaultSize&&(r[n.panelId]=t)}return r}let KE=new Map;function KI(e){let t=(0,P.useId)();return`${e??t}`}let KP="u">typeof window?P.useLayoutEffect:P.useEffect;function KO(e){let t=(0,P.useRef)(e);return KP(()=>{t.current=e},[e]),(0,P.useCallback)((...e)=>t.current?.(...e),[t])}function Kz(...e){return KO(t=>{e.forEach(e=>{if(e)switch(typeof e){case"function":e(t);break;case"object":e.current=t}})})}function KA(e){let t=(0,P.useRef)({...e});return KP(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}let KT=(0,P.createContext)(null);function KR({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:a,elementRef:i,groupRef:o,id:l,onLayoutChange:s,onLayoutChanged:c,orientation:d="horizontal",resizeTargetMinimumSize:u={coarse:20,fine:10},style:f,...m}){let h,p=(0,P.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=KO(e=>{Ki(p.current.onLayoutChange,e)||(p.current.onLayoutChange=e,s?.(e))}),x=KO(e=>{Ki(p.current.onLayoutChanged,e)||(p.current.onLayoutChanged=e,c?.(e))}),v=KI(l),b=(0,P.useRef)(null),[y,w]=function(){let[e,t]=(0,P.useState)({});return[e,(0,P.useCallback)(()=>t({}),[])]}(),j=(0,P.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:u,separators:[]}),k=Kz(b,i);h=(0,P.useRef)({getLayout:()=>({}),setLayout:Kx}),(0,P.useImperativeHandle)(o,()=>h.current,[]),KP(()=>{Object.assign(h.current,Kd({groupId:v}))});let N=KO((e,t)=>{let r=Km,a=W1(e),i=W2(e);if(i){let e=!1;return"active"===r.state&&(e=r.hitRegions.some(e=>e.group===a)),{flexGrow:i.layout[t]??1,pointerEvents:e?"none":void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),C=KA({defaultLayout:n,disableCursor:r}),S=(0,P.useMemo)(()=>({get disableCursor(){return!!C.disableCursor},getPanelStyles:N,id:v,orientation:d,registerPanel:e=>{let t=j.current;return t.panels=WW(d,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerSeparator:e=>{let t=j.current;return t.separators=WW(d,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=j.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=W1(v),a=W2(v);r&&a&&W3(r,{...a,derivedPanelConstraints:WU(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=j.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[N,v,w,d,C]),M=(0,P.useRef)(null);return KP(()=>{let e,t,n,r,i,o,l,s,c,u,f,m,h,p=b.current;if(null===p)return;let y=j.current;if(void 0!==C.defaultLayout&&Object.keys(C.defaultLayout).length===y.panels.length)for(let t of(e={},y.panels)){let n=C.defaultLayout[t.id];void 0!==n&&(e[t.id]=n)}let w={disabled:!!a,element:p,id:v,mutableState:{defaultLayout:e,disableCursor:!!C.disableCursor,expandedPanelSizes:j.current.lastExpandedPanelSizes,layouts:j.current.layouts},orientation:d,panels:y.panels,resizeTargetMinimumSize:y.resizeTargetMinimumSize,separators:y.separators};M.current=w;let k=(t=!0,Wq(w.element.ownerDocument.defaultView,"Cannot register an unmounted Group"),n=w.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,(o=new n(e=>{for(let n of e){let{borderBoxSize:e,target:r}=n;if(r===w.element){if(t){let e=WH({group:w});if(0===e)return;let t=W2(w.id);if(!t)return;let n=WU(w),r=t.defaultLayoutDeferred?KM(n):t.layout,a=Ko({layout:function({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let a=0,i=0,o=!1,l=new Map,s=[];for(let c of e.panels){let e=r[c.id]??0;if("preserve-pixel-size"===c.panelConstraints.groupResizeBehavior){o=!0;let r=WV(e/100*n/t*100);l.set(c.id,r),a+=r}else s.push(c.id),i+=e}if(!o||0===s.length)return r;let c=100-a,d={...r};if(l.forEach((e,t)=>{d[t]=e}),i>0)for(let e of s){let t=r[e]??0;d[e]=WV(t/i*c)}else{let e=WV(c/s.length);for(let t of s)d[t]=e}return d}({group:w,nextGroupSize:e,prevGroupSize:t.groupSize,prevLayout:r}),panelConstraints:n});if(!t.defaultLayoutDeferred&&Ki(t.layout,a)&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}(t.derivedPanelConstraints,n)&&t.groupSize===e)return;W3(w,{defaultLayoutDeferred:!1,derivedPanelConstraints:n,groupSize:e,layout:a,separatorToPanels:t.separatorToPanels})}}else!function(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let a=WH({group:e}),i="horizontal"===e.orientation?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,l={asPercentage:WV(i/a*100),inPixels:i};r.mutableValues.prevSize=l,r.onResize(l,r.id,o)}(w,r,e)}})).observe(w.element),w.panels.forEach(e=>{Wq(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&o.observe(e.element)}),l=WH({group:w}),s=WU(w),c=w.panels.map(({id:e})=>e).join(","),(u=w.mutableState.defaultLayout)&&(function(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}(w.panels,u)||(u=void 0)),f=Ko({layout:w.mutableState.layouts[c]??u??KM(s),panelConstraints:s}),m=w.element.ownerDocument,KE.set(m,(KE.get(m)??0)+1),h=new Map,WZ(w).forEach(e=>{e.separator&&h.set(e.separator,e.panels)}),W3(w,{defaultLayoutDeferred:0===l,derivedPanelConstraints:s,groupSize:l,layout:f,separatorToPanels:h}),w.separators.forEach(e=>{Wq(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener("keydown",Kf)}),1===KE.get(m)&&(m.addEventListener("dblclick",Ks,!0),m.addEventListener("pointerdown",Kg,!0),m.addEventListener("pointerleave",Kk),m.addEventListener("pointermove",KN),m.addEventListener("pointerout",KC),m.addEventListener("pointerup",KS,!0)),function(){t=!1,KE.set(m,Math.max(0,(KE.get(m)??0)-1)),(WQ=new Map(WQ)).delete(w),w.separators.forEach(e=>{e.element.removeEventListener("keydown",Kf)}),KE.get(m)||(m.removeEventListener("dblclick",Ks,!0),m.removeEventListener("pointerdown",Kg,!0),m.removeEventListener("pointerleave",Kk),m.removeEventListener("pointermove",KN),m.removeEventListener("pointerout",KC),m.removeEventListener("pointerup",KS,!0)),o.disconnect()}),{defaultLayoutDeferred:N,derivedPanelConstraints:S,layout:E}=W2(w.id,!0);!N&&S.length>0&&(g(E),x(E));let I=W5(v,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:r}=e.next;if(t||0===n.length)return;let a=w.panels.map(({id:e})=>e).join(",");w.mutableState.layouts[a]=r,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Kt(t.collapsedSize,r[t.panelId]),a=Kt(t.collapsedSize,n[t.panelId]);e&&!a&&(w.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let i="active"!==Km.state;g(r),i&&x(r)});return()=>{M.current=null,k(),I()}},[a,v,x,g,d,y,C]),(0,P.useEffect)(()=>{let e=M.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,E.jsx)(KT.Provider,{value:S,children:(0,E.jsx)("div",{...m,className:t,"data-group":!0,"data-testid":v,id:v,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:"horizontal"===d?"row":"column",flexWrap:"nowrap",touchAction:"horizontal"===d?"pan-y":"pan-x"},children:e})})}function K_(){let e=(0,P.useContext)(KT);return Wq(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function KD({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:a,disabled:i,elementRef:o,groupResizeBehavior:l="preserve-relative-size",id:s,maxSize:c="100%",minSize:d="0%",onResize:u,panelRef:f,style:m,...h}){let p,g=!!s,x=KI(s),v=KA({disabled:i}),b=(0,P.useRef)(null),y=Kz(b,o),{getPanelStyles:w,id:j,orientation:k,registerPanel:N,updatePanelProps:C}=K_(),S=null!==u,M=KO((e,t,n)=>{u?.(e,s,n)});KP(()=>{let e=b.current;if(null!==e)return N({element:e,id:x,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:S?M:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:n,collapsible:r,defaultSize:a,disabled:v.disabled,maxSize:c,minSize:d}})},[l,n,r,a,S,x,g,c,d,M,N,v]),(0,P.useEffect)(()=>{C(x,{disabled:i})},[i,x,C]),function(e,t){let{id:n}=K_(),r=(0,P.useRef)({collapse:Kv,expand:Kv,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Kv});(0,P.useImperativeHandle)(t,()=>r.current,[]),KP(()=>{Object.assign(r.current,Kl({groupId:n,panelId:e}))})}(x,f);let I=()=>{let e=w(j,x);if(e)return JSON.stringify(e)},O=(0,P.useSyncExternalStore)(e=>W5(j,e),I,I);return p=O?JSON.parse(O):void 0!==a?{flexGrow:void 0,flexShrink:void 0,flexBasis:a}:{flexGrow:1},(0,E.jsx)("div",{...h,"data-disabled":i||void 0,"data-panel":!0,"data-testid":x,id:x,ref:y,style:{...KL,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...p},children:(0,E.jsx)("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:"horizontal"===k?"pan-y":"pan-x"},children:e})})}KR.displayName="Group",KD.displayName="Panel";let KL={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function K$({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:a,id:i,style:o,...l}){let s,c,d=KI(i),u=KA({disabled:n,disableDoubleClick:r}),[f,m]=(0,P.useState)({}),[h,p]=(0,P.useState)("inactive"),[g,x]=(0,P.useState)(!1),v=(0,P.useRef)(null),b=Kz(v,a),{disableCursor:y,id:w,orientation:j,registerSeparator:k,updateSeparatorProps:N}=K_();return KP(()=>{let e=v.current;if(null!==e){var t;let n={disabled:u.disabled,disableDoubleClick:u.disableDoubleClick,element:e,id:d},r=k(n),a=(t=e=>{p("inactive"!==e.next.state&&e.next.hitRegions.some(e=>e.separator===n)?e.next.state:"inactive")},Kh.addListener("change",t)),i=W5(w,e=>{let{derivedPanelConstraints:t,layout:r,separatorToPanels:a}=e.next,i=a.get(n);if(i){let e=i[0],n=i.indexOf(e);m(function({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let a,i,o=e[n],l=t.find(e=>e.panelId===n);if(l){let s=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,d=[r,r+1];i=Ko({layout:Ka({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n],a=Ko({layout:Ka({delta:s-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:a,valueMin:i,valueNow:o}}({layout:r,panelConstraints:t,panelId:e.id,panelIndex:n}))}});return()=>{a(),i(),r()}}},[w,d,k,u]),(0,P.useEffect)(()=>{N(d,{disabled:n,disableDoubleClick:r})},[n,r,d,N]),n&&!y&&(s="not-allowed"),c=n?"disabled":"active"===h?"active":g?"focus":h,(0,E.jsx)("div",{...l,"aria-controls":f.valueControls,"aria-disabled":n||void 0,"aria-orientation":"horizontal"===j?"vertical":"horizontal","aria-valuemax":f.valueMax,"aria-valuemin":f.valueMin,"aria-valuenow":f.valueNow,children:e,className:t,"data-separator":c,"data-testid":d,id:d,onBlur:()=>x(!1),onFocus:()=>x(!0),ref:b,role:"separator",style:{flexBasis:"auto",cursor:s,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}function KF({className:e,direction:t,orientation:n,...r}){let a=n??t;return(0,E.jsx)(KR,{"data-slot":"resizable-panel-group","data-orientation":a??"horizontal",orientation:a,className:(0,B.cn)("flex h-full w-full data-[orientation=vertical]:flex-col",e),...r})}function KB({...e}){return(0,E.jsx)(KD,{"data-slot":"resizable-panel",...e})}function KV({withHandle:e,className:t,...n}){return(0,E.jsx)(K$,{"data-slot":"resizable-handle",className:(0,B.cn)("relative flex w-px items-center justify-center bg-border outline-none after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...n,children:e&&(0,E.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-background",children:(0,E.jsx)(WF,{className:"size-2.5"})})})}K$.displayName="Separator";let KH=(0,z.default)("folder-kanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]),KU=(0,z.default)("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]),Kq=[{id:"ui-polish",name:"UI Polish",purpose:"整理组件视觉细节、间距和状态反馈。",models:["gpt-5-codex","gpt-5-high"]},{id:"interaction-audit",name:"Interaction Audit",purpose:"检查拖拽、滚动、键盘和选择流程。",models:["gpt-5-codex"]},{id:"typescript-check",name:"TypeScript Check",purpose:"处理类型、lint 和接口兼容。",models:["gpt-5-mini"]},{id:"telemetry-reader",name:"Telemetry Reader",purpose:"读取机器状态、运行指标和队列遥测。",models:["gpt-5-mini"]},{id:"risk-summarizer",name:"Risk Summarizer",purpose:"归纳运行风险、阻塞点和维护建议。",models:["gpt-5-codex"]},{id:"changelog-writer",name:"Changelog Writer",purpose:"整理发布说明和用户可读变更。",models:["gpt-5-mini"]},{id:"default-worker",name:"Default Worker",purpose:"通用子任务执行者。",models:["gpt-5-codex"]}],KW=[{id:"agent-ui-library",title:"Vantaloom UI 库迁移",agent:"Frontend Orchestrator",status:"working",goal:"把核心标签、画布节点和管理面板统一到可复用组件层。",progress:72,taskProgress:[100,100,75,32],runtime:"2h 18m",tokens:392e3,lastOpened:"刚刚",roadmap:[{title:"整理基础组件映射",state:"done"},{title:"接入画布节点容器",state:"done"},{title:"修正拖拽与剪切板交互",state:"running"},{title:"补充管理页面",state:"queued"}],settings:{subagents:["ui-polish","interaction-audit","typescript-check"],mainModels:["gpt-5-codex","gpt-5-high"],folders:["D:/Projects/Vantaloom-ui","D:/Projects/Vantaloom-ui/apps"],blockedCommands:["git reset --hard","Remove-Item -Recurse .next"],allowedTools:["shell","browser","apply_patch","node_repl"],deniedTools:["network deploy","destructive git"],plugins:["Browser","Spreadsheets"],hosts:["Studio-PC","Linux-runner-02"]}},{id:"agent-ops-review",title:"工作组运行巡检",agent:"Ops Sentinel",status:"working",goal:"检查工作组机器负载、队列阻塞和夜间维护风险。",progress:48,taskProgress:[100,64,28],runtime:"54m",tokens:184e3,lastOpened:"6 分钟前",roadmap:[{title:"读取机器状态",state:"done"},{title:"分析队列拥塞",state:"running"},{title:"生成维护建议",state:"queued"}],settings:{subagents:["telemetry-reader","risk-summarizer"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/ops"],blockedCommands:["shutdown","Restart-Service"],allowedTools:["shell","browser"],deniedTools:["write secrets"],plugins:["Browser"],hosts:["Studio-PC","MacBook-build"]}},{id:"agent-doc-sync",title:"发布说明整理",agent:"Docs Agent",status:"paused",goal:"把最近组件变更整理成可发布的文档摘要。",progress:31,taskProgress:[86,22,0],runtime:"23m",tokens:91e3,lastOpened:"22 分钟前",roadmap:[{title:"扫描组件变更",state:"running"},{title:"归纳破坏性变化",state:"queued"},{title:"输出发布草稿",state:"queued"}],settings:{subagents:["changelog-writer"],mainModels:["gpt-5-mini"],folders:["D:/Projects/Vantaloom-ui/docs"],blockedCommands:["git push"],allowedTools:["shell","apply_patch"],deniedTools:["browser credentials"],plugins:[],hosts:["Studio-PC"]}},{id:"agent-browser-lab",title:"浏览器标签适配",agent:"Preview Agent",status:"idle",goal:"验证浏览器标签页不同尺寸和 UA 的预览行为。",progress:100,taskProgress:[100,100,100],runtime:"1h 42m",tokens:246e3,lastOpened:"今天 14:20",roadmap:[{title:"补充自适应尺寸",state:"done"},{title:"加入前进后退刷新",state:"done"},{title:"验证画布节点容器",state:"done"}],settings:{subagents:["responsive-checker"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/packages/ui"],blockedCommands:["pnpm publish"],allowedTools:["browser","shell"],deniedTools:["external network write"],plugins:["Browser"],hosts:["Studio-PC"]}},{id:"agent-data-tab",title:"数据表标签优化",agent:"Data UI Agent",status:"idle",goal:"完善 CSV / JSON 表格标签的排序、复制与列宽交互。",progress:100,taskProgress:[100,100,100,100],runtime:"38m",tokens:132e3,lastOpened:"昨天 19:04",roadmap:[{title:"列宽拖动",state:"done"},{title:"行选择",state:"done"},{title:"复制单元格",state:"done"},{title:"接入多标签页",state:"done"}],settings:{subagents:["table-a11y"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui/packages/ui/src/components"],blockedCommands:["Remove-Item"],allowedTools:["shell","apply_patch"],deniedTools:["remote write"],plugins:[],hosts:["Studio-PC"]}}];function KK(e,t,n,r,a,i,o,l,s){return{id:e,title:t,agent:n,status:r,goal:a,progress:i,taskProgress:[100,i,0],runtime:o,tokens:l,lastOpened:s,roadmap:[{title:"读取上下文",state:i>20?"done":"running"},{title:"执行当前任务",state:i>20?"running":"queued"},{title:"整理结果",state:"queued"}],settings:{subagents:["default-worker"],mainModels:["gpt-5-codex"],folders:["D:/Projects/Vantaloom-ui"],blockedCommands:["git reset --hard"],allowedTools:["shell","apply_patch"],deniedTools:["destructive git"],plugins:[],hosts:["Studio-PC"]}}}KW.push(KK("agent-terminal-polish","终端标签组打磨","Terminal Agent","working","检查终端 TUI 渲染、字体和滚动行为。",37,"41m",118e3,"9 分钟前"),KK("agent-table-review","数据表交互复核","Table Agent","working","复核排序、列宽拖动和单元格复制体验。",62,"1h 07m",211e3,"12 分钟前"),KK("agent-node-canvas-docs","节点画布文档化","Canvas Writer","paused","把节点、连线和吸附策略整理成内部说明。",18,"16m",64e3,"31 分钟前"),KK("agent-file-tree-audit","文件树交互审阅","Explorer Agent","idle","审阅框选、多选拖拽和插入线表现。",100,"52m",152e3,"今天 13:12"),KK("agent-auth-flow","登录注册流程整理","Access Agent","idle","检查本机用户与工作组接入之间的边界。",100,"44m",99e3,"今天 11:45"),KK("agent-settings-panel","设置面板导航审阅","Settings Agent","idle","检查主菜单、子菜单和搜索跳转体验。",100,"36m",87e3,"昨天 21:18"),KK("agent-diff-view","Diff 标签页复盘","Review Agent","idle","整理统一差异、分栏差异和折叠区域规则。",100,"1h 11m",176e3,"昨天 16:02"),KK("agent-clipboard-stack","剪切板堆叠交互记录","Clipboard Agent","idle","记录钥匙扣展开、拖拽排序和垃圾桶联动。",100,"1h 24m",234e3,"周五 18:33")),KW.filter(e=>"idle"!==e.status);let KG=KW.filter(e=>"idle"===e.status).sort((e,t)=>e.lastOpened.localeCompare(t.lastOpened));function KX({conversation:e,mainModels:t,onMainModelsChange:n}){let{models:r,loading:a}=nl(),[i,o]=P.useState(""),l=P.useMemo(()=>r.filter(e=>!1!==e.available),[r]),s=P.useMemo(()=>{let e=new Map;for(let t of l){let n=t.providerName?.trim()||"其他",r=e.get(n);r?r.push(t):e.set(n,[t])}return Array.from(e.entries()).map(([e,t])=>({provider:e,models:t}))},[l]),c=P.useMemo(()=>{let e=i.trim().toLowerCase();return e?s.map(t=>({provider:t.provider,models:t.models.filter(n=>n.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e))})).filter(e=>e.models.length>0):s},[s,i]),d=P.useMemo(()=>new Set(t),[t]),u=e?.lastModelRef??"",f=u&&d.has(u)?u:t[0],m=P.useMemo(()=>new Set(l.map(e=>e.value)),[l]),h=P.useMemo(()=>new Map(r.map(e=>[e.value,e])),[r]),p=P.useMemo(()=>t.filter(e=>!m.has(e)).map(e=>{let t=h.get(e);return{id:e,label:t?.label??e,provider:t?.providerName?.trim()||""}}),[t,m,h]),g=P.useMemo(()=>{let e=i.trim().toLowerCase();return e?p.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):p},[p,i]),x=P.useCallback(e=>{n(d.has(e)?t.filter(t=>t!==e):[...t,e])},[t,n,d]),v=P.useCallback(e=>{let r=e.map(e=>e.value);if(r.every(e=>d.has(e))){let e=new Set(r);n(t.filter(t=>!e.has(t)))}else n([...t,...r.filter(e=>!d.has(e))])},[t,n,d]);return(0,E.jsxs)("div",{className:"grid gap-3",children:[e?.agent?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:e.agent}):null,(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"该会话可用的语言模型,按渠道分组;可选多个,作为允许使用的模型集合。主模型(标记为「主」)由实际使用动态决定,无需在此手动指定。"}),(0,E.jsxs)("div",{className:"relative",children:[(0,E.jsx)(IX,{className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,E.jsx)(V,{value:i,onChange:e=>o(e.target.value),placeholder:"搜索模型或渠道...",className:"h-8 pl-8"})]}),(0,E.jsx)("div",{className:"grid max-h-[min(22rem,50svh)] gap-3 overflow-auto rounded-lg border bg-card/40 p-2",children:a&&0===r.length?(0,E.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:"读取模型中…"}):0===c.length&&0===g.length?(0,E.jsx)("p",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:0===r.length?"没有可用模型":"没有匹配的模型"}):(0,E.jsxs)(E.Fragment,{children:[c.map(e=>{let t=e.models.map(e=>e.value),n=t.filter(e=>d.has(e)).length,r=n===t.length;return(0,E.jsxs)("div",{className:"grid gap-1",children:[(0,E.jsxs)("div",{className:"flex items-center justify-between gap-2 px-1",children:[(0,E.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,E.jsx)("span",{className:"truncate text-xs font-semibold text-foreground",children:e.provider}),(0,E.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[n,"/",t.length]})]}),(0,E.jsx)(F.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 shrink-0 px-2 text-xs",onClick:()=>v(e.models),children:r?"取消全选":"全选"})]}),(0,E.jsx)("div",{className:"grid gap-0.5",children:e.models.map(e=>{let t=d.has(e.value),n=e.value===f;return(0,E.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":t,onClick:()=>x(e.value),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),x(e.value))},className:(0,B.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50",t?"bg-primary/10 text-foreground":"hover:bg-muted"),children:[(0,E.jsx)(EF,{checked:t,tabIndex:-1,className:"pointer-events-none"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.label}),n?(0,E.jsx)("span",{className:"shrink-0 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"主"}):null]},e.value)})})]},e.provider)}),g.length>0?(0,E.jsxs)("div",{className:"grid gap-1",children:[(0,E.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,E.jsx)("span",{className:"truncate text-xs font-semibold text-muted-foreground",children:"已禁用 / 不可用"}),(0,E.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:g.length})]}),(0,E.jsx)("div",{className:"grid gap-0.5",children:g.map(e=>(0,E.jsxs)("div",{role:"button",tabIndex:0,"aria-pressed":!0,title:"该模型所属渠道已禁用或不可用,点击可移除",onClick:()=>x(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),x(e.id))},className:(0,B.cn)("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm opacity-60 transition-colors outline-none hover:bg-muted hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50"),children:[(0,E.jsx)(EF,{checked:!0,tabIndex:-1,className:"pointer-events-none"}),(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:[e.label,e.provider?(0,E.jsxs)("span",{className:"ml-1.5 text-[11px] text-muted-foreground/70",children:["· ",e.provider]}):null]}),(0,E.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"不可用"})]},e.id))})]}):null]})})]})}async function KY(e,t){let n=new URLSearchParams;e&&n.set("conversationId",e),t&&n.set("workspace",t);let r=n.toString();return Ge(`/api/local/agent/project-docs${r?`?${r}`:""}`)}async function KZ(e,t,n,r){return Ge("/api/local/agent/project-docs",{method:"PUT",body:JSON.stringify({path:e,content:t,conversationId:n,workspace:r})})}let KJ=null,KQ=null;async function K0(){let e=Date.now();return KJ&&e-KJ.at<3e4?KJ.value:KQ||(KQ=(async()=>{try{let e=await Ge("/api/local/agent-config");return KJ={value:e,at:Date.now()},e}finally{KQ=null}})())}async function K1(e){let t=await Ge("/api/local/agent-config",{method:"PUT",body:JSON.stringify(e)});return KJ={value:t,at:Date.now()},t}async function K2(e){return Ge(e&&"local"!==e?`/v1/remote/${e}/agent/engines`:"/api/local/agent/engines")}function K5(e){return"installing-node"===e||"installing-bridge"===e}async function K3(){return Ge("/api/local/agent/engines/install-adapter",{method:"POST"})}async function K4(){return Ge("/api/local/agent/engines/install-status")}async function K6(){return Ge("/api/local/agent/reclaude/status")}async function K8(){return Ge("/api/local/agent/reclaude/login/start",{method:"POST",body:"{}"})}async function K7(e){return Ge("/api/local/agent/reclaude/login/poll",{method:"POST",body:JSON.stringify({state:e})})}async function K9(){return Ge("/api/local/agent/reclaude/logout",{method:"POST",body:"{}"})}async function Ge(e,t){let n=await fetch((0,H.localAPIURL)(e),{cache:"no-store",...t,headers:{...t?.body?{"Content-Type":"application/json"}:{},...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error("string"==typeof r?.error?r.error:"agent config api failed");return r}let Gt=[{engine:"vantaloom",available:!0}];function Gn(e){let[t,n]=P.useState([]),[r,a]=P.useState(!0),i=P.useCallback(async()=>{a(!0);try{let t=await K2(e);n(Array.isArray(t.engines)&&t.engines.length>0?t.engines:Gt)}catch{n(Gt)}finally{a(!1)}},[e]);return P.useEffect(()=>{i()},[i]),{engines:t,loading:r,refresh:i}}let Gr={folders:[],blockedCommands:[],allowedTools:[],deniedTools:[],plugins:[],hosts:["local"]},Ga=["运行环境配置","选择工作目录","模型设置","确认开始"],Gi=[{value:"vantaloom",label:"Vantaloom"},{value:"claude-code",label:"Claude Code"},{value:"reclaude",label:"reclaude"}];function Go({onCreated:e,onCancel:t}){let{machines:n}=TV(),{models:r}=nl(),[a,i]=P.useState("local"),{engines:o}=Gn(a),l=P.useCallback(e=>{if("vantaloom"===e)return!0;let t=o.find(t=>t.engine===e);return t?.available??!1},[o]),s=P.useCallback(e=>o.find(t=>t.engine===e)?.reason,[o]),[c,d]=P.useState(0),[u,f]=P.useState(""),[m,h]=P.useState("vantaloom"),[p,g]=P.useState(Kq),[x,v]=P.useState([]),[b,y]=P.useState(""),[w,j]=P.useState(Gr),[k,N]=P.useState(!1),[C,S]=P.useState("");P.useEffect(()=>{"vantaloom"===m||l(m)||h("vantaloom")},[m,l]);let M=_D(m);P.useEffect(()=>{M&&j(e=>{let t=1===e.hosts.length&&"local"===e.hosts[0],n=e.folders.slice(-1),r=n.length===e.folders.length;return t&&r?e:{...e,hosts:["local"],folders:n}})},[M]);let I=P.useMemo(()=>({id:"new-agent-conversation",title:u.trim()||"新 Agent 对话",agent:"Local Agent",status:k?"working":"idle",goal:"",progress:0,taskProgress:[100,0],runtime:"0m",tokens:0,lastOpened:"刚刚",roadmap:[{title:"配置会话环境",state:"done"},{title:"等待首条消息",state:"queued"}],settings:{subagents:[],mainModels:x,...w,engine:m,ccModel:M?b:void 0}}),[b,k,m,M,x,w,u]),O="local"===a?"本机":n.find(e=>e.id===a)?.name??a,z=P.useCallback(async()=>{if(!k){N(!0),S("");try{let t=await e7({title:u.trim()||"新 Agent 对话",agent:"Local Agent",goal:"",ownerMachineId:a,settings:{subagents:[],mainModels:M?[]:x,...w,engine:m,ccModel:M?b:void 0}});e(t)}catch(t){let e="local"===a?void 0:n.find(e=>e.id===a)?.name;"local"!==a&&d(0),S(function(e,t){let n;if(n=e instanceof Error?e.message:String(e??""),/relay to .* failed/i.test(n)||n.includes("目标机器离线或未连接")||/no response from/i.test(n)||/relay timeout|request timeout/i.test(n)||/Hub connection not configured/i.test(n)){let e=t?`机器「${t}」`:"目标机器";return`${e}当前离线或无法连接,无法在其上运行 agent。请确认该机器已开启并联网,或改在本机运行。`}return e instanceof Error&&e.message?e.message:"操作失败"}(t,e))}finally{N(!1)}}},[b,k,m,M,n,x,e,a,w,u]),A=c===Ga.length-1;return(0,E.jsxs)("div",{className:"vtl-app-background flex h-full min-h-0 flex-col","data-tour":"init-wizard",children:[(0,E.jsx)("header",{className:"shrink-0 px-6 pt-8 pb-6",children:(0,E.jsx)("ol",{className:"mx-auto flex max-w-2xl items-center",children:Ga.map((e,t)=>{let n=t<c,r=t===c;return(0,E.jsxs)("li",{className:"flex min-w-0 flex-1 items-center last:flex-none",children:[(0,E.jsxs)("button",{type:"button","aria-current":r?"step":void 0,"aria-label":`第 ${t+1} 步:${e}`,onClick:()=>{t<=c&&d(t)},className:"group flex shrink-0 items-center gap-2 outline-none",children:[(0,E.jsx)("span",{className:(0,B.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border text-sm font-medium transition-colors",n?"border-primary bg-primary text-primary-foreground":r?"border-primary text-primary ring-2 ring-primary/30":"border-border bg-background text-muted-foreground"),children:n?(0,E.jsx)(CV,{className:"size-4"}):t+1}),(0,E.jsx)("span",{className:(0,B.cn)("hidden truncate text-sm font-medium transition-colors sm:inline",r?"text-foreground":n?"text-foreground/80":"text-muted-foreground"),children:e})]}),t<Ga.length-1?(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("mx-3 h-px min-w-6 flex-1 transition-colors",t<c?"bg-primary":"bg-border")}):null]},e)})})}),(0,E.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6",children:(0,E.jsxs)("div",{className:"mx-auto w-full max-w-2xl",children:[0===c?(0,E.jsxs)("div",{className:"grid gap-6",children:[(0,E.jsx)(Gs,{value:a,onChange:e=>{i(e)},machines:n}),(0,E.jsxs)("div",{className:"grid gap-2","data-tour":"wizard-engine",children:[(0,E.jsx)("label",{htmlFor:"agent-init-engine",className:"text-sm font-medium text-foreground",children:"运行哪个 Agent"}),(0,E.jsx)(zB,{id:"agent-init-engine",value:m,onValueChange:e=>h(e),placeholder:"选择运行引擎",title:"选择运行引擎",className:"w-full",options:Gi.map(e=>{let t=l(e.value);return{value:e.value,label:`${e.label}${t?"":"(不可用)"}`,disabled:!t}})}),s(m)?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:s(m)}):null,M?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code(含 reclaude)运行在所选的 owner 机器上;其工具(读/写/执行)锁定在该机本地(跨机能力待 MCP 扩展)。"}):null]}),(0,E.jsx)(TJ,{value:w.hosts,onValueChange:e=>j(t=>({...t,hosts:e})),disabled:M,hint:M?"Claude Code 的工具锁定在所选 owner 机器本地,可访问主机已锁定。":void 0})]}):null,1===c?(0,E.jsxs)("div",{className:"grid gap-6",children:[(0,E.jsxs)("div",{className:"grid gap-2",children:[(0,E.jsx)("label",{htmlFor:"agent-init-title",className:"text-sm font-medium text-foreground",children:"对话名称(可选)"}),(0,E.jsx)(V,{id:"agent-init-title",value:u,placeholder:"新 Agent 对话",onChange:e=>f(e.currentTarget.value)})]}),(0,E.jsx)(TW,{title:"可访问的工作区文件夹",value:w.folders,onValueChange:e=>j(t=>({...t,folders:M?e.slice(-1):e}))}),M?(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"Claude Code 仅支持单个工作目录(作为会话的工作根目录)。"}):null]}):null,2===c?M?(0,E.jsxs)("div",{className:"grid gap-3",children:[(0,E.jsx)("label",{htmlFor:"agent-init-cc-model",className:"text-base font-semibold tracking-normal text-foreground",children:"Claude Code 模型"}),(0,E.jsx)(zB,{id:"agent-init-cc-model",value:""===b?_R:b,onValueChange:e=>y(e===_R?"":e),placeholder:"选择 Claude Code 模型",title:"选择 Claude Code 模型",className:"w-full",options:__.map(e=>({value:e.value,label:e.label}))}),(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"模型由 Claude Code 提供,不走 Vantaloom 模型路由。"})]}):(0,E.jsx)(KX,{conversation:I,sharedSubagents:p,mainModels:x,enabledSubagentIds:[],onMainModelsChange:v,onSharedSubagentsChange:g}):null,3===c?(0,E.jsxs)("div",{className:"grid gap-4",children:[(0,E.jsxs)("div",{className:"grid gap-3 rounded-xl border bg-card p-5",children:[(0,E.jsx)("h3",{className:"text-base font-semibold tracking-normal",children:"配置摘要"}),(0,E.jsxs)("div",{className:"grid gap-2.5",children:[(0,E.jsx)(Gl,{icon:(0,E.jsx)(KH,{}),label:"工作目录",value:w.folders.length>0?`${w.folders.length} 个目录`:"未选择"}),(0,E.jsx)(Gl,{icon:(0,E.jsx)($,{}),label:"运行环境",value:O}),(0,E.jsx)(Gl,{icon:(0,E.jsx)(_q,{}),label:"运行引擎",value:Gi.find(e=>e.value===m)?.label??m}),(0,E.jsx)(Gl,{icon:(0,E.jsx)(UB,{}),label:"模型",value:M?__.find(e=>(e.value===_R?"":e.value)===b)?.label??"默认模型":x.length>0?x.map(e=>r.find(t=>t.value===e)?.label??e).join("、"):"默认模型"})]})]}),C?(0,E.jsx)("div",{className:"text-sm text-destructive",children:C}):null]}):null]})}),(0,E.jsx)("footer",{className:"flex shrink-0 items-center justify-between px-6 pb-8",children:(0,E.jsxs)("div",{className:"mx-auto flex w-full max-w-2xl items-center justify-between",children:[(0,E.jsxs)(F.Button,{type:"button",variant:"ghost",disabled:k,onClick:()=>{0===c?t?.():d(e=>Math.max(0,e-1))},children:[(0,E.jsx)(IH,{className:"size-4"}),0===c?"取消":"上一步"]}),A?(0,E.jsxs)(F.Button,{type:"button",disabled:k,onClick:()=>void z(),children:[(0,E.jsx)(KU,{className:"size-4"}),k?"创建中…":"确认开始"]}):(0,E.jsxs)(F.Button,{type:"button",onClick:()=>d(e=>Math.min(Ga.length-1,e+1)),children:["下一步",(0,E.jsx)(MC,{className:"size-4"})]})]})})]})}function Gl({icon:e,label:t,value:n}){return(0,E.jsxs)("div",{className:"grid grid-cols-[auto_5rem_minmax(0,1fr)] items-center gap-3",children:[(0,E.jsx)("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4",children:e}),(0,E.jsx)("span",{className:"text-sm text-muted-foreground",children:t}),(0,E.jsx)("span",{className:"min-w-0 truncate text-sm font-medium text-foreground",children:n})]})}function Gs({value:e,onChange:t,machines:n}){let r=P.useMemo(()=>{let e=[],t=!1;for(let r of n)if(r.isLocal)t=!0,e.unshift({id:"local",name:"本机",online:!0,reachable:!0});else{let t="online"===r.status;e.push({id:r.id,name:r.name,online:t,reachable:r.reachable??t})}return t||e.unshift({id:"local",name:"本机",online:!0,reachable:!0}),e},[n]);return(0,E.jsxs)("div",{className:"grid gap-2",children:[(0,E.jsx)("label",{htmlFor:"agent-init-run-machine",className:"text-sm font-medium text-foreground",children:"Agent 运行位置"}),(0,E.jsx)(zB,{id:"agent-init-run-machine",value:e,onValueChange:t,placeholder:"选择运行位置",title:"选择运行位置",className:"w-full",options:r.map(e=>{let t=e.reachable?"":e.online?"(在线·不可达)":"(离线)";return{value:e.id,label:`${e.name}${t}`,disabled:!e.reachable}})}),(0,E.jsx)("p",{className:"text-xs text-muted-foreground",children:"选择 agent 实际运行在工作组里的哪台机器(默认本机)。会话与历史会保存在所选机器,并可从任意端进入。"})]})}let Gc=H4.map(e=>({id:e.id,title:e.title,description:e.description,icon:e.icon,keywords:e.keywords}));function Gd(e){return Gc.find(t=>t.id===e)}function Gu(e,t){let n=Gd(e),r="file-tab-viewer"===e?{id:t,kind:e,title:"选择文件"}:H7(e)?Ue(e,t):void 0;return{id:t,kind:e,title:r?.title??n?.title??"组件",tab:r,tabs:"multi-tab-system"===e?[]:void 0,terminal:"terminal-tab-group"===e?{sessionIds:[],autoStart:!0}:void 0}}function Gf(e){return"subagent-conversation-panel"!==e.kind&&"context-breakdown"!==e.kind}let Gm="application/vnd.vantaloom.agent-panel";function Gh(e){let t=Gf(e)?Gd(e.kind):void 0,n={content:e};return{id:`agent-panel-${e.id}`,title:e.title,description:t?.description??("subagent-conversation-panel"===e.kind?"子代理运行信息流。":"来自 Agent 工作区的面板。"),meta:"Agent panel",icon:t?.icon,dragData:{"application/vnd.vantaloom.clip-kind":"agent-panel",[Gm]:JSON.stringify(n)},payloads:{[Gm]:n}}}function Gp({ownerMachineId:e,title:t,resolvedLocation:n,className:r}){let a=function(e){let{machines:t}=TV();return P.useMemo(()=>{if(eF(e))return"本机";let n=t.find(t=>t.id===e);return n?n.isLocal?"本机":n.name:e??"本机"},[t,e])}(e),i=n??a,o=t.trim()||"新 Agent 对话";return(0,E.jsxs)("div",{className:(0,B.cn)("flex h-9 shrink-0 items-center gap-1.5 border-b px-3 text-sm",r),children:[(0,E.jsx)($,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,E.jsx)("span",{className:"shrink-0 truncate text-muted-foreground",title:i,children:i}),(0,E.jsx)("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"/"}),(0,E.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",title:o,children:o})]})}function Gg({rounds:e,onJumpToRound:t,activeRunId:n,className:r}){let[a,i]=P.useState(!1),o=P.useRef(null),[l,s]=P.useState(304);if(P.useEffect(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&i(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]),P.useLayoutEffect(()=>{if(!a)return;let e=()=>{let e=o.current;if(!e)return;let t=e.getBoundingClientRect().left;s(Math.max(120,Math.min(304,window.innerWidth-t-16)))};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a]),!e.length)return null;let c=e.length>24?e.slice(e.length-24):e;return(0,E.jsxs)("div",{ref:o,className:(0,B.cn)("relative",r),children:[(0,E.jsx)("button",{type:"button","aria-label":"轮次时间轴",title:`轮次时间轴 \xb7 共 ${e.length} 轮`,onClick:()=>i(e=>!e),className:(0,B.cn)("group flex flex-col items-start gap-[7px] rounded-md px-1.5 py-2 outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted/50",a&&"invisible"),children:c.map(e=>{let t=!!n&&e.runId===n;return(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("h-[3px] rounded-full transition-all duration-200",t?"w-5 bg-foreground/85":"w-2.5 bg-muted-foreground/30 group-hover:bg-muted-foreground/55")},e.runId)})}),a?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"fixed inset-0 z-40","aria-hidden":"true",onClick:()=>i(!1)}),(0,E.jsx)("div",{style:{width:l},className:"absolute left-0 top-0 z-50 max-h-[20rem] overflow-y-auto overflow-x-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md vtl-scrollbar-hidden",children:(0,E.jsx)("div",{className:"grid grid-cols-[minmax(0,1fr)] gap-px",children:e.map(e=>{let r=!!n&&e.runId===n;return(0,E.jsxs)("button",{type:"button",className:(0,B.cn)("flex w-full min-w-0 items-center gap-2 rounded px-2 py-1 text-left transition-colors",r?"bg-muted":"hover:bg-muted/70"),onClick:()=>{t(e),i(!1)},children:[(0,E.jsx)("span",{"aria-hidden":"true",className:(0,B.cn)("h-[2.5px] shrink-0 rounded-full transition-all",r?"w-3.5 bg-foreground/85":"w-2.5 bg-muted-foreground/40")}),(0,E.jsx)("span",{className:(0,B.cn)("min-w-0 flex-1 truncate text-[13px] leading-snug",r?"font-medium text-foreground":"text-foreground/90"),children:e.title?.trim()||e.summary?.trim()||"未命名轮次"})]},e.runId)})})})]}):null]})}let Gx={expand:"展开",collapse:"收起",completed:"完成",thinking:"运行中"};function Gv({icon:e,title:t,role:n,running:r,status:a,active:i,onClick:o,events:l}){let s=P.useMemo(()=>(function(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.kind==="user")return e.slice(t);return e})(l),[l]);return(0,E.jsxs)("button",{type:"button",onClick:o,className:(0,B.cn)("relative flex h-48 w-full shrink-0 flex-col overflow-hidden rounded-xl border bg-card text-left shadow-md transition-all","hover:-translate-y-0.5 hover:shadow-lg",i?"border-primary/70 ring-2 ring-primary/40":r?"border-green-500/50":"border-border/70"),children:[(0,E.jsxs)("div",{className:"flex items-center gap-2 border-b bg-muted/50 px-2.5 py-1.5",children:[(0,E.jsx)("span",{className:"shrink-0",children:e}),(0,E.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium",children:[t,(0,E.jsxs)("span",{className:"ml-1 text-[10px] font-normal text-muted-foreground",children:["· ",n]})]}),(0,E.jsxs)("span",{className:(0,B.cn)("flex shrink-0 items-center gap-0.5 rounded px-1.5 py-px text-[9.5px]",r?"bg-green-500/15 text-green-600 dark:text-green-400":"failed"===a?"bg-hot-pink/15 text-hot-pink":"bg-muted text-muted-foreground"),children:[r?(0,E.jsx)(_,{className:"size-2.5 animate-spin"}):null,r?"运行中":"failed"===a?"失败":"paused"===a?"已暂停":"已完成"]})]}),(0,E.jsxs)("div",{className:"relative min-h-0 flex-1 overflow-hidden bg-background",children:[s.length>0?(0,E.jsx)("div",{className:"pointer-events-none absolute inset-0",children:(0,E.jsx)(IV,{events:s,bottomInset:8,contentClassName:"max-w-none px-3",labels:Gx})}):(0,E.jsx)("div",{className:"flex h-full items-center justify-center text-[11px] text-muted-foreground/50",children:"暂无内容"}),(0,E.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-background to-transparent"})]})]})}function Gb({subagent:e,ownerMachineId:t,active:n,onClick:r}){let[a,i]=P.useState([]);P.useEffect(()=>{let n,r=!1,a=async()=>{try{let o=await eX(e.id,t);if(r)return;i(o.events);let l="working"===o.conversation.status||!!o.conversation.running;n=window.setTimeout(a,l?1500:6e3)}catch{if(r)return;n=window.setTimeout(a,4e3)}};return a(),()=>{r=!0,n&&window.clearTimeout(n)}},[e.id,t]);let o=Ij(e.type),l=o.Icon;return(0,E.jsx)(Gv,{icon:(0,E.jsx)(l,{className:(0,B.cn)("size-4",o.color)}),title:e.name||`${o.label}子代理`,role:o.label,running:e.running,status:e.status,active:n,onClick:r,events:a})}function Gy({conversationTitle:e,rootEvents:t,rootOwnerMachineId:n,running:r,subagentTree:a,baselineSubagentIds:i,activeSubagentPath:o,onSelectMain:l,onSelectSubagent:s}){let c=P.useMemo(()=>(function e(t,n=[]){for(let r of t)n.push({id:r.id,name:r.subagentName,type:r.subagentType,status:r.status,running:r.running,ownerMachineId:r.ownerMachineId,createdAt:r.createdAt}),e(r.children??[],n);return n})(a).filter(e=>!i.has(e.id)).sort((e,t)=>(e.createdAt??"").localeCompare(t.createdAt??"")),[a,i]),d=o[o.length-1]?.id,u=0===o.length;return(0,E.jsx)("div",{className:"h-full min-h-0 overflow-y-auto px-4 py-4 vtl-scrollbar-hidden",children:(0,E.jsxs)("div",{className:"ml-auto flex w-full max-w-[20rem] flex-col gap-4",children:[(0,E.jsx)(Gv,{icon:(0,E.jsx)(CB,{className:"size-4 text-sky-500"}),title:"主 Agent",role:e||"主对话",running:r,status:r?"working":"idle",active:u,onClick:l,events:t}),c.map(e=>(0,E.jsx)(Gb,{subagent:e,ownerMachineId:n,active:e.id===d,onClick:()=>s({id:e.id,ownerMachineId:e.ownerMachineId??n,name:e.name,subagentType:e.type})},e.id))]})})}function Gw(e){return`vtl:composer-draft:${e}`}function Gj(e){if(!e)return"";try{return window.localStorage.getItem(Gw(e))??""}catch{return""}}function Gk(e){return`vtl:agent:prompt-history:${e}`}function GN(e){if(!e)return[];try{let t=window.localStorage.getItem(Gk(e));if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))return[];return n.filter(e=>"string"==typeof e)}catch{return[]}}let GC="__bottom__";function GS(e){return`vtl:agent-read-pos:${e}`}function GM(e,t){if(e)try{if(!t)return void window.localStorage.removeItem(GS(e));window.localStorage.setItem(GS(e),t)}catch{}}let GE=(0,z.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]),GI=(0,z.default)("file-diff",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]),GP=(0,z.default)("file-type-corner",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"15usau"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M3 16v-1.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5V16",key:"s1gz5"}],["path",{d:"M6 22h2",key:"194x9m"}],["path",{d:"M7 14v8",key:"11ixej"}]]),GO=(0,z.default)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Gz=(0,z.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),GA=(0,z.default)("panel-bottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]),GT=(0,z.default)("panel-top",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);function GR(e,t){return"function"==typeof e?e(t):e}function G_(e,t){return n=>{t.setState(t=>({...t,[e]:GR(n,t[e])}))}}function GD(e){return e instanceof Function}function GL(e,t,n){let r,a=[];return i=>{let o,l;n.key&&n.debug&&(o=Date.now());let s=e(i);if(!(s.length!==a.length||s.some((e,t)=>a[t]!==e)))return r;if(a=s,n.key&&n.debug&&(l=Date.now()),r=t(...s),null==n||null==n.onChange||n.onChange(r),n.key&&n.debug&&null!=n&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-l)*100)/100,r=t/16,a=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${a(t,5)} /${a(e,5)} ms`,`
41
41
  font-size: .6rem;
42
42
  font-weight: bold;
43
43
  color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,null==n?void 0:n.key)}return r}}function G$(e,t,n,r){return{debug:()=>{var n;return null!=(n=null==e?void 0:e.debugAll)?n:e[t]},key:!1,onChange:r}}let GF="debugHeaders";function GB(e,t,n){var r;let a={id:null!=(r=n.id)?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(a),e},getContext:()=>({table:e,header:a,column:t})};return e._features.forEach(t=>{null==t.createHeader||t.createHeader(a,e)}),a}function GV(e,t,n,r){var a,i;let o=0,l=function(e,t){void 0===t&&(t=1),o=Math.max(o,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;null!=(n=e.columns)&&n.length&&l(e.columns,t+1)},0)};l(e);let s=[],c=(e,t)=>{let a={depth:t,id:[r,`${t}`].filter(Boolean).join("_"),headers:[]},i=[];e.forEach(e=>{let o,l=[...i].reverse()[0],s=e.column.depth===a.depth,c=!1;if(s&&e.column.parent?o=e.column.parent:(o=e.column,c=!0),l&&(null==l?void 0:l.column)===o)l.subHeaders.push(e);else{let a=GB(n,o,{id:[r,t,o.id,null==e?void 0:e.id].filter(Boolean).join("_"),isPlaceholder:c,placeholderId:c?`${i.filter(e=>e.column===o).length}`:void 0,depth:t,index:i.length});a.subHeaders.push(e),i.push(a)}a.headers.push(e),e.headerGroup=a}),s.push(a),t>0&&c(i,t-1)};c(t.map((e,t)=>GB(n,e,{depth:o,index:t})),o-1),s.reverse();let d=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];return e.subHeaders&&e.subHeaders.length?(r=[],d(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:a}=e;t+=n,r.push(a)})):t=1,n+=Math.min(...r),e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return d(null!=(a=null==(i=s[0])?void 0:i.headers)?a:[]),s}let GH=(e,t,n,r,a,i,o)=>{let l={id:t,index:r,original:n,depth:a,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(l._valuesCache.hasOwnProperty(t))return l._valuesCache[t];let n=e.getColumn(t);if(null!=n&&n.accessorFn)return l._valuesCache[t]=n.accessorFn(l.original,r),l._valuesCache[t]},getUniqueValues:t=>{if(l._uniqueValuesCache.hasOwnProperty(t))return l._uniqueValuesCache[t];let n=e.getColumn(t);if(null!=n&&n.accessorFn)return n.columnDef.getUniqueValues?l._uniqueValuesCache[t]=n.columnDef.getUniqueValues(l.original,r):l._uniqueValuesCache[t]=[l.getValue(t)],l._uniqueValuesCache[t]},renderValue:t=>{var n;return null!=(n=l.getValue(t))?n:e.options.renderFallbackValue},subRows:null!=i?i:[],getLeafRows:()=>{var e,t;let n,r;return e=l.subRows,t=e=>e.subRows,n=[],(r=e=>{e.forEach(e=>{n.push(e);let a=t(e);null!=a&&a.length&&r(a)})})(e),n},getParentRow:()=>l.parentId?e.getRow(l.parentId,!0):void 0,getParentRows:()=>{let e=[],t=l;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:GL(()=>[e.getAllLeafColumns()],t=>t.map(t=>{var n;let r;return n=t.id,r={id:`${l.id}_${t.id}`,row:l,column:t,getValue:()=>l.getValue(n),renderValue:()=>{var t;return null!=(t=r.getValue())?t:e.options.renderFallbackValue},getContext:GL(()=>[e,t,l,r],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),G$(e.options,"debugCells","cell.getContext"))},e._features.forEach(n=>{null==n.createCell||n.createCell(r,t,l,e)},{}),r}),G$(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:GL(()=>[l.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),G$(e.options,"debugRows","getAllCellsByColumnId"))};for(let t=0;t<e._features.length;t++){let n=e._features[t];null==n||null==n.createRow||n.createRow(l,e)}return l},GU=(e,t,n)=>{var r,a;let i=null==n||null==(r=n.toString())?void 0:r.toLowerCase();return!!(null==(a=e.getValue(t))||null==(a=a.toString())||null==(a=a.toLowerCase())?void 0:a.includes(i))};GU.autoRemove=e=>G0(e);let Gq=(e,t,n)=>{var r;return!!(null==(r=e.getValue(t))||null==(r=r.toString())?void 0:r.includes(n))};Gq.autoRemove=e=>G0(e);let GW=(e,t,n)=>{var r;return(null==(r=e.getValue(t))||null==(r=r.toString())?void 0:r.toLowerCase())===(null==n?void 0:n.toLowerCase())};GW.autoRemove=e=>G0(e);let GK=(e,t,n)=>{var r;return null==(r=e.getValue(t))?void 0:r.includes(n)};GK.autoRemove=e=>G0(e);let GG=(e,t,n)=>!n.some(n=>{var r;return!(null!=(r=e.getValue(t))&&r.includes(n))});GG.autoRemove=e=>G0(e)||!(null!=e&&e.length);let GX=(e,t,n)=>n.some(n=>{var r;return null==(r=e.getValue(t))?void 0:r.includes(n)});GX.autoRemove=e=>G0(e)||!(null!=e&&e.length);let GY=(e,t,n)=>e.getValue(t)===n;GY.autoRemove=e=>G0(e);let GZ=(e,t,n)=>e.getValue(t)==n;GZ.autoRemove=e=>G0(e);let GJ=(e,t,n)=>{let[r,a]=n,i=e.getValue(t);return i>=r&&i<=a};GJ.resolveFilterValue=e=>{let[t,n]=e,r="number"!=typeof t?parseFloat(t):t,a="number"!=typeof n?parseFloat(n):n,i=null===t||Number.isNaN(r)?-1/0:r,o=null===n||Number.isNaN(a)?1/0:a;if(i>o){let e=i;i=o,o=e}return[i,o]},GJ.autoRemove=e=>G0(e)||G0(e[0])&&G0(e[1]);let GQ={includesString:GU,includesStringSensitive:Gq,equalsString:GW,arrIncludes:GK,arrIncludesAll:GG,arrIncludesSome:GX,equals:GY,weakEquals:GZ,inNumberRange:GJ};function G0(e){return null==e||""===e}function G1(e,t,n){return!!e&&!!e.autoRemove&&e.autoRemove(t,n)||void 0===t||"string"==typeof t&&!t}let G2={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+("number"==typeof r?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(r>n||void 0===r&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(r<n||void 0===r&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,a;return n.forEach(t=>{let n=t.getValue(e);null!=n&&(void 0===r?n>=n&&(r=a=n):(r>n&&(r=n),a<n&&(a=n)))}),[r,a]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let a=t.getValue(e);null!=a&&(a*=1)>=a&&(++n,r+=a)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!(Array.isArray(n)&&n.every(e=>"number"==typeof e)))return;if(1===n.length)return n[0];let r=Math.floor(n.length/2),a=n.sort((e,t)=>e-t);return n.length%2!=0?a[r]:(a[r-1]+a[r])/2},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},G5=()=>({left:[],right:[]}),G3={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},G4=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),G6=null;function G8(e){return"touchstart"===e.type}function G7(e,t){return t?"center"===t?e.getCenterVisibleLeafColumns():"left"===t?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}let G9=()=>({pageIndex:0,pageSize:10}),Xe=()=>({top:[],bottom:[]}),Xt=(e,t,n,r,a)=>{var i;let o=a.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&null!=(i=o.subRows)&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>Xt(e,t.id,n,r,a))};function Xn(e,t){let n=e.getState().rowSelection,r=[],a={},i=function(e,t){return e.map(e=>{var t;let o=Xr(e,n);if(o&&(r.push(e),a[e.id]=e),null!=(t=e.subRows)&&t.length&&(e={...e,subRows:i(e.subRows)}),o)return e}).filter(Boolean)};return{rows:i(t.rows),flatRows:r,rowsById:a}}function Xr(e,t){var n;return null!=(n=t[e.id])&&n}function Xa(e,t,n){var r;if(!(null!=(r=e.subRows)&&r.length))return!1;let a=!0,i=!1;return e.subRows.forEach(e=>{if((!i||a)&&(e.getCanSelect()&&(Xr(e,t)?i=!0:a=!1),e.subRows&&e.subRows.length)){let n=Xa(e,t);"all"===n?i=!0:("some"===n&&(i=!0),a=!1)}}),a?"all":!!i&&"some"}let Xi=/([0-9]+)/gm;function Xo(e,t){return e===t?0:e>t?1:-1}function Xl(e){return"number"==typeof e?isNaN(e)||e===1/0||e===-1/0?"":String(e):"string"==typeof e?e:""}function Xs(e,t){let n=e.split(Xi).filter(Boolean),r=t.split(Xi).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),a=parseInt(e,10),i=parseInt(t,10),o=[a,i].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return -1;continue}if(isNaN(o[1]))return isNaN(a)?-1:1;if(a>i)return 1;if(i>a)return -1}return n.length-r.length}let Xc={alphanumeric:(e,t,n)=>Xs(Xl(e.getValue(n)).toLowerCase(),Xl(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive:(e,t,n)=>Xs(Xl(e.getValue(n)),Xl(t.getValue(n))),text:(e,t,n)=>Xo(Xl(e.getValue(n)).toLowerCase(),Xl(t.getValue(n)).toLowerCase()),textCaseSensitive:(e,t,n)=>Xo(Xl(e.getValue(n)),Xl(t.getValue(n))),datetime:(e,t,n)=>{let r=e.getValue(n),a=t.getValue(n);return r>a?1:r<a?-1:0},basic:(e,t,n)=>Xo(e.getValue(n),t.getValue(n))},Xd=[{createTable:e=>{e.getHeaderGroups=GL(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>{var i,o;let l=null!=(i=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?i:[],s=null!=(o=null==a?void 0:a.map(e=>n.find(t=>t.id===e)).filter(Boolean))?o:[];return GV(t,[...l,...n.filter(e=>!(null!=r&&r.includes(e.id))&&!(null!=a&&a.includes(e.id))),...s],e)},G$(e.options,GF,"getHeaderGroups")),e.getCenterHeaderGroups=GL(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,a)=>GV(t,n=n.filter(e=>!(null!=r&&r.includes(e.id))&&!(null!=a&&a.includes(e.id))),e,"center"),G$(e.options,GF,"getCenterHeaderGroups")),e.getLeftHeaderGroups=GL(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var a;return GV(t,null!=(a=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?a:[],e,"left")},G$(e.options,GF,"getLeftHeaderGroups")),e.getRightHeaderGroups=GL(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var a;return GV(t,null!=(a=null==r?void 0:r.map(e=>n.find(t=>t.id===e)).filter(Boolean))?a:[],e,"right")},G$(e.options,GF,"getRightHeaderGroups")),e.getFooterGroups=GL(()=>[e.getHeaderGroups()],e=>[...e].reverse(),G$(e.options,GF,"getFooterGroups")),e.getLeftFooterGroups=GL(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),G$(e.options,GF,"getLeftFooterGroups")),e.getCenterFooterGroups=GL(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),G$(e.options,GF,"getCenterFooterGroups")),e.getRightFooterGroups=GL(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),G$(e.options,GF,"getRightFooterGroups")),e.getFlatHeaders=GL(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),G$(e.options,GF,"getFlatHeaders")),e.getLeftFlatHeaders=GL(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),G$(e.options,GF,"getLeftFlatHeaders")),e.getCenterFlatHeaders=GL(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),G$(e.options,GF,"getCenterFlatHeaders")),e.getRightFlatHeaders=GL(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),G$(e.options,GF,"getRightFlatHeaders")),e.getCenterLeafHeaders=GL(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),G$(e.options,GF,"getCenterLeafHeaders")),e.getLeftLeafHeaders=GL(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),G$(e.options,GF,"getLeftLeafHeaders")),e.getRightLeafHeaders=GL(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!(null!=(t=e.subHeaders)&&t.length)}),G$(e.options,GF,"getRightLeafHeaders")),e.getLeafHeaders=GL(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>{var r,a,i,o,l,s;return[...null!=(r=null==(a=e[0])?void 0:a.headers)?r:[],...null!=(i=null==(o=t[0])?void 0:o.headers)?i:[],...null!=(l=null==(s=n[0])?void 0:s.headers)?l:[]].map(e=>e.getLeafHeaders()).flat()},G$(e.options,GF,"getLeafHeaders"))}},{getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:G_("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:null!=n?n:!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;let a=e.columns;return null==(n=a.length?a.some(e=>e.getIsVisible()):null==(r=t.getState().columnVisibility)?void 0:r[e.id])||n},e.getCanHide=()=>{var n,r;return(null==(n=e.columnDef.enableHiding)||n)&&(null==(r=t.options.enableHiding)||r)},e.getToggleVisibilityHandler=()=>t=>{null==e.toggleVisibility||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=GL(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),G$(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=GL(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],G$(t.options,"debugRows","getVisibleCells"))},createTable:e=>{let t=(t,n)=>GL(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join("_")],e=>e.filter(e=>null==e.getIsVisible?void 0:e.getIsVisible()),G$(e.options,"debugColumns",t));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>null==e.options.onColumnVisibilityChange?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{var n;e.setColumnVisibility(t?{}:null!=(n=e.initialState.columnVisibility)?n:{})},e.toggleAllColumnsVisible=t=>{var n;t=null!=(n=t)?n:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(null!=n.getCanHide&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(null!=e.getIsVisible&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>null==e.getIsVisible?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{var n;e.toggleAllColumnsVisible(null==(n=t.target)?void 0:n.checked)}}},{getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:G_("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=GL(e=>[G7(t,e)],t=>t.findIndex(t=>t.id===e.id),G$(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var r;return(null==(r=G7(t,n)[0])?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;let a=G7(t,n);return(null==(r=a[a.length-1])?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>null==e.options.onColumnOrderChange?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:null!=(n=e.initialState.columnOrder)?n:[])},e._getOrderColumnsFn=GL(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let a=[];if(null!=e&&e.length){let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&a.push(n.splice(r,1)[0])}a=[...a,...n]}else a=r;var i=a;if(!(null!=t&&t.length)||!n)return i;let o=i.filter(e=>!t.includes(e.id));return"remove"===n?o:[...t.map(e=>i.find(t=>t.id===e)).filter(Boolean),...o]},G$(e.options,"debugTable","_getOrderColumnsFn"))}},{getInitialState:e=>({columnPinning:G5(),...e}),getDefaultOptions:e=>({onColumnPinningChange:G_("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>{var t,a,i,o,l,s;return"right"===n?{left:(null!=(i=null==e?void 0:e.left)?i:[]).filter(e=>!(null!=r&&r.includes(e))),right:[...(null!=(o=null==e?void 0:e.right)?o:[]).filter(e=>!(null!=r&&r.includes(e))),...r]}:"left"===n?{left:[...(null!=(l=null==e?void 0:e.left)?l:[]).filter(e=>!(null!=r&&r.includes(e))),...r],right:(null!=(s=null==e?void 0:e.right)?s:[]).filter(e=>!(null!=r&&r.includes(e)))}:{left:(null!=(t=null==e?void 0:e.left)?t:[]).filter(e=>!(null!=r&&r.includes(e))),right:(null!=(a=null==e?void 0:e.right)?a:[]).filter(e=>!(null!=r&&r.includes(e)))}})},e.getCanPin=()=>e.getLeafColumns().some(e=>{var n,r,a;return(null==(n=e.columnDef.enablePinning)||n)&&(null==(r=null!=(a=t.options.enableColumnPinning)?a:t.options.enablePinning)||r)}),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:a}=t.getState().columnPinning,i=n.some(e=>null==r?void 0:r.includes(e)),o=n.some(e=>null==a?void 0:a.includes(e));return i?"left":!!o&&"right"},e.getPinnedIndex=()=>{var n,r;let a=e.getIsPinned();return a?null!=(n=null==(r=t.getState().columnPinning)||null==(r=r[a])?void 0:r.indexOf(e.id))?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=GL(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...null!=t?t:[],...null!=n?n:[]];return e.filter(e=>!r.includes(e.column.id))},G$(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=GL(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:"left"})),G$(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=GL(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:"right"})),G$(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>null==e.options.onColumnPinningChange?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?G5():null!=(n=null==(r=e.initialState)?void 0:r.columnPinning)?n:G5())},e.getIsSomeColumnsPinned=t=>{var n,r,a;let i=e.getState().columnPinning;return t?!!(null==(n=i[t])?void 0:n.length):!!((null==(r=i.left)?void 0:r.length)||(null==(a=i.right)?void 0:a.length))},e.getLeftLeafColumns=GL(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),G$(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=GL(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(null!=t?t:[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),G$(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=GL(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...null!=t?t:[],...null!=n?n:[]];return e.filter(e=>!r.includes(e.id))},G$(e.options,"debugColumns","getCenterLeafColumns"))}},{createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},{getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:G_("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=null==n?void 0:n.getValue(e.id);return"string"==typeof r?GQ.includesString:"number"==typeof r?GQ.inNumberRange:"boolean"==typeof r||null!==r&&"object"==typeof r?GQ.equals:Array.isArray(r)?GQ.arrIncludes:GQ.weakEquals},e.getFilterFn=()=>{var n,r;return GD(e.columnDef.filterFn)?e.columnDef.filterFn:"auto"===e.columnDef.filterFn?e.getAutoFilterFn():null!=(n=null==(r=t.options.filterFns)?void 0:r[e.columnDef.filterFn])?n:GQ[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,a;return(null==(n=e.columnDef.enableColumnFilter)||n)&&(null==(r=t.options.enableColumnFilters)||r)&&(null==(a=t.options.enableFilters)||a)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return null==(n=t.getState().columnFilters)||null==(n=n.find(t=>t.id===e.id))?void 0:n.value},e.getFilterIndex=()=>{var n,r;return null!=(n=null==(r=t.getState().columnFilters)?void 0:r.findIndex(t=>t.id===e.id))?n:-1},e.setFilterValue=n=>{t.setColumnFilters(t=>{var r,a;let i=e.getFilterFn(),o=null==t?void 0:t.find(t=>t.id===e.id),l=GR(n,o?o.value:void 0);if(G1(i,l,e))return null!=(r=null==t?void 0:t.filter(t=>t.id!==e.id))?r:[];let s={id:e.id,value:l};return o?null!=(a=null==t?void 0:t.map(t=>t.id===e.id?s:t))?a:[]:null!=t&&t.length?[...t,s]:[s]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();null==e.options.onColumnFiltersChange||e.options.onColumnFiltersChange(e=>{var r;return null==(r=GR(t,e))?void 0:r.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&G1(t.getFilterFn(),e.value,t))&&!0})})},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.columnFilters)?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel)?e.getPreFilteredRowModel():e._getFilteredRowModel()}},{createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},{getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:G_("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;let r=null==(n=e.getCoreRowModel().flatRows[0])||null==(n=n._getAllCellsByColumnId()[t.id])?void 0:n.getValue();return"string"==typeof r||"number"==typeof r}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,r,a,i;return(null==(n=e.columnDef.enableGlobalFilter)||n)&&(null==(r=t.options.enableGlobalFilter)||r)&&(null==(a=t.options.enableFilters)||a)&&(null==(i=null==t.options.getColumnCanGlobalFilter?void 0:t.options.getColumnCanGlobalFilter(e))||i)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>GQ.includesString,e.getGlobalFilterFn=()=>{var t,n;let{globalFilterFn:r}=e.options;return GD(r)?r:"auto"===r?e.getGlobalAutoFilterFn():null!=(t=null==(n=e.options.filterFns)?void 0:n[r])?t:GQ[r]},e.setGlobalFilter=t=>{null==e.options.onGlobalFilterChange||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:G_("sorting",e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=null==t?void 0:t.getValue(e.id);if("[object Date]"===Object.prototype.toString.call(n))return Xc.datetime;if("string"==typeof n&&(r=!0,n.split(Xi).length>1))return Xc.alphanumeric}return r?Xc.text:Xc.basic},e.getAutoSortDir=()=>{let n=t.getFilteredRowModel().flatRows[0];return"string"==typeof(null==n?void 0:n.getValue(e.id))?"asc":"desc"},e.getSortingFn=()=>{var n,r;if(!e)throw Error();return GD(e.columnDef.sortingFn)?e.columnDef.sortingFn:"auto"===e.columnDef.sortingFn?e.getAutoSortingFn():null!=(n=null==(r=t.options.sortingFns)?void 0:r[e.columnDef.sortingFn])?n:Xc[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let a=e.getNextSortingOrder(),i=null!=n;t.setSorting(o=>{let l,s=null==o?void 0:o.find(t=>t.id===e.id),c=null==o?void 0:o.findIndex(t=>t.id===e.id),d=[],u=i?n:"desc"===a;if("toggle"!=(l=null!=o&&o.length&&e.getCanMultiSort()&&r?s?"toggle":"add":null!=o&&o.length&&c!==o.length-1?"replace":s?"toggle":"replace")||i||a||(l="remove"),"add"===l){var f;(d=[...o,{id:e.id,desc:u}]).splice(0,d.length-(null!=(f=t.options.maxMultiSortColCount)?f:Number.MAX_SAFE_INTEGER))}else d="toggle"===l?o.map(t=>t.id===e.id?{...t,desc:u}:t):"remove"===l?o.filter(t=>t.id!==e.id):[{id:e.id,desc:u}];return d})},e.getFirstSortDir=()=>{var n,r;return(null!=(n=null!=(r=e.columnDef.sortDescFirst)?r:t.options.sortDescFirst)?n:"desc"===e.getAutoSortDir())?"desc":"asc"},e.getNextSortingOrder=n=>{var r,a;let i=e.getFirstSortDir(),o=e.getIsSorted();return o?(o===i||null!=(r=t.options.enableSortingRemoval)&&!r||!!n&&null!=(a=t.options.enableMultiRemove)&&!a)&&("desc"===o?"asc":"desc"):i},e.getCanSort=()=>{var n,r;return(null==(n=e.columnDef.enableSorting)||n)&&(null==(r=t.options.enableSorting)||r)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return null!=(n=null!=(r=e.columnDef.enableMultiSort)?r:t.options.enableMultiSort)?n:!!e.accessorFn},e.getIsSorted=()=>{var n;let r=null==(n=t.getState().sorting)?void 0:n.find(t=>t.id===e.id);return!!r&&(r.desc?"desc":"asc")},e.getSortIndex=()=>{var n,r;return null!=(n=null==(r=t.getState().sorting)?void 0:r.findIndex(t=>t.id===e.id))?n:-1},e.clearSorting=()=>{t.setSorting(t=>null!=t&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(null==r.persist||r.persist(),null==e.toggleSorting||e.toggleSorting(void 0,!!e.getCanMultiSort()&&(null==t.options.isMultiSortEvent?void 0:t.options.isMultiSortEvent(r))))}}},createTable:e=>{e.setSorting=t=>null==e.options.onSortingChange?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.sorting)?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel)?e.getPreSortedRowModel():e._getSortedRowModel()}},{getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return null!=(t=null==(n=e.getValue())||null==n.toString?void 0:n.toString())?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:G_("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>null!=t&&t.includes(e.id)?t.filter(t=>t!==e.id):[...null!=t?t:[],e.id])},e.getCanGroup=()=>{var n,r;return(null==(n=e.columnDef.enableGrouping)||n)&&(null==(r=t.options.enableGrouping)||r)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return null==(n=t.getState().grouping)?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return null==(n=t.getState().grouping)?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=null==n?void 0:n.getValue(e.id);return"number"==typeof r?G2.sum:"[object Date]"===Object.prototype.toString.call(r)?G2.extent:void 0},e.getAggregationFn=()=>{var n,r;if(!e)throw Error();return GD(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:"auto"===e.columnDef.aggregationFn?e.getAutoAggregationFn():null!=(n=null==(r=t.options.aggregationFns)?void 0:r[e.columnDef.aggregationFn])?n:G2[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>null==e.options.onGroupingChange?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:null!=(n=null==(r=e.initialState)?void 0:r.grouping)?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel)?e.getPreGroupedRowModel():e._getGroupedRowModel()},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return null!=r&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!(null!=(t=n.subRows)&&t.length)}}},{getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:G_("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,a;if(!t)return void e._queue(()=>{t=!0});if(null!=(r=null!=(a=e.options.autoResetAll)?a:e.options.autoResetExpanded)?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>null==e.options.onExpandedChange?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{(null!=t?t:!e.getIsAllRowsExpanded())?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{var n,r;e.setExpanded(t?{}:null!=(n=null==(r=e.initialState)?void 0:r.expanded)?n:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{null==t.persist||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return!0===t||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return"boolean"==typeof t?!0===t:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(!0===e.getState().expanded?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(".");t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel)?e.getPreExpandedRowModel():e._getExpandedRowModel()},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var a;let i=!0===r||!!(null!=r&&r[e.id]),o={};if(!0===r?Object.keys(t.getRowModel().rowsById).forEach(e=>{o[e]=!0}):o=r,n=null!=(a=n)?a:!i,!i&&n)return{...o,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=o;return n}return r})},e.getIsExpanded=()=>{var n;let r=t.getState().expanded;return!!(null!=(n=null==t.options.getIsRowExpanded?void 0:t.options.getIsRowExpanded(e))?n:!0===r||(null==r?void 0:r[e.id]))},e.getCanExpand=()=>{var n,r,a;return null!=(n=null==t.options.getRowCanExpand?void 0:t.options.getRowCanExpand(e))?n:(null==(r=t.options.enableExpanding)||r)&&!!(null!=(a=e.subRows)&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)n=(r=t.getRow(r.parentId,!0)).getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},{getInitialState:e=>({...e,pagination:{...G9(),...null==e?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:G_("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,a;if(!t)return void e._queue(()=>{t=!0});if(null!=(r=null!=(a=e.options.autoResetAll)?a:e.options.autoResetPageIndex)?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>null==e.options.onPaginationChange?void 0:e.options.onPaginationChange(e=>GR(t,e)),e.resetPagination=t=>{var n;e.setPagination(t?G9():null!=(n=e.initialState.pagination)?n:G9())},e.setPageIndex=t=>{e.setPagination(n=>{let r=GR(t,n.pageIndex);return r=Math.max(0,Math.min(r,void 0===e.options.pageCount||-1===e.options.pageCount?Number.MAX_SAFE_INTEGER:e.options.pageCount-1)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n,r;e.setPageIndex(t?0:null!=(n=null==(r=e.initialState)||null==(r=r.pagination)?void 0:r.pageIndex)?n:0)},e.resetPageSize=t=>{var n,r;e.setPageSize(t?10:null!=(n=null==(r=e.initialState)||null==(r=r.pagination)?void 0:r.pageSize)?n:10)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,GR(t,e.pageSize)),r=Math.floor(e.pageSize*e.pageIndex/n);return{...e,pageIndex:r,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{var r;let a=GR(t,null!=(r=e.options.pageCount)?r:-1);return"number"==typeof a&&(a=Math.max(-1,a)),{...n,pageCount:a}}),e.getPageOptions=GL(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},G$(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return -1===n||0!==n&&t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel)?e.getPrePaginationRowModel():e._getPaginationRowModel(),e.getPageCount=()=>{var t;return null!=(t=e.options.pageCount)?t:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var t;return null!=(t=e.options.rowCount)?t:e.getPrePaginationRowModel().rows.length}}},{getInitialState:e=>({rowPinning:Xe(),...e}),getDefaultOptions:e=>({onRowPinningChange:G_("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,r,a)=>{let i=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=new Set([...a?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],e.id,...i]);t.setRowPinning(e=>{var t,r,a,i,l,s;return"bottom"===n?{top:(null!=(a=null==e?void 0:e.top)?a:[]).filter(e=>!(null!=o&&o.has(e))),bottom:[...(null!=(i=null==e?void 0:e.bottom)?i:[]).filter(e=>!(null!=o&&o.has(e))),...Array.from(o)]}:"top"===n?{top:[...(null!=(l=null==e?void 0:e.top)?l:[]).filter(e=>!(null!=o&&o.has(e))),...Array.from(o)],bottom:(null!=(s=null==e?void 0:e.bottom)?s:[]).filter(e=>!(null!=o&&o.has(e)))}:{top:(null!=(t=null==e?void 0:e.top)?t:[]).filter(e=>!(null!=o&&o.has(e))),bottom:(null!=(r=null==e?void 0:e.bottom)?r:[]).filter(e=>!(null!=o&&o.has(e)))}})},e.getCanPin=()=>{var n;let{enableRowPinning:r,enablePinning:a}=t.options;return"function"==typeof r?r(e):null==(n=null!=r?r:a)||n},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:a}=t.getState().rowPinning,i=n.some(e=>null==r?void 0:r.includes(e)),o=n.some(e=>null==a?void 0:a.includes(e));return i?"top":!!o&&"bottom"},e.getPinnedIndex=()=>{var n,r;let a=e.getIsPinned();if(!a)return -1;let i=null==(n="top"===a?t.getTopRows():t.getBottomRows())?void 0:n.map(e=>{let{id:t}=e;return t});return null!=(r=null==i?void 0:i.indexOf(e.id))?r:-1}},createTable:e=>{e.setRowPinning=t=>null==e.options.onRowPinningChange?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?Xe():null!=(n=null==(r=e.initialState)?void 0:r.rowPinning)?n:Xe())},e.getIsSomeRowsPinned=t=>{var n,r,a;let i=e.getState().rowPinning;return t?!!(null==(n=i[t])?void 0:n.length):!!((null==(r=i.top)?void 0:r.length)||(null==(a=i.bottom)?void 0:a.length))},e._getPinnedRows=(t,n,r)=>{var a;return(null==(a=e.options.keepPinnedRows)||a?(null!=n?n:[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(null!=n?n:[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r}))},e.getTopRows=GL(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),G$(e.options,"debugRows","getTopRows")),e.getBottomRows=GL(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),G$(e.options,"debugRows","getBottomRows")),e.getCenterRows=GL(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...null!=t?t:[],...null!=n?n:[]]);return e.filter(e=>!r.has(e.id))},G$(e.options,"debugRows","getCenterRows"))}},{getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:G_("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>null==e.options.onRowSelectionChange?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:null!=(n=e.initialState.rowSelection)?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=void 0!==t?t:!e.getIsAllRowsSelected();let r={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):a.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=void 0!==t?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(t=>{Xt(a,t.id,r,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=GL(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?Xn(e,n):{rows:[],flatRows:[],rowsById:{}},G$(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=GL(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?Xn(e,n):{rows:[],flatRows:[],rowsById:{}},G$(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=GL(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?Xn(e,n):{rows:[],flatRows:[],rowsById:{}},G$(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;let n=Object.keys(null!=(t=e.getState().rowSelection)?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return!e.getIsAllPageRowsSelected()&&t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let a=e.getIsSelected();t.setRowSelection(i=>{var o;if(n=void 0!==n?n:!a,e.getCanSelect()&&a===n)return i;let l={...i};return Xt(l,e.id,n,null==(o=null==r?void 0:r.selectChildren)||o,t),l})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return Xr(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return"some"===Xa(e,n)},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return"all"===Xa(e,n)},e.getCanSelect=()=>{var n;return"function"==typeof t.options.enableRowSelection?t.options.enableRowSelection(e):null==(n=t.options.enableRowSelection)||n},e.getCanSelectSubRows=()=>{var n;return"function"==typeof t.options.enableSubRowSelection?t.options.enableSubRowSelection(e):null==(n=t.options.enableSubRowSelection)||n},e.getCanMultiSelect=()=>{var n;return"function"==typeof t.options.enableMultiRowSelection?t.options.enableMultiRowSelection(e):null==(n=t.options.enableMultiRowSelection)||n},e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{var r;t&&e.toggleSelected(null==(r=n.target)?void 0:r.checked)}}}},{getDefaultColumnDef:()=>G3,getInitialState:e=>({columnSizing:{},columnSizingInfo:G4(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:G_("columnSizing",e),onColumnSizingInfoChange:G_("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,a;let i=t.getState().columnSizing[e.id];return Math.min(Math.max(null!=(n=e.columnDef.minSize)?n:G3.minSize,null!=(r=null!=i?i:e.columnDef.size)?r:G3.size),null!=(a=e.columnDef.maxSize)?a:G3.maxSize)},e.getStart=GL(e=>[e,G7(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),G$(t.options,"debugColumns","getStart")),e.getAfter=GL(e=>[e,G7(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),G$(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>{var n,r;return(null==(n=e.columnDef.enableResizing)||n)&&(null==(r=t.options.enableColumnResizing)||r)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{if(e.subHeaders.length)e.subHeaders.forEach(n);else{var r;t+=null!=(r=e.column.getSize())?r:0}};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),a=null==r?void 0:r.getCanResize();return i=>{if(!r||!a||(null==i.persist||i.persist(),G8(i)&&i.touches&&i.touches.length>1))return;let o=e.getSize(),l=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],s=G8(i)?Math.round(i.touches[0].clientX):i.clientX,c={},d=(e,n)=>{"number"==typeof n&&(t.setColumnSizingInfo(e=>{var r,a;let i="rtl"===t.options.columnResizeDirection?-1:1,o=(n-(null!=(r=null==e?void 0:e.startOffset)?r:0))*i,l=Math.max(o/(null!=(a=null==e?void 0:e.startSize)?a:0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;c[t]=Math.round(100*Math.max(n+n*l,0))/100}),{...e,deltaOffset:o,deltaPercentage:l}}),("onChange"===t.options.columnResizeMode||"end"===e)&&t.setColumnSizing(e=>({...e,...c})))},u=e=>{d("end",e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=n||("u">typeof document?document:null),m={moveHandler:e=>d("move",e.clientX),upHandler:e=>{null==f||f.removeEventListener("mousemove",m.moveHandler),null==f||f.removeEventListener("mouseup",m.upHandler),u(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d("move",e.touches[0].clientX),!1),upHandler:e=>{var t;null==f||f.removeEventListener("touchmove",h.moveHandler),null==f||f.removeEventListener("touchend",h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),u(null==(t=e.touches[0])?void 0:t.clientX)}},p=!!function(){if("boolean"==typeof G6)return G6;let e=!1;try{let t=()=>{};window.addEventListener("test",t,{get passive(){return e=!0,!1}}),window.removeEventListener("test",t)}catch(t){e=!1}return G6=e}()&&{passive:!1};G8(i)?(null==f||f.addEventListener("touchmove",h.moveHandler,p),null==f||f.addEventListener("touchend",h.upHandler,p)):(null==f||f.addEventListener("mousemove",m.moveHandler,p),null==f||f.addEventListener("mouseup",m.upHandler,p)),t.setColumnSizingInfo(e=>({...e,startOffset:s,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>null==e.options.onColumnSizingChange?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>null==e.options.onColumnSizingInfoChange?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:null!=(n=e.initialState.columnSizing)?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?G4():null!=(n=e.initialState.columnSizingInfo)?n:G4())},e.getTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getLeftTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getLeftHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getCenterTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getCenterHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0},e.getRightTotalSize=()=>{var t,n;return null!=(t=null==(n=e.getRightHeaderGroups()[0])?void 0:n.headers.reduce((e,t)=>e+t.getSize(),0))?t:0}}}];function Xu(e,t){var n,r,a;let i;return e?"function"==typeof(r=n=e)&&(i=Object.getPrototypeOf(r)).prototype&&i.prototype.isReactComponent||"function"==typeof n||"object"==typeof(a=n)&&"symbol"==typeof a.$$typeof&&["react.memo","react.forward_ref"].includes(a.$$typeof.description)?P.createElement(e,t):e:null}function Xf(e,t,n){let r,a=n.initialDeps??[],i=!0;function o(){let o=e();return(o.length!==a.length||o.some((e,t)=>a[t]!==e))&&(a=o,r=t(...o),(null==n?void 0:n.onChange)&&!(i&&n.skipInitialOnChange)&&n.onChange(r),i=!1),r}return o.updateDeps=e=>{a=e},o}function Xm(e,t){if(void 0!==e)return e;throw Error(`Unexpected undefined${t?`: ${t}`:""}`)}let Xh=()=>{if(void 0!==o)return o;if("u"<typeof navigator)return o=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return o=!0;let e=navigator.maxTouchPoints;return o="MacIntel"===navigator.platform&&void 0!==e&&e>0},Xp=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Xg=e=>e,Xx=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Xv=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let a=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(a(Xp(n)),!r.ResizeObserver)return()=>{};let i=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(null==e?void 0:e.borderBoxSize){let t=e.borderBoxSize[0];if(t)return void a({width:t.inlineSize,height:t.blockSize})}a(Xp(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Xb={passive:!0},Xy="u"<typeof window||"onscrollend"in window,Xw=(e,t)=>((e,t,n)=>{var r,a;let i,o=e.scrollElement;if(!o)return;let l=e.targetWindow;if(!l)return;let s=e.options.useScrollendEvent&&Xy,c=0,d=s?null:(r=()=>t(c,!1),a=e.options.isScrollingResetDelay,function(...e){l.clearTimeout(i),i=l.setTimeout(()=>r.apply(this,e),a)}),u=e=>()=>{c=n(o),null==d||d(),t(c,e)},f=u(!0),m=u(!1);return o.addEventListener("scroll",f,Xb),s&&o.addEventListener("scrollend",m,Xb),()=>{o.removeEventListener("scroll",f),s&&o.removeEventListener("scrollend",m)}})(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Xj=(e,t,n)=>{if(null==t?void 0:t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Xk=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;null==(i=null==(a=r.scrollElement)?void 0:a.scrollTo)||i.call(a,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})};class XN{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,t,n;return(null==(n=null==(t=null==(e=this.targetWindow)?void 0:e.performance)?void 0:t.now)?void 0:n.call(t))??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){for(let[e,n]of(this.observer.unobserve(t),this.elementsCache))if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var n;null==(n=t())||n.disconnect(),e=null},observe:e=>{var n;return null==(n=t())?void 0:n.observe(e,{box:"border-box"})},unobserve:e=>{var n;return null==(n=t())?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Xg,rangeExtractor:Xx,onChange:()=>{},measureElement:Xj,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate"};for(let n in e){let r=e[n];void 0!==r&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;null==(n=(t=this.options).onChange)||n.call(t,this,e)},this.maybeNotify=Xf(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),null!=this.rafId&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();if(this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{null!==this._intendedScrollOffset&&1.5>Math.abs(e-this._intendedScrollOffset)&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,Xh()&&null!=this.targetWindow&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener("touchstart",t,Xb),e.addEventListener("touchend",n,Xb),this.unsubs.push(()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchend",n),null!==this._iosTouchEndTimerId&&null!=this.targetWindow&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(0===this._iosDeferredAdjustment||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let a=t-1;a>=0;a--){let t=e[a];if(n.has(t.lane))continue;let i=r.get(t.lane);if(null==i||t.end>i.end?r.set(t.lane,t):t.end<i.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=Xf(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,a,i,o)=>(void 0!==this.prevLanes&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a,lanes:i,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=Xf(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:a,lanes:i,laneAssignmentMode:o},l)=>{let s=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),1===i){var d;let a,i=this.options.gap,o=2*e,l=this._flatMeasurements;if(!l||l.length<o){let e=new Float64Array(o);l&&c>0&&e.set(l.subarray(0,2*c)),l=e,this._flatMeasurements=l}if(0===c)a=t+n;else{let e=c-1;a=l[2*e]+l[2*e+1]+i}for(let t=c;t<e;t++){let e=r(t),n=s.get(e),o="number"==typeof n?n:this.options.estimateSize(t);l[2*t]=a,l[2*t+1]=o,a+=o+i}let u=(d=l,new Proxy(Array(e),{get(t,n,a){if("string"==typeof n){let a=n.charCodeAt(0);if(a>=48&&a<=57){let a=+n;if(Number.isInteger(a)&&a>=0&&a<e){let e=t[a];if(!e){let n=d[2*a];e=t[a]={index:a,key:r(a),start:n,size:d[2*a+1],end:n+d[2*a+1],lane:0}}return e}}if("length"===n)return e}return Reflect.get(t,n,a)}}));return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,c),f=Array(i).fill(void 0);for(let e=0;e<c;e++){let t=u[e];t&&(f[t.lane]=e)}for(let a=c;a<e;a++){let e,i,l=r(a),c=this.laneAssignments.get(a),d="estimate"===o||s.has(l);if(void 0!==c&&this.options.lanes>1){let r=f[e=c],a=void 0!==r?u[r]:void 0;i=a?a.end+this.options.gap:t+n}else{let r=1===this.options.lanes?u[a-1]:this.getFurthestMeasurement(u,a);i=r?r.end+this.options.gap:t+n,e=r?r.lane:a%this.options.lanes,this.options.lanes>1&&d&&this.laneAssignments.set(a,e)}let m=s.get(l),h="number"==typeof m?m:this.options.estimateSize(a),p=i+h;u[a]={index:a,start:i,size:h,end:p,key:l,lane:e},f[e]=a}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Xf(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:a}){let i=e.length-1,o=a?e=>a[2*e]:t=>e[t].start,l=a?e=>a[2*e]+a[2*e+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:i};let s=XC(0,i,o,n),c=s;if(1===r)for(;c<i&&l(c)<n+t;)c++;else if(r>1){let a=Array(r).fill(0);for(;c<i&&a.some(e=>e<n+t);){let t=e[c];a[t.lane]=t.end,c++}let o=Array(r).fill(n+t);for(;s>=0&&o.some(e=>e>=n);){let t=e[s];o[t.lane]=t.start,s--}s=Math.max(0,s-s%r),c=Math.min(i,c+(r-1-c%r))}return{startIndex:s,endIndex:c}}({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:1===r&&null!=this._flatMeasurements?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Xf(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,a)=>null===r||null===a?[]:e({startIndex:r,endIndex:a,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t;if(!this.scrollState||"smooth"!==this.scrollState.behavior)return!0;let n=this.scrollState.index??(null==(t=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))?void 0:t.index);if(void 0!==n&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,n-t),a=Math.min(this.options.count-1,n+t);return e>=r&&e<=a}return!0},this.measureElement=e=>{if(!e)return void this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;let r,a,i;if(e<0||e>=this.options.count)return;let o=this._flatMeasurements;if(1===this.options.lanes&&null!==o)i=this.options.getItemKey(e),a=o[2*e],r=o[2*e+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,a=t.start,r=t.size}let l=t-(this.itemSizeCache.get(i)??r);0!==l&&((null==(n=this.scrollState)?void 0:n.behavior)!=="smooth"&&(void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:a,size:r,end:a+r,lane:0},l,this):a<this.getScrollOffset()+this.scrollAdjustments&&"backward"!==this.scrollDirection)&&(Xh()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=l:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0})),(null===this.pendingMin||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=Xf(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,a=e.length;r<a;r++){let a=t[e[r]];n.push(a)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(0===t.length)return;let n=this._flatMeasurements,r=1===this.options.lanes&&null!=n,a=XC(0,t.length-1,r?e=>n[2*e]:e=>Xm(t[e]).start,e);return Xm(t[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),a=this.getScrollOffset();return"auto"===t&&(t=e>=a+r?"end":"start"),"center"===t?e+=(n-r)/2:"end"===t&&(e-=r),Math.max(Math.min(this.getMaxScrollOffset(),e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),a=this.measurementsCache[e];if(!a)return;if("auto"===t)if(a.end>=r+n-this.options.scrollPaddingEnd)t="end";else{if(!(a.start<=r+this.options.scrollPaddingStart))return[r,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let i="end"===t?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,t,a.size),t]},this.scrollToOffset=(e,{align:t="start",behavior:n="auto"}={})=>{let r=this.getOffsetForAlignment(e,t),a=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t="auto",behavior:n="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[a,i]=r,o=this.now();this.scrollState={index:e,align:i,behavior:n,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t="auto"}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:"start",behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t,n=this.getMeasurements();if(0===n.length)t=this.options.paddingStart;else if(1===this.options.lanes){let r=n.length-1,a=this._flatMeasurements;t=null!=a?a[2*r]+a[2*r+1]:(null==(e=n[r])?void 0:e.end)??0}else{let e=Array(this.options.lanes).fill(null),r=n.length-1;for(;r>=0&&e.some(e=>null===e);){let t=n[r];null===e[t.lane]&&(e[t.lane]=t.end),r--}t=Math.max(...e.filter(e=>null!==e))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(0===this.itemSizeCache.size)return e;for(let t of this.getMeasurements())t&&this.itemSizeCache.has(t.key)&&e.push({index:t.index,key:t.key,start:t.start,size:t.size,end:t.end,lane:t.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}null==this.rafId&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=null!=this.scrollState.index?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&1.01>Math.abs(t-this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r="smooth"===this.scrollState.behavior&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior="auto"),this._scrollToOffset(t,{adjustments:void 0,behavior:r?"smooth":"auto"})}this.scheduleScrollReconcile()}}let XC=(e,t,n,r)=>{for(;e<=t;){let a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else{if(!(i>r))return a;t=a-1}}return e>0?e-1:0},XS="u">typeof document?P.useLayoutEffect:P.useEffect,XM=(0,z.default)("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]),XE={pathSeparator:"/",searchPlaceholder:"Filter rows...",rows:e=>`${e.toLocaleString()} rows`,columns:e=>`${e.toLocaleString()} columns`,selected:e=>`${e.toLocaleString()} selected`,copied:"Copied",copyCell:"Copy cell",noRows:"No rows match this view.",selectAllRows:"Select all visible rows",selectRow:e=>`Select row ${e+1}`,resizeColumn:"Resize column",sortAsc:"Sort ascending",sortDesc:"Sort descending",sortClear:"Clear sorting"};function XI(e,t){return"function"==typeof e?e(t):e}function XP(e){return null==e?"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):e instanceof Date?e.toISOString():JSON.stringify(e)}function XO(e){return"number"==typeof e?e:"boolean"==typeof e?+!!e:XP(e).toLowerCase()}function Xz({file:e={name:"data-table.csv",type:"records"},rows:t,data:n,columns:r,source:a,rowId:i,sorting:o,defaultSorting:l=[],onSortingChange:s,globalFilter:c,defaultGlobalFilter:d="",onGlobalFilterChange:u,rowSelection:f,defaultRowSelection:m={},onRowSelectionChange:h,columnSizing:p,defaultColumnSizing:g={},onColumnSizingChange:x,onCellCopy:v,showHeader:b=!0,showToolbar:y=!0,rowHeight:w=32,overscan:j=14,labels:k,className:N,headerClassName:C,toolbarClassName:S,gridClassName:M,...I}){let O=P.useMemo(()=>({...XE,...k}),[k]),z=P.useMemo(()=>{var e,t;let n;return(e=a)?"csv"===e.type?function(e,t=","){let n=function(e,t=","){let n=[],r="",a=[],i=!1;for(let o=0;o<e.length;o+=1){let l=e[o],s=e[o+1];if('"'===l){i&&'"'===s?(r+='"',o+=1):i=!i;continue}if(!i&&l===t){a.push(r),r="";continue}if(!i&&("\n"===l||"\r"===l)){"\r"===l&&"\n"===s&&(o+=1),a.push(r),n.push(a),a=[],r="";continue}r+=l}return a.push(r),a.some(e=>e.length>0)&&n.push(a),n}(e.trim(),t),r=n[0]?.map((e,t)=>e.trim()||`Column ${t+1}`)??[];return{rows:n.slice(1).map(e=>{let t={};return r.forEach((n,r)=>{t[n]=e[r]??""}),t}),columns:r.map(e=>({id:e,header:e,accessorKey:e,minWidth:96,width:Math.max(120,Math.min(260,12*e.length+80))}))}}(e.content,e.delimiter):Array.isArray(n="string"==typeof(t=e.content)?JSON.parse(t):t)?{rows:n,columns:void 0}:n&&"object"==typeof n?{rows:n.rows??n.data??[n],columns:n.columns}:{rows:[{value:n}],columns:void 0}:{rows:void 0,columns:void 0}},[a]),A=P.useMemo(()=>n??t??z.rows??[],[n,t,z.rows]),T=P.useMemo(()=>r??z.columns??function(e){let t=new Set;for(let n of e.slice(0,50))Object.keys(n).forEach(e=>t.add(e));return Array.from(t).map(e=>({id:e,header:e,accessorKey:e,minWidth:96,width:Math.max(120,Math.min(280,12*e.length+88))}))}(A),[r,z.columns,A]),[R,_]=P.useState(l),[D,L]=P.useState(d),[$,F]=P.useState(m),[H,U]=P.useState(g),[q,W]=P.useState(void 0),[K,G]=P.useState(void 0),X=P.useRef(null),Y=o??R,Z=c??D,J=f??$,Q=p??H,ee=function(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=P.useState(()=>({current:function(e){var t,n;let r=[...Xd,...null!=(t=e._features)?t:[]],a={_features:r},i=a._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultOptions?void 0:t.getDefaultOptions(a)),{}),o={...null!=(n=e.initialState)?n:{}};a._features.forEach(e=>{var t;o=null!=(t=null==e.getInitialState?void 0:e.getInitialState(o))?t:o});let l=[],s=!1,c={_features:r,options:{...i,...e},initialState:o,_queue:e=>{l.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;l.length;)l.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{a.setState(a.initialState)},setOptions:e=>{var t;t=GR(e,a.options),a.options=a.options.mergeOptions?a.options.mergeOptions(i,t):{...i,...t}},getState:()=>a.options.state,setState:e=>{null==a.options.onStateChange||a.options.onStateChange(e)},_getRowId:(e,t,n)=>{var r;return null!=(r=null==a.options.getRowId?void 0:a.options.getRowId(e,t,n))?r:`${n?[n.id,t].join("."):t}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(e,t)=>{let n=(t?a.getPrePaginationRowModel():a.getRowModel()).rowsById[e];if(!n&&!(n=a.getCoreRowModel().rowsById[e]))throw Error();return n},_getDefaultColumnDef:GL(()=>[a.options.defaultColumn],e=>{var t;return e=null!=(t=e)?t:{},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t,n;return null!=(t=null==(n=e.renderValue())||null==n.toString?void 0:n.toString())?t:null},...a._features.reduce((e,t)=>Object.assign(e,null==t.getDefaultColumnDef?void 0:t.getDefaultColumnDef()),{}),...e}},G$(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:GL(()=>[a._getColumnDefs()],e=>{let t=function(e,n,r){return void 0===r&&(r=0),e.map(e=>{let i=function(e,t,n,r){var a,i;let o,l={...e._getDefaultColumnDef(),...t},s=l.accessorKey,c=null!=(a=null!=(i=l.id)?i:s?"function"==typeof String.prototype.replaceAll?s.replaceAll(".","_"):s.replace(/\./g,"_"):void 0)?a:"string"==typeof l.header?l.header:void 0;if(l.accessorFn?o=l.accessorFn:s&&(o=s.includes(".")?e=>{let t=e;for(let e of s.split(".")){var n;t=null==(n=t)?void 0:n[e]}return t}:e=>e[l.accessorKey]),!c)throw Error();let d={id:`${String(c)}`,accessorFn:o,parent:r,depth:n,columnDef:l,columns:[],getFlatColumns:GL(()=>[!0],()=>{var e;return[d,...null==(e=d.columns)?void 0:e.flatMap(e=>e.getFlatColumns())]},G$(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:GL(()=>[e._getOrderColumnsFn()],e=>{var t;return null!=(t=d.columns)&&t.length?e(d.columns.flatMap(e=>e.getLeafColumns())):[d]},G$(e.options,"debugColumns","column.getLeafColumns"))};for(let t of e._features)null==t.createColumn||t.createColumn(d,e);return d}(a,e,r,n);return i.columns=e.columns?t(e.columns,i,r+1):[],i})};return t(e)},G$(e,"debugColumns","getAllColumns")),getAllFlatColumns:GL(()=>[a.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),G$(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:GL(()=>[a.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),G$(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:GL(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),G$(e,"debugColumns","getAllLeafColumns")),getColumn:e=>a._getAllFlatColumnsById()[e]};Object.assign(a,c);for(let e=0;e<a._features.length;e++){let t=a._features[e];null==t||null==t.createTable||t.createTable(a)}return a}(t)})),[r,a]=P.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}})),n.current}({data:A,columns:P.useMemo(()=>T.map(e=>({id:e.id,accessorFn:(t,n)=>e.accessorFn?e.accessorFn(t,n):e.accessorKey?t[e.accessorKey]:void 0,header:()=>e.header,cell:t=>e.cell?e.cell({row:t.row.original,rowIndex:t.row.index,value:t.getValue(),column:e}):XP(t.getValue()),sortingFn:(e,t,n)=>{let r=XO(e.getValue(n)),a=XO(t.getValue(n));return"number"==typeof r&&"number"==typeof a?r-a:String(r).localeCompare(String(a),void 0,{numeric:!0})},enableSorting:e.enableSorting??!0,enableGlobalFilter:e.enableFiltering??!0,size:e.width??168,minSize:e.minWidth??80,maxSize:e.maxWidth??640,meta:{align:e.align,className:e.className,headerClassName:e.headerClassName,copyValue:e.copyValue,sourceColumn:e}})),[T]),state:{sorting:Y,globalFilter:Z,rowSelection:J,columnSizing:Q},defaultColumn:{minSize:80,size:168,maxSize:640},columnResizeMode:"onChange",enableRowSelection:!0,getRowId:"function"==typeof i?(e,t)=>i(e,t):i?(e,t)=>XP(e[i])||String(t):void 0,onSortingChange:e=>{let t=XI(e,Y);void 0===o&&_(t),s?.(t)},onGlobalFilterChange:e=>{let t=XI(e,Z);void 0===c&&L(t),u?.(t)},onRowSelectionChange:e=>{let t=XI(e,J);void 0===f&&F(t),h?.(t)},onColumnSizingChange:e=>{let t=XI(e,Q);void 0===p&&U(t),x?.(t)},globalFilterFn:(e,t,n)=>{let r=String(n??"").trim().toLowerCase();return!r||XP(e.getValue(t)).toLowerCase().includes(r)},getCoreRowModel:e=>GL(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,a,i){void 0===a&&(a=0);let o=[];for(let s=0;s<t.length;s++){let c=GH(e,e._getRowId(t[s],s,i),t[s],s,a,void 0,null==i?void 0:i.id);if(n.flatRows.push(c),n.rowsById[c.id]=c,o.push(c),e.options.getSubRows){var l;c.originalSubRows=e.options.getSubRows(t[s],s),null!=(l=c.originalSubRows)&&l.length&&(c.subRows=r(c.originalSubRows,a+1,c))}}return o};return n.rows=r(t),n},G$(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>GL(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{var a,i,o,l,s,c,d,u,f,m;let h,p,g,x,v,b,y,w,j,k;if(!t.rows.length||!(null!=n&&n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}let N=[],C=[];(null!=n?n:[]).forEach(t=>{var n;let r=e.getColumn(t.id);if(!r)return;let a=r.getFilterFn();a&&N.push({id:t.id,filterFn:a,resolvedValue:null!=(n=null==a.resolveFilterValue?void 0:a.resolveFilterValue(t.value))?n:t.value})});let S=(null!=n?n:[]).map(e=>e.id),M=e.getGlobalFilterFn(),E=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());r&&M&&E.length&&(S.push("__global__"),E.forEach(e=>{var t;C.push({id:e.id,filterFn:M,resolvedValue:null!=(t=null==M.resolveFilterValue?void 0:M.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){let n=t.flatRows[e];if(n.columnFilters={},N.length)for(let e=0;e<N.length;e++){let t=(h=N[e]).id;n.columnFilters[t]=h.filterFn(n,t,h.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(C.length){for(let e=0;e<C.length;e++){let t=(p=C[e]).id;if(p.filterFn(n,t,p.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return a=t.rows,i=e=>{for(let t=0;t<S.length;t++)if(!1===e.columnFilters[S[t]])return!1;return!0},e.options.filterFromLeafRows?(o=a,l=i,g=[],x={},v=null!=(c=(s=e).options.maxLeafRowFilterDepth)?c:100,{rows:(b=function(e,t){void 0===t&&(t=0);let n=[];for(let a=0;a<e.length;a++){var r;let i=e[a],o=GH(s,i.id,i.original,i.index,i.depth,void 0,i.parentId);if(o.columnFilters=i.columnFilters,null!=(r=i.subRows)&&r.length&&t<v){if(o.subRows=b(i.subRows,t+1),l(i=o)&&!o.subRows.length||l(i)||o.subRows.length){n.push(i),x[i.id]=i,g.push(i);continue}}else l(i=o)&&(n.push(i),x[i.id]=i,g.push(i))}return n})(o),flatRows:g,rowsById:x}):(d=a,u=i,y=[],w={},j=null!=(m=(f=e).options.maxLeafRowFilterDepth)?m:100,{rows:(k=function(e,t){void 0===t&&(t=0);let n=[];for(let a=0;a<e.length;a++){let i=e[a];if(u(i)){var r;if(null!=(r=i.subRows)&&r.length&&t<j){let e=GH(f,i.id,i.original,i.index,i.depth,void 0,i.parentId);e.subRows=k(i.subRows,t+1),i=e}n.push(i),y.push(i),w[i.id]=i}}return n})(d),flatRows:y,rowsById:w})},G$(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>GL(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(null!=t&&t.length))return n;let r=e.getState().sorting,a=[],i=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),o={};i.forEach(t=>{let n=e.getColumn(t.id);n&&(o[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});let l=e=>{let t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<i.length;r+=1){var n;let a=i[r],l=o[a.id],s=l.sortUndefined,c=null!=(n=null==a?void 0:a.desc)&&n,d=0;if(s){let n=e.getValue(a.id),r=t.getValue(a.id),i=void 0===n,o=void 0===r;if(i||o){if("first"===s)return i?-1:1;if("last"===s)return i?1:-1;d=i&&o?0:i?s:-s}}if(0===d&&(d=l.sortingFn(e,t,a.id)),0!==d)return c&&(d*=-1),l.invertSorting&&(d*=-1),d}return e.index-t.index}),t.forEach(e=>{var t;a.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=l(e.subRows))}),t};return{rows:l(n.rows),flatRows:a,rowsById:n.rowsById}},G$(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}),et=ee.getRowModel().rows,en=function({useFlushSync:e=!0,...t}){let n=P.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,a)=>{var i;e&&a?(0,x7.flushSync)(n):n(),null==(i=t.onChange)||i.call(t,r,a)}},[a]=P.useState(()=>new XN(r));return a.setOptions(r),XS(()=>a._didMount(),[]),XS(()=>a._willUpdate()),a}({observeElementRect:Xv,observeElementOffset:Xw,scrollToFn:Xk,...{count:et.length,getScrollElement:()=>X.current,estimateSize:()=>w,overscan:j,scrollMargin:w}}),er=ee.getVisibleLeafColumns(),ea=er.reduce((e,t)=>e+t.getSize(),40),ei=`40px ${er.map(e=>`${e.getSize()}px`).join(" ")}`,eo=(e?.path??e?.name??"data-table").split(/[\\/]+/).filter(Boolean),el=ee.getSelectedRowModel().rows.length;async function es(e,t){let n=T.find(e=>e.id===t);if(!n)return;let r=e.getValue(t),a=n.copyValue?n.copyValue({row:e.original,rowIndex:e.index,value:r,column:n}):XP(r);await XA(a)&&(G({rowId:e.id,columnId:t}),v?.({row:e.original,rowIndex:e.index,columnId:t,value:r,text:a}),window.setTimeout(()=>{G(n=>n?.rowId===e.id&&n.columnId===t?void 0:n)},1200))}return(0,E.jsxs)("div",{"data-slot":"data-table-tab-viewer",className:(0,B.cn)("vtl-surface-panel relative grid min-h-0 w-full min-w-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",b&&y?"grid-rows-[auto_auto_minmax(0,1fr)]":b||y?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",N),...I,children:[b&&(0,E.jsxs)("div",{"data-slot":"data-table-tab-viewer-header",className:(0,B.cn)("flex min-h-9 min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",C),children:[(0,E.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,E.jsx)(_W,{className:"size-3.5"})}),(0,E.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:eo.map((e,t)=>(0,E.jsxs)(P.Fragment,{children:[t>0&&(0,E.jsx)("span",{className:"text-muted-foreground",children:O.pathSeparator}),(0,E.jsx)("span",{className:(0,B.cn)("truncate",t<eo.length-1?"text-muted-foreground":"text-foreground"),children:e})]},`${e}-${t}`))}),(0,E.jsx)("span",{className:"shrink-0 text-muted-foreground ui-text-kbd",children:e.type??"records"})]}),y&&(0,E.jsxs)("div",{"data-slot":"data-table-tab-viewer-toolbar",className:(0,B.cn)("flex min-h-10 min-w-0 items-center gap-2 border-b px-3 py-1.5",S),children:[(0,E.jsxs)("div",{className:"relative min-w-36 flex-1 sm:max-w-80",children:[(0,E.jsx)(IX,{className:"pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,E.jsx)(V,{value:Z,onChange:e=>ee.setGlobalFilter(e.target.value),placeholder:O.searchPlaceholder,className:"h-7 rounded-md border-border bg-background pl-8 ui-text-control"})]}),(0,E.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-muted-foreground ui-text-kbd",children:[(0,E.jsx)("span",{children:O.rows(et.length)}),(0,E.jsx)("span",{className:"h-3 w-px bg-border"}),(0,E.jsx)("span",{children:O.columns(T.length)}),el>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{className:"h-3 w-px bg-border"}),(0,E.jsx)("span",{className:"text-foreground",children:O.selected(el)})]})]})]}),(0,E.jsx)("div",{ref:X,"data-slot":"data-table-tab-viewer-grid",className:(0,B.cn)("min-h-0 min-w-0 overflow-auto bg-background","[scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]","[&::-webkit-scrollbar]:size-2.5 [&::-webkit-scrollbar-corner]:bg-transparent [&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-[3px] [&::-webkit-scrollbar-thumb]:border-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:bg-clip-content",M),children:(0,E.jsxs)("div",{className:"relative min-h-full",style:{width:ea,minWidth:"100%"},children:[(0,E.jsxs)("div",{"data-slot":"data-table-tab-viewer-head",className:"sticky top-0 z-20 grid min-w-full border-b bg-muted/70 backdrop-blur",style:{gridTemplateColumns:ei,width:ea,minWidth:"100%"},children:[(0,E.jsx)("div",{className:"grid h-8 place-items-center border-r",children:(0,E.jsx)(EF,{checked:!!ee.getIsAllRowsSelected()||!!ee.getIsSomeRowsSelected()&&"indeterminate",onCheckedChange:e=>ee.toggleAllRowsSelected(!0===e),"aria-label":O.selectAllRows})}),ee.getFlatHeaders().map(e=>{let t=e.column.columnDef.meta,n=e.column.getIsSorted();return(0,E.jsxs)("div",{className:(0,B.cn)("group/header relative flex h-8 min-w-0 items-center border-r text-muted-foreground",t?.align==="right"&&"justify-end",t?.align==="center"&&"justify-center",t?.headerClassName),children:[(0,E.jsxs)("button",{type:"button",disabled:!e.column.getCanSort(),"aria-label":`${XP(t?.sourceColumn.header??e.id)}: ${"asc"===n?O.sortDesc:"desc"===n?O.sortClear:O.sortAsc}`,onClick:e.column.getToggleSortingHandler(),className:(0,B.cn)("flex h-full min-w-0 flex-1 items-center gap-1.5 px-2 text-left ui-text-kbd",e.column.getCanSort()&&"text-foreground hover:bg-muted"),children:[(0,E.jsx)("span",{className:"truncate",children:Xu(e.column.columnDef.header,e.getContext())}),"asc"===n?(0,E.jsx)(ns,{className:"size-3 shrink-0"}):"desc"===n?(0,E.jsx)(RU,{className:"size-3 shrink-0"}):e.column.getCanSort()?(0,E.jsx)(XM,{className:"size-3 shrink-0 opacity-45"}):null]}),e.column.getCanResize()&&(0,E.jsx)("button",{type:"button","aria-label":O.resizeColumn,onDoubleClick:()=>e.column.resetSize(),onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:(0,B.cn)("absolute top-0 right-0 h-full w-2 translate-x-1/2 cursor-col-resize touch-none","after:absolute after:top-1 after:right-1/2 after:bottom-1 after:w-px after:bg-border","hover:after:bg-foreground",e.column.getIsResizing()&&"after:bg-foreground")})]},e.id)})]}),0===et.length?(0,E.jsx)("div",{className:"grid min-h-44 place-items-center text-muted-foreground ui-text-body",children:O.noRows}):(0,E.jsx)("div",{"data-slot":"data-table-tab-viewer-rows",className:"relative",style:{height:en.getTotalSize()},children:en.getVirtualItems().map(e=>{let t=et[e.index];return t?(0,E.jsxs)("div",{"data-slot":"data-table-tab-viewer-row","data-state":t.getIsSelected()?"selected":void 0,className:(0,B.cn)("absolute left-0 grid min-w-full border-b transition-colors","hover:bg-muted/40 data-[state=selected]:bg-muted/65"),style:{gridTemplateColumns:ei,width:ea,minWidth:"100%",height:e.size,transform:`translateY(${e.start-en.options.scrollMargin}px)`},children:[(0,E.jsx)("div",{className:"grid place-items-center border-r",children:(0,E.jsx)(EF,{checked:t.getIsSelected(),onCheckedChange:e=>t.toggleSelected(!0===e),"aria-label":O.selectRow(t.index)})}),t.getVisibleCells().map(e=>{let n=e.column.columnDef.meta,r=q?.rowId===t.id&&q.columnId===e.column.id,a=K?.rowId===t.id&&K.columnId===e.column.id;return(0,E.jsxs)("button",{type:"button","data-slot":"data-table-tab-viewer-cell","data-active":r?"":void 0,onClick:()=>W({rowId:t.id,columnId:e.column.id}),onDoubleClick:()=>es(t,e.column.id),className:(0,B.cn)("group/cell relative flex min-w-0 items-center border-r px-2 text-left ui-text-code","focus-visible:z-10 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none","data-active:bg-selection/10",n?.align==="right"&&"justify-end text-right",n?.align==="center"&&"justify-center text-center",n?.className),style:{height:w},children:[(0,E.jsx)("span",{className:"min-w-0 truncate",children:Xu(e.column.columnDef.cell,e.getContext())}),(0,E.jsx)("span",{className:(0,B.cn)("absolute top-1/2 right-1 grid size-5 -translate-y-1/2 place-items-center rounded-full border bg-background/95 text-muted-foreground opacity-0 shadow-xs transition-opacity","group-hover/cell:opacity-100",r&&"opacity-100"),title:O.copyCell,onClick:n=>{n.stopPropagation(),es(t,e.column.id)},children:a?(0,E.jsx)(CV,{className:"size-3"}):(0,E.jsx)(Eu,{className:"size-3"})})]},e.id)})]},t.id):null})})]})})]})}async function XA(e){try{return await navigator.clipboard?.writeText(e),!0}catch{var t=e;try{let e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",document.body.appendChild(e),e.select();let n=document.execCommand("copy");return document.body.removeChild(e),n}catch{return!1}}}let XT=(0,z.default)("rows-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);function XR({open:e,labels:t,currentView:n,onOpenChange:r,onToggleView:a}){let i="unified"===n?t.split:t.unified;return(0,E.jsx)("div",{"data-slot":"diff-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,E.jsxs)("div",{className:"relative size-8",children:[(0,E.jsx)(F.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":i,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),a()},className:(0,B.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out active:translate-y-0",e?"pointer-events-auto -translate-y-[42px] opacity-100":"pointer-events-none translate-y-1 opacity-0"),children:"unified"===n?(0,E.jsx)(GE,{className:"size-4"}):(0,E.jsx)(XT,{className:"size-4"})}),(0,E.jsx)(F.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>r(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,E.jsx)(MD,{className:(0,B.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function X_(e){return void 0===e?"":String(e)}function XD({line:e,language:t}){let n=P.useMemo(()=>(function(e,t){if(!e)return[{text:" ",type:"plain"}];let n=RegExp(`("(?:(?:\\\\.)|[^"\\\\])*"|'(?:(?:\\\\.)|[^'\\\\])*'|\\\`(?:(?:\\\\.)|[^\\\`\\\\])*\\\`|//.*|${"css"===t?"\\b(?:align-items|background|border|className|color|display|font|gap|grid|height|justify-content|margin|padding|position|width)\\b":"\\b(?:as|async|await|const|export|false|from|function|if|import|in|let|new|null|return|string|true|type|undefined)\\b"}|\\b\\d+(?:\\.\\d+)?\\b|[{}()[\\].,;:<>/=+\\-*])`,"g"),r=[],a=0;for(let t of e.matchAll(n)){let n=t[0],i=t.index??0;i>a&&r.push({text:e.slice(a,i),type:"plain"}),n.startsWith("//")?r.push({text:n,type:"comment"}):/^["'`]/.test(n)?r.push({text:n,type:"string"}):/^\d/.test(n)?r.push({text:n,type:"number"}):/^[{}()[\].,;:<>/=+\-*]$/.test(n)?r.push({text:n,type:"punctuation"}):r.push({text:n,type:"keyword"}),a=i+n.length}return a<e.length&&r.push({text:e.slice(a),type:"plain"}),r})(e,t),[t,e]);return(0,E.jsx)(E.Fragment,{children:n.map((e,t)=>(0,E.jsx)("span",{className:(0,B.cn)("comment"===e.type&&"text-[var(--vtl-diff-comment)] italic","keyword"===e.type&&"text-[var(--vtl-diff-keyword)]","string"===e.type&&"text-[var(--vtl-diff-string)]","number"===e.type&&"text-[var(--vtl-diff-number)]","punctuation"===e.type&&"text-[var(--vtl-diff-punctuation)]"),children:e.text},`${e.text}-${t}`))})}function XL({row:e,language:t,side:n,blankType:r}){if(!e)return(0,E.jsxs)("div",{className:(0,B.cn)("relative grid grid-cols-[2.5rem_minmax(0,1fr)] items-stretch overflow-hidden bg-[var(--vtl-diff-empty-bg)]","old"===n&&"border-r",r&&"bg-[image:var(--vtl-diff-empty-hatch)]"),children:[r&&(0,E.jsx)("span",{className:(0,B.cn)("absolute inset-y-0 left-0 w-1","insert"===r&&"bg-[var(--vtl-diff-insert-fg)]","delete"===r&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,E.jsx)("span",{}),(0,E.jsx)("span",{})]});let a="old"===n?"insert"===e.type?void 0:e.oldLineNumber:"delete"===e.type?void 0:e.newLineNumber;return(0,E.jsxs)("div",{className:(0,B.cn)("relative grid grid-cols-[2.5rem_minmax(0,1fr)] items-stretch overflow-hidden","old"===n&&"border-r","insert"===e.type&&"bg-[var(--vtl-diff-insert-bg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-bg)]"),children:["context"!==e.type&&(0,E.jsx)("span",{className:(0,B.cn)("absolute inset-y-0 left-0 w-1","insert"===e.type&&"bg-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,E.jsx)("span",{className:(0,B.cn)("select-none bg-inherit px-2 text-right text-[var(--vtl-diff-gutter-fg)]","insert"===e.type&&"text-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"text-[var(--vtl-diff-delete-fg)]"),children:X_(a)}),(0,E.jsx)("span",{className:"overflow-hidden px-3 text-[var(--vtl-diff-code-fg)]",children:(0,E.jsx)("span",{className:"inline-block whitespace-pre will-change-transform",style:{transform:"translateX(calc(var(--vtl-diff-scroll-left,0px) * -1))"},children:(0,E.jsx)(XD,{line:e.content,language:t})})})]})}function X$({row:e,language:t,style:n,viewportWidth:r}){return(0,E.jsx)("div",{"data-slot":"diff-tab-viewer-line","data-type":e.type,className:(0,B.cn)("absolute w-full min-w-full ui-text-code","insert"===e.type&&"bg-[var(--vtl-diff-insert-bg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-bg)]"),style:n,children:(0,E.jsxs)("div",{className:"sticky left-0 grid h-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch",style:{width:r},children:["context"!==e.type&&(0,E.jsx)("span",{className:(0,B.cn)("absolute inset-y-0 left-0 w-1","insert"===e.type&&"bg-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"bg-[var(--vtl-diff-delete-fg)]")}),(0,E.jsx)("span",{className:(0,B.cn)("select-none bg-inherit px-2 text-right text-[var(--vtl-diff-gutter-fg)]","insert"===e.type&&"text-[var(--vtl-diff-insert-fg)]","delete"===e.type&&"text-[var(--vtl-diff-delete-fg)]"),children:X_(e.newLineNumber)}),(0,E.jsx)("span",{className:"overflow-hidden px-3 text-[var(--vtl-diff-code-fg)]",children:(0,E.jsx)("span",{className:"inline-block whitespace-pre will-change-transform",style:{transform:"translateX(calc(var(--vtl-diff-scroll-left,0px) * -1))"},children:(0,E.jsx)(XD,{line:e.content,language:t})})})]})})}function XF({row:e,language:t,style:n,viewportWidth:r}){return(0,E.jsx)("div",{"data-slot":"diff-tab-viewer-split-line",className:"absolute w-full min-w-full ui-text-code",style:n,children:(0,E.jsxs)("div",{className:"sticky left-0 grid h-full grid-cols-[minmax(0,1fr)_minmax(0,1fr)] items-stretch",style:{width:r},children:[(0,E.jsx)(XL,{row:e.oldLine,language:t,side:"old",blankType:e.oldBlankType}),(0,E.jsx)(XL,{row:e.newLine,language:t,side:"new",blankType:e.newBlankType})]})})}function XB({row:e,labels:t,style:n,viewportWidth:r,onExpand:a}){let i="fold-count"===e.kind,o=(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("span",{}),i?(0,E.jsx)("div",{className:"flex h-full min-w-0 items-center justify-start px-3 text-muted-foreground",children:(0,E.jsx)("span",{children:t.foldedLines(e.hiddenCount)})}):(0,E.jsx)("button",{type:"button",className:"group flex h-full min-w-0 items-center gap-2 px-3 text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:bg-muted/70","aria-label":"down"===e.direction?t.expandDown:t.expandUp,onClick:()=>a(e.direction),children:(0,E.jsxs)(E.Fragment,{children:["down"===e.direction?(0,E.jsx)(nc,{className:"size-3.5 shrink-0"}):(0,E.jsx)(Ev,{className:"size-3.5 shrink-0"}),(0,E.jsx)("span",{className:"h-px min-w-8 flex-1 bg-border transition-colors group-hover:bg-foreground/35"})]})})]});return void 0!==r?(0,E.jsx)("div",{"data-slot":`diff-tab-viewer-${e.kind}`,className:"absolute w-full min-w-full bg-muted/25 ui-text-code",style:n,children:(0,E.jsx)("div",{className:"sticky left-0 grid h-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch",style:{width:r},children:o})}):(0,E.jsx)("div",{"data-slot":`diff-tab-viewer-${e.kind}`,className:"absolute grid w-full min-w-full grid-cols-[2.5rem_minmax(0,1fr)] items-stretch bg-muted/25 ui-text-code",style:n,children:o})}let XV={pathSeparator:"/",additions:"additions",deletions:"deletions",actions:"Diff view options",unified:"Unified diff",split:"Split diff",foldedLines:e=>`${e} folded lines`,expandDown:"Expand next lines",expandUp:"Expand previous lines",expandAll:"Expand folded lines",empty:"No diff content."};function XH(e){return(e.path??e.name).split(/[\\/]+/).filter(Boolean)}function XU({file:e,lines:t,diff:n,showHeader:r=!0,contextBefore:a=4,contextAfter:i=4,minFoldLines:o=18,expandStep:l=50,rowHeight:s=22,view:c,defaultView:d="unified",onViewChange:u,labels:f,className:m,headerClassName:h,viewerClassName:p,style:g,...x}){let v,b=P.useMemo(()=>({...XV,...f}),[f]),y=P.useMemo(()=>t??(n?function(e){let t=[],n=0,r=0,a=!1;for(let i of e.split("\n")){let e=/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/.exec(i);if(e){n=Number(e[1]),r=Number(e[2]),a=!0;continue}if(!a||i.startsWith("\\ No newline"))continue;let o=i[0],l=i.slice(1);if("+"===o){t.push({type:"insert",content:l,newLineNumber:r}),r+=1;continue}if("-"===o){t.push({type:"delete",content:l,oldLineNumber:n,newLineNumber:r}),n+=1;continue}t.push({type:"context",content:" "===o?l:i,oldLineNumber:n,newLineNumber:r}),n+=1,r+=1}return t}(n):[]),[n,t]),[w,j]=P.useState({}),[k,N]=P.useState(0),[C,S]=P.useState(d),[M,I]=P.useState(!1),O=P.useRef(null),[z,A]=function(){let e=P.useRef(null),[t,n]=P.useState({height:0,width:0});return P.useEffect(()=>{let t=e.current;if(!t)return;function r(){n({height:t.getBoundingClientRect().height,width:t.clientWidth})}r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),[e,t]}(),T=(v=/\.([^.\\/]+)$/.exec(e.name||e.path||""),(e.language??v?.[1]??"text").toLowerCase()),R=c??C,_=P.useMemo(()=>y.reduce((e,t)=>({additions:e.additions+ +("insert"===t.type),deletions:e.deletions+ +("delete"===t.type),maxLineLength:Math.max(e.maxLineLength,t.content.length)}),{additions:0,deletions:0,maxLineLength:0}),[y]),D=P.useMemo(()=>(function({rows:e,folds:t,contextBefore:n,contextAfter:r,minFoldLines:a}){let i=[],o=0;function l(e,t){i.push({kind:"line",id:`line-${t}-${e.type}`,line:e})}for(;o<e.length;){let s=e[o];if(s?.type!=="context"){s&&l(s,o),o+=1;continue}let c=o;for(;o<e.length&&e[o]?.type==="context";)o+=1;let d=o,u=d-c;if(u<=n+r+a){for(let t=c;t<d;t+=1)l(e[t],t);continue}let f=`${c}-${d}`,m=t[f]??{revealTop:0,revealBottom:0},h=Math.min(n+m.revealTop,u),p=Math.min(r+m.revealBottom,u-h),g=c+h,x=d-p,v=x-g;if(v<=0){for(let t=c;t<d;t+=1)l(e[t],t);continue}for(let t=c;t<g;t+=1)l(e[t],t);i.push({kind:"fold-action",id:`fold-${f}-down-${v}`,foldId:f,direction:"down",hiddenCount:v}),i.push({kind:"fold-count",id:`fold-${f}-count-${v}`,foldId:f,hiddenCount:v}),i.push({kind:"fold-action",id:`fold-${f}-up-${v}`,foldId:f,direction:"up",hiddenCount:v});for(let t=x;t<d;t+=1)l(e[t],t)}return i})({rows:y,folds:w,contextBefore:a,contextAfter:i,minFoldLines:o}),[i,a,w,o,y]),L=P.useMemo(()=>(function(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!r)break;if("line"!==r.kind){t.push(r),n+=1;continue}if("context"===r.line.type){t.push({kind:"split-line",id:`split-${r.id}`,oldLine:r.line,newLine:r.line}),n+=1;continue}let a=[];for(;e[n]?.kind==="line";){let t=e[n];if("context"===t.line.type)break;a.push(t.line),n+=1}let i=a.filter(e=>"delete"===e.type),o=a.filter(e=>"insert"===e.type),l=Math.max(i.length,o.length);for(let e=0;e<l;e+=1){let n=i[e],r=o[e];t.push({kind:"split-line",id:`split-change-${t.length}-${n?.oldLineNumber??"empty"}-${r?.newLineNumber??"empty"}`,oldLine:n,newLine:r,oldBlankType:n?void 0:"insert",newBlankType:r?void 0:"delete"})}}return t})(D),[D]),$="split"===R?L:D,F=XH(e),V=$.length*s,H=Math.max(0,Math.floor(k/s)-12),U=Math.min($.length,Math.ceil((k+A.height)/s)+12),q=$.slice(H,U),W=Math.max(A.width,1),K=9.6*_.maxLineLength+168,G=Math.max(760,K),X=Math.max(A.width,1),Y=Math.max(X,X/2+K),Z=`${e.path??e.name}-${n??""}-${t?.length??0}`;return P.useEffect(()=>{j({}),N(0),I(!1)},[Z]),P.useEffect(()=>{if(M)return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e);function e(e){let t=e.target;t instanceof Node&&O.current?.contains(t)||I(!1)}},[M]),(0,E.jsxs)("div",{ref:O,"data-slot":"diff-tab-viewer","data-view":R,className:(0,B.cn)("vtl-surface-panel relative grid min-h-0 w-full min-w-0 overflow-hidden rounded-[var(--surface-panel-radius)] border",r?"grid-rows-[auto_minmax(0,1fr)]":"grid-rows-[minmax(0,1fr)]",m),style:g,...x,children:[r&&(0,E.jsxs)("div",{"data-slot":"diff-tab-viewer-header",className:(0,B.cn)("flex min-w-0 items-center gap-2 border-b bg-muted/35 px-3 py-2",h),children:[(0,E.jsx)("span",{className:"grid size-5 shrink-0 place-items-center rounded-md border bg-background text-muted-foreground",children:(0,E.jsx)(GI,{className:"size-3.5"})}),(0,E.jsx)("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 ui-text-kbd",children:F.map((e,t)=>(0,E.jsxs)(P.Fragment,{children:[t>0&&(0,E.jsx)("span",{className:"text-muted-foreground",children:b.pathSeparator}),(0,E.jsx)("span",{className:(0,B.cn)("truncate",t===F.length-1?"font-medium text-foreground":"text-muted-foreground"),children:e})]},`${e}-${t}`))}),(0,E.jsxs)("div",{className:"hidden shrink-0 items-center gap-1.5 sm:flex",children:[(0,E.jsxs)(nw,{variant:"outline",className:"text-[var(--vtl-diff-insert-fg)]",children:["+",_.additions," ",b.additions]}),(0,E.jsxs)(nw,{variant:"outline",className:"text-[var(--vtl-diff-delete-fg)]",children:["-",_.deletions," ",b.deletions]})]})]}),0===y.length?(0,E.jsx)("div",{className:"grid min-h-0 place-items-center p-6 text-muted-foreground ui-text-body",children:b.empty}):(0,E.jsx)("div",{ref:z,"data-slot":"diff-tab-viewer-body",className:(0,B.cn)("min-h-0 min-w-0 overflow-auto bg-background font-mono","[scrollbar-color:var(--border)_transparent] [scrollbar-width:thin]","[&::-webkit-scrollbar]:size-2.5 [&::-webkit-scrollbar-corner]:bg-transparent [&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-[3px] [&::-webkit-scrollbar-thumb]:border-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:bg-clip-content",p),style:{"--vtl-diff-scroll-left":"0px"},onScroll:e=>{N(e.currentTarget.scrollTop),e.currentTarget.style.setProperty("--vtl-diff-scroll-left",`${e.currentTarget.scrollLeft}px`)},children:(0,E.jsx)("div",{"data-slot":"diff-tab-viewer-scroll-width",className:"relative min-h-full",style:{height:V,width:"split"===R?Y:G,minWidth:"100%"},children:q.map((e,t)=>{let n=H+t,r={height:s,lineHeight:`${s}px`,transform:`translateY(${n*s}px)`};return"line"===e.kind?(0,E.jsx)(X$,{row:e.line,language:T,style:r,viewportWidth:W},e.id):"split-line"===e.kind?(0,E.jsx)(XF,{row:e,language:T,style:r,viewportWidth:X},e.id):(0,E.jsx)(XB,{row:e,labels:b,style:r,viewportWidth:"split"===R?X:void 0,onExpand:t=>{var n;return n=e.foldId,void j(e=>{let r=e[n]??{revealTop:0,revealBottom:0};return"all"===t?{...e,[n]:{revealTop:Number.MAX_SAFE_INTEGER,revealBottom:0}}:{...e,[n]:{revealTop:"down"===t?r.revealTop+l:r.revealTop,revealBottom:"up"===t?r.revealBottom+l:r.revealBottom}}})}},e.id)})})}),(0,E.jsx)(XR,{open:M,labels:b,currentView:R,onOpenChange:I,onToggleView:function(){var e;e="unified"===R?"split":"unified",void 0===c&&S(e),u?.(e)}})]})}let Xq=(0,z.default)("binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]),XW=(0,z.default)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),XK=(0,z.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),XG=(0,z.default)("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]);var XX=e.i(32800);function XY(e){return new XX.LanguageSupport(XX.StreamLanguage.define(e))}function XZ(t){return e.A(22206).then(e=>e.sql({dialect:e[t]}))}let XJ=[XX.LanguageDescription.of({name:"C",extensions:["c","h","ino"],load:()=>e.A(92137).then(e=>e.cpp())}),XX.LanguageDescription.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>e.A(92137).then(e=>e.cpp())}),XX.LanguageDescription.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>XZ("Cassandra")}),XX.LanguageDescription.of({name:"CSS",extensions:["css"],load:()=>e.A(79258).then(e=>e.css())}),XX.LanguageDescription.of({name:"Go",extensions:["go"],load:()=>e.A(44771).then(e=>e.go())}),XX.LanguageDescription.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>e.A(82412).then(e=>e.html())}),XX.LanguageDescription.of({name:"Java",extensions:["java"],load:()=>e.A(35733).then(e=>e.java())}),XX.LanguageDescription.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>e.A(56714).then(e=>e.javascript())}),XX.LanguageDescription.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>e.A(68909).then(e=>e.jinja())}),XX.LanguageDescription.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>e.A(42017).then(e=>e.json())}),XX.LanguageDescription.of({name:"JSX",extensions:["jsx"],load:()=>e.A(56714).then(e=>e.javascript({jsx:!0}))}),XX.LanguageDescription.of({name:"LESS",extensions:["less"],load:()=>e.A(23404).then(e=>e.less())}),XX.LanguageDescription.of({name:"Liquid",extensions:["liquid"],load:()=>e.A(20628).then(e=>e.liquid())}),XX.LanguageDescription.of({name:"MariaDB SQL",load:()=>XZ("MariaSQL")}),XX.LanguageDescription.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>e.A(80207).then(e=>e.markdown())}),XX.LanguageDescription.of({name:"MS SQL",load:()=>XZ("MSSQL")}),XX.LanguageDescription.of({name:"MySQL",load:()=>XZ("MySQL")}),XX.LanguageDescription.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>e.A(50333).then(e=>e.php())}),XX.LanguageDescription.of({name:"PLSQL",extensions:["pls"],load:()=>XZ("PLSQL")}),XX.LanguageDescription.of({name:"PostgreSQL",load:()=>XZ("PostgreSQL")}),XX.LanguageDescription.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>e.A(43848).then(e=>e.python())}),XX.LanguageDescription.of({name:"Rust",extensions:["rs"],load:()=>e.A(22094).then(e=>e.rust())}),XX.LanguageDescription.of({name:"Sass",extensions:["sass"],load:()=>e.A(62363).then(e=>e.sass({indented:!0}))}),XX.LanguageDescription.of({name:"SCSS",extensions:["scss"],load:()=>e.A(62363).then(e=>e.sass())}),XX.LanguageDescription.of({name:"SQL",extensions:["sql"],load:()=>XZ("StandardSQL")}),XX.LanguageDescription.of({name:"SQLite",load:()=>XZ("SQLite")}),XX.LanguageDescription.of({name:"TSX",extensions:["tsx"],load:()=>e.A(56714).then(e=>e.javascript({jsx:!0,typescript:!0}))}),XX.LanguageDescription.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>e.A(56714).then(e=>e.javascript({typescript:!0}))}),XX.LanguageDescription.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>e.A(11043).then(e=>e.wast())}),XX.LanguageDescription.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>e.A(25290).then(e=>e.xml())}),XX.LanguageDescription.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>e.A(66027).then(e=>e.yaml())}),XX.LanguageDescription.of({name:"APL",extensions:["dyalog","apl"],load:()=>e.A(66919).then(e=>XY(e.apl))}),XX.LanguageDescription.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>e.A(96245).then(e=>XY(e.asciiArmor))}),XX.LanguageDescription.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>e.A(95592).then(e=>XY(e.asn1({})))}),XX.LanguageDescription.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>e.A(38120).then(e=>XY(e.asterisk))}),XX.LanguageDescription.of({name:"Brainfuck",extensions:["b","bf"],load:()=>e.A(33855).then(e=>XY(e.brainfuck))}),XX.LanguageDescription.of({name:"Cobol",extensions:["cob","cpy"],load:()=>e.A(37413).then(e=>XY(e.cobol))}),XX.LanguageDescription.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>e.A(38138).then(e=>XY(e.csharp))}),XX.LanguageDescription.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>e.A(32566).then(e=>XY(e.clojure))}),XX.LanguageDescription.of({name:"ClojureScript",extensions:["cljs"],load:()=>e.A(32566).then(e=>XY(e.clojure))}),XX.LanguageDescription.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>e.A(48876).then(e=>XY(e.gss))}),XX.LanguageDescription.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>e.A(44086).then(e=>XY(e.cmake))}),XX.LanguageDescription.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>e.A(11973).then(e=>XY(e.coffeeScript))}),XX.LanguageDescription.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>e.A(16995).then(e=>XY(e.commonLisp))}),XX.LanguageDescription.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>e.A(45748).then(e=>XY(e.cypher))}),XX.LanguageDescription.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>e.A(64832).then(e=>XY(e.cython))}),XX.LanguageDescription.of({name:"Crystal",extensions:["cr"],load:()=>e.A(55133).then(e=>XY(e.crystal))}),XX.LanguageDescription.of({name:"D",extensions:["d"],load:()=>e.A(24299).then(e=>XY(e.d))}),XX.LanguageDescription.of({name:"Dart",extensions:["dart"],load:()=>e.A(38138).then(e=>XY(e.dart))}),XX.LanguageDescription.of({name:"diff",extensions:["diff","patch"],load:()=>e.A(85978).then(e=>XY(e.diff))}),XX.LanguageDescription.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>e.A(89654).then(e=>XY(e.dockerFile))}),XX.LanguageDescription.of({name:"DTD",extensions:["dtd"],load:()=>e.A(77925).then(e=>XY(e.dtd))}),XX.LanguageDescription.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>e.A(27553).then(e=>XY(e.dylan))}),XX.LanguageDescription.of({name:"EBNF",load:()=>e.A(6232).then(e=>XY(e.ebnf))}),XX.LanguageDescription.of({name:"ECL",extensions:["ecl"],load:()=>e.A(11956).then(e=>XY(e.ecl))}),XX.LanguageDescription.of({name:"edn",extensions:["edn"],load:()=>e.A(32566).then(e=>XY(e.clojure))}),XX.LanguageDescription.of({name:"Eiffel",extensions:["e"],load:()=>e.A(25267).then(e=>XY(e.eiffel))}),XX.LanguageDescription.of({name:"Elm",extensions:["elm"],load:()=>e.A(6956).then(e=>XY(e.elm))}),XX.LanguageDescription.of({name:"Erlang",extensions:["erl"],load:()=>e.A(2095).then(e=>XY(e.erlang))}),XX.LanguageDescription.of({name:"Esper",load:()=>e.A(45412).then(e=>XY(e.esper))}),XX.LanguageDescription.of({name:"Factor",extensions:["factor"],load:()=>e.A(2075).then(e=>XY(e.factor))}),XX.LanguageDescription.of({name:"FCL",load:()=>e.A(68091).then(e=>XY(e.fcl))}),XX.LanguageDescription.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>e.A(54669).then(e=>XY(e.forth))}),XX.LanguageDescription.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>e.A(76946).then(e=>XY(e.fortran))}),XX.LanguageDescription.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>e.A(36855).then(e=>XY(e.fSharp))}),XX.LanguageDescription.of({name:"Gas",extensions:["s"],load:()=>e.A(40367).then(e=>XY(e.gas))}),XX.LanguageDescription.of({name:"Gherkin",extensions:["feature"],load:()=>e.A(23161).then(e=>XY(e.gherkin))}),XX.LanguageDescription.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>e.A(97713).then(e=>XY(e.groovy))}),XX.LanguageDescription.of({name:"Haskell",extensions:["hs"],load:()=>e.A(56334).then(e=>XY(e.haskell))}),XX.LanguageDescription.of({name:"Haxe",extensions:["hx"],load:()=>e.A(70963).then(e=>XY(e.haxe))}),XX.LanguageDescription.of({name:"HXML",extensions:["hxml"],load:()=>e.A(70963).then(e=>XY(e.hxml))}),XX.LanguageDescription.of({name:"HTTP",load:()=>e.A(35064).then(e=>XY(e.http))}),XX.LanguageDescription.of({name:"IDL",extensions:["pro"],load:()=>e.A(89381).then(e=>XY(e.idl))}),XX.LanguageDescription.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>e.A(59695).then(e=>XY(e.jsonld))}),XX.LanguageDescription.of({name:"Julia",extensions:["jl"],load:()=>e.A(64014).then(e=>XY(e.julia))}),XX.LanguageDescription.of({name:"Kotlin",extensions:["kt","kts"],load:()=>e.A(38138).then(e=>XY(e.kotlin))}),XX.LanguageDescription.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>e.A(42765).then(e=>XY(e.liveScript))}),XX.LanguageDescription.of({name:"Lua",extensions:["lua"],load:()=>e.A(97328).then(e=>XY(e.lua))}),XX.LanguageDescription.of({name:"mIRC",extensions:["mrc"],load:()=>e.A(34747).then(e=>XY(e.mirc))}),XX.LanguageDescription.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>e.A(15637).then(e=>XY(e.mathematica))}),XX.LanguageDescription.of({name:"Modelica",extensions:["mo"],load:()=>e.A(4877).then(e=>XY(e.modelica))}),XX.LanguageDescription.of({name:"MUMPS",extensions:["mps"],load:()=>e.A(51221).then(e=>XY(e.mumps))}),XX.LanguageDescription.of({name:"Mbox",extensions:["mbox"],load:()=>e.A(64186).then(e=>XY(e.mbox))}),XX.LanguageDescription.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>e.A(84274).then(e=>XY(e.nginx))}),XX.LanguageDescription.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>e.A(51971).then(e=>XY(e.nsis))}),XX.LanguageDescription.of({name:"NTriples",extensions:["nt","nq"],load:()=>e.A(42967).then(e=>XY(e.ntriples))}),XX.LanguageDescription.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>e.A(38138).then(e=>XY(e.objectiveC))}),XX.LanguageDescription.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>e.A(38138).then(e=>XY(e.objectiveCpp))}),XX.LanguageDescription.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>e.A(36855).then(e=>XY(e.oCaml))}),XX.LanguageDescription.of({name:"Octave",extensions:["m"],load:()=>e.A(22492).then(e=>XY(e.octave))}),XX.LanguageDescription.of({name:"Oz",extensions:["oz"],load:()=>e.A(73945).then(e=>XY(e.oz))}),XX.LanguageDescription.of({name:"Pascal",extensions:["p","pas"],load:()=>e.A(2372).then(e=>XY(e.pascal))}),XX.LanguageDescription.of({name:"Perl",extensions:["pl","pm"],load:()=>e.A(44660).then(e=>XY(e.perl))}),XX.LanguageDescription.of({name:"Pig",extensions:["pig"],load:()=>e.A(28734).then(e=>XY(e.pig))}),XX.LanguageDescription.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>e.A(36584).then(e=>XY(e.powerShell))}),XX.LanguageDescription.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>e.A(97145).then(e=>XY(e.properties))}),XX.LanguageDescription.of({name:"ProtoBuf",extensions:["proto"],load:()=>e.A(86304).then(e=>XY(e.protobuf))}),XX.LanguageDescription.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>e.A(86501).then(e=>XY(e.pug))}),XX.LanguageDescription.of({name:"Puppet",extensions:["pp"],load:()=>e.A(16397).then(e=>XY(e.puppet))}),XX.LanguageDescription.of({name:"Q",extensions:["q"],load:()=>e.A(71617).then(e=>XY(e.q))}),XX.LanguageDescription.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>e.A(62905).then(e=>XY(e.r))}),XX.LanguageDescription.of({name:"RPM Changes",load:()=>e.A(31053).then(e=>XY(e.rpmChanges))}),XX.LanguageDescription.of({name:"RPM Spec",extensions:["spec"],load:()=>e.A(31053).then(e=>XY(e.rpmSpec))}),XX.LanguageDescription.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>e.A(84403).then(e=>XY(e.ruby))}),XX.LanguageDescription.of({name:"SAS",extensions:["sas"],load:()=>e.A(57388).then(e=>XY(e.sas))}),XX.LanguageDescription.of({name:"Scala",extensions:["scala"],load:()=>e.A(38138).then(e=>XY(e.scala))}),XX.LanguageDescription.of({name:"Scheme",extensions:["scm","ss"],load:()=>e.A(94780).then(e=>XY(e.scheme))}),XX.LanguageDescription.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>e.A(8240).then(e=>XY(e.shell))}),XX.LanguageDescription.of({name:"Sieve",extensions:["siv","sieve"],load:()=>e.A(46740).then(e=>XY(e.sieve))}),XX.LanguageDescription.of({name:"Smalltalk",extensions:["st"],load:()=>e.A(48213).then(e=>XY(e.smalltalk))}),XX.LanguageDescription.of({name:"Solr",load:()=>e.A(47982).then(e=>XY(e.solr))}),XX.LanguageDescription.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>e.A(36855).then(e=>XY(e.sml))}),XX.LanguageDescription.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>e.A(85501).then(e=>XY(e.sparql))}),XX.LanguageDescription.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>e.A(44878).then(e=>XY(e.spreadsheet))}),XX.LanguageDescription.of({name:"Squirrel",extensions:["nut"],load:()=>e.A(38138).then(e=>XY(e.squirrel))}),XX.LanguageDescription.of({name:"Stylus",extensions:["styl"],load:()=>e.A(76475).then(e=>XY(e.stylus))}),XX.LanguageDescription.of({name:"Swift",extensions:["swift"],load:()=>e.A(8835).then(e=>XY(e.swift))}),XX.LanguageDescription.of({name:"sTeX",load:()=>e.A(42690).then(e=>XY(e.stex))}),XX.LanguageDescription.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>e.A(42690).then(e=>XY(e.stex))}),XX.LanguageDescription.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>e.A(78077).then(e=>XY(e.verilog))}),XX.LanguageDescription.of({name:"Tcl",extensions:["tcl"],load:()=>e.A(139).then(e=>XY(e.tcl))}),XX.LanguageDescription.of({name:"Textile",extensions:["textile"],load:()=>e.A(75208).then(e=>XY(e.textile))}),XX.LanguageDescription.of({name:"TiddlyWiki",load:()=>e.A(44524).then(e=>XY(e.tiddlyWiki))}),XX.LanguageDescription.of({name:"Tiki wiki",load:()=>e.A(38168).then(e=>XY(e.tiki))}),XX.LanguageDescription.of({name:"TOML",extensions:["toml"],load:()=>e.A(40346).then(e=>XY(e.toml))}),XX.LanguageDescription.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>e.A(13368).then(e=>XY(e.troff))}),XX.LanguageDescription.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>e.A(49796).then(e=>XY(e.ttcn))}),XX.LanguageDescription.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>e.A(80429).then(e=>XY(e.ttcnCfg))}),XX.LanguageDescription.of({name:"Turtle",extensions:["ttl"],load:()=>e.A(98657).then(e=>XY(e.turtle))}),XX.LanguageDescription.of({name:"Web IDL",extensions:["webidl"],load:()=>e.A(86672).then(e=>XY(e.webIDL))}),XX.LanguageDescription.of({name:"VB.NET",extensions:["vb"],load:()=>e.A(39480).then(e=>XY(e.vb))}),XX.LanguageDescription.of({name:"VBScript",extensions:["vbs"],load:()=>e.A(77625).then(e=>XY(e.vbScript))}),XX.LanguageDescription.of({name:"Velocity",extensions:["vtl"],load:()=>e.A(42762).then(e=>XY(e.velocity))}),XX.LanguageDescription.of({name:"Verilog",extensions:["v"],load:()=>e.A(78077).then(e=>XY(e.verilog))}),XX.LanguageDescription.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>e.A(24973).then(e=>XY(e.vhdl))}),XX.LanguageDescription.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>e.A(50321).then(e=>XY(e.xQuery))}),XX.LanguageDescription.of({name:"Yacas",extensions:["ys"],load:()=>e.A(79514).then(e=>XY(e.yacas))}),XX.LanguageDescription.of({name:"Z80",extensions:["z80"],load:()=>e.A(91533).then(e=>XY(e.z80))}),XX.LanguageDescription.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>e.A(20878).then(e=>XY(e.mscgen))}),XX.LanguageDescription.of({name:"Xù",extensions:["xu"],load:()=>e.A(20878).then(e=>XY(e.xu))}),XX.LanguageDescription.of({name:"MsGenny",extensions:["msgenny"],load:()=>e.A(20878).then(e=>XY(e.msgenny))}),XX.LanguageDescription.of({name:"Vue",extensions:["vue"],load:()=>e.A(99646).then(e=>e.vue())}),XX.LanguageDescription.of({name:"Angular Template",load:()=>e.A(29423).then(e=>e.angular())})];var XQ=e.i(68113),X0=e.i(2262),X1=e.i(17300);function X2(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let a=e(t,n);return!!a&&(r(n.update(a)),!0)}}let X5=X2(function(e,t,n=t.selection.ranges){let r=[],a=-1;t:for(let{from:e,to:i}of n){let n=r.length,o=1e9,l;for(let n=e;n<=i;){let s=t.doc.lineAt(n);if(void 0==l&&!(l=X6(t,s.from).line))continue t;if(s.from>a&&(e==i||i>s.from)){a=s.from;let e=/^\s*/.exec(s.text)[0].length,t=e==s.length,n=s.text.slice(e,e+l.length)==l?e:-1;e<s.text.length&&e<o&&(o=e),r.push({line:s,comment:n,token:l,indent:e,empty:t,single:!1})}n=s.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:a,empty:i,single:o}of r)(o||!i)&&e.push({from:t.from+a,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:a}of r)if(n>=0){let r=t.from+n,i=r+a.length;" "==t.text[i-t.from]&&i++,e.push({from:r,to:i})}return{changes:e}}return null},0),X3=X2(X8,0),X4=X2((e,t)=>X8(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),a=n.to<=r.to?r:e.doc.lineAt(n.to);a.from>r.from&&a.from==n.to&&(a=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let i=t.length-1;i>=0&&t[i].to>r.from?t[i].to=a.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:a.to})}return t}(t)),0);function X6(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function X8(e,t,n=t.selection.ranges){let r=n.map(e=>X6(t,e.from).block);if(!r.every(e=>e))return null;let a=n.map((e,n)=>(function(e,{open:t,close:n},r,a){let i,o,l=e.sliceDoc(r-50,r),s=e.sliceDoc(a,a+50),c=/\s*$/.exec(l)[0].length,d=/^\s*/.exec(s)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&s.slice(d,d+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};a-r<=100?i=o=e.sliceDoc(r,a):(i=e.sliceDoc(r,r+50),o=e.sliceDoc(a-50,a));let f=/^\s*/.exec(i)[0].length,m=/\s*$/.exec(o)[0].length,h=o.length-m-n.length;return i.slice(f,f+t.length)==t&&o.slice(h,h+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(i.charAt(f+t.length))},close:{pos:a-m-n.length,margin:+!!/\s/.test(o.charAt(h-1))}}:null})(t,r[n],e.from,e.to));if(2!=e&&!a.every(e=>e))return{changes:t.changes(n.map((e,t)=>a[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&a.some(e=>e)){let e=[];for(let t=0,n;t<a.length;t++)if(n=a[t]){let a=r[t],{open:i,close:o}=n;e.push({from:i.pos-a.open.length,to:i.pos+i.margin},{from:o.pos-o.margin,to:o.pos+a.close.length})}return{changes:e}}return null}let X7=XQ.Annotation.define(),X9=XQ.Annotation.define(),Ye=XQ.Facet.define(),Yt=XQ.Facet.define({combine:e=>(0,XQ.combineConfig)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),Yn=XQ.StateField.define({create:()=>Yp.empty,update(e,t){let n=t.state.facet(Yt),r=t.annotation(X7);if(r){let a=Ys.fromTransaction(t,r.selection),i=r.side,o=0==i?e.undone:e.done;return o=a?Yc(o,o.length,n.minDepth,a):Yf(o,t.startState.selection),new Yp(0==i?r.rest:o,0==i?o:r.rest)}let a=t.annotation(X9);if(("full"==a||"before"==a)&&(e=e.isolate()),!1===t.annotation(XQ.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let i=Ys.fromTransaction(t),o=t.annotation(XQ.Transaction.time),l=t.annotation(XQ.Transaction.userEvent);return i?e=e.addChanges(i,o,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,n.newGroupDelay)),("full"==a||"after"==a)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new Yp(e.done.map(Ys.fromJSON),e.undone.map(Ys.fromJSON))});function Yr(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let a=n.field(Yn,!1);if(!a)return!1;let i=a.pop(e,n,t);return!!i&&(r(i),!0)}}let Ya=Yr(0,!1),Yi=Yr(1,!1),Yo=Yr(0,!0),Yl=Yr(1,!0);class Ys{constructor(e,t,n,r,a){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=a}setSelAfter(e){return new Ys(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new Ys(e.changes&&XQ.ChangeSet.fromJSON(e.changes),[],e.mapped&&XQ.ChangeDesc.fromJSON(e.mapped),e.startSelection&&XQ.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(XQ.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=Yu;for(let t of e.startState.facet(Ye)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new Ys(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Yu)}static selection(e){return new Ys(void 0,Yu,void 0,void 0,e)}}function Yc(e,t,n,r){let a=e.slice(t+1>n+20?t-n-1:0,t);return a.push(r),a}function Yd(e,t){return e.length?t.length?e.concat(t):e:t}let Yu=[];function Yf(e,t){if(!e.length)return[Ys.selection([t])];{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Yc(e,e.length-1,1e9,n.setSelAfter(r)))}}function Ym(e,t){if(!e.length)return e;let n=e.length,r=Yu;for(;n;){let a=function(e,t,n){let r=Yd(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Yu,n);if(!e.changes)return Ys.selection(r);let a=e.changes.map(t),i=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(i):i;return new Ys(a,XQ.StateEffect.mapEffects(e.effects,t),o,e.startSelection.map(i),r)}(e[n-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let t=e.slice(0,n);return t[n-1]=a,t}t=a.mapped,n--,r=a.selectionsAfter}return r.length?[Ys.selection(r)]:Yu}let Yh=/^(input\.type|delete)($|\.)/;class Yp{constructor(e,t,n=0,r){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new Yp(this.done,this.undone):this}addChanges(e,t,n,r,a){var i,o;let l,s,c=this.done,d=c[c.length-1];return new Yp(c=d&&d.changes&&!d.changes.empty&&e.changes&&(!n||Yh.test(n))&&(!d.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(a,(i=d.changes,o=e.changes,l=[],s=!1,i.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,n,r)=>{for(let e=0;e<l.length;){let t=l[e++],a=l[e++];r>=t&&n<=a&&(s=!0)}}),s))||"input.type.compose"==n)?Yc(c,c.length-1,r.minDepth,new Ys(e.changes.compose(d.changes),Yd(XQ.StateEffect.mapEffects(e.effects,d.changes),d.effects),d.mapped,d.startSelection,Yu)):Yc(c,c.length,r.minDepth,e),Yu,t,n)}addSelection(e,t,n,r){var a;let i=this.done.length?this.done[this.done.length-1].selectionsAfter:Yu;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(a=i[i.length-1],a.ranges.length==e.ranges.length&&0===a.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new Yp(Yf(this.done,e),this.undone,t,n)}addMapping(e){return new Yp(Ym(this.done,e),Ym(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let a=r[r.length-1],i=a.selectionsAfter[0]||(a.startSelection?a.startSelection.map(a.changes.invertedDesc,1):t.selection);if(n&&a.selectionsAfter.length){let n,o;return t.update({selection:a.selectionsAfter[a.selectionsAfter.length-1],annotations:X7.of({side:e,rest:(n=r[r.length-1],(o=r.slice())[r.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:i}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!a.changes)return null;let n=1==r.length?Yu:r.slice(0,r.length-1);return a.mapped&&(n=Ym(n,a.mapped)),t.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:X7.of({side:e,rest:n,selection:i}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}Yp.empty=new Yp(Yu,Yu);function Yg(e,t){return XQ.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function Yx(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Yv({state:e,dispatch:t},n){let r=Yg(e.selection,n);return!r.eq(e.selection,!0)&&(t(Yx(e,r)),!0)}function Yb(e,t){return XQ.EditorSelection.cursor(t?e.to:e.from)}function Yy(e,t){return Yv(e,n=>n.empty?e.moveByChar(n,t):Yb(n,t))}function Yw(e){return e.textDirectionAt(e.state.selection.main.head)==X0.Direction.LTR}let Yj=e=>Yy(e,!Yw(e)),Yk=e=>Yy(e,Yw(e));function YN(e,t){return Yv(e,n=>n.empty?e.moveByGroup(n,t):Yb(n,t))}function YC(e,t,n){let r,a,i=(0,XX.syntaxTree)(e).resolveInner(t.head),o=n?X1.NodeProp.closedBy:X1.NodeProp.openedBy;for(let r=t.head;;){let t=n?i.childAfter(r):i.childBefore(r);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?r=n?t.to:t.from:i=t}return a=i.type.prop(o)&&(r=n?(0,XX.matchBrackets)(e,i.from,1):(0,XX.matchBrackets)(e,i.to,-1))&&r.matched?n?r.end.to:r.end.from:n?i.to:i.from,XQ.EditorSelection.cursor(a,n?-1:1)}function YS(e,t){return Yv(e,n=>{if(!n.empty)return Yb(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}"u">typeof Intl&&Intl.Segmenter;let YM=e=>YS(e,!1),YE=e=>YS(e,!0);function YI(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,a;if(t){for(let t of e.state.facet(X0.EditorView.scrollMargins)){let a=t(e);(null==a?void 0:a.top)&&(n=Math.max(null==a?void 0:a.top,n)),(null==a?void 0:a.bottom)&&(r=Math.max(null==a?void 0:a.bottom,r))}a=e.scrollDOM.clientHeight-n-r}else a=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,a-5)}}function YP(e,t){let n,r=YI(e),{state:a}=e,i=Yg(a.selection,n=>n.empty?e.moveVertically(n,t,r.height):Yb(n,t));if(i.eq(a.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(a.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+r.marginTop,s=o.bottom-r.marginBottom;t&&t.top>l&&t.bottom<s&&(n=X0.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(Yx(a,i),{effects:n}),!0}let YO=e=>YP(e,!1),Yz=e=>YP(e,!0);function YA(e,t,n){let r=e.lineBlockAt(t.head),a=e.moveToLineBoundary(t,n);if(a.head==t.head&&a.head!=(n?r.to:r.from)&&(a=e.moveToLineBoundary(t,n,!1)),!n&&a.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(a=XQ.EditorSelection.cursor(r.from+n))}return a}function YT(e,t){let n=Yg(e.state.selection,e=>{let n=t(e);return XQ.EditorSelection.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return!n.eq(e.state.selection)&&(e.dispatch(Yx(e.state,n)),!0)}function YR(e,t){return YT(e,n=>e.moveByChar(n,t))}let Y_=e=>YR(e,!Yw(e)),YD=e=>YR(e,Yw(e));function YL(e,t){return YT(e,n=>e.moveByGroup(n,t))}function Y$(e,t){return YT(e,n=>e.moveVertically(n,t))}let YF=e=>Y$(e,!1),YB=e=>Y$(e,!0);function YV(e,t){return YT(e,n=>e.moveVertically(n,t,YI(e).height))}let YH=e=>YV(e,!1),YU=e=>YV(e,!0),Yq=({state:e,dispatch:t})=>(t(Yx(e,{anchor:0})),!0),YW=({state:e,dispatch:t})=>(t(Yx(e,{anchor:e.doc.length})),!0),YK=({state:e,dispatch:t})=>(t(Yx(e,{anchor:e.selection.main.anchor,head:0})),!0),YG=({state:e,dispatch:t})=>(t(Yx(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function YX(e,t){let{state:n}=e,r=n.selection,a=n.selection.ranges.slice();for(let r of n.selection.ranges){let i=n.doc.lineAt(r.head);if(t?i.to<e.state.doc.length:i.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<i.from||r.head>i.to){a.some(e=>e.head==r.head)||a.push(r);break}if(r.head==n.head)break;n=r}}return a.length!=r.ranges.length&&(e.dispatch(Yx(n,XQ.EditorSelection.create(a,a.length-1))),!0)}function YY(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,a=r.changeByRange(r=>{let{from:a,to:i}=r;if(a==i){let o=t(r);o<a?(n="delete.backward",o=YZ(e,o,!1)):o>a&&(n="delete.forward",o=YZ(e,o,!0)),a=Math.min(a,o),i=Math.max(i,o)}else a=YZ(e,a,!1),i=YZ(e,i,!0);return a==i?{range:r}:{changes:{from:a,to:i},range:XQ.EditorSelection.cursor(a,a<r.head?-1:1)}});return!a.changes.empty&&(e.dispatch(r.update(a,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?X0.EditorView.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function YZ(e,t,n){if(e instanceof X0.EditorView)for(let r of e.state.facet(X0.EditorView.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}let YJ=(e,t,n)=>YY(e,r=>{let a=r.from,{state:i}=e,o=i.doc.lineAt(a),l,s;if(n&&!t&&a>o.from&&a<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,a-o.from))){if(" "==l[l.length-1])return a-1;let e=(0,XQ.countColumn)(l,i.tabSize)%(0,XX.getIndentUnit)(i)||(0,XX.getIndentUnit)(i);for(let t=0;t<e&&" "==l[l.length-1-t];t++)a--;s=a}else(s=(0,XQ.findClusterBreak)(o.text,a-o.from,t,t)+o.from)==a&&o.number!=(t?i.doc.lines:1)?s+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(s-o.from,a-o.from))&&(s=(0,XQ.findClusterBreak)(o.text,s-o.from,!1,!1)+o.from);return s}),YQ=e=>YJ(e,!1,!0),Y0=e=>YJ(e,!0,!1),Y1=(e,t)=>YY(e,n=>{let r=n.head,{state:a}=e,i=a.doc.lineAt(r),o=a.charCategorizer(r);for(let e=null;;){if(r==(t?i.to:i.from)){r==n.head&&i.number!=(t?a.doc.lines:1)&&(r+=t?1:-1);break}let l=(0,XQ.findClusterBreak)(i.text,r-i.from,t)+i.from,s=i.text.slice(Math.min(r,l)-i.from,Math.max(r,l)-i.from),c=o(s);if(null!=e&&c!=e)break;(" "!=s||r!=n.head)&&(e=c),r=l}return r}),Y2=e=>Y1(e,!1);function Y5(e){let t=[],n=-1;for(let r of e.selection.ranges){let a=e.doc.lineAt(r.from),i=e.doc.lineAt(r.to);if(r.empty||r.to!=i.from||(i=e.doc.lineAt(r.to-1)),n>=a.number){let e=t[t.length-1];e.to=i.to,e.ranges.push(r)}else t.push({from:a.from,to:i.to,ranges:[r]});n=i.number+1}return t}function Y3(e,t,n){if(e.readOnly)return!1;let r=[],a=[];for(let t of Y5(e)){if(n?t.to==e.doc.length:0==t.from)continue;let i=e.doc.lineAt(n?t.to+1:t.from-1),o=i.length+1;if(n)for(let n of(r.push({from:t.to,to:i.to},{from:t.from,insert:i.text+e.lineBreak}),t.ranges))a.push(XQ.EditorSelection.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(r.push({from:i.from,to:t.from},{from:t.to,insert:e.lineBreak+i.text}),t.ranges))a.push(XQ.EditorSelection.range(n.anchor-o,n.head-o))}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:XQ.EditorSelection.create(a,e.selection.mainIndex),userEvent:"move.line"})),!0)}function Y4(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Y5(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let a=e.changes(r);return t(e.update({changes:a,selection:e.selection.map(a,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let Y6=Y7(!1),Y8=Y7(!0);function Y7(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:a}=n,i=t.doc.lineAt(r),o=!e&&r==a&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=(0,XX.syntaxTree)(e).resolveInner(t),r=n.childBefore(t),a=n.childAfter(t),i;return r&&a&&r.to<=t&&a.from>=t&&(i=r.type.prop(X1.NodeProp.closedBy))&&i.indexOf(a.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(r.to,a.from))?{from:r.to,to:a.from}:null}(t,r);e&&(r=a=(a<=i.to?i:t.doc.lineAt(a)).to);let l=new XX.IndentContext(t,{simulateBreak:r,simulateDoubleBreak:!!o}),s=(0,XX.getIndentation)(l,r);for(null==s&&(s=(0,XQ.countColumn)(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));a<i.to&&/\s/.test(i.text[a-i.from]);)a++;o?{from:r,to:a}=o:r>i.from&&r<i.from+100&&!/\S/.test(i.text.slice(0,r))&&(r=i.from);let c=["",(0,XX.indentString)(t,s)];return o&&c.push((0,XX.indentString)(t,l.lineIndent(i.from,-1))),{changes:{from:r,to:a,insert:XQ.Text.of(c)},range:XQ.EditorSelection.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y9(e,t){let n=-1;return e.changeByRange(r=>{let a=[];for(let i=r.from;i<=r.to;){let o=e.doc.lineAt(i);o.number>n&&(r.empty||r.to>o.from)&&(t(o,a,r),n=o.number),i=o.to+1}let i=e.changes(a);return{changes:a,range:XQ.EditorSelection.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}let Ze=[{key:"Ctrl-b",run:Yj,shift:Y_,preventDefault:!0},{key:"Ctrl-f",run:Yk,shift:YD},{key:"Ctrl-p",run:YM,shift:YF},{key:"Ctrl-n",run:YE,shift:YB},{key:"Ctrl-a",run:e=>Yv(e,t=>XQ.EditorSelection.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>YT(e,t=>XQ.EditorSelection.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>Yv(e,t=>XQ.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>YT(e,t=>XQ.EditorSelection.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:Y0},{key:"Ctrl-h",run:YQ},{key:"Ctrl-k",run:e=>YY(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:Y2},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:XQ.Text.of(["",""])},range:XQ.EditorSelection.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),a=n==r.from?n-1:(0,XQ.findClusterBreak)(r.text,n-r.from,!1)+r.from,i=n==r.to?n+1:(0,XQ.findClusterBreak)(r.text,n-r.from,!0)+r.from;return{changes:{from:a,to:i,insert:e.doc.slice(n,i).append(e.doc.slice(a,n))},range:XQ.EditorSelection.cursor(i)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Yz}],Zt=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>Yv(e,t=>YC(e.state,t,!Yw(e))),shift:e=>YT(e,t=>YC(e.state,t,!Yw(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>Yv(e,t=>YC(e.state,t,Yw(e))),shift:e=>YT(e,t=>YC(e.state,t,Yw(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>Y3(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>Y4(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>Y3(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>Y4(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>YX(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>YX(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=XQ.EditorSelection.create([n.main]):n.main.empty||(r=XQ.EditorSelection.create([XQ.EditorSelection.cursor(n.main.head)])),!!r&&(t(Yx(e,r)),!0)}},{key:"Mod-Enter",run:Y8},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=Y5(e).map(({from:t,to:n})=>XQ.EditorSelection.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:XQ.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=Yg(e.selection,t=>{let n=(0,XX.syntaxTree)(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return XQ.EditorSelection.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(Yx(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Y9(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let a=(0,XQ.countColumn)(r,e.tabSize),i=0,o=(0,XX.indentString)(e,Math.max(0,a-(0,XX.getIndentUnit)(e)));for(;i<r.length&&i<o.length&&r.charCodeAt(i)==o.charCodeAt(i);)i++;n.push({from:t.from+i,to:t.from+r.length,insert:o.slice(i)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Y9(e,(t,n)=>{n.push({from:t.from,insert:e.facet(XX.indentUnit)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new XX.IndentContext(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),a=Y9(e,(t,a,i)=>{let o=(0,XX.getIndentation)(r,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],s=(0,XX.indentString)(e,o);(l!=s||i.from<t.from+l.length)&&(n[t.from]=o,a.push({from:t.from,to:t.from+l.length,insert:s}))});return a.changes.empty||t(e.update(a,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Y5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=Yg(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),a=e.coordsAtPos(t.head,t.assoc||1);a&&(n=r.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let n,r;return n=!1,r=Yg(e.selection,t=>{let r=(0,XX.matchBrackets)(e,t.head,-1)||(0,XX.matchBrackets)(e,t.head,1)||t.head>0&&(0,XX.matchBrackets)(e,t.head-1,1)||t.head<e.doc.length&&(0,XX.matchBrackets)(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let a=r.start.from==t.head?r.end.to:r.end.from;return XQ.EditorSelection.cursor(a)}),!!n&&(t(Yx(e,r)),!0)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=X6(e.state,n.from);return r.line?X5(e):!!r.block&&X4(e)}},{key:"Alt-A",run:X3},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:Yj,shift:Y_,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>YN(e,!Yw(e)),shift:e=>YL(e,!Yw(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>Yv(e,t=>YA(e,t,!Yw(e))),shift:e=>YT(e,t=>YA(e,t,!Yw(e))),preventDefault:!0},{key:"ArrowRight",run:Yk,shift:YD,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>YN(e,Yw(e)),shift:e=>YL(e,Yw(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>Yv(e,t=>YA(e,t,Yw(e))),shift:e=>YT(e,t=>YA(e,t,Yw(e))),preventDefault:!0},{key:"ArrowUp",run:YM,shift:YF,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Yq,shift:YK},{mac:"Ctrl-ArrowUp",run:YO,shift:YH},{key:"ArrowDown",run:YE,shift:YB,preventDefault:!0},{mac:"Cmd-ArrowDown",run:YW,shift:YG},{mac:"Ctrl-ArrowDown",run:Yz,shift:YU},{key:"PageUp",run:YO,shift:YH},{key:"PageDown",run:Yz,shift:YU},{key:"Home",run:e=>Yv(e,t=>YA(e,t,!1)),shift:e=>YT(e,t=>YA(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:Yq,shift:YK},{key:"End",run:e=>Yv(e,t=>YA(e,t,!0)),shift:e=>YT(e,t=>YA(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:YW,shift:YG},{key:"Enter",run:Y6,shift:Y6},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:YQ,shift:YQ,preventDefault:!0},{key:"Delete",run:Y0,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Y2,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>Y1(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>YY(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>YY(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(Ze.map(e=>({mac:e.key,run:e.run,shift:e.shift}))));var Zn=e.i(41016);let Zr="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class Za{constructor(e,t,n=0,r=e.length,a,i){this.test=i,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=a?e=>a(Zr(e)):Zr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return(0,XQ.codePointAt)(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=(0,XQ.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,XQ.codePointSize)(e);let r=this.normalize(t);if(r.length)for(let e=0,a=n,i=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,a,i,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;i&&e<t.length&&t.charCodeAt(e)==n?a++:i=!1}}}match(e,t,n,r,a){let i=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?i={from:n.from,to:r,precise:a&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:r,precise:n&&a}:this.matches.push({from:t,index:1,precise:n})),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"u">typeof Symbol&&(Za.prototype[Symbol.iterator]=function(){return this});let Zi={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Zo="gm"+(null==/x/.unicode?"":"u");class Zl{constructor(e,t,n,r=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=Zi,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Zd(e,t,n,r,a);this.re=new RegExp(t,Zo+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let i=e.lineAt(r);this.curLineStart=i.from,this.matchPos=Zu(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Zu(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let Zs=new WeakMap;class Zc{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Zs.get(e);if(!r||r.from>=n||r.to<=t){let r=new Zc(t,e.sliceString(t,n));return Zs.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:a,from:i}=r;return i>t&&(a=e.sliceString(t,i)+a,i=t),r.to<n&&(a+=e.sliceString(r.to,n)),Zs.set(e,new Zc(i,a)),new Zc(t,a.slice(t-i,n-i))}}class Zd{constructor(e,t,n,r,a){this.text=e,this.to=a,this.done=!1,this.value=Zi,this.matchPos=Zu(e,r),this.re=new RegExp(t,Zo+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=Zc.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=Zu(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Zc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Zu(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}"u">typeof Symbol&&(Zl.prototype[Symbol.iterator]=Zd.prototype[Symbol.iterator]=function(){return this});let Zf={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Zm=XQ.Facet.define({combine:e=>(0,XQ.combineConfig)(e,Zf,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),Zh=X0.Decoration.mark({class:"cm-selectionMatch"}),Zp=X0.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Zg(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=XQ.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=XQ.CharCategory.Word)}let Zx=X0.ViewPlugin.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Zm),{state:n}=e,r=n.selection;if(r.ranges.length>1)return X0.Decoration.none;let a=r.main,i,o=null;if(a.empty){if(!t.highlightWordAroundCursor)return X0.Decoration.none;let e=n.wordAt(a.head);if(!e)return X0.Decoration.none;o=n.charCategorizer(a.head),i=n.sliceDoc(e.from,e.to)}else{let e=a.to-a.from;if(e<t.minSelectionLength||e>200)return X0.Decoration.none;if(t.wholeWords){var l,s,c;if(i=n.sliceDoc(a.from,a.to),!(Zg(o=n.charCategorizer(a.head),n,a.from,a.to)&&(l=o,s=a.from,c=a.to,l(n.sliceDoc(s,s+1))==XQ.CharCategory.Word&&l(n.sliceDoc(c-1,c))==XQ.CharCategory.Word)))return X0.Decoration.none}else if(!(i=n.sliceDoc(a.from,a.to)))return X0.Decoration.none}let d=[];for(let r of e.visibleRanges){let e=new Za(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!o||Zg(o,n,r,i))&&(a.empty&&r<=a.from&&i>=a.to?d.push(Zp.range(r,i)):(r>=a.to||i<=a.from)&&d.push(Zh.range(r,i)),d.length>t.maxMatches))return X0.Decoration.none}}return X0.Decoration.set(d)}},{decorations:e=>e.decorations}),Zv=X0.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Zb=XQ.Facet.define({combine:e=>(0,XQ.combineConfig)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ZG(e),scrollToMatch:e=>X0.EditorView.scrollIntoView(e)})});class Zy{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,Zo),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new ZM(this):new Zk(this)}getCursor(e,t=0,n){let r=e.doc?e:XQ.EditorState.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?ZN(this,r,t,n):Zj(this,r,t,n)}}class Zw{constructor(e){this.spec=e}}function Zj(e,t,n,r){var a,i,o,l;let s;return e.wholeWord&&(o=t.doc,l=t.charCategorizer(t.selection.main.head),s=(e,t,n,r)=>((r>e||r+n.length<t)&&(r=Math.max(0,e-2),n=o.sliceString(r,Math.min(o.length,t+2))),(l(ZC(n,e-r))!=XQ.CharCategory.Word||l(ZS(n,e-r))!=XQ.CharCategory.Word)&&(l(ZS(n,t-r))!=XQ.CharCategory.Word||l(ZC(n,t-r))!=XQ.CharCategory.Word))),e.test&&(a=e.test,i=s,s=(e,n,r,o)=>(!i||!!i(e,n,r,o))&&a(e>=o&&n<=o+r.length?r.slice(e-o,n-o):t.doc.sliceString(e,n),t,e,n)),new Za(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),s)}class Zk extends Zw{constructor(e){super(e)}nextMatch(e,t,n){let r=Zj(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Zj(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),a=Zj(this.spec,e,n,r),i=null;for(;!a.nextOverlapping().done;)i=a.value;if(i)return i;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Zj(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let a=Zj(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}}function ZN(e,t,n,r){var a,i,o;let l;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),l=(e,t,n)=>!n[0].length||(o(ZC(n.input,n.index))!=XQ.CharCategory.Word||o(ZS(n.input,n.index))!=XQ.CharCategory.Word)&&(o(ZS(n.input,n.index+n[0].length))!=XQ.CharCategory.Word||o(ZC(n.input,n.index+n[0].length))!=XQ.CharCategory.Word)),e.test&&(a=e.test,i=l,l=(e,n,r)=>(!i||i(e,n,r))&&a(r[0],t,e,n)),new Zl(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:l},n,r)}function ZC(e,t){return e.slice((0,XQ.findClusterBreak)(e,t,!1),t)}function ZS(e,t){return e.slice(t,(0,XQ.findClusterBreak)(e,t))}class ZM extends Zw{nextMatch(e,t,n){let r=ZN(this.spec,e,n,e.doc.length).next();return r.done&&(r=ZN(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let a=Math.max(t,n-1e4*r),i=ZN(this.spec,e,a,n),o=null;for(;!i.next().done;)o=i.value;if(o&&(a==t||o.from>a+10))return o;if(a==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=ZN(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let a=ZN(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}}let ZE=XQ.StateEffect.define(),ZI=XQ.StateEffect.define(),ZP=XQ.StateField.define({create:e=>new ZO(ZV(e).create(),null),update(e,t){for(let n of t.effects)n.is(ZE)?e=new ZO(n.value.create(),e.panel):n.is(ZI)&&(e=new ZO(e.query,n.value?ZB:null));return e},provide:e=>X0.showPanel.from(e,e=>e.panel)});class ZO{constructor(e,t){this.query=e,this.panel=t}}let Zz=X0.Decoration.mark({class:"cm-searchMatch"}),ZA=X0.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ZT=X0.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(ZP))}update(e){let t=e.state.field(ZP);(t!=e.startState.field(ZP)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return X0.Decoration.none;let{view:n}=this,r=new XQ.RangeSetBuilder;for(let t=0,a=n.visibleRanges,i=a.length;t<i;t++){let{from:o,to:l}=a[t];for(;t<i-1&&l>a[t+1].from-500;)l=a[++t].to;e.highlight(n.state,o,l,(e,t)=>{let a=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,a?ZA:Zz)})}return r.finish()}},{decorations:e=>e.decorations});function ZR(e){return t=>{let n=t.state.field(ZP,!1);return n&&n.query.spec.valid?e(t,n):Zq(t)}}let Z_=ZR((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let a=XQ.EditorSelection.single(r.from,r.to),i=e.state.facet(Zb);return e.dispatch({selection:a,effects:[ZZ(e,r),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),ZU(e),!0}),ZD=ZR((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,a=t.prevMatch(n,r,r);if(!a)return!1;let i=XQ.EditorSelection.single(a.from,a.to),o=e.state.facet(Zb);return e.dispatch({selection:i,effects:[ZZ(e,a),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),ZU(e),!0}),ZL=ZR((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!!n&&!!n.length&&(e.dispatch({selection:XQ.EditorSelection.create(n.map(e=>XQ.EditorSelection.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),Z$=ZR((e,{query:t})=>{let{state:n}=e,{from:r,to:a}=n.selection.main;if(n.readOnly)return!1;let i=t.nextMatch(n,r,r);if(!i)return!1;let o=i,l=[],s,c,d=[];o.precise?o.from==r&&o.to==a&&(c=n.toText(t.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),d.push(X0.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):o=t.nextMatch(n,o.from,o.to);let u=e.state.changes(l);return o&&(s=XQ.EditorSelection.single(o.from,o.to).map(u),d.push(ZZ(e,o)),d.push(n.facet(Zb).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:d,userEvent:"input.replace"}),!0}),ZF=ZR((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:a,precise:i}=r;i&&n.push({from:e,to:a,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:X0.EditorView.announce.of(r),userEvent:"input.replace.all"}),!0});function ZB(e){return e.state.facet(Zb).createPanel(e)}function ZV(e,t){var n,r,a,i,o;let l=e.selection.main,s=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!s)return t;let c=e.facet(Zb);return new Zy({search:(null!=(n=null==t?void 0:t.literal)?n:c.literal)?s:s.replace(/\n/g,"\\n"),caseSensitive:null!=(r=null==t?void 0:t.caseSensitive)?r:c.caseSensitive,literal:null!=(a=null==t?void 0:t.literal)?a:c.literal,regexp:null!=(i=null==t?void 0:t.regexp)?i:c.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:c.wholeWord})}function ZH(e){let t=(0,X0.getPanel)(e,ZB);return t&&t.dom.querySelector("[main-field]")}function ZU(e){let t=ZH(e);t&&t==e.root.activeElement&&t.select()}let Zq=e=>{let t=e.state.field(ZP,!1);if(t&&t.panel){let n=ZH(e);if(n&&n!=e.root.activeElement){let r=ZV(e.state,t.query.spec);r.valid&&e.dispatch({effects:ZE.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ZI.of(!0),t?ZE.of(ZV(e.state,t.query.spec)):XQ.StateEffect.appendConfig.of(ZQ)]});return!0},ZW=e=>{let t=e.state.field(ZP,!1);if(!t||!t.panel)return!1;let n=(0,X0.getPanel)(e,ZB);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ZI.of(!1)}),!0},ZK=[{key:"Mod-f",run:Zq,scope:"editor search-panel"},{key:"F3",run:Z_,shift:ZD,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Z_,shift:ZD,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ZW,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:a}=n.main,i=[],o=0;for(let t=new Za(e.doc,e.sliceDoc(r,a));!t.next().done;){if(i.length>1e3)return!1;t.value.from==r&&(o=i.length),i.push(XQ.EditorSelection.range(t.value.from,t.value.to))}return t(e.update({selection:XQ.EditorSelection.create(i,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:a}=(0,X0.showDialog)(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return a.then(n=>{let a=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!a)return void e.dispatch({effects:r});let i=t.doc.lineAt(t.selection.main.head),[,o,l,s,c]=a,d=s?+s.slice(1):0,u=l?+l:i.number;if(l&&c){let e=u/100;o&&(e=e*("-"==o?-1:1)+i.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else l&&o&&(u=u*("-"==o?-1:1)+i.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),m=XQ.EditorSelection.cursor(f.from+Math.max(0,Math.min(d,f.length)));e.dispatch({effects:[r,X0.EditorView.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=XQ.EditorSelection.create(n.ranges.map(t=>e.wordAt(t.head)||XQ.EditorSelection.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let a=function(e,t){let{main:n,ranges:r}=e.selection,a=e.wordAt(n.head),i=a&&a.from==n.from&&a.to==n.to;for(let n=!1,a=new Za(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(n)return null;a=new Za(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==a.value.from))continue;if(i){let t=e.wordAt(a.value.from);if(!t||t.from!=a.value.from||t.to!=a.value.to)continue}return a.value}}(e,r);return!!a&&(t(e.update({selection:e.selection.addRange(XQ.EditorSelection.range(a.from,a.to),!1),effects:X0.EditorView.scrollIntoView(a.to)})),!0)},preventDefault:!0}];class ZG{constructor(e){this.view=e;let t=this.query=e.state.field(ZP).query.spec;function n(e,t,n){return(0,Zn.default)("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=(0,Zn.default)("input",{value:t.search,placeholder:ZX(e,"Find"),"aria-label":ZX(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,Zn.default)("input",{value:t.replace,placeholder:ZX(e,"Replace"),"aria-label":ZX(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,Zn.default)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=(0,Zn.default)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=(0,Zn.default)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=(0,Zn.default)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>Z_(e),[ZX(e,"next")]),n("prev",()=>ZD(e),[ZX(e,"previous")]),n("select",()=>ZL(e),[ZX(e,"all")]),(0,Zn.default)("label",null,[this.caseField,ZX(e,"match case")]),(0,Zn.default)("label",null,[this.reField,ZX(e,"regexp")]),(0,Zn.default)("label",null,[this.wordField,ZX(e,"by word")]),...e.state.readOnly?[]:[(0,Zn.default)("br"),this.replaceField,n("replace",()=>Z$(e),[ZX(e,"replace")]),n("replaceAll",()=>ZF(e),[ZX(e,"replace all")])],(0,Zn.default)("button",{name:"close",onclick:()=>ZW(e),"aria-label":ZX(e,"close"),type:"button"},["×"])])}commit(){let e=new Zy({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ZE.of(e)}))}keydown(e){(0,X0.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ZD:Z_)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Z$(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(ZE)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Zb).top}}function ZX(e,t){return e.state.phrase(t)}let ZY=/[\s\.,:;?!]/;function ZZ(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),a=e.state.doc.lineAt(n).to,i=Math.max(r.from,t-30),o=Math.min(a,n+30),l=e.state.sliceDoc(i,o);if(i!=r.from){for(let e=0;e<30;e++)if(!ZY.test(l[e+1])&&ZY.test(l[e])){l=l.slice(e);break}}if(o!=a){for(let e=l.length-1;e>l.length-30;e--)if(!ZY.test(l[e-1])&&ZY.test(l[e])){l=l.slice(0,e);break}}return X0.EditorView.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}let ZJ=X0.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ZQ=[ZP,XQ.Prec.low(ZT),ZJ];var Z0=e.i(62291),Z1=X0;class Z2{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Z5{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(Ja).markerFilter;r&&(e=r(e,n));let a=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),i=new XQ.RangeSetBuilder,o=[],l=0,s=n.doc.iter(),c=0,d=n.doc.length;for(let e=0;;){let t,n,r=e==a.length?null:a[e];if(!r&&!o.length)break;if(o.length)t=l,n=o.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if((t=r.from)>d)break;n=r.to,o.push(r),e++}for(;e<a.length;){let r=a[e];if(r.from==t&&(r.to>r.from||r.to==t))o.push(r),e++,n=Math.min(r.to,n);else{n=Math.min(r.from,n);break}}n=Math.min(n,d);let u=!1;if(o.some(e=>e.from==t&&(e.to==n||n==d))&&!(u=t==n)&&n-t<10){let e=t-(c+s.value.length);e>0&&(s.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!s.lineBreak&&c+s.value.length>e)break;e=c+s.value.length,c+=s.value.length,s.next()}}let f=Jm(o);if(u)i.add(t,t,Z1.Decoration.widget({widget:new Js(f),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");i.add(t,n,Z1.Decoration.mark({class:"cm-lintRange cm-lintRange-"+f+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>n)}))}if((l=n)==d)break;for(let e=0;e<o.length;e++)o[e].to<=l&&o.splice(e--,1)}let u=i.finish();return new Z5(u,t,Z3(u))}}function Z3(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:a})=>{if(!(t&&0>a.diagnostics.indexOf(t)))if(r){if(0>a.diagnostics.indexOf(r.diagnostic))return!1;r=new Z2(r.from,n,r.diagnostic)}else r=new Z2(e,n,t||a.diagnostics[0])}),r}function Z4(e,t){let n=t.pos,r=t.end||n,a=e.state.facet(Ja).hideOn(e,n,r);if(null!=a)return a;let i=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Z6))||e.changes.touchesRange(i.from,Math.max(i.to,r)))}let Z6=XQ.StateEffect.define(),Z8=XQ.StateEffect.define(),Z7=XQ.StateEffect.define(),Z9=XQ.StateField.define({create:()=>new Z5(Z1.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,a=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=Z3(n,e.selected.diagnostic,a)||Z3(n,null,a)}!n.size&&a&&t.state.facet(Ja).autoPanel&&(a=null),e=new Z5(n,a,r)}for(let n of t.effects)if(n.is(Z6)){let r=t.state.facet(Ja).autoPanel?n.value.length?Jd.open:null:e.panel;e=Z5.init(n.value,r,t.state)}else n.is(Z8)?e=new Z5(e.diagnostics,n.value?Jd.open:null,e.selected):n.is(Z7)&&(e=new Z5(e.diagnostics,e.panel,n.value));return e},provide:e=>[Z1.showPanel.from(e,e=>e.panel),Z1.EditorView.decorations.from(e,e=>e.diagnostics)]}),Je=Z1.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function Jt(e,t){return(0,Zn.default)("ul",{class:"cm-tooltip-lint"},t.map(t=>Jl(e,t,!1)))}let Jn=e=>{let t=e.state.field(Z9,!1);return!!t&&!!t.panel&&(e.dispatch({effects:Z8.of(!1)}),!0)},Jr=[{key:"Mod-Shift-m",run:e=>{var t,n;let r=e.state.field(Z9,!1);r&&r.panel||e.dispatch({effects:(t=e.state,n=[Z8.of(!0)],t.field(Z9,!1)?n:n.concat(XQ.StateEffect.appendConfig.of(Jx)))});let a=(0,Z1.getPanel)(e,Jd.open);return a&&a.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(Z9,!1);if(!t)return!1;let n=e.state.selection.main,r=Z3(t.diagnostics,null,n.to+1);return(!!r||!!(r=Z3(t.diagnostics,null,0))&&(r.from!=n.from||r.to!=n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),(0,Z1.activateHover)(e,r.from,1,{tooltip:Jg,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],Ja=XQ.Facet.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...(0,XQ.combineConfig)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Ji,tooltipFilter:Ji,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,a)=>e(n,r,a)||t(n,r,a):e:t,autoPanel:(e,t)=>e||t})})});function Ji(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Jo(e){let t=[];if(e)n:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue n}}t.push("")}return t}function Jl(e,t,n){var r;let a=n?Jo(t.actions):[];return(0,Zn.default)("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},(0,Zn.default)("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(r=t.actions)?void 0:r.map((n,r)=>{let i=!1,o=r=>{if(r.preventDefault(),i)return;i=!0;let a=Z3(e.state.field(Z9).diagnostics,t);a&&n.apply(e,a.from,a.to)},{name:l}=n,s=a[r]?l.indexOf(a[r]):-1,c=s<0?l:[l.slice(0,s),(0,Zn.default)("u",l.slice(s,s+1)),l.slice(s+1)],d=n.markClass?" "+n.markClass:"";return(0,Zn.default)("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:o,onmousedown:o,"aria-label":` Action: ${l}${s<0?"":` (access key "${a[r]})"`}.`},c)}),t.source&&(0,Zn.default)("div",{class:"cm-diagnosticSource"},t.source))}class Js extends Z1.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return(0,Zn.default)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Jc{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=Jl(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Jd{constructor(e){this.view=e,this.items=[];let t=t=>{if(!t.ctrlKey&&!t.altKey&&!t.metaKey){if(27==t.keyCode)Jn(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],r=Jo(n.actions);for(let a=0;a<r.length;a++)if(r[a].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z3(this.view.state.field(Z9).diagnostics,n);t&&n.actions[a].apply(e,t.from,t.to)}}t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=(0,Zn.default)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=(0,Zn.default)("div",{class:"cm-panel-lint"},this.list,(0,Zn.default)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Jn(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Z9).selected;if(!e)return -1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return -1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Z9),n=0,r=!1,a=null,i=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:l})=>{for(let e of l.diagnostics){if(i.has(e))continue;i.add(e);let o=-1,l;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(l=new Jc(this.view,e),this.items.splice(n,0,l),r=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),a=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new Jc(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z3(this.view.state.field(Z9).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Z7.of(t)})}static open(e){return new Jd(e)}}function Ju(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let Jf=Z1.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ju("#f11")},".cm-lintRange-warning":{backgroundImage:Ju("orange")},".cm-lintRange-info":{backgroundImage:Ju("#999")},".cm-lintRange-hint":{backgroundImage:Ju("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Jm(e){let t="hint",n=1;for(let a of e){var r;let e="error"==(r=a.severity)?4:"warning"==r?3:"info"==r?2:1;e>n&&(n=e,t=a.severity)}return t}Z1.GutterMarker;let Jh=XQ.StateEffect.define(),Jp=XQ.StateField.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=Z4(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(Jh)?t.value:e,e)),provide:e=>Z1.showTooltip.from(e)}),Jg=(0,Z1.hoverTooltip)(function(e,t,n){let{diagnostics:r}=e.state.field(Z9),a,i=-1,o=-1;r.between(t-(n<0),t+ +(n>0),(e,r,{spec:l})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return a=l.diagnostics,i=e,o=r,!1});let l=e.state.facet(Ja).tooltipFilter;return(a&&l&&(a=l(a,e.state)),a)?{pos:i,end:o,above:e.state.doc.lineAt(i).to<o,create:()=>({dom:Jt(e,a)})}:null},{hideOn:Z4}),Jx=[Z9,Z1.EditorView.decorations.compute([Z9],e=>{let{selected:t,panel:n}=e.field(Z9);return t&&n&&t.from!=t.to?Z1.Decoration.set([Je.range(t.from,t.to)]):Z1.Decoration.none}),Jg,Jf],Jv=XQ.Facet.define({combine:e=>(0,XQ.combineConfig)(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}),Jb=[(0,X0.lineNumbers)(),(0,X0.highlightActiveLineGutter)(),(0,X0.highlightSpecialChars)(),function(e={}){return[Yn,Yt.of(e),X0.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?Ya:"historyRedo"==e.inputType?Yi:null;return!!n&&(e.preventDefault(),n(t))}})]}(),(0,XX.foldGutter)(),(0,X0.drawSelection)(),(0,X0.dropCursor)(),XQ.EditorState.allowMultipleSelections.of(!0),(0,XX.indentOnInput)(),(0,XX.syntaxHighlighting)(XX.defaultHighlightStyle,{fallback:!0}),(0,XX.bracketMatching)(),(0,Z0.closeBrackets)(),(0,Z0.autocompletion)(),(0,X0.rectangularSelection)(),(0,X0.crosshairCursor)(),(0,X0.highlightActiveLine)(),[Zv,Zx],X0.keymap.of([...Z0.closeBracketsKeymap,...Zt,...ZK,{key:"Mod-z",run:Ya,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Yi,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Yi,preventDefault:!0},{key:"Mod-u",run:Yo,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Yl,preventDefault:!0},...XX.foldKeymap,...Z0.completionKeymap,...Jr])];var Jy=e.i(99242);function Jw(e){let t=e.name||e.path||"",n=/\.([^.\\/]+)$/.exec(t);return n?.[1]?.toLowerCase()}function Jj(e){if(e.kind)return e.kind;let t=e.mimeType?.toLowerCase()??"",n=Jw(e);return t.startsWith("image/")?"svg"===n?"svg":"image":t.startsWith("video/")?"video":t.includes("html")?"html":t.includes("markdown")?"markdown":t.includes("json")?"code":t.startsWith("text/")?"text":"svg"===n?"svg":"html"===n||"htm"===n?"html":"md"===n||"mdx"===n?"markdown":["png","jpg","jpeg","gif","webp","avif"].includes(n??"")?"image":["mp4","webm","mov","m4v","ogg"].includes(n??"")?"video":["zip","tar","gz","7z","rar","exe","dll","bin","wasm","pdf","psd"].includes(n??"")?"binary":"code"}function Jk(e){if(e&&!(e<=0))return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function JN(e){let t=Jj(e);return"binary"===t?["hex"]:"image"===t||"video"===t?["preview"]:["html","markdown","richtext","svg"].includes(t)?["code","preview"]:["code"]}async function JC(e){let t=function(e){for(let t of[(e.language??Jw(e)??"text").toLowerCase(),e.mimeType?.toLowerCase()]){if(!t)continue;let e=XX.LanguageDescription.matchLanguageName(XJ,t,!0);if(e)return e}for(let t of[e.name,e.path]){if(!t)continue;let e=XX.LanguageDescription.matchFilename(XJ,t);if(e)return e}}(e);if(!t)return[];try{return await t.load()}catch{return[]}}let JS=XX.HighlightStyle.define([{tag:Jy.tags.comment,color:"var(--vtl-cm-comment)",fontStyle:"italic"},{tag:[Jy.tags.keyword,Jy.tags.modifier,Jy.tags.operatorKeyword],color:"var(--vtl-cm-keyword)"},{tag:[Jy.tags.atom,Jy.tags.bool,Jy.tags.null],color:"var(--vtl-cm-constant)"},{tag:[Jy.tags.number,Jy.tags.integer,Jy.tags.float],color:"var(--vtl-cm-number)"},{tag:[Jy.tags.string,Jy.tags.special(Jy.tags.string),Jy.tags.regexp],color:"var(--vtl-cm-string)"},{tag:[Jy.tags.variableName,Jy.tags.self,Jy.tags.propertyName],color:"var(--vtl-cm-variable)"},{tag:[Jy.tags.definition(Jy.tags.variableName),Jy.tags.function(Jy.tags.variableName)],color:"var(--vtl-cm-function)"},{tag:[Jy.tags.className,Jy.tags.typeName,Jy.tags.namespace],color:"var(--vtl-cm-type)"},{tag:[Jy.tags.tagName,Jy.tags.heading],color:"var(--vtl-cm-tag)"},{tag:Jy.tags.attributeName,color:"var(--vtl-cm-attribute)"},{tag:[Jy.tags.attributeValue,Jy.tags.link],color:"var(--vtl-cm-string)"},{tag:[Jy.tags.punctuation,Jy.tags.separator,Jy.tags.bracket],color:"var(--vtl-cm-punctuation)"},{tag:[Jy.tags.invalid],color:"var(--vtl-cm-invalid)"}]),JM=X0.EditorView.theme({"&":{height:"100%",backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-foreground)",fontSize:"var(--font-size-code)",lineHeight:"var(--vtl-cm-line-height)"},".cm-scroller":{fontFamily:"var(--font-family-mono)",height:"100%",overflow:"auto",scrollbarColor:"var(--border) transparent",scrollbarWidth:"thin"},".cm-scroller::-webkit-scrollbar":{width:"10px",height:"10px"},".cm-scroller::-webkit-scrollbar-track, .cm-scroller::-webkit-scrollbar-corner":{background:"transparent"},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:"var(--border)",border:"3px solid transparent",borderRadius:"9999px",backgroundClip:"content-box"},".cm-content":{minHeight:"100%",caretColor:"var(--vtl-cm-foreground)",padding:"0 0"},".cm-gutters":{backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-gutter-foreground)",borderRightColor:"transparent",left:"0",position:"sticky",zIndex:"2"},".cm-gutter":{minWidth:"2.5rem"},".cm-gutters .cm-foldGutter":{display:"none !important"},".cm-lineNumbers .cm-gutterElement":{minWidth:"2.5rem",padding:"0 0.5rem 0 0",textAlign:"right",lineHeight:"var(--vtl-cm-line-height)"},".cm-activeLine":{backgroundColor:"var(--vtl-cm-active-line)"},".cm-activeLineGutter":{backgroundColor:"var(--vtl-cm-background)",color:"var(--vtl-cm-foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--vtl-cm-selection) !important"},".cm-line ::selection, .cm-content ::selection, ::selection":{backgroundColor:"var(--vtl-cm-selection) !important",color:"var(--vtl-cm-selection-text) !important"},"&.cm-focused":{outline:"none"},".cm-cursor":{borderLeftColor:"var(--vtl-cm-foreground)"},".cm-line":{caretColor:"var(--vtl-cm-foreground)",lineHeight:"var(--vtl-cm-line-height)",minHeight:"var(--vtl-cm-line-height)",padding:"0 0.75rem"}});function JE({value:e,file:t,readOnly:n,onValueChange:r,wrapLines:a,className:i}){let o=P.useRef(null),l=P.useRef(null),s=P.useRef(e),c=P.useRef(r);return P.useEffect(()=>{c.current=r},[r]),P.useEffect(()=>{s.current=e;let t=l.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e]),P.useEffect(()=>{let e=o.current;if(!e)return;let r=!1,i=new XQ.Compartment,d=new X0.EditorView({parent:e,state:XQ.EditorState.create({doc:s.current,extensions:[Jb,JM,XQ.EditorState.readOnly.of(n),X0.EditorView.editable.of(!n),a?X0.EditorView.lineWrapping:[],i.of([]),XQ.Prec.high((0,XX.syntaxHighlighting)(JS)),X0.EditorView.updateListener.of(e=>{if(!e.docChanged)return;let t=e.state.doc.toString();s.current=t,c.current?.(t)})]})});return l.current=d,JC(t).then(e=>{r||l.current!==d||d.dispatch({effects:i.reconfigure(e)})}),()=>{r=!0,d.destroy(),l.current=null}},[t.kind,t.language,t.mimeType,t.name,t.path,t.readOnly,n,a]),(0,E.jsx)("div",{"data-slot":"file-tab-code-editor",className:(0,B.cn)("size-full overflow-hidden bg-background",i),ref:o})}let JI=(0,z.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),JP=(0,z.default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function JO({open:e,labels:t,currentView:n,currentMode:r,saving:a,modified:i,canSwitchView:o,canSwitchMode:l,canSave:s,canOpenHistory:c,onOpenChange:d,onToggleView:u,onToggleMode:f,onSave:m,onHistory:h}){let p=[o?{key:"view",label:"code"===n?t.preview:t.code,onClick:u,icon:"code"===n?(0,E.jsx)(GT,{className:"size-4"}):(0,E.jsx)(nd,{className:"size-4"})}:void 0,l?{key:"mode",label:"review"===r?t.edit:t.review,onClick:f,icon:"review"===r?(0,E.jsx)(XW,{className:"size-4"}):(0,E.jsx)(A,{className:"size-4"})}:void 0,s?{key:"save",label:a?t.saving:t.save,onClick:m,disabled:a||!i,icon:(0,E.jsx)(JP,{className:"size-4"})}:void 0,c?{key:"history",label:t.history,onClick:h,icon:(0,E.jsx)(JI,{className:"size-4"})}:void 0].filter(e=>void 0!==e);return 0===p.length?null:(0,E.jsx)("div",{"data-slot":"file-tab-floating-actions",className:"absolute right-3 bottom-3 z-20",children:(0,E.jsxs)("div",{className:"relative size-8",children:[p.map((t,n)=>(0,E.jsx)(F.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.label,disabled:t.disabled,onClick:()=>{t.disabled||t.onClick()},className:(0,B.cn)("absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur transition-[opacity,transform] duration-150 ease-out",e?"pointer-events-auto opacity-100":"pointer-events-none translate-y-1 opacity-0",t.disabled&&"opacity-45"),style:{transform:e?`translateY(-${(n+1)*42}px)`:void 0},children:t.icon},t.key)),(0,E.jsx)(F.Button,{type:"button",variant:"outline",size:"icon-sm","aria-label":t.actions,"aria-expanded":e,onClick:()=>d(!e),className:"absolute inset-0 rounded-full bg-background/95 shadow-md backdrop-blur",children:(0,E.jsx)(MD,{className:(0,B.cn)("size-4 transition-transform",e&&"rotate-90")})})]})})}function Jz({value:e}){let t=e.split(/\n{2,}/);return(0,E.jsx)("div",{className:"mx-auto grid w-full max-w-3xl gap-3 p-6",children:t.map((e,t)=>{let n=e.trim();return n?n.startsWith("### ")?(0,E.jsx)("h3",{className:"ui-text-body font-semibold text-foreground",children:n.replace(/^###\s+/,"")},t):n.startsWith("## ")?(0,E.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:n.replace(/^##\s+/,"")},t):n.startsWith("# ")?(0,E.jsx)("h1",{className:"text-xl font-semibold text-foreground",children:n.replace(/^#\s+/,"")},t):n.startsWith(">")?(0,E.jsx)("blockquote",{className:"ui-text-body border-l-2 pl-3 text-muted-foreground",children:n.replace(/^>\s?/gm,"")},t):/^[-*]\s+/m.test(n)?(0,E.jsx)("ul",{className:"ui-text-body grid list-disc gap-1 pl-5",children:n.split("\n").map(e=>(0,E.jsx)("li",{children:e.replace(/^[-*]\s+/,"")},e))},t):n.startsWith("```")?(0,E.jsx)("pre",{className:"overflow-auto rounded-lg border bg-code p-3 ui-text-code text-code-foreground",children:n.replace(/^```\w*\n?/,"").replace(/```$/,"")},t):(0,E.jsx)("p",{className:"ui-text-body text-muted-foreground",children:n},t):null})})}function JA({title:e,value:t,className:n}){let r=function(){let[e,t]=P.useState("light");return P.useEffect(()=>{function e(){let e=document.documentElement.classList.contains("dark"),n=document.documentElement.classList.contains("light");e||n?t(e?"dark":"light"):t(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}e();let n=new MutationObserver(e),r=window.matchMedia("(prefers-color-scheme: dark)");return n.observe(document.documentElement,{attributeFilter:["class"],attributes:!0}),r.addEventListener("change",e),()=>{n.disconnect(),r.removeEventListener("change",e)}},[]),e}(),a=P.useMemo(()=>{let e,n;return e="dark"===r?"rgba(255, 255, 255, 0.16)":"#d8dee9",n=`<style data-vantaloom-scrollbar>