@tom2012/cc-web 1.5.61 → 1.5.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{c as Pe,r as l,ai as re,aj as Y,ak as He,j as r,al as K,am as z,an as _e,e as Q,ao as an,R as Ce,ap as We,aq as jt,ar as Zo,as as Rt,at as Jo,au as Qo,av as er,aw as tr,ax as nr,ay as or,q as rr,az as sr,K as ir,L as ar,N as cr,O as lr,Q as dr,B as ee,T as ue,I as je,U as ur,aA as $t,aB as mt,aC as fr,aD as pr,aE as mr,a5 as cn,aF as hr,l as ln,aG as xr,a3 as gr,aH as vr,a4 as yr,v as wr,A as br,o as Sr,X as Cr,aI as Nr,aJ as jr,aK as Rr,aL as Ar,aM as Tr,aN as Pr,aO as Ht,aP as Er,t as lt,s as Ir,S as Or}from"./index-DXFpmfKx.js";import{C as dn}from"./chevron-down-BA1cERVL.js";import{a as kr,C as _r,g as Dr,T as Vt,S as Wt}from"./PomodoroTimer-CW7YFD_r.js";/**
1
+ import{c as Pe,r as l,ah as re,ai as Y,aj as He,j as r,ak as K,al as z,am as _e,e as Q,an,R as Ce,ao as We,ap as jt,aq as Zo,ar as Rt,as as Jo,at as Qo,au as er,av as tr,aw as nr,ax as or,q as rr,ay as sr,K as ir,L as ar,N as cr,O as lr,Q as dr,B as ee,T as ue,I as je,U as ur,az as $t,aA as mt,aB as fr,aC as pr,aD as mr,a5 as cn,aE as hr,l as ln,aF as xr,a3 as gr,aG as vr,a4 as yr,v as wr,A as br,o as Sr,X as Cr,aH as Nr,aI as jr,aJ as Rr,aK as Ar,aL as Tr,aM as Pr,aN as Ht,aO as Er,t as lt,s as Ir,S as Or}from"./index-BDv7gsVx.js";import{C as dn}from"./chevron-down-B-qjlP5y.js";import{a as kr,C as _r,g as Dr,T as Vt,S as Wt}from"./PomodoroTimer-B6PQkQo8.js";/**
2
2
  * @license lucide-react v0.309.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{ae as f,r,aS as g,j as e,e as a}from"./index-DXFpmfKx.js";import{U as j}from"./user-C_yfEM0L.js";import{B as p}from"./bot-bcJRQuAH.js";function v(){const{token:n}=f(),[o,c]=r.useState(!0),[i,l]=r.useState(null),[t,d]=r.useState(null),[m,x]=r.useState("");if(r.useEffect(()=>{n&&(c(!0),g(n).then(s=>{document.title=s.projectName+" — cc-web",d(s.session),x(s.projectName)}).catch(s=>l(s.message||"链接无效或已过期")).finally(()=>c(!1)))},[n]),o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("span",{className:"text-muted-foreground text-sm",children:"加载中…"})});if(i||!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-foreground font-medium",children:"无法加载会话"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:i??"链接无效或已过期"})]})});const u=new Date(t.startedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsx("div",{className:"min-h-screen bg-background text-foreground",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:m}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[e.jsx("span",{children:u}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.messageCount," 条消息"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[t.messages.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),t.messages.map((s,h)=>e.jsxs("div",{className:a("flex gap-2.5",s.role==="user"?"flex-row-reverse":"flex-row"),children:[e.jsx("div",{className:a("flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center mt-0.5",s.role==="user"?"bg-blue-500/10":"bg-muted"),children:s.role==="user"?e.jsx(j,{className:"h-3.5 w-3.5 text-blue-400"}):e.jsx(p,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("div",{className:a("max-w-[85%] text-sm rounded-lg px-3 py-2 whitespace-pre-wrap break-words",s.role==="user"?"bg-blue-500/10 text-blue-400":"bg-muted text-foreground"),children:s.content})]},h))]})]})})}export{v as ShareViewPage};
1
+ import{ad as f,r,aR as g,j as e,e as a}from"./index-BDv7gsVx.js";import{U as j}from"./user-Be7ZsoJx.js";import{B as p}from"./bot-DPu2RVPX.js";function v(){const{token:n}=f(),[o,c]=r.useState(!0),[i,l]=r.useState(null),[t,d]=r.useState(null),[m,x]=r.useState("");if(r.useEffect(()=>{n&&(c(!0),g(n).then(s=>{document.title=s.projectName+" — cc-web",d(s.session),x(s.projectName)}).catch(s=>l(s.message||"链接无效或已过期")).finally(()=>c(!1)))},[n]),o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("span",{className:"text-muted-foreground text-sm",children:"加载中…"})});if(i||!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-foreground font-medium",children:"无法加载会话"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:i??"链接无效或已过期"})]})});const u=new Date(t.startedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsx("div",{className:"min-h-screen bg-background text-foreground",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:m}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[e.jsx("span",{children:u}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.messageCount," 条消息"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[t.messages.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),t.messages.map((s,h)=>e.jsxs("div",{className:a("flex gap-2.5",s.role==="user"?"flex-row-reverse":"flex-row"),children:[e.jsx("div",{className:a("flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center mt-0.5",s.role==="user"?"bg-blue-500/10":"bg-muted"),children:s.role==="user"?e.jsx(j,{className:"h-3.5 w-3.5 text-blue-400"}):e.jsx(p,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("div",{className:a("max-w-[85%] text-sm rounded-lg px-3 py-2 whitespace-pre-wrap break-words",s.role==="user"?"bg-blue-500/10 text-blue-400":"bg-muted text-foreground"),children:s.content})]},h))]})]})})}export{v as ShareViewPage};
@@ -1,6 +1,6 @@
1
- import{c as k,a3 as z,r,aQ as P,j as e,B as S,a4 as U,aa as B,I as F,e as g,o as p,H as O,A as R,aR as q,t as G}from"./index-DXFpmfKx.js";import{U as Q}from"./user-C_yfEM0L.js";import{D as _}from"./download-C_Km7Hqg.js";import{C as Z}from"./chevron-down-BA1cERVL.js";/**
1
+ import{c as k,a3 as P,r,aP as z,j as e,B as S,a4 as U,a9 as B,I as F,e as g,o as p,H as O,A as q,aQ as G,t as Q}from"./index-BDv7gsVx.js";import{U as R}from"./user-Be7ZsoJx.js";import{D as _}from"./download-BUpYWvYh.js";import{C as Z}from"./chevron-down-B-qjlP5y.js";/**
2
2
  * @license lucide-react v0.309.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const $=k("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]);function X(){const C=z(),[o,f]=r.useState([]),[x,I]=r.useState(!0),[i,E]=r.useState(null),[c,L]=r.useState(""),[d,h]=r.useState(null),[D,H]=r.useState(null),[j,w]=r.useState(null),[N,M]=r.useState(new Set);r.useEffect(()=>{P().then(f).catch(t=>E(t instanceof Error?t.message:"Failed to load SkillHub")).finally(()=>I(!1))},[]);const b=r.useMemo(()=>{const t=new Set;return o.forEach(a=>{var s;return(s=a.tags)==null?void 0:s.forEach(n=>t.add(n))}),Array.from(t).sort()},[o]),A=r.useMemo(()=>o.some(t=>!t.tags||t.tags.length===0),[o]),v=r.useMemo(()=>{let t=o;if(d==="__untagged__"?t=t.filter(a=>!a.tags||a.tags.length===0):d&&(t=t.filter(a=>{var s;return(s=a.tags)==null?void 0:s.includes(d)})),c.trim()){const a=c.toLowerCase();t=t.filter(s=>{var n;return s.label.toLowerCase().includes(a)||s.description.toLowerCase().includes(a)||s.command.toLowerCase().includes(a)||s.author.toLowerCase().includes(a)||((n=s.tags)==null?void 0:n.some(m=>m.toLowerCase().includes(a)))})}return t},[o,c,d]),T=async(t,a)=>{if(a.stopPropagation(),!(j||N.has(t.id))){w(t.id);try{await q(t.id),M(s=>new Set(s).add(t.id)),f(s=>s.map(n=>n.id===t.id?{...n,downloads:(n.downloads||0)+1}:n))}catch(s){G.error(s instanceof Error?s.message:"Download failed")}finally{w(null)}}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>C("/"),children:[e.jsx(U,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("h1",{className:"font-semibold text-lg",children:"SkillHub"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(B,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(F,{placeholder:"搜索命令...",value:c,onChange:t=>L(t.target.value),className:"pl-8 h-9"})]})]})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:[b.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(null),children:"全部"}),b.map(t=>e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d===t?null:t),children:t},t)),A&&e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d==="__untagged__"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d==="__untagged__"?null:"__untagged__"),children:"无标签"})]}),x&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),i&&e.jsx("div",{className:"text-center text-destructive py-20",children:i}),!x&&!i&&o.length===0&&e.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[e.jsx("p",{className:"text-lg mb-2",children:"SkillHub 还没有命令"}),e.jsx("p",{className:"text-sm",children:"在快捷命令面板中点击分享按钮来提交第一个命令吧!"})]}),!x&&!i&&o.length>0&&v.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的命令"}),e.jsx("div",{className:"space-y-3",children:v.map((t,a)=>{var y;const s=D===t.id,n=N.has(t.id),m=j===t.id,u=t.parentId?o.find(l=>l.id===t.parentId):void 0;return e.jsxs(p.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:a*.03,ease:"easeOut"},className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>H(s?null:t.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.label}),(y=t.tags)==null?void 0:y.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[e.jsx($,{className:"h-2.5 w-2.5"}),l]},l))]}),u&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(O,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["继承: ",u.label]})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"h-3 w-3"}),t.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),t.downloads||0]}),e.jsx("span",{children:t.createdAt})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(S,{size:"sm",variant:n?"outline":"default",disabled:m||n,onClick:l=>T(t,l),title:u?`将同时下载继承的「${u.label}」`:void 0,children:[e.jsx(_,{className:"h-3.5 w-3.5 mr-1"}),n?"已下载":m?"下载中...":"下载"]}),e.jsx(p.span,{animate:{rotate:s?180:0},transition:{duration:.2},children:e.jsx(Z,{className:"h-4 w-4 text-muted-foreground"})})]})]}),e.jsx(R,{children:s&&e.jsx(p.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:t.command})})})})]},t.id)})})]})]})}export{X as SkillHubPage};
6
+ */const $=k("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]);function X(){const C=P(),[o,f]=r.useState([]),[x,I]=r.useState(!0),[i,E]=r.useState(null),[c,L]=r.useState(""),[d,h]=r.useState(null),[D,H]=r.useState(null),[j,w]=r.useState(null),[N,M]=r.useState(new Set);r.useEffect(()=>{z().then(f).catch(t=>E(t instanceof Error?t.message:"Failed to load SkillHub")).finally(()=>I(!1))},[]);const b=r.useMemo(()=>{const t=new Set;return o.forEach(a=>{var s;return(s=a.tags)==null?void 0:s.forEach(n=>t.add(n))}),Array.from(t).sort()},[o]),A=r.useMemo(()=>o.some(t=>!t.tags||t.tags.length===0),[o]),v=r.useMemo(()=>{let t=o;if(d==="__untagged__"?t=t.filter(a=>!a.tags||a.tags.length===0):d&&(t=t.filter(a=>{var s;return(s=a.tags)==null?void 0:s.includes(d)})),c.trim()){const a=c.toLowerCase();t=t.filter(s=>{var n;return s.label.toLowerCase().includes(a)||s.description.toLowerCase().includes(a)||s.command.toLowerCase().includes(a)||s.author.toLowerCase().includes(a)||((n=s.tags)==null?void 0:n.some(m=>m.toLowerCase().includes(a)))})}return t},[o,c,d]),T=async(t,a)=>{if(a.stopPropagation(),!(j||N.has(t.id))){w(t.id);try{await G(t.id),M(s=>new Set(s).add(t.id)),f(s=>s.map(n=>n.id===t.id?{...n,downloads:(n.downloads||0)+1}:n))}catch(s){Q.error(s instanceof Error?s.message:"Download failed")}finally{w(null)}}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>C("/"),children:[e.jsx(U,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("h1",{className:"font-semibold text-lg",children:"SkillHub"}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(B,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(F,{placeholder:"搜索命令...",value:c,onChange:t=>L(t.target.value),className:"pl-8 h-9"})]})]})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:[b.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(null),children:"全部"}),b.map(t=>e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d===t?null:t),children:t},t)),A&&e.jsx("button",{className:g("px-3 py-1 rounded-full text-xs font-medium transition-colors",d==="__untagged__"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>h(d==="__untagged__"?null:"__untagged__"),children:"无标签"})]}),x&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),i&&e.jsx("div",{className:"text-center text-destructive py-20",children:i}),!x&&!i&&o.length===0&&e.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[e.jsx("p",{className:"text-lg mb-2",children:"SkillHub 还没有命令"}),e.jsx("p",{className:"text-sm",children:"在快捷命令面板中点击分享按钮来提交第一个命令吧!"})]}),!x&&!i&&o.length>0&&v.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的命令"}),e.jsx("div",{className:"space-y-3",children:v.map((t,a)=>{var y;const s=D===t.id,n=N.has(t.id),m=j===t.id,u=t.parentId?o.find(l=>l.id===t.parentId):void 0;return e.jsxs(p.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:a*.03,ease:"easeOut"},className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>H(s?null:t.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.label}),(y=t.tags)==null?void 0:y.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[e.jsx($,{className:"h-2.5 w-2.5"}),l]},l))]}),u&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(O,{className:"h-3 w-3 text-muted-foreground"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["继承: ",u.label]})]}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(R,{className:"h-3 w-3"}),t.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),t.downloads||0]}),e.jsx("span",{children:t.createdAt})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(S,{size:"sm",variant:n?"outline":"default",disabled:m||n,onClick:l=>T(t,l),title:u?`将同时下载继承的「${u.label}」`:void 0,children:[e.jsx(_,{className:"h-3.5 w-3.5 mr-1"}),n?"已下载":m?"下载中...":"下载"]}),e.jsx(p.span,{animate:{rotate:s?180:0},transition:{duration:.2},children:e.jsx(Z,{className:"h-4 w-4 text-muted-foreground"})})]})]}),e.jsx(q,{children:s&&e.jsx(p.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:t.command})})})})]},t.id)})})]})]})}export{X as SkillHubPage};
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-DXFpmfKx.js";/**
1
+ import{c as t}from"./index-BDv7gsVx.js";/**
2
2
  * @license lucide-react v0.309.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-DXFpmfKx.js";/**
1
+ import{c as o}from"./index-BDv7gsVx.js";/**
2
2
  * @license lucide-react v0.309.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-DXFpmfKx.js";/**
1
+ import{c as o}from"./index-BDv7gsVx.js";/**
2
2
  * @license lucide-react v0.309.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-b-X_bbm4.js","assets/PomodoroTimer-CW7YFD_r.js","assets/download-C_Km7Hqg.js","assets/chevron-down-BA1cERVL.js","assets/bot-bcJRQuAH.js","assets/user-C_yfEM0L.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-D801GJ15.js","assets/SkillHubPage-DkbnofIo.js","assets/ShareViewPage-JtExNvr9.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-CxmRkD_s.js","assets/PomodoroTimer-B6PQkQo8.js","assets/download-BUpYWvYh.js","assets/chevron-down-B-qjlP5y.js","assets/bot-DPu2RVPX.js","assets/user-Be7ZsoJx.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-C4AwXw1s.js","assets/SkillHubPage-BUlWl5RI.js","assets/ShareViewPage-T2Z7Bx3L.js"])))=>i.map(i=>d[i]);
2
2
  var pw=Object.defineProperty;var mw=(e,t,n)=>t in e?pw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var tl=(e,t,n)=>mw(e,typeof t!="symbol"?t+"":t,n);function gw(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var OM=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function IM(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}),n}var jm={exports:{}},ya={},Rm={exports:{}},G={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -272,4 +272,4 @@ Error generating stack: `+o.message+`
272
272
 
273
273
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
274
274
 
275
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},MR="DialogDescriptionWarning",AR=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${qx(MR).contentName}}.`;return p.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},DR=Fx,LR=$x,Jx=Ux,ew=Wx,tw=Gx,nw=Yx,_R=Qx;const hf=DR,OR=LR,rw=p.forwardRef(({className:e,...t},n)=>h.jsx(Jx,{ref:n,className:q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));rw.displayName=Jx.displayName;const Ga=p.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(OR,{children:[h.jsx(rw,{}),h.jsxs(ew,{ref:r,className:q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,h.jsxs(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(uf,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ga.displayName=ew.displayName;const Ka=({className:e,...t})=>h.jsx("div",{className:q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ka.displayName="DialogHeader";const Ya=({className:e,...t})=>h.jsx("div",{className:q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ya.displayName="DialogFooter";const Xa=p.forwardRef(({className:e,...t},n)=>h.jsx(tw,{ref:n,className:q("text-lg font-semibold leading-none tracking-tight",e),...t}));Xa.displayName=tw.displayName;const Qa=p.forwardRef(({className:e,...t},n)=>h.jsx(nw,{ref:n,className:q("text-sm text-muted-foreground",e),...t}));Qa.displayName=nw.displayName;function IR({project:e,open:t,onOpenChange:n,onUpdated:r}){const[s,o]=p.useState([]),[i,a]=p.useState([]),[l,c]=p.useState(!1),[d,u]=p.useState(null);p.useEffect(()=>{if(!t)return;o(e.shares?[...e.shares]:[]),u(null);let g=!1;return sx().then(v=>{g||a(v)}).catch(()=>{}),()=>{g=!0}},[t,e.id]);const f=new Set(s.map(g=>g.username)),y=i.filter(g=>g!==e.owner&&!f.has(g)),w=g=>{o(v=>[...v,{username:g,permission:"view"}])},x=g=>{o(v=>v.filter(E=>E.username!==g))},S=g=>{o(v=>v.map(E=>E.username===g?{...E,permission:E.permission==="view"?"edit":"view"}:E))},m=async()=>{c(!0),u(null);try{const g=await ox(e.id,s);r(g),n(!1)}catch(g){u(g instanceof Error?g.message:"Failed to update shares")}finally{c(!1)}};return h.jsx(hf,{open:t,onOpenChange:n,children:h.jsxs(Ga,{className:"sm:max-w-md",children:[h.jsxs(Ka,{children:[h.jsxs(Xa,{className:"flex items-center gap-2",children:[h.jsx(kc,{className:"h-4 w-4"}),"共享设置"]}),h.jsx(Qa,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),h.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[s.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),s.map(g=>h.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[h.jsx("span",{className:"text-sm font-medium",children:g.username}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{onClick:()=>S(g.username),className:"focus:outline-none",children:h.jsx(rr,{variant:g.permission==="edit"?"default":"secondary",className:"cursor-pointer text-xs",children:g.permission==="edit"?"可编辑":"可见"})}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>x(g.username),children:h.jsx(Ex,{className:"h-3.5 w-3.5"})})]})]},g.username))]}),y.length>0&&h.jsxs("div",{className:"border-t pt-3",children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.map(g=>h.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>w(g),children:[h.jsx(ma,{className:"h-3 w-3"}),g]},g))})]}),d&&h.jsx("p",{className:"text-sm text-destructive",children:d}),h.jsxs(Ya,{children:[h.jsx(ie,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),h.jsx(ie,{onClick:()=>void m(),disabled:l,children:l?"保存中...":"保存"})]})]})})}function VR(e,t){switch(e){case"thinking":return"Thinking…";case"tool_use":return t?`${t}`:"Tool…";case"tool_result":return"Reading…";case"text":return"Writing…"}}function FR({status:e}){return h.jsx("span",{className:q("inline-block w-2 h-2 rounded-full",{"bg-green-500":e==="running","bg-zinc-400":e==="stopped","bg-yellow-400 animate-pulse":e==="restarting"})})}const km=R.memo(function({project:t,active:n=!1,statusStack:r=[],onDelete:s,onArchive:o,onUnarchive:i,onUpdated:a}){var g,v;const l=_a(),[c,d]=p.useState(!1),u=!!t._sharedPermission,f=t._sharedPermission==="view",y=E=>{E.stopPropagation(),confirm(`Delete project "${t.name}"? This cannot be undone.`)&&s(t.id)},w=E=>{E.stopPropagation(),o(t.id)},x=E=>{E.stopPropagation(),i(t.id)},S=h.jsx(Vn.div,{whileHover:!t.archived&&!n?{y:-2}:{},transition:{duration:.2},children:h.jsxs(nf,{className:q("group cursor-pointer transition-colors relative",t.archived?"opacity-60 hover:opacity-80 hover:border-zinc-400":n?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-zinc-400 hover:shadow-md"),onClick:()=>!t.archived&&l(`/projects/${t.id}`),children:[h.jsxs(rf,{className:"pb-2",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx(sf,{className:q("text-base leading-tight",t.archived&&"text-muted-foreground"),children:t.name}),h.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!u&&h.jsxs(h.Fragment,{children:[t.archived?h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:x,title:"Restore project",children:h.jsx(jN,{className:"h-3.5 w-3.5"})}):h.jsxs(h.Fragment,{children:[h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:E=>{E.stopPropagation(),d(!0)},title:"共享设置",children:h.jsx(kc,{className:"h-3.5 w-3.5"})}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:w,title:"Archive project",children:h.jsx(RN,{className:"h-3.5 w-3.5"})})]}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:y,title:"Delete project",children:h.jsx(Ex,{className:"h-3.5 w-3.5"})})]})})]}),h.jsx("div",{className:"flex items-center gap-1.5",children:t.archived?h.jsx(rr,{variant:"secondary",className:"text-xs",children:"Archived"}):h.jsxs(h.Fragment,{children:[h.jsx(FR,{status:t.status}),h.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:t.status}),n&&r.length>0&&h.jsx("div",{className:"ml-auto",children:h.jsx(qd,{mode:"wait",children:r.slice(-1).map(E=>h.jsx(Vn.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.25,ease:"easeOut"},children:h.jsx(rr,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:VR(E.phase,E.detail)})},E.id))})})]})})]}),h.jsxs(of,{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[h.jsx(Ec,{className:"h-3.5 w-3.5 flex-shrink-0"}),h.jsx("span",{className:"truncate font-mono",children:t.folderPath})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(rr,{variant:"outline",className:"text-xs font-mono",children:t.cliTool??"claude"}),h.jsx(rr,{variant:t.permissionMode==="unlimited"?"destructive":"secondary",className:"text-xs",children:t.permissionMode==="unlimited"?"Unlimited":"Limited"}),u&&h.jsxs(rr,{variant:"outline",className:"text-xs gap-0.5",children:[f?h.jsx(DN,{className:"h-3 w-3"}):h.jsx(Sx,{className:"h-3 w-3"}),f?"可见":"可编辑"]}),!u&&t.shares&&t.shares.length>0&&h.jsxs(rr,{variant:"outline",className:"text-xs gap-0.5",children:[h.jsx(kc,{className:"h-3 w-3"}),t.shares.length]}),h.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleDateString()})]}),(t.tags??[]).length>0&&h.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(t.tags??[]).slice(0,3).map(E=>h.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",E]},E)),(((g=t.tags)==null?void 0:g.length)??0)>3&&h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",(((v=t.tags)==null?void 0:v.length)??0)-3]})]})]})]})}),m=n&&!t.archived?h.jsx("div",{className:"card-active-glow rounded-lg",children:S}):S;return h.jsxs(h.Fragment,{children:[m,!u&&a&&h.jsx(IR,{project:t,open:c,onOpenChange:d,onUpdated:a})]})});function sw({onSelect:e}){const[t,n]=p.useState(""),[r,s]=p.useState(null),[o,i]=p.useState([]),[a,l]=p.useState(!0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[y,w]=p.useState(""),[x,S]=p.useState(null),[m,g]=p.useState(!1),v=p.useRef(null),E=async D=>{l(!0),d(null);try{const L=await yx(D);n(L.path),s(L.parent),i(L.entries)}catch(L){d(L instanceof Error?L.message:"Failed to load directory")}finally{l(!1)}};p.useEffect(()=>{E()},[]),p.useEffect(()=>{u&&setTimeout(()=>{var D;return(D=v.current)==null?void 0:D.focus()},0)},[u]);const C=()=>{w(""),S(null),f(!0)},T=()=>{f(!1),w(""),S(null)},k=async()=>{const D=y.trim();if(D){g(!0),S(null);try{const{path:L}=await vx(t,D);f(!1),w(""),await E(t),E(L)}catch(L){S(L instanceof Error?L.message:"Failed to create folder")}finally{g(!1)}}},b=D=>{D.key==="Enter"?(D.preventDefault(),k()):D.key==="Escape"&&T()},A=t.split("/").filter(Boolean),P=D=>{const L="/"+A.slice(0,D+1).join("/");E(L)};return h.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[h.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[h.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>void E(),title:"Home",children:h.jsx(ON,{className:"h-3 w-3"})}),h.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:A.map((D,L)=>h.jsxs(R.Fragment,{children:[h.jsx(wx,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),h.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>P(L),children:D})]},L))}),h.jsxs(ie,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:C,disabled:u||a||!!c,title:"New folder",children:[h.jsx(_N,{className:"h-3.5 w-3.5"}),h.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a&&h.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),c&&h.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:c}),!a&&!c&&h.jsxs("div",{className:"p-1",children:[r&&h.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground",onClick:()=>void E(r),children:[h.jsx(MN,{className:"h-4 w-4 text-muted-foreground"}),h.jsx("span",{children:".."})]}),u&&h.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[h.jsx(lm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),h.jsx("input",{ref:v,className:q("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",x&&"border-destructive"),placeholder:"Folder name",value:y,onChange:D=>{w(D.target.value),S(null)},onKeyDown:b,disabled:m}),h.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>void k(),disabled:!y.trim()||m,title:"Create",children:h.jsx(AN,{className:"h-3.5 w-3.5 text-green-600"})}),h.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:T,disabled:m,title:"Cancel",children:h.jsx(uf,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),x&&h.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:x}),o.length===0&&!u&&h.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),o.map(D=>h.jsxs("button",{className:q("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left",D.type==="dir"?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{D.type==="dir"&&E(D.path)},disabled:D.type==="file",children:[D.type==="dir"?h.jsx(lm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):h.jsx(LN,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:"truncate",children:D.name})]},D.path))]})]}),h.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[h.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),h.jsx(ie,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const zR=[{value:"claude",label:"Claude",desc:"Anthropic Claude Code CLI"},{value:"opencode",label:"OpenCode",desc:"OpenCode CLI (sst/opencode)"},{value:"codex",label:"Codex",desc:"OpenAI Codex CLI"},{value:"qwen",label:"Qwen",desc:"Qwen Code CLI (QwenLM)"}],bm={claude:{limited:"claude",unlimited:"claude --dangerously-skip-permissions"},opencode:{limited:"opencode",unlimited:"opencode --dangerously-skip-permissions"},codex:{limited:"codex",unlimited:"codex --ask-for-approval never --sandbox danger-full-access"},qwen:{limited:"qwen-code",unlimited:"qwen-code --yolo"}};function BR({open:e,onOpenChange:t,onCreated:n}){const[r,s]=p.useState("name"),[o,i]=p.useState(""),[a,l]=p.useState(""),[c,d]=p.useState("claude"),[u,f]=p.useState("limited"),[y,w]=p.useState(!1),[x,S]=p.useState(null),m=()=>{s("name"),i(""),l(""),d("claude"),f("limited"),S(null),w(!1)},g=b=>{b||m(),t(b)},v=()=>{if(!o.trim()){S("Please enter a project name");return}S(null),s("folder")},E=b=>{l(b),s("settings")},C=async()=>{w(!0),S(null);try{const b=await ix({name:o.trim(),folderPath:a,permissionMode:u,cliTool:c});n(b),g(!1)}catch(b){S(b instanceof Error?b.message:"Failed to create project")}finally{w(!1)}},T={name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"},k=["name","folder","settings"];return h.jsx(hf,{open:e,onOpenChange:g,children:h.jsxs(Ga,{className:"sm:max-w-lg",children:[h.jsxs(Ka,{children:[h.jsx(Xa,{children:T[r]}),h.jsxs(Qa,{children:[r==="name"&&"Give your project a name.",r==="folder"&&"Choose the working directory for this project.",r==="settings"&&"Choose the AI coding tool and run mode."]})]}),h.jsx("div",{className:"flex gap-2 mb-2",children:k.map((b,A)=>h.jsx("div",{className:`h-1.5 flex-1 rounded-full ${r===b?"bg-primary":k.indexOf(r)>A?"bg-primary/40":"bg-muted"}`},b))}),r==="name"&&h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{htmlFor:"project-name",children:"Project Name"}),h.jsx(go,{id:"project-name",placeholder:"My Project",value:o,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&v()},autoFocus:!0})]}),x&&h.jsx("p",{className:"text-sm text-destructive",children:x})]}),r==="folder"&&h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Working Directory"}),h.jsx(sw,{onSelect:E})]}),r==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"AI Coding Tool"}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:zR.map(b=>h.jsxs("label",{className:`flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors ${c===b.value?"border-primary bg-primary/5":"hover:bg-accent"}`,children:[h.jsx("input",{type:"radio",name:"cliTool",value:b.value,checked:c===b.value,onChange:()=>d(b.value),className:"accent-primary"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:b.label}),h.jsx("div",{className:"text-xs text-muted-foreground",children:b.desc})]})]},b.value))})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Permission Mode"}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[h.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:u==="limited",onChange:()=>f("limited"),className:"mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:"Limited"}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",h.jsx("code",{className:"bg-muted px-1 rounded",children:bm[c].limited})," — asks for permission before file changes."]})]})]}),h.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[h.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:u==="unlimited",onChange:()=>f("unlimited"),className:"mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",h.jsx("code",{className:"bg-muted px-1 rounded",children:bm[c].unlimited})," — acts autonomously."]})]})]})]})]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:[h.jsx("span",{className:"font-medium",children:"Folder:"})," ",h.jsx("span",{className:"font-mono",children:a})]}),x&&h.jsx("p",{className:"text-sm text-destructive",children:x})]}),h.jsxs(Ya,{children:[r!=="name"&&h.jsx(ie,{variant:"outline",onClick:()=>s(r==="settings"?"folder":"name"),disabled:y,children:"Back"}),r==="name"&&h.jsx(ie,{onClick:v,children:"Next"}),r==="folder"&&h.jsx(ie,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r==="settings"&&h.jsx(ie,{onClick:()=>void C(),disabled:y,children:y?"Creating...":"Create Project"})]})]})})}function $R({open:e,onOpenChange:t,onOpened:n}){const[r,s]=p.useState(""),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=()=>{s(""),l(null),i(!1)},d=f=>{f||c(),t(f)},u=async f=>{s(f),i(!0),l(null);try{const y=await ax(f);n(y),d(!1)}catch(y){l(y instanceof Error?y.message:"Failed to open project"),i(!1)}};return h.jsx(hf,{open:e,onOpenChange:d,children:h.jsxs(Ga,{className:"sm:max-w-lg",children:[h.jsxs(Ka,{children:[h.jsx(Xa,{children:"Open Existing Project"}),h.jsxs(Qa,{children:["Select a folder that contains a ",h.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Project Folder"}),h.jsx(sw,{onSelect:f=>void u(f)})]}),a&&h.jsx("p",{className:"text-sm text-destructive",children:a}),r&&!a&&o&&h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),h.jsx(Ya,{children:h.jsx(ie,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"})})]})})}function UR(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const WR=e=>{switch(e){case"success":return KR;case"info":return XR;case"warning":return YR;case"error":return QR;default:return null}},HR=Array(12).fill(0),GR=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},HR.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),KR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),YR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),XR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),QR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),ZR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},R.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),R.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),qR=()=>{const[e,t]=R.useState(document.hidden);return R.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Tc=1;class JR{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,o=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Tc++,i=this.toasts.find(l=>l.id===o),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),i?this.toasts=this.toasts.map(l=>l.id===o?(this.publish({...l,...t,id:o,title:r}),{...l,...t,id:o,dismissible:a,title:r}):l):this.addToast({title:r,...s,dismissible:a,id:o}),o},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let o=r!==void 0,i;const a=s.then(async c=>{if(i=["resolve",c],R.isValidElement(c))o=!1,this.create({id:r,type:"default",message:c});else if(tM(c)&&!c.ok){o=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...w})}else if(c instanceof Error){o=!1;const u=typeof n.error=="function"?await n.error(c):n.error,f=typeof n.description=="function"?await n.description(c):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...w})}else if(n.success!==void 0){o=!1;const u=typeof n.success=="function"?await n.success(c):n.success,f=typeof n.description=="function"?await n.description(c):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:f,...w})}}).catch(async c=>{if(i=["reject",c],n.error!==void 0){o=!1;const d=typeof n.error=="function"?await n.error(c):n.error,u=typeof n.description=="function"?await n.description(c):n.description,y=typeof d=="object"&&!R.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:u,...y})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,d)=>a.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=(n==null?void 0:n.id)||Tc++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const et=new JR,eM=(e,t)=>{const n=(t==null?void 0:t.id)||Tc++;return et.addToast({title:e,...t,id:n}),n},tM=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",nM=eM,rM=()=>et.toasts,sM=()=>et.getActiveToasts(),Di=Object.assign(nM,{success:et.success,info:et.info,warning:et.warning,error:et.error,custom:et.custom,message:et.message,promise:et.promise,dismiss:et.dismiss,loading:et.loading},{getHistory:rM,getToasts:sM});UR("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function li(e){return e.label!==void 0}const oM=3,iM="24px",aM="16px",Cm=4e3,lM=356,uM=14,cM=45,dM=200;function Ft(...e){return e.filter(Boolean).join(" ")}function fM(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const hM=e=>{var t,n,r,s,o,i,a,l,c;const{invert:d,toast:u,unstyled:f,interacting:y,setHeights:w,visibleToasts:x,heights:S,index:m,toasts:g,expanded:v,removeToast:E,defaultRichColors:C,closeButton:T,style:k,cancelButtonStyle:b,actionButtonStyle:A,className:P="",descriptionClassName:D="",duration:L,position:Q,gap:le,expandByDefault:ge,classNames:z,icons:re,closeButtonAriaLabel:j="Close toast"}=e,[_,V]=R.useState(null),[$,se]=R.useState(null),[H,Z]=R.useState(!1),[K,pe]=R.useState(!1),[Je,J]=R.useState(!1),[Xt,cn]=R.useState(!1),[Qt,It]=R.useState(!1),[gs,Xn]=R.useState(0),[Za,Qn]=R.useState(0),dn=R.useRef(u.duration||L||Cm),Ao=R.useRef(null),kt=R.useRef(null),qa=m===0,Ja=m+1<=x,ze=u.type,N=u.dismissible!==!1,B=u.className||"",Y=u.descriptionClassName||"",ee=R.useMemo(()=>S.findIndex(U=>U.toastId===u.id)||0,[S,u.id]),ue=R.useMemo(()=>{var U;return(U=u.closeButton)!=null?U:T},[u.closeButton,T]),Pe=R.useMemo(()=>u.duration||L||Cm,[u.duration,L]),Ge=R.useRef(0),ye=R.useRef(0),Zn=R.useRef(0),fn=R.useRef(null),[uw,cw]=Q.split("-"),pf=R.useMemo(()=>S.reduce((U,Me,Be)=>Be>=ee?U:U+Me.height,0),[S,ee]),mf=qR(),dw=u.invert||d,el=ze==="loading";ye.current=R.useMemo(()=>ee*le+pf,[ee,pf]),R.useEffect(()=>{dn.current=Pe},[Pe]),R.useEffect(()=>{Z(!0)},[]),R.useEffect(()=>{const U=kt.current;if(U){const Me=U.getBoundingClientRect().height;return Qn(Me),w(Be=>[{toastId:u.id,height:Me,position:u.position},...Be]),()=>w(Be=>Be.filter(it=>it.toastId!==u.id))}},[w,u.id]),R.useLayoutEffect(()=>{if(!H)return;const U=kt.current,Me=U.style.height;U.style.height="auto";const Be=U.getBoundingClientRect().height;U.style.height=Me,Qn(Be),w(it=>it.find(Le=>Le.toastId===u.id)?it.map(Le=>Le.toastId===u.id?{...Le,height:Be}:Le):[{toastId:u.id,height:Be,position:u.position},...it])},[H,u.title,u.description,w,u.id,u.jsx,u.action,u.cancel]);const hn=R.useCallback(()=>{pe(!0),Xn(ye.current),w(U=>U.filter(Me=>Me.toastId!==u.id)),setTimeout(()=>{E(u)},dM)},[u,E,w,ye]);R.useEffect(()=>{if(u.promise&&ze==="loading"||u.duration===1/0||u.type==="loading")return;let U;return v||y||mf?(()=>{if(Zn.current<Ge.current){const it=new Date().getTime()-Ge.current;dn.current=dn.current-it}Zn.current=new Date().getTime()})():(()=>{dn.current!==1/0&&(Ge.current=new Date().getTime(),U=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),hn()},dn.current))})(),()=>clearTimeout(U)},[v,y,u,ze,mf,hn]),R.useEffect(()=>{u.delete&&(hn(),u.onDismiss==null||u.onDismiss.call(u,u))},[hn,u.delete]);function fw(){var U;if(re!=null&&re.loading){var Me;return R.createElement("div",{className:Ft(z==null?void 0:z.loader,u==null||(Me=u.classNames)==null?void 0:Me.loader,"sonner-loader"),"data-visible":ze==="loading"},re.loading)}return R.createElement(GR,{className:Ft(z==null?void 0:z.loader,u==null||(U=u.classNames)==null?void 0:U.loader),visible:ze==="loading"})}const hw=u.icon||(re==null?void 0:re[ze])||WR(ze);var gf,yf;return R.createElement("li",{tabIndex:0,ref:kt,className:Ft(P,B,z==null?void 0:z.toast,u==null||(t=u.classNames)==null?void 0:t.toast,z==null?void 0:z.default,z==null?void 0:z[ze],u==null||(n=u.classNames)==null?void 0:n[ze]),"data-sonner-toast":"","data-rich-colors":(gf=u.richColors)!=null?gf:C,"data-styled":!(u.jsx||u.unstyled||f),"data-mounted":H,"data-promise":!!u.promise,"data-swiped":Qt,"data-removed":K,"data-visible":Ja,"data-y-position":uw,"data-x-position":cw,"data-index":m,"data-front":qa,"data-swiping":Je,"data-dismissible":N,"data-type":ze,"data-invert":dw,"data-swipe-out":Xt,"data-swipe-direction":$,"data-expanded":!!(v||ge&&H),"data-testid":u.testId,style:{"--index":m,"--toasts-before":m,"--z-index":g.length-m,"--offset":`${K?gs:ye.current}px`,"--initial-height":ge?"auto":`${Za}px`,...k,...u.style},onDragEnd:()=>{J(!1),V(null),fn.current=null},onPointerDown:U=>{U.button!==2&&(el||!N||(Ao.current=new Date,Xn(ye.current),U.target.setPointerCapture(U.pointerId),U.target.tagName!=="BUTTON"&&(J(!0),fn.current={x:U.clientX,y:U.clientY})))},onPointerUp:()=>{var U,Me,Be;if(Xt||!N)return;fn.current=null;const it=Number(((U=kt.current)==null?void 0:U.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Do=Number(((Me=kt.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Be=Ao.current)==null?void 0:Be.getTime()),pt=_==="x"?it:Do,Lo=Math.abs(pt)/Le;if(Math.abs(pt)>=cM||Lo>.11){Xn(ye.current),u.onDismiss==null||u.onDismiss.call(u,u),se(_==="x"?it>0?"right":"left":Do>0?"down":"up"),hn(),cn(!0);return}else{var bt,Ct;(bt=kt.current)==null||bt.style.setProperty("--swipe-amount-x","0px"),(Ct=kt.current)==null||Ct.style.setProperty("--swipe-amount-y","0px")}It(!1),J(!1),V(null)},onPointerMove:U=>{var Me,Be,it;if(!fn.current||!N||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;const Le=U.clientY-fn.current.y,pt=U.clientX-fn.current.x;var Lo;const bt=(Lo=e.swipeDirections)!=null?Lo:fM(Q);!_&&(Math.abs(pt)>1||Math.abs(Le)>1)&&V(Math.abs(pt)>Math.abs(Le)?"x":"y");let Ct={x:0,y:0};const vf=qn=>1/(1.5+Math.abs(qn)/20);if(_==="y"){if(bt.includes("top")||bt.includes("bottom"))if(bt.includes("top")&&Le<0||bt.includes("bottom")&&Le>0)Ct.y=Le;else{const qn=Le*vf(Le);Ct.y=Math.abs(qn)<Math.abs(Le)?qn:Le}}else if(_==="x"&&(bt.includes("left")||bt.includes("right")))if(bt.includes("left")&&pt<0||bt.includes("right")&&pt>0)Ct.x=pt;else{const qn=pt*vf(pt);Ct.x=Math.abs(qn)<Math.abs(pt)?qn:pt}(Math.abs(Ct.x)>0||Math.abs(Ct.y)>0)&&It(!0),(Be=kt.current)==null||Be.style.setProperty("--swipe-amount-x",`${Ct.x}px`),(it=kt.current)==null||it.style.setProperty("--swipe-amount-y",`${Ct.y}px`)}},ue&&!u.jsx&&ze!=="loading"?R.createElement("button",{"aria-label":j,"data-disabled":el,"data-close-button":!0,onClick:el||!N?()=>{}:()=>{hn(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Ft(z==null?void 0:z.closeButton,u==null||(r=u.classNames)==null?void 0:r.closeButton)},(yf=re==null?void 0:re.close)!=null?yf:ZR):null,(ze||u.icon||u.promise)&&u.icon!==null&&((re==null?void 0:re[ze])!==null||u.icon)?R.createElement("div",{"data-icon":"",className:Ft(z==null?void 0:z.icon,u==null||(s=u.classNames)==null?void 0:s.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||fw():null,u.type!=="loading"?hw:null):null,R.createElement("div",{"data-content":"",className:Ft(z==null?void 0:z.content,u==null||(o=u.classNames)==null?void 0:o.content)},R.createElement("div",{"data-title":"",className:Ft(z==null?void 0:z.title,u==null||(i=u.classNames)==null?void 0:i.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?R.createElement("div",{"data-description":"",className:Ft(D,Y,z==null?void 0:z.description,u==null||(a=u.classNames)==null?void 0:a.description)},typeof u.description=="function"?u.description():u.description):null),R.isValidElement(u.cancel)?u.cancel:u.cancel&&li(u.cancel)?R.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||b,onClick:U=>{li(u.cancel)&&N&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,U),hn())},className:Ft(z==null?void 0:z.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,R.isValidElement(u.action)?u.action:u.action&&li(u.action)?R.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||A,onClick:U=>{li(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,U),!U.defaultPrevented&&hn())},className:Ft(z==null?void 0:z.actionButton,u==null||(c=u.classNames)==null?void 0:c.actionButton)},u.action.label):null)};function Tm(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function pM(e,t){const n={};return[e,t].forEach((r,s)=>{const o=s===1,i=o?"--mobile-offset":"--offset",a=o?aM:iM;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}const mM=R.forwardRef(function(t,n){const{id:r,invert:s,position:o="bottom-right",hotkey:i=["altKey","KeyT"],expand:a,closeButton:l,className:c,offset:d,mobileOffset:u,theme:f="light",richColors:y,duration:w,style:x,visibleToasts:S=oM,toastOptions:m,dir:g=Tm(),gap:v=uM,icons:E,containerAriaLabel:C="Notifications"}=t,[T,k]=R.useState([]),b=R.useMemo(()=>r?T.filter(H=>H.toasterId===r):T.filter(H=>!H.toasterId),[T,r]),A=R.useMemo(()=>Array.from(new Set([o].concat(b.filter(H=>H.position).map(H=>H.position)))),[b,o]),[P,D]=R.useState([]),[L,Q]=R.useState(!1),[le,ge]=R.useState(!1),[z,re]=R.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),j=R.useRef(null),_=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=R.useRef(null),$=R.useRef(!1),se=R.useCallback(H=>{k(Z=>{var K;return(K=Z.find(pe=>pe.id===H.id))!=null&&K.delete||et.dismiss(H.id),Z.filter(({id:pe})=>pe!==H.id)})},[]);return R.useEffect(()=>et.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{k(Z=>Z.map(K=>K.id===H.id?{...K,delete:!0}:K))});return}setTimeout(()=>{By.flushSync(()=>{k(Z=>{const K=Z.findIndex(pe=>pe.id===H.id);return K!==-1?[...Z.slice(0,K),{...Z[K],...H},...Z.slice(K+1)]:[H,...Z]})})})}),[T]),R.useEffect(()=>{if(f!=="system"){re(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?re("dark"):re("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:Z})=>{re(Z?"dark":"light")})}catch{H.addListener(({matches:K})=>{try{re(K?"dark":"light")}catch(pe){console.error(pe)}})}},[f]),R.useEffect(()=>{T.length<=1&&Q(!1)},[T]),R.useEffect(()=>{const H=Z=>{var K;if(i.every(J=>Z[J]||Z.code===J)){var Je;Q(!0),(Je=j.current)==null||Je.focus()}Z.code==="Escape"&&(document.activeElement===j.current||(K=j.current)!=null&&K.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[i]),R.useEffect(()=>{if(j.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,$.current=!1)}},[j.current]),R.createElement("section",{ref:n,"aria-label":`${C} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((H,Z)=>{var K;const[pe,Je]=H.split("-");return b.length?R.createElement("ol",{key:H,dir:g==="auto"?Tm():g,tabIndex:-1,ref:j,className:c,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":pe,"data-x-position":Je,style:{"--front-toast-height":`${((K=P[0])==null?void 0:K.height)||0}px`,"--width":`${lM}px`,"--gap":`${v}px`,...x,...pM(d,u)},onBlur:J=>{$.current&&!J.currentTarget.contains(J.relatedTarget)&&($.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||$.current||($.current=!0,V.current=J.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{le||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||ge(!0)},onPointerUp:()=>ge(!1)},b.filter(J=>!J.position&&Z===0||J.position===H).map((J,Xt)=>{var cn,Qt;return R.createElement(hM,{key:J.id,icons:E,index:Xt,toast:J,defaultRichColors:y,duration:(cn=m==null?void 0:m.duration)!=null?cn:w,className:m==null?void 0:m.className,descriptionClassName:m==null?void 0:m.descriptionClassName,invert:s,visibleToasts:S,closeButton:(Qt=m==null?void 0:m.closeButton)!=null?Qt:l,interacting:le,position:H,style:m==null?void 0:m.style,unstyled:m==null?void 0:m.unstyled,classNames:m==null?void 0:m.classNames,cancelButtonStyle:m==null?void 0:m.cancelButtonStyle,actionButtonStyle:m==null?void 0:m.actionButtonStyle,closeButtonAriaLabel:m==null?void 0:m.closeButtonAriaLabel,removeToast:se,toasts:b.filter(It=>It.position==J.position),heights:P.filter(It=>It.position==J.position),setHeights:D,expandByDefault:a,gap:v,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),ow=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,iw=5,aw=3e3;function BM(e,t){const n=p.useRef(null),r=p.useRef(0),s=p.useRef(!0),o=p.useRef(!1),i=p.useRef(t);i.current=t;const a=p.useRef(!1),l=p.useCallback(w=>{var x;((x=n.current)==null?void 0:x.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(w))},[]),c=p.useCallback((w,x)=>{var S;((S=n.current)==null?void 0:S.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:w,rows:x})),a.current=!1):a.current=!0},[]),d=p.useCallback(w=>{l({type:"terminal_input",data:w})},[l]),u=p.useCallback((w,x)=>{l({type:"terminal_resize",cols:w,rows:x})},[l]),f=p.useCallback(()=>{l({type:"chat_subscribe"})},[l]),y=p.useCallback(()=>{if(!s.current||o.current)return;const w=Mo();if(!w){window.location.href="/login";return}o.current=!0;const x=new WebSocket(`${ow}/ws/projects/${e}`);n.current=x,x.onopen=()=>{o.current=!1,r.current=0,x.send(JSON.stringify({type:"auth",token:w}))},x.onmessage=S=>{var g,v,E,C,T,k,b,A;let m;try{m=JSON.parse(S.data)}catch{return}switch(m.type){case"connected":a.current=!1,(v=(g=i.current).onConnected)==null||v.call(g);break;case"terminal_data":(C=(E=i.current).onTerminalData)==null||C.call(E,m.data);break;case"status":(k=(T=i.current).onStatus)==null||k.call(T,m.status);break;case"chat_message":{const P=m;(A=(b=i.current).onChatMessage)==null||A.call(b,P);break}case"error":console.error("[WS] Server error:",m.message);break}},x.onclose=()=>{o.current=!1,n.current=null,s.current&&r.current<iw&&(r.current++,setTimeout(y,aw))},x.onerror=S=>{o.current=!1,console.error("[WS] WebSocket error:",S)}},[e]);return p.useEffect(()=>(s.current=!0,y(),()=>{var w;s.current=!1,(w=n.current)==null||w.close(),n.current=null}),[y]),{subscribeTerminal:c,sendTerminalInput:d,sendTerminalResize:u,subscribeChatMessages:f}}function gM(e){const t=p.useRef(null),n=p.useRef(0),r=p.useRef(!0),s=p.useRef(!1),o=p.useRef(e);o.current=e;const i=p.useCallback(()=>{if(!r.current||s.current)return;const a=Mo();if(!a)return;s.current=!0;const l=new WebSocket(`${ow}/ws/dashboard`);t.current=l,l.onopen=()=>{s.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:a}))},l.onmessage=c=>{var d,u;try{const f=JSON.parse(c.data);f.type==="activity_update"?o.current.onActivityUpdate(f):f.type==="project_stopped"&&((u=(d=o.current).onProjectStopped)==null||u.call(d,f.projectId,f.projectName))}catch{}},l.onclose=()=>{s.current=!1,t.current=null,r.current&&n.current<iw&&(n.current++,setTimeout(i,aw))},l.onerror=c=>{s.current=!1,console.error("[DashboardWS] Error:",c)}},[]);p.useEffect(()=>(r.current=!0,i(),()=>{var a;r.current=!1,(a=t.current)==null||a.close(),t.current=null}),[i])}function yM(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h${r}m`:`${r}m`}const Pm=5*36e5;function vM(e){if(!e||e.utilization===void 0||e.utilization<=0||!e.resetAt)return null;const t=new Date(e.resetAt).getTime()-Date.now();if(t<=0)return null;const n=Pm-t;return n<=0?null:Math.round(e.utilization/(n/Pm))}function ui({label:e,bucket:t}){if(!t||t.utilization===void 0)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",s=yM(t.resetAt);return h.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",h.jsxs("span",{className:q("font-medium",r),children:[n,"%"]}),s&&h.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",s,")"]})]})}function xM({className:e}){const[t,n]=p.useState("loading"),[r,s]=p.useState(!1);p.useEffect(()=>{const f=async()=>{try{n(await mx())}catch{n(null)}};f();const y=setInterval(()=>void f(),5*60*1e3);return()=>clearInterval(y)},[]);const o=async()=>{s(!0);try{n(await gx())}catch{n(null)}finally{s(!1)}};if(t==="loading"||!t)return null;const i=!!t.fiveHour,a=!!t.sevenDay,l=!!t.sevenDaySonnet,c=!!t.sevenDayOpus,d=i||a||l||c,u=vM(t.fiveHour);return h.jsxs("div",{className:q("flex items-center gap-1.5 text-xs",e),children:[u!==null&&h.jsxs("span",{className:q("font-medium",u<=100?"text-green-400":"text-orange-400"),title:`5h 使用进度:按当前速率,窗口结束时预计使用 ${u}%`,children:[u,"%"]}),t.planName&&h.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),d&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"|"}),h.jsx(ui,{label:"5h",bucket:t.fiveHour}),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d",bucket:t.sevenDay})]}),l&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),h.jsx("button",{onClick:()=>void o(),className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:h.jsx($N,{className:q("h-3 w-3",r&&"animate-spin")})})]})}function wM(){const[e,t]=p.useState([]),[n,r]=p.useState(!1),[s,o]=p.useState(""),[i,a]=p.useState(""),[l,c]=p.useState(""),[d,u]=p.useState(null),[f,y]=p.useState(""),[w,x]=p.useState(""),[S,m]=p.useState(""),g=p.useRef(null),v=p.useRef(null);p.useEffect(()=>{dx().then(t).catch(()=>t([]))},[]),p.useEffect(()=>{n&&setTimeout(()=>{var k;return(k=g.current)==null?void 0:k.focus()},0)},[n]),p.useEffect(()=>{d&&setTimeout(()=>{var k;return(k=v.current)==null?void 0:k.focus()},0)},[d]);const E=async()=>{const k=i.trim();if(k)try{const b=await fx({label:s.trim()||k,command:k,...l?{parentId:l}:{}});t(A=>[...A,b]),o(""),a(""),c(""),r(!1)}catch(b){console.error("[GlobalShortcuts] Failed to add:",b)}},C=async k=>{try{await px(k),t(b=>b.filter(A=>A.id!==k)),d===k&&u(null)}catch(b){console.error("[GlobalShortcuts] Failed to delete:",b)}},T=async()=>{const k=w.trim();if(!(!k||!d))try{const b=await hx(d,{label:f.trim()||k,command:k,parentId:S||null});t(A=>A.map(P=>P.id===d?b:P)),u(null)}catch(b){console.error("[GlobalShortcuts] Failed to save:",b)}};return h.jsxs("section",{className:"mt-10",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(cm,{className:"h-4 w-4 text-muted-foreground"}),h.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷命令"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),h.jsxs("button",{onClick:()=>{r(k=>!k),u(null)},className:q("flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-md border transition-colors",n?"border-border text-foreground bg-muted":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:[h.jsx(ma,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&h.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-border bg-background space-y-3",children:[h.jsx("input",{ref:g,placeholder:"名称(可选)",value:s,onChange:k=>o(k.target.value),className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),h.jsx("textarea",{placeholder:"命令内容…",value:i,onChange:k=>a(k.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),E()),k.key==="Escape"&&(r(!1),o(""),a(""),c(""))}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kl,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:l,onChange:k=>c(k.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground outline-none focus:border-border transition-colors",children:[h.jsx("option",{value:"",children:"无继承"}),e.map(k=>h.jsx("option",{value:k.id,children:k.label},k.id))]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>{r(!1),o(""),a("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),h.jsx("button",{onClick:()=>void E(),disabled:!i.trim(),className:q("text-sm px-3 py-1 rounded transition-colors text-white",i.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),e.length===0&&!n?h.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-lg",children:[h.jsx(cm,{className:"h-6 w-6"}),h.jsx("p",{className:"text-sm",children:"还没有全局快捷命令"})]}):h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(k=>d===k.id?h.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[h.jsx("input",{ref:v,value:f,onChange:b=>y(b.target.value),placeholder:"名称(可选)",className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),h.jsx("textarea",{value:w,onChange:b=>x(b.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),T()),b.key==="Escape"&&u(null)}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kl,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:S,onChange:b=>m(b.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground outline-none focus:border-border transition-colors",children:[h.jsx("option",{value:"",children:"无继承"}),e.filter(b=>b.id!==k.id).map(b=>h.jsx("option",{value:b.id,children:b.label},b.id))]})]}),h.jsxs("div",{className:"flex gap-2 justify-end",children:[h.jsx("button",{onClick:()=>u(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),h.jsx("button",{onClick:()=>void T(),disabled:!w.trim(),className:q("text-xs px-2.5 py-1 rounded transition-colors text-white",w.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},k.id):h.jsxs("div",{className:"group relative rounded-lg border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[h.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:k.label}),k.parentId&&(()=>{const b=e.find(A=>A.id===k.parentId);return b?h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(Kl,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",b.label]})]}):null})(),!k.parentId&&k.label!==k.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:k.command}),h.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{onClick:()=>{u(k.id),y(k.label),x(k.command),m(k.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:h.jsx(Sx,{className:"h-3.5 w-3.5"})}),h.jsx("button",{onClick:()=>void C(k.id),className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:h.jsx(uf,{className:"h-3.5 w-3.5"})})]})]},k.id))})]})}const lw=p.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function SM(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function EM(){return p.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>SM())}function kM({children:e}){const[t,n]=p.useState(()=>RP(Zr.theme,"system")),r=EM(),s=t==="system"?r:t;p.useEffect(()=>{const i=document.documentElement;i.classList.remove("light","dark"),i.classList.add(s)},[s]);const o=i=>{n(i),tx(Zr.theme,i)};return h.jsx(lw.Provider,{value:{theme:t,resolved:s,setTheme:o},children:e})}function bM(){return p.useContext(lw)}function CM(){const{theme:e,setTheme:t}=bM(),n=[{value:"light",icon:GN,label:"浅色"},{value:"dark",icon:BN,label:"深色"},{value:"system",icon:zN,label:"系统"}];return h.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:r,icon:s,label:o})=>h.jsx("button",{onClick:()=>t(r),className:q("p-1 rounded-sm transition-colors",e===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:h.jsx(s,{className:"h-3.5 w-3.5"})},r))})}function TM(){const e=_a(),{projects:t,loading:n,error:r,fetchProjects:s,addProject:o,updateProject:i,removeProject:a}=am(),l=xr(N=>N.clearToken),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[y,w]=p.useState(new Set),x=p.useRef(new Map),[S,m]=p.useState(new Map),g=p.useRef(0),[v,E]=p.useState(!!document.fullscreenElement),[C,T]=p.useState(!1),[k,b]=p.useState(""),[A,P]=p.useState([]),[D,L]=p.useState(!1);p.useEffect(()=>{if(!k.trim()||k.trim().length<2){P([]);return}const N=setTimeout(()=>{L(!0),xx(k).then(B=>P(B)).catch(()=>P([])).finally(()=>L(!1))},400);return()=>clearTimeout(N)},[k]);const Q=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()};p.useEffect(()=>{const N=()=>E(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]),p.useEffect(()=>{s()},[s]),p.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]);const le=2e3,ge=3,z=8e3,re=p.useCallback(N=>{if(N.status){const ee=am.getState().projects.find(ue=>ue.id===N.projectId);ee&&ee.status!==N.status&&i({...ee,status:N.status})}const B=Date.now(),Y=x.current;if(B-N.lastActivityAt<le){w(ye=>ye.has(N.projectId)?ye:new Set(ye).add(N.projectId));const ee=Y.get(N.projectId)??[];let ue=!1;if(N.semantic){const ye=ee[ee.length-1],Zn=`${N.semantic.phase}:${N.semantic.detail??""}`,fn=ye?`${ye.phase}:${ye.detail??""}`:"";Zn!==fn?(ee.push({id:g.current++,phase:N.semantic.phase,detail:N.semantic.detail,ts:B}),ue=!0):ye&&(ye.ts=B)}const Pe=ee.filter(ye=>B-ye.ts<z),Ge=Pe.length>ge?Pe.slice(-ge):Pe;Ge.length!==ee.length&&(ue=!0),Y.set(N.projectId,Ge),ue&&m(new Map(Y))}else w(ee=>{if(!ee.has(N.projectId))return ee;const ue=new Set(ee);return ue.delete(N.projectId),ue}),Y.has(N.projectId)&&Y.get(N.projectId).length>0&&(Y.set(N.projectId,[]),m(new Map(Y)))},[]),j=p.useCallback((N,B)=>{"Notification"in window&&Notification.permission==="granted"&&new Notification("Claude 已完成",{body:`项目「${B}」的任务已完成`,icon:"/terminal.svg"})},[]);gM({onActivityUpdate:re,onProjectStopped:j}),p.useEffect(()=>{const N=setInterval(()=>{const B=Date.now(),Y=x.current;let ee=!1;for(const[ue,Pe]of Y){const Ge=Pe.filter(ye=>B-ye.ts<z);Ge.length!==Pe.length&&(Y.set(ue,Ge),ee=!0)}ee&&m(new Map(Y)),w(ue=>{let Pe=!1;const Ge=new Set(ue);for(const ye of ue){const Zn=Y.get(ye);(!Zn||Zn.length===0)&&(Ge.delete(ye),Pe=!0)}return Pe?Ge:ue})},3e3);return()=>clearInterval(N)},[]);const _=()=>{l(),e("/login")},V=N=>{o(N)},$=N=>{o(N)},se=async N=>{try{await lx(N),a(N)}catch(B){Di.error(B instanceof Error?B.message:"Failed to delete project")}},H=async N=>{try{const B=await ux(N);i(B)}catch(B){Di.error(B instanceof Error?B.message:"Failed to archive project")}},Z=async N=>{try{const B=await cx(N);i(B)}catch(B){Di.error(B instanceof Error?B.message:"Failed to restore project")}},K=p.useMemo(()=>t.filter(N=>!N.archived),[t]),pe=p.useMemo(()=>t.filter(N=>N.archived),[t]),Je=p.useMemo(()=>Array.from(new Set(t.flatMap(N=>N.tags??[]))),[t]),[J,Xt]=p.useState([]),cn=p.useMemo(()=>J.length===0?K:K.filter(N=>J.some(B=>{var Y;return(Y=N.tags)==null?void 0:Y.includes(B)})),[K,J]),[Qt,It]=AP(Zr.projectOrder,[],{parse:!0}),[gs,Xn]=p.useState(null),[Za,Qn]=p.useState(null);p.useEffect(()=>{if(K.length===0)return;const N=K.map(B=>B.id);It(B=>{const Y=B.filter(Pe=>N.includes(Pe)),ee=N.filter(Pe=>!B.includes(Pe)),ue=[...Y,...ee];return ue.join(",")===B.join(",")?B:ue})},[K]);const dn=p.useMemo(()=>Qt.length===0?cn:[...cn].sort((N,B)=>{const Y=Qt.indexOf(N.id),ee=Qt.indexOf(B.id);return Y===-1?1:ee===-1?-1:Y-ee}),[cn,Qt]),Ao=p.useCallback(N=>Xn(N),[]),kt=p.useCallback(()=>{Xn(null),Qn(null)},[]),qa=p.useCallback((N,B)=>{N.preventDefault(),Qn(B)},[]),Ja=p.useCallback((N,B,Y)=>{if(N.preventDefault(),!Y||Y===B){Qn(null);return}It(ee=>{const ue=[...ee],Pe=ue.indexOf(Y),Ge=ue.indexOf(B);return Pe===-1||Ge===-1?ee:(ue.splice(Pe,1),ue.splice(Ge,0,Y),ue)}),Xn(null),Qn(null)},[It]),ze={onDelete:N=>void se(N),onArchive:N=>void H(N),onUnarchive:N=>void Z(N),onUpdated:i};return h.jsxs("div",{className:"min-h-screen bg-background",children:[h.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:h.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(um,{className:"h-5 w-5"}),h.jsx("span",{className:"font-semibold text-lg",children:"CC Web"})]}),h.jsx(xM,{}),h.jsxs("div",{className:"relative",children:[h.jsx(UN,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),h.jsx(go,{placeholder:"搜索历史对话…",value:k,onChange:N=>b(N.target.value),className:"pl-8 h-8 text-xs w-48"}),k.trim().length>=2&&h.jsxs("div",{className:"absolute top-full mt-1 right-0 w-96 max-h-80 overflow-y-auto bg-popover border border-border rounded-lg shadow-xl z-50",children:[D&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"搜索中…"}),!D&&A.length===0&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"无结果"}),A.map((N,B)=>h.jsxs("button",{className:"w-full text-left px-4 py-2.5 hover:bg-muted transition-colors border-b border-border last:border-0",onClick:()=>{e(`/project/${N.projectId}`),b("")},children:[h.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[h.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:N.projectName}),h.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:new Date(N.startedAt).toLocaleDateString("zh-CN")})]}),h.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:N.snippet})]},B))]})]}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"SkillHub",children:h.jsx(HN,{className:"h-4 w-4"})}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:h.jsx(WN,{className:"h-4 w-4"})}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:Q,title:v?"Exit fullscreen":"Fullscreen",children:v?h.jsx(FN,{className:"h-4 w-4"}):h.jsx(VN,{className:"h-4 w-4"})}),h.jsx(CM,{}),h.jsxs(ie,{variant:"ghost",size:"sm",onClick:_,children:[h.jsx(IN,{className:"h-4 w-4 mr-2"}),"Logout"]})]})}),h.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[h.jsxs("div",{className:"flex items-center justify-between mb-6",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Projects"}),h.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(ie,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Ec,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(ie,{onClick:()=>d(!0),children:[h.jsx(ma,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),n&&h.jsx("div",{className:"text-center text-muted-foreground py-12",children:"Loading projects..."}),r&&h.jsx("div",{className:"text-center text-destructive py-12",children:r}),!n&&!r&&t.length===0&&h.jsxs("div",{className:"text-center py-20",children:[h.jsx(um,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),h.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),h.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),h.jsxs("div",{className:"flex gap-2 justify-center",children:[h.jsxs(ie,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Ec,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(ie,{onClick:()=>d(!0),children:[h.jsx(ma,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!n&&!r&&Je.length>0&&h.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[Je.map(N=>h.jsxs("button",{onClick:()=>Xt(B=>B.includes(N)?B.filter(Y=>Y!==N):[...B,N]),className:q("px-2 py-0.5 rounded-full text-xs border transition-colors",J.includes(N)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",N]},N)),J.length>0&&h.jsx("button",{onClick:()=>Xt([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&dn.length>0&&h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:dn.map((N,B)=>h.jsx(Vn.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:B*.05,ease:"easeOut"},draggable:!0,onDragStart:()=>Ao(N.id),onDragOver:Y=>qa(Y,N.id),onDrop:Y=>Ja(Y,N.id,gs),onDragEnd:kt,style:{opacity:gs===N.id?.4:1,cursor:"grab"},className:q(Za===N.id&&gs!==N.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:h.jsx(km,{project:N,active:y.has(N.id),statusStack:S.get(N.id)??[],...ze})},N.id))}),!n&&!r&&pe.length>0&&h.jsxs("div",{className:"mt-10",children:[h.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>T(N=>!N),children:[h.jsx(Vn.span,{animate:{rotate:C?90:0},transition:{duration:.2},children:h.jsx(wx,{className:"h-4 w-4"})}),h.jsx("span",{className:"font-medium",children:"Archived"}),h.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:pe.length})]}),h.jsx(qd,{children:C&&h.jsx(Vn.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden",children:h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:pe.map(N=>h.jsx(km,{project:N,active:!1,...ze},N.id))})})})]}),h.jsx(wM,{})]}),h.jsx(BR,{open:c,onOpenChange:d,onCreated:V}),h.jsx($R,{open:u,onOpenChange:f,onOpened:$})]})}class PM extends R.Component{constructor(){super(...arguments);tl(this,"state",{hasError:!1,error:null});tl(this,"handleReset",()=>{var n,r;this.setState({hasError:!1,error:null}),(r=(n=this.props).onReset)==null||r.call(n)})}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("[ErrorBoundary]",n,r.componentStack),Di.error(n.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[h.jsx("p",{children:"出错了"}),h.jsx("button",{onClick:this.handleReset,className:"px-3 py-1.5 text-xs rounded-md border border-border hover:bg-muted transition-colors",children:"重新加载"})]}):this.props.children}}const NM=R.lazy(()=>bo(()=>import("./ProjectPage-b-X_bbm4.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ProjectPage}))),jM=R.lazy(()=>bo(()=>import("./SettingsPage-D801GJ15.js"),__vite__mapDeps([7,3,1])).then(e=>({default:e.SettingsPage}))),RM=R.lazy(()=>bo(()=>import("./SkillHubPage-DkbnofIo.js"),__vite__mapDeps([8,5,2,3])).then(e=>({default:e.SkillHubPage}))),MM=R.lazy(()=>bo(()=>import("./ShareViewPage-JtExNvr9.js"),__vite__mapDeps([9,5,4])).then(e=>({default:e.ShareViewPage})));function AM(){return h.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function ci({children:e}){const[t,n]=p.useState(!1),r=xr(o=>o.token),s=xr(o=>o.setToken);return p.useEffect(()=>{if(r){n(!0);return}pa()?lf().then(o=>s(o)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),!t&&!r?null:r?h.jsx(h.Fragment,{children:e}):h.jsx(ev,{to:"/login",replace:!0})}function DM(){return h.jsxs(kM,{children:[h.jsx(mM,{richColors:!0,position:"bottom-right"}),h.jsx(PM,{children:h.jsx(IE,{children:h.jsx(p.Suspense,{fallback:h.jsx(AM,{}),children:h.jsxs(LE,{children:[h.jsx(yn,{path:"/login",element:h.jsx(TN,{})}),h.jsx(yn,{path:"/",element:h.jsx(ci,{children:h.jsx(TM,{})})}),h.jsx(yn,{path:"/projects/:id",element:h.jsx(ci,{children:h.jsx(NM,{})})}),h.jsx(yn,{path:"/settings",element:h.jsx(ci,{children:h.jsx(jM,{})})}),h.jsx(yn,{path:"/skillhub",element:h.jsx(ci,{children:h.jsx(RM,{})})}),h.jsx(yn,{path:"/share/:token",element:h.jsx(MM,{})}),h.jsx(yn,{path:"*",element:h.jsx(ev,{to:"/",replace:!0})})]})})})})]})}nu.createRoot(document.getElementById("root")).render(h.jsx(R.StrictMode,{children:h.jsx(DM,{})}));export{EN as $,qd as A,ie as B,wx as C,HP as D,DN as E,Ec as F,dx as G,Kl as H,go as I,YP as J,hf as K,Ga as L,FN as M,Ka as N,Xa as O,Sx as P,Qa as Q,R,Zr as S,jn as T,Ya as U,KP as V,GP as W,uf as X,QP as Y,cm as Z,bo as _,OM as a,$P as a0,kN as a1,UP as a2,_a as a3,MN as a4,rr as a5,CM as a6,uN as a7,zP as a8,BP as a9,iN as aA,lN as aB,nf as aC,rf as aD,sf as aE,of as aF,Ex as aG,mN as aH,oN as aI,cN as aJ,fN as aK,pN as aL,aN as aM,hN as aN,dN as aO,gN as aP,XP as aQ,ZP as aR,bN as aS,IM as aT,UN as aa,MP as ab,BM as ac,xM as ad,VM as ae,AP as af,am as ag,um as ah,yo as ai,kr as aj,ej as ak,un as al,Fn as am,XN as an,Ba as ao,Yl as ap,vo as aq,Ua as ar,Sd as as,Nx as at,gR as au,Rj as av,Ox as aw,Tx as ax,bx as ay,sN as az,Mo as b,ne as c,eN as d,q as e,VN as f,Nm as g,qP as h,RP as i,h as j,yx as k,$N as l,JP as m,lm as n,Vn as o,yN as p,AN as q,p as r,tx as s,Di as t,bM as u,ma as v,tN as w,vN as x,xN as y,wN as z};
275
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},MR="DialogDescriptionWarning",AR=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${qx(MR).contentName}}.`;return p.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},DR=Fx,LR=$x,Jx=Ux,ew=Wx,tw=Gx,nw=Yx,_R=Qx;const hf=DR,OR=LR,rw=p.forwardRef(({className:e,...t},n)=>h.jsx(Jx,{ref:n,className:q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));rw.displayName=Jx.displayName;const Ga=p.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(OR,{children:[h.jsx(rw,{}),h.jsxs(ew,{ref:r,className:q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,h.jsxs(_R,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(uf,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ga.displayName=ew.displayName;const Ka=({className:e,...t})=>h.jsx("div",{className:q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ka.displayName="DialogHeader";const Ya=({className:e,...t})=>h.jsx("div",{className:q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ya.displayName="DialogFooter";const Xa=p.forwardRef(({className:e,...t},n)=>h.jsx(tw,{ref:n,className:q("text-lg font-semibold leading-none tracking-tight",e),...t}));Xa.displayName=tw.displayName;const Qa=p.forwardRef(({className:e,...t},n)=>h.jsx(nw,{ref:n,className:q("text-sm text-muted-foreground",e),...t}));Qa.displayName=nw.displayName;function IR({project:e,open:t,onOpenChange:n,onUpdated:r}){const[s,o]=p.useState([]),[i,a]=p.useState([]),[l,c]=p.useState(!1),[d,u]=p.useState(null);p.useEffect(()=>{if(!t)return;o(e.shares?[...e.shares]:[]),u(null);let g=!1;return sx().then(v=>{g||a(v)}).catch(()=>{}),()=>{g=!0}},[t,e.id]);const f=new Set(s.map(g=>g.username)),y=i.filter(g=>g!==e.owner&&!f.has(g)),w=g=>{o(v=>[...v,{username:g,permission:"view"}])},x=g=>{o(v=>v.filter(E=>E.username!==g))},S=g=>{o(v=>v.map(E=>E.username===g?{...E,permission:E.permission==="view"?"edit":"view"}:E))},m=async()=>{c(!0),u(null);try{const g=await ox(e.id,s);r(g),n(!1)}catch(g){u(g instanceof Error?g.message:"Failed to update shares")}finally{c(!1)}};return h.jsx(hf,{open:t,onOpenChange:n,children:h.jsxs(Ga,{className:"sm:max-w-md",children:[h.jsxs(Ka,{children:[h.jsxs(Xa,{className:"flex items-center gap-2",children:[h.jsx(kc,{className:"h-4 w-4"}),"共享设置"]}),h.jsx(Qa,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),h.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[s.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),s.map(g=>h.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[h.jsx("span",{className:"text-sm font-medium",children:g.username}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{onClick:()=>S(g.username),className:"focus:outline-none",children:h.jsx(rr,{variant:g.permission==="edit"?"default":"secondary",className:"cursor-pointer text-xs",children:g.permission==="edit"?"可编辑":"可见"})}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>x(g.username),children:h.jsx(Ex,{className:"h-3.5 w-3.5"})})]})]},g.username))]}),y.length>0&&h.jsxs("div",{className:"border-t pt-3",children:[h.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.map(g=>h.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>w(g),children:[h.jsx(ma,{className:"h-3 w-3"}),g]},g))})]}),d&&h.jsx("p",{className:"text-sm text-destructive",children:d}),h.jsxs(Ya,{children:[h.jsx(ie,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),h.jsx(ie,{onClick:()=>void m(),disabled:l,children:l?"保存中...":"保存"})]})]})})}function VR(e,t){switch(e){case"thinking":return"Thinking…";case"tool_use":return t?`${t}`:"Tool…";case"tool_result":return"Reading…";case"text":return"Writing…"}}function FR({status:e}){return h.jsx("span",{className:q("inline-block w-2 h-2 rounded-full",{"bg-green-500":e==="running","bg-zinc-400":e==="stopped","bg-yellow-400 animate-pulse":e==="restarting"})})}const km=R.memo(function({project:t,active:n=!1,statusStack:r=[],onDelete:s,onArchive:o,onUnarchive:i,onUpdated:a}){var g,v;const l=_a(),[c,d]=p.useState(!1),u=!!t._sharedPermission,f=t._sharedPermission==="view",y=E=>{E.stopPropagation(),confirm(`Delete project "${t.name}"? This cannot be undone.`)&&s(t.id)},w=E=>{E.stopPropagation(),o(t.id)},x=E=>{E.stopPropagation(),i(t.id)},S=h.jsx(Vn.div,{whileHover:!t.archived&&!n?{y:-2}:{},transition:{duration:.2},children:h.jsxs(nf,{className:q("group cursor-pointer transition-colors relative",t.archived?"opacity-60 hover:opacity-80 hover:border-zinc-400":n?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-zinc-400 hover:shadow-md"),onClick:()=>!t.archived&&l(`/projects/${t.id}`),children:[h.jsxs(rf,{className:"pb-2",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx(sf,{className:q("text-base leading-tight",t.archived&&"text-muted-foreground"),children:t.name}),h.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!u&&h.jsxs(h.Fragment,{children:[t.archived?h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:x,title:"Restore project",children:h.jsx(jN,{className:"h-3.5 w-3.5"})}):h.jsxs(h.Fragment,{children:[h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:E=>{E.stopPropagation(),d(!0)},title:"共享设置",children:h.jsx(kc,{className:"h-3.5 w-3.5"})}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:w,title:"Archive project",children:h.jsx(RN,{className:"h-3.5 w-3.5"})})]}),h.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:y,title:"Delete project",children:h.jsx(Ex,{className:"h-3.5 w-3.5"})})]})})]}),h.jsx("div",{className:"flex items-center gap-1.5",children:t.archived?h.jsx(rr,{variant:"secondary",className:"text-xs",children:"Archived"}):h.jsxs(h.Fragment,{children:[h.jsx(FR,{status:t.status}),h.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:t.status}),n&&r.length>0&&h.jsx("div",{className:"ml-auto",children:h.jsx(qd,{mode:"wait",children:r.slice(-1).map(E=>h.jsx(Vn.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.25,ease:"easeOut"},children:h.jsx(rr,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:VR(E.phase,E.detail)})},E.id))})})]})})]}),h.jsxs(of,{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[h.jsx(Ec,{className:"h-3.5 w-3.5 flex-shrink-0"}),h.jsx("span",{className:"truncate font-mono",children:t.folderPath})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(rr,{variant:"outline",className:"text-xs font-mono",children:t.cliTool??"claude"}),h.jsx(rr,{variant:t.permissionMode==="unlimited"?"destructive":"secondary",className:"text-xs",children:t.permissionMode==="unlimited"?"Unlimited":"Limited"}),u&&h.jsxs(rr,{variant:"outline",className:"text-xs gap-0.5",children:[f?h.jsx(DN,{className:"h-3 w-3"}):h.jsx(Sx,{className:"h-3 w-3"}),f?"可见":"可编辑"]}),!u&&t.shares&&t.shares.length>0&&h.jsxs(rr,{variant:"outline",className:"text-xs gap-0.5",children:[h.jsx(kc,{className:"h-3 w-3"}),t.shares.length]}),h.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t.createdAt).toLocaleDateString()})]}),(t.tags??[]).length>0&&h.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(t.tags??[]).slice(0,3).map(E=>h.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",E]},E)),(((g=t.tags)==null?void 0:g.length)??0)>3&&h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",(((v=t.tags)==null?void 0:v.length)??0)-3]})]})]})]})}),m=n&&!t.archived?h.jsx("div",{className:"card-active-glow rounded-lg",children:S}):S;return h.jsxs(h.Fragment,{children:[m,!u&&a&&h.jsx(IR,{project:t,open:c,onOpenChange:d,onUpdated:a})]})});function sw({onSelect:e}){const[t,n]=p.useState(""),[r,s]=p.useState(null),[o,i]=p.useState([]),[a,l]=p.useState(!0),[c,d]=p.useState(null),[u,f]=p.useState(!1),[y,w]=p.useState(""),[x,S]=p.useState(null),[m,g]=p.useState(!1),v=p.useRef(null),E=async D=>{l(!0),d(null);try{const L=await yx(D);n(L.path),s(L.parent),i(L.entries)}catch(L){d(L instanceof Error?L.message:"Failed to load directory")}finally{l(!1)}};p.useEffect(()=>{E()},[]),p.useEffect(()=>{u&&setTimeout(()=>{var D;return(D=v.current)==null?void 0:D.focus()},0)},[u]);const C=()=>{w(""),S(null),f(!0)},T=()=>{f(!1),w(""),S(null)},k=async()=>{const D=y.trim();if(D){g(!0),S(null);try{const{path:L}=await vx(t,D);f(!1),w(""),await E(t),E(L)}catch(L){S(L instanceof Error?L.message:"Failed to create folder")}finally{g(!1)}}},b=D=>{D.key==="Enter"?(D.preventDefault(),k()):D.key==="Escape"&&T()},A=t.split("/").filter(Boolean),P=D=>{const L="/"+A.slice(0,D+1).join("/");E(L)};return h.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[h.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[h.jsx(ie,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>void E(),title:"Home",children:h.jsx(ON,{className:"h-3 w-3"})}),h.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:A.map((D,L)=>h.jsxs(R.Fragment,{children:[h.jsx(wx,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),h.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>P(L),children:D})]},L))}),h.jsxs(ie,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:C,disabled:u||a||!!c,title:"New folder",children:[h.jsx(_N,{className:"h-3.5 w-3.5"}),h.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a&&h.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),c&&h.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:c}),!a&&!c&&h.jsxs("div",{className:"p-1",children:[r&&h.jsxs("button",{className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground",onClick:()=>void E(r),children:[h.jsx(MN,{className:"h-4 w-4 text-muted-foreground"}),h.jsx("span",{children:".."})]}),u&&h.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[h.jsx(lm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),h.jsx("input",{ref:v,className:q("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",x&&"border-destructive"),placeholder:"Folder name",value:y,onChange:D=>{w(D.target.value),S(null)},onKeyDown:b,disabled:m}),h.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>void k(),disabled:!y.trim()||m,title:"Create",children:h.jsx(AN,{className:"h-3.5 w-3.5 text-green-600"})}),h.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:T,disabled:m,title:"Cancel",children:h.jsx(uf,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),x&&h.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:x}),o.length===0&&!u&&h.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),o.map(D=>h.jsxs("button",{className:q("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left",D.type==="dir"?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{D.type==="dir"&&E(D.path)},disabled:D.type==="file",children:[D.type==="dir"?h.jsx(lm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):h.jsx(LN,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:"truncate",children:D.name})]},D.path))]})]}),h.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[h.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),h.jsx(ie,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const zR=[{value:"claude",label:"Claude",desc:"Anthropic Claude Code CLI"},{value:"opencode",label:"OpenCode",desc:"OpenCode CLI (sst/opencode)"},{value:"codex",label:"Codex",desc:"OpenAI Codex CLI"},{value:"qwen",label:"Qwen",desc:"Qwen Code CLI (QwenLM)"}],bm={claude:{limited:"claude",unlimited:"claude --dangerously-skip-permissions"},opencode:{limited:"opencode",unlimited:"opencode --dangerously-skip-permissions"},codex:{limited:"codex",unlimited:"codex --ask-for-approval never --sandbox danger-full-access"},qwen:{limited:"qwen-code",unlimited:"qwen-code --yolo"}};function BR({open:e,onOpenChange:t,onCreated:n}){const[r,s]=p.useState("name"),[o,i]=p.useState(""),[a,l]=p.useState(""),[c,d]=p.useState("claude"),[u,f]=p.useState("limited"),[y,w]=p.useState(!1),[x,S]=p.useState(null),m=()=>{s("name"),i(""),l(""),d("claude"),f("limited"),S(null),w(!1)},g=b=>{b||m(),t(b)},v=()=>{if(!o.trim()){S("Please enter a project name");return}S(null),s("folder")},E=b=>{l(b),s("settings")},C=async()=>{w(!0),S(null);try{const b=await ix({name:o.trim(),folderPath:a,permissionMode:u,cliTool:c});n(b),g(!1)}catch(b){S(b instanceof Error?b.message:"Failed to create project")}finally{w(!1)}},T={name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"},k=["name","folder","settings"];return h.jsx(hf,{open:e,onOpenChange:g,children:h.jsxs(Ga,{className:"sm:max-w-lg",children:[h.jsxs(Ka,{children:[h.jsx(Xa,{children:T[r]}),h.jsxs(Qa,{children:[r==="name"&&"Give your project a name.",r==="folder"&&"Choose the working directory for this project.",r==="settings"&&"Choose the AI coding tool and run mode."]})]}),h.jsx("div",{className:"flex gap-2 mb-2",children:k.map((b,A)=>h.jsx("div",{className:`h-1.5 flex-1 rounded-full ${r===b?"bg-primary":k.indexOf(r)>A?"bg-primary/40":"bg-muted"}`},b))}),r==="name"&&h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{htmlFor:"project-name",children:"Project Name"}),h.jsx(go,{id:"project-name",placeholder:"My Project",value:o,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&v()},autoFocus:!0})]}),x&&h.jsx("p",{className:"text-sm text-destructive",children:x})]}),r==="folder"&&h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Working Directory"}),h.jsx(sw,{onSelect:E})]}),r==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"AI Coding Tool"}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:zR.map(b=>h.jsxs("label",{className:`flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors ${c===b.value?"border-primary bg-primary/5":"hover:bg-accent"}`,children:[h.jsx("input",{type:"radio",name:"cliTool",value:b.value,checked:c===b.value,onChange:()=>d(b.value),className:"accent-primary"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:b.label}),h.jsx("div",{className:"text-xs text-muted-foreground",children:b.desc})]})]},b.value))})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Permission Mode"}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[h.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:u==="limited",onChange:()=>f("limited"),className:"mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:"Limited"}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",h.jsx("code",{className:"bg-muted px-1 rounded",children:bm[c].limited})," — asks for permission before file changes."]})]})]}),h.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[h.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:u==="unlimited",onChange:()=>f("unlimited"),className:"mt-0.5"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",h.jsx("code",{className:"bg-muted px-1 rounded",children:bm[c].unlimited})," — acts autonomously."]})]})]})]})]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:[h.jsx("span",{className:"font-medium",children:"Folder:"})," ",h.jsx("span",{className:"font-mono",children:a})]}),x&&h.jsx("p",{className:"text-sm text-destructive",children:x})]}),h.jsxs(Ya,{children:[r!=="name"&&h.jsx(ie,{variant:"outline",onClick:()=>s(r==="settings"?"folder":"name"),disabled:y,children:"Back"}),r==="name"&&h.jsx(ie,{onClick:v,children:"Next"}),r==="folder"&&h.jsx(ie,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r==="settings"&&h.jsx(ie,{onClick:()=>void C(),disabled:y,children:y?"Creating...":"Create Project"})]})]})})}function $R({open:e,onOpenChange:t,onOpened:n}){const[r,s]=p.useState(""),[o,i]=p.useState(!1),[a,l]=p.useState(null),c=()=>{s(""),l(null),i(!1)},d=f=>{f||c(),t(f)},u=async f=>{s(f),i(!0),l(null);try{const y=await ax(f);n(y),d(!1)}catch(y){l(y instanceof Error?y.message:"Failed to open project"),i(!1)}};return h.jsx(hf,{open:e,onOpenChange:d,children:h.jsxs(Ga,{className:"sm:max-w-lg",children:[h.jsxs(Ka,{children:[h.jsx(Xa,{children:"Open Existing Project"}),h.jsxs(Qa,{children:["Select a folder that contains a ",h.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(jn,{children:"Project Folder"}),h.jsx(sw,{onSelect:f=>void u(f)})]}),a&&h.jsx("p",{className:"text-sm text-destructive",children:a}),r&&!a&&o&&h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),h.jsx(Ya,{children:h.jsx(ie,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"})})]})})}function UR(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const WR=e=>{switch(e){case"success":return KR;case"info":return XR;case"warning":return YR;case"error":return QR;default:return null}},HR=Array(12).fill(0),GR=({visible:e,className:t})=>R.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},R.createElement("div",{className:"sonner-spinner"},HR.map((n,r)=>R.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),KR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),YR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),XR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),QR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},R.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),ZR=R.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},R.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),R.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),qR=()=>{const[e,t]=R.useState(document.hidden);return R.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Tc=1;class JR{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,o=typeof(t==null?void 0:t.id)=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Tc++,i=this.toasts.find(l=>l.id===o),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),i?this.toasts=this.toasts.map(l=>l.id===o?(this.publish({...l,...t,id:o,title:r}),{...l,...t,id:o,dismissible:a,title:r}):l):this.addToast({title:r,...s,dismissible:a,id:o}),o},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let o=r!==void 0,i;const a=s.then(async c=>{if(i=["resolve",c],R.isValidElement(c))o=!1,this.create({id:r,type:"default",message:c});else if(tM(c)&&!c.ok){o=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...w})}else if(c instanceof Error){o=!1;const u=typeof n.error=="function"?await n.error(c):n.error,f=typeof n.description=="function"?await n.description(c):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...w})}else if(n.success!==void 0){o=!1;const u=typeof n.success=="function"?await n.success(c):n.success,f=typeof n.description=="function"?await n.description(c):n.description,w=typeof u=="object"&&!R.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:f,...w})}}).catch(async c=>{if(i=["reject",c],n.error!==void 0){o=!1;const d=typeof n.error=="function"?await n.error(c):n.error,u=typeof n.description=="function"?await n.description(c):n.description,y=typeof d=="object"&&!R.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:u,...y})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,d)=>a.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=(n==null?void 0:n.id)||Tc++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const et=new JR,eM=(e,t)=>{const n=(t==null?void 0:t.id)||Tc++;return et.addToast({title:e,...t,id:n}),n},tM=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",nM=eM,rM=()=>et.toasts,sM=()=>et.getActiveToasts(),Di=Object.assign(nM,{success:et.success,info:et.info,warning:et.warning,error:et.error,custom:et.custom,message:et.message,promise:et.promise,dismiss:et.dismiss,loading:et.loading},{getHistory:rM,getToasts:sM});UR("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function li(e){return e.label!==void 0}const oM=3,iM="24px",aM="16px",Cm=4e3,lM=356,uM=14,cM=45,dM=200;function Ft(...e){return e.filter(Boolean).join(" ")}function fM(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const hM=e=>{var t,n,r,s,o,i,a,l,c;const{invert:d,toast:u,unstyled:f,interacting:y,setHeights:w,visibleToasts:x,heights:S,index:m,toasts:g,expanded:v,removeToast:E,defaultRichColors:C,closeButton:T,style:k,cancelButtonStyle:b,actionButtonStyle:A,className:P="",descriptionClassName:D="",duration:L,position:Q,gap:le,expandByDefault:ge,classNames:z,icons:re,closeButtonAriaLabel:j="Close toast"}=e,[_,V]=R.useState(null),[$,se]=R.useState(null),[H,Z]=R.useState(!1),[K,pe]=R.useState(!1),[Je,J]=R.useState(!1),[Xt,cn]=R.useState(!1),[Qt,It]=R.useState(!1),[gs,Xn]=R.useState(0),[Za,Qn]=R.useState(0),dn=R.useRef(u.duration||L||Cm),Ao=R.useRef(null),kt=R.useRef(null),qa=m===0,Ja=m+1<=x,ze=u.type,N=u.dismissible!==!1,B=u.className||"",Y=u.descriptionClassName||"",ee=R.useMemo(()=>S.findIndex(U=>U.toastId===u.id)||0,[S,u.id]),ue=R.useMemo(()=>{var U;return(U=u.closeButton)!=null?U:T},[u.closeButton,T]),Pe=R.useMemo(()=>u.duration||L||Cm,[u.duration,L]),Ge=R.useRef(0),ye=R.useRef(0),Zn=R.useRef(0),fn=R.useRef(null),[uw,cw]=Q.split("-"),pf=R.useMemo(()=>S.reduce((U,Me,Be)=>Be>=ee?U:U+Me.height,0),[S,ee]),mf=qR(),dw=u.invert||d,el=ze==="loading";ye.current=R.useMemo(()=>ee*le+pf,[ee,pf]),R.useEffect(()=>{dn.current=Pe},[Pe]),R.useEffect(()=>{Z(!0)},[]),R.useEffect(()=>{const U=kt.current;if(U){const Me=U.getBoundingClientRect().height;return Qn(Me),w(Be=>[{toastId:u.id,height:Me,position:u.position},...Be]),()=>w(Be=>Be.filter(it=>it.toastId!==u.id))}},[w,u.id]),R.useLayoutEffect(()=>{if(!H)return;const U=kt.current,Me=U.style.height;U.style.height="auto";const Be=U.getBoundingClientRect().height;U.style.height=Me,Qn(Be),w(it=>it.find(Le=>Le.toastId===u.id)?it.map(Le=>Le.toastId===u.id?{...Le,height:Be}:Le):[{toastId:u.id,height:Be,position:u.position},...it])},[H,u.title,u.description,w,u.id,u.jsx,u.action,u.cancel]);const hn=R.useCallback(()=>{pe(!0),Xn(ye.current),w(U=>U.filter(Me=>Me.toastId!==u.id)),setTimeout(()=>{E(u)},dM)},[u,E,w,ye]);R.useEffect(()=>{if(u.promise&&ze==="loading"||u.duration===1/0||u.type==="loading")return;let U;return v||y||mf?(()=>{if(Zn.current<Ge.current){const it=new Date().getTime()-Ge.current;dn.current=dn.current-it}Zn.current=new Date().getTime()})():(()=>{dn.current!==1/0&&(Ge.current=new Date().getTime(),U=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),hn()},dn.current))})(),()=>clearTimeout(U)},[v,y,u,ze,mf,hn]),R.useEffect(()=>{u.delete&&(hn(),u.onDismiss==null||u.onDismiss.call(u,u))},[hn,u.delete]);function fw(){var U;if(re!=null&&re.loading){var Me;return R.createElement("div",{className:Ft(z==null?void 0:z.loader,u==null||(Me=u.classNames)==null?void 0:Me.loader,"sonner-loader"),"data-visible":ze==="loading"},re.loading)}return R.createElement(GR,{className:Ft(z==null?void 0:z.loader,u==null||(U=u.classNames)==null?void 0:U.loader),visible:ze==="loading"})}const hw=u.icon||(re==null?void 0:re[ze])||WR(ze);var gf,yf;return R.createElement("li",{tabIndex:0,ref:kt,className:Ft(P,B,z==null?void 0:z.toast,u==null||(t=u.classNames)==null?void 0:t.toast,z==null?void 0:z.default,z==null?void 0:z[ze],u==null||(n=u.classNames)==null?void 0:n[ze]),"data-sonner-toast":"","data-rich-colors":(gf=u.richColors)!=null?gf:C,"data-styled":!(u.jsx||u.unstyled||f),"data-mounted":H,"data-promise":!!u.promise,"data-swiped":Qt,"data-removed":K,"data-visible":Ja,"data-y-position":uw,"data-x-position":cw,"data-index":m,"data-front":qa,"data-swiping":Je,"data-dismissible":N,"data-type":ze,"data-invert":dw,"data-swipe-out":Xt,"data-swipe-direction":$,"data-expanded":!!(v||ge&&H),"data-testid":u.testId,style:{"--index":m,"--toasts-before":m,"--z-index":g.length-m,"--offset":`${K?gs:ye.current}px`,"--initial-height":ge?"auto":`${Za}px`,...k,...u.style},onDragEnd:()=>{J(!1),V(null),fn.current=null},onPointerDown:U=>{U.button!==2&&(el||!N||(Ao.current=new Date,Xn(ye.current),U.target.setPointerCapture(U.pointerId),U.target.tagName!=="BUTTON"&&(J(!0),fn.current={x:U.clientX,y:U.clientY})))},onPointerUp:()=>{var U,Me,Be;if(Xt||!N)return;fn.current=null;const it=Number(((U=kt.current)==null?void 0:U.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Do=Number(((Me=kt.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Be=Ao.current)==null?void 0:Be.getTime()),pt=_==="x"?it:Do,Lo=Math.abs(pt)/Le;if(Math.abs(pt)>=cM||Lo>.11){Xn(ye.current),u.onDismiss==null||u.onDismiss.call(u,u),se(_==="x"?it>0?"right":"left":Do>0?"down":"up"),hn(),cn(!0);return}else{var bt,Ct;(bt=kt.current)==null||bt.style.setProperty("--swipe-amount-x","0px"),(Ct=kt.current)==null||Ct.style.setProperty("--swipe-amount-y","0px")}It(!1),J(!1),V(null)},onPointerMove:U=>{var Me,Be,it;if(!fn.current||!N||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;const Le=U.clientY-fn.current.y,pt=U.clientX-fn.current.x;var Lo;const bt=(Lo=e.swipeDirections)!=null?Lo:fM(Q);!_&&(Math.abs(pt)>1||Math.abs(Le)>1)&&V(Math.abs(pt)>Math.abs(Le)?"x":"y");let Ct={x:0,y:0};const vf=qn=>1/(1.5+Math.abs(qn)/20);if(_==="y"){if(bt.includes("top")||bt.includes("bottom"))if(bt.includes("top")&&Le<0||bt.includes("bottom")&&Le>0)Ct.y=Le;else{const qn=Le*vf(Le);Ct.y=Math.abs(qn)<Math.abs(Le)?qn:Le}}else if(_==="x"&&(bt.includes("left")||bt.includes("right")))if(bt.includes("left")&&pt<0||bt.includes("right")&&pt>0)Ct.x=pt;else{const qn=pt*vf(pt);Ct.x=Math.abs(qn)<Math.abs(pt)?qn:pt}(Math.abs(Ct.x)>0||Math.abs(Ct.y)>0)&&It(!0),(Be=kt.current)==null||Be.style.setProperty("--swipe-amount-x",`${Ct.x}px`),(it=kt.current)==null||it.style.setProperty("--swipe-amount-y",`${Ct.y}px`)}},ue&&!u.jsx&&ze!=="loading"?R.createElement("button",{"aria-label":j,"data-disabled":el,"data-close-button":!0,onClick:el||!N?()=>{}:()=>{hn(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Ft(z==null?void 0:z.closeButton,u==null||(r=u.classNames)==null?void 0:r.closeButton)},(yf=re==null?void 0:re.close)!=null?yf:ZR):null,(ze||u.icon||u.promise)&&u.icon!==null&&((re==null?void 0:re[ze])!==null||u.icon)?R.createElement("div",{"data-icon":"",className:Ft(z==null?void 0:z.icon,u==null||(s=u.classNames)==null?void 0:s.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||fw():null,u.type!=="loading"?hw:null):null,R.createElement("div",{"data-content":"",className:Ft(z==null?void 0:z.content,u==null||(o=u.classNames)==null?void 0:o.content)},R.createElement("div",{"data-title":"",className:Ft(z==null?void 0:z.title,u==null||(i=u.classNames)==null?void 0:i.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?R.createElement("div",{"data-description":"",className:Ft(D,Y,z==null?void 0:z.description,u==null||(a=u.classNames)==null?void 0:a.description)},typeof u.description=="function"?u.description():u.description):null),R.isValidElement(u.cancel)?u.cancel:u.cancel&&li(u.cancel)?R.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||b,onClick:U=>{li(u.cancel)&&N&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,U),hn())},className:Ft(z==null?void 0:z.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,R.isValidElement(u.action)?u.action:u.action&&li(u.action)?R.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||A,onClick:U=>{li(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,U),!U.defaultPrevented&&hn())},className:Ft(z==null?void 0:z.actionButton,u==null||(c=u.classNames)==null?void 0:c.actionButton)},u.action.label):null)};function Tm(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function pM(e,t){const n={};return[e,t].forEach((r,s)=>{const o=s===1,i=o?"--mobile-offset":"--offset",a=o?aM:iM;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}const mM=R.forwardRef(function(t,n){const{id:r,invert:s,position:o="bottom-right",hotkey:i=["altKey","KeyT"],expand:a,closeButton:l,className:c,offset:d,mobileOffset:u,theme:f="light",richColors:y,duration:w,style:x,visibleToasts:S=oM,toastOptions:m,dir:g=Tm(),gap:v=uM,icons:E,containerAriaLabel:C="Notifications"}=t,[T,k]=R.useState([]),b=R.useMemo(()=>r?T.filter(H=>H.toasterId===r):T.filter(H=>!H.toasterId),[T,r]),A=R.useMemo(()=>Array.from(new Set([o].concat(b.filter(H=>H.position).map(H=>H.position)))),[b,o]),[P,D]=R.useState([]),[L,Q]=R.useState(!1),[le,ge]=R.useState(!1),[z,re]=R.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),j=R.useRef(null),_=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=R.useRef(null),$=R.useRef(!1),se=R.useCallback(H=>{k(Z=>{var K;return(K=Z.find(pe=>pe.id===H.id))!=null&&K.delete||et.dismiss(H.id),Z.filter(({id:pe})=>pe!==H.id)})},[]);return R.useEffect(()=>et.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{k(Z=>Z.map(K=>K.id===H.id?{...K,delete:!0}:K))});return}setTimeout(()=>{By.flushSync(()=>{k(Z=>{const K=Z.findIndex(pe=>pe.id===H.id);return K!==-1?[...Z.slice(0,K),{...Z[K],...H},...Z.slice(K+1)]:[H,...Z]})})})}),[T]),R.useEffect(()=>{if(f!=="system"){re(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?re("dark"):re("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:Z})=>{re(Z?"dark":"light")})}catch{H.addListener(({matches:K})=>{try{re(K?"dark":"light")}catch(pe){console.error(pe)}})}},[f]),R.useEffect(()=>{T.length<=1&&Q(!1)},[T]),R.useEffect(()=>{const H=Z=>{var K;if(i.every(J=>Z[J]||Z.code===J)){var Je;Q(!0),(Je=j.current)==null||Je.focus()}Z.code==="Escape"&&(document.activeElement===j.current||(K=j.current)!=null&&K.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[i]),R.useEffect(()=>{if(j.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,$.current=!1)}},[j.current]),R.createElement("section",{ref:n,"aria-label":`${C} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((H,Z)=>{var K;const[pe,Je]=H.split("-");return b.length?R.createElement("ol",{key:H,dir:g==="auto"?Tm():g,tabIndex:-1,ref:j,className:c,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":pe,"data-x-position":Je,style:{"--front-toast-height":`${((K=P[0])==null?void 0:K.height)||0}px`,"--width":`${lM}px`,"--gap":`${v}px`,...x,...pM(d,u)},onBlur:J=>{$.current&&!J.currentTarget.contains(J.relatedTarget)&&($.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||$.current||($.current=!0,V.current=J.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{le||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||ge(!0)},onPointerUp:()=>ge(!1)},b.filter(J=>!J.position&&Z===0||J.position===H).map((J,Xt)=>{var cn,Qt;return R.createElement(hM,{key:J.id,icons:E,index:Xt,toast:J,defaultRichColors:y,duration:(cn=m==null?void 0:m.duration)!=null?cn:w,className:m==null?void 0:m.className,descriptionClassName:m==null?void 0:m.descriptionClassName,invert:s,visibleToasts:S,closeButton:(Qt=m==null?void 0:m.closeButton)!=null?Qt:l,interacting:le,position:H,style:m==null?void 0:m.style,unstyled:m==null?void 0:m.unstyled,classNames:m==null?void 0:m.classNames,cancelButtonStyle:m==null?void 0:m.cancelButtonStyle,actionButtonStyle:m==null?void 0:m.actionButtonStyle,closeButtonAriaLabel:m==null?void 0:m.closeButtonAriaLabel,removeToast:se,toasts:b.filter(It=>It.position==J.position),heights:P.filter(It=>It.position==J.position),setHeights:D,expandByDefault:a,gap:v,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),ow=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,iw=5,aw=3e3;function BM(e,t){const n=p.useRef(null),r=p.useRef(0),s=p.useRef(!0),o=p.useRef(!1),i=p.useRef(t);i.current=t;const a=p.useRef(!1),l=p.useCallback(w=>{var x;((x=n.current)==null?void 0:x.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(w))},[]),c=p.useCallback((w,x)=>{var S;((S=n.current)==null?void 0:S.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:w,rows:x})),a.current=!1):a.current=!0},[]),d=p.useCallback(w=>{l({type:"terminal_input",data:w})},[l]),u=p.useCallback((w,x)=>{l({type:"terminal_resize",cols:w,rows:x})},[l]),f=p.useCallback(()=>{l({type:"chat_subscribe"})},[l]),y=p.useCallback(()=>{if(!s.current||o.current)return;const w=Mo();if(!w){window.location.href="/login";return}o.current=!0;const x=new WebSocket(`${ow}/ws/projects/${e}`);n.current=x,x.onopen=()=>{o.current=!1,r.current=0,x.send(JSON.stringify({type:"auth",token:w}))},x.onmessage=S=>{var g,v,E,C,T,k,b,A;let m;try{m=JSON.parse(S.data)}catch{return}switch(m.type){case"connected":a.current=!1,(v=(g=i.current).onConnected)==null||v.call(g);break;case"terminal_data":(C=(E=i.current).onTerminalData)==null||C.call(E,m.data);break;case"status":(k=(T=i.current).onStatus)==null||k.call(T,m.status);break;case"chat_message":{const P=m;(A=(b=i.current).onChatMessage)==null||A.call(b,P);break}case"error":console.error("[WS] Server error:",m.message);break}},x.onclose=()=>{o.current=!1,n.current=null,s.current&&r.current<iw&&(r.current++,setTimeout(y,aw))},x.onerror=S=>{o.current=!1,console.error("[WS] WebSocket error:",S)}},[e]);return p.useEffect(()=>(s.current=!0,y(),()=>{var w;s.current=!1,(w=n.current)==null||w.close(),n.current=null}),[y]),{subscribeTerminal:c,sendTerminalInput:d,sendTerminalResize:u,subscribeChatMessages:f}}function gM(e){const t=p.useRef(null),n=p.useRef(0),r=p.useRef(!0),s=p.useRef(!1),o=p.useRef(e);o.current=e;const i=p.useCallback(()=>{if(!r.current||s.current)return;const a=Mo();if(!a)return;s.current=!0;const l=new WebSocket(`${ow}/ws/dashboard`);t.current=l,l.onopen=()=>{s.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:a}))},l.onmessage=c=>{var d,u;try{const f=JSON.parse(c.data);f.type==="activity_update"?o.current.onActivityUpdate(f):f.type==="project_stopped"&&((u=(d=o.current).onProjectStopped)==null||u.call(d,f.projectId,f.projectName))}catch{}},l.onclose=()=>{s.current=!1,t.current=null,r.current&&n.current<iw&&(n.current++,setTimeout(i,aw))},l.onerror=c=>{s.current=!1,console.error("[DashboardWS] Error:",c)}},[]);p.useEffect(()=>(r.current=!0,i(),()=>{var a;r.current=!1,(a=t.current)==null||a.close(),t.current=null}),[i])}function yM(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h${r}m`:`${r}m`}const Pm=5*36e5;function vM(e){if(!e||e.utilization===void 0||e.utilization<=0||!e.resetAt)return null;const t=new Date(e.resetAt).getTime()-Date.now();if(t<=0)return null;const n=Pm-t;return n<=0?null:Math.round(e.utilization/(n/Pm))}function ui({label:e,bucket:t}){if(!t||t.utilization===void 0)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",s=yM(t.resetAt);return h.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",h.jsxs("span",{className:q("font-medium",r),children:[n,"%"]}),s&&h.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",s,")"]})]})}function xM({className:e}){const[t,n]=p.useState("loading"),[r,s]=p.useState(!1);p.useEffect(()=>{const f=async()=>{try{n(await mx())}catch{n(null)}};f();const y=setInterval(()=>void f(),5*60*1e3);return()=>clearInterval(y)},[]);const o=async()=>{s(!0);try{n(await gx())}catch{n(null)}finally{s(!1)}};if(t==="loading"||!t)return null;const i=!!t.fiveHour,a=!!t.sevenDay,l=!!t.sevenDaySonnet,c=!!t.sevenDayOpus,d=i||a||l||c,u=vM(t.fiveHour);return h.jsxs("div",{className:q("flex items-center gap-1.5 text-xs",e),children:[u!==null&&h.jsxs("span",{className:q("font-medium",u<=100?"text-green-400":"text-orange-400"),title:`5h 使用进度:按当前速率,窗口结束时预计使用 ${u}%`,children:[u,"%"]}),t.planName&&h.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),d&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"|"}),h.jsx(ui,{label:"5h",bucket:t.fiveHour}),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d",bucket:t.sevenDay})]}),l&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(ui,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),h.jsx("button",{onClick:()=>void o(),className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:h.jsx($N,{className:q("h-3 w-3",r&&"animate-spin")})})]})}function wM(){const[e,t]=p.useState([]),[n,r]=p.useState(!1),[s,o]=p.useState(""),[i,a]=p.useState(""),[l,c]=p.useState(""),[d,u]=p.useState(null),[f,y]=p.useState(""),[w,x]=p.useState(""),[S,m]=p.useState(""),g=p.useRef(null),v=p.useRef(null);p.useEffect(()=>{dx().then(t).catch(()=>t([]))},[]),p.useEffect(()=>{n&&setTimeout(()=>{var k;return(k=g.current)==null?void 0:k.focus()},0)},[n]),p.useEffect(()=>{d&&setTimeout(()=>{var k;return(k=v.current)==null?void 0:k.focus()},0)},[d]);const E=async()=>{const k=i.trim();if(k)try{const b=await fx({label:s.trim()||k,command:k,...l?{parentId:l}:{}});t(A=>[...A,b]),o(""),a(""),c(""),r(!1)}catch(b){console.error("[GlobalShortcuts] Failed to add:",b)}},C=async k=>{try{await px(k),t(b=>b.filter(A=>A.id!==k)),d===k&&u(null)}catch(b){console.error("[GlobalShortcuts] Failed to delete:",b)}},T=async()=>{const k=w.trim();if(!(!k||!d))try{const b=await hx(d,{label:f.trim()||k,command:k,parentId:S||null});t(A=>A.map(P=>P.id===d?b:P)),u(null)}catch(b){console.error("[GlobalShortcuts] Failed to save:",b)}};return h.jsxs("section",{className:"mt-10",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(cm,{className:"h-4 w-4 text-muted-foreground"}),h.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷命令"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),h.jsxs("button",{onClick:()=>{r(k=>!k),u(null)},className:q("flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-md border transition-colors",n?"border-border text-foreground bg-muted":"border-border text-muted-foreground hover:text-foreground hover:bg-muted"),children:[h.jsx(ma,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&h.jsxs("div",{className:"mb-4 p-4 rounded-lg border border-border bg-background space-y-3",children:[h.jsx("input",{ref:g,placeholder:"名称(可选)",value:s,onChange:k=>o(k.target.value),className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),h.jsx("textarea",{placeholder:"命令内容…",value:i,onChange:k=>a(k.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground placeholder:text-muted-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),E()),k.key==="Escape"&&(r(!1),o(""),a(""),c(""))}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kl,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:l,onChange:k=>c(k.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-3 py-1.5 text-foreground outline-none focus:border-border transition-colors",children:[h.jsx("option",{value:"",children:"无继承"}),e.map(k=>h.jsx("option",{value:k.id,children:k.label},k.id))]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>{r(!1),o(""),a("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),h.jsx("button",{onClick:()=>void E(),disabled:!i.trim(),className:q("text-sm px-3 py-1 rounded transition-colors text-white",i.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),e.length===0&&!n?h.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-lg",children:[h.jsx(cm,{className:"h-6 w-6"}),h.jsx("p",{className:"text-sm",children:"还没有全局快捷命令"})]}):h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(k=>d===k.id?h.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[h.jsx("input",{ref:v,value:f,onChange:b=>y(b.target.value),placeholder:"名称(可选)",className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground placeholder:text-muted-foreground outline-none focus:border-border transition-colors"}),h.jsx("textarea",{value:w,onChange:b=>x(b.target.value),rows:3,className:"w-full text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground font-mono outline-none focus:border-border transition-colors resize-none",onKeyDown:b=>{b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),T()),b.key==="Escape"&&u(null)}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Kl,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:S,onChange:b=>m(b.target.value),className:"flex-1 text-sm bg-muted border border-border rounded px-2.5 py-1 text-foreground outline-none focus:border-border transition-colors",children:[h.jsx("option",{value:"",children:"无继承"}),e.filter(b=>b.id!==k.id).map(b=>h.jsx("option",{value:b.id,children:b.label},b.id))]})]}),h.jsxs("div",{className:"flex gap-2 justify-end",children:[h.jsx("button",{onClick:()=>u(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),h.jsx("button",{onClick:()=>void T(),disabled:!w.trim(),className:q("text-xs px-2.5 py-1 rounded transition-colors text-white",w.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},k.id):h.jsxs("div",{className:"group relative rounded-lg border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[h.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:k.label}),k.parentId&&(()=>{const b=e.find(A=>A.id===k.parentId);return b?h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(Kl,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",b.label]})]}):null})(),!k.parentId&&k.label!==k.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:k.command}),h.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{onClick:()=>{u(k.id),y(k.label),x(k.command),m(k.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:h.jsx(Sx,{className:"h-3.5 w-3.5"})}),h.jsx("button",{onClick:()=>void C(k.id),className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:h.jsx(uf,{className:"h-3.5 w-3.5"})})]})]},k.id))})]})}const lw=p.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function SM(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function EM(){return p.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>SM())}function kM({children:e}){const[t,n]=p.useState(()=>RP(Zr.theme,"system")),r=EM(),s=t==="system"?r:t;p.useEffect(()=>{const i=document.documentElement;i.classList.remove("light","dark"),i.classList.add(s)},[s]);const o=i=>{n(i),tx(Zr.theme,i)};return h.jsx(lw.Provider,{value:{theme:t,resolved:s,setTheme:o},children:e})}function bM(){return p.useContext(lw)}function CM(){const{theme:e,setTheme:t}=bM(),n=[{value:"light",icon:GN,label:"浅色"},{value:"dark",icon:BN,label:"深色"},{value:"system",icon:zN,label:"系统"}];return h.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:r,icon:s,label:o})=>h.jsx("button",{onClick:()=>t(r),className:q("p-1 rounded-sm transition-colors",e===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:h.jsx(s,{className:"h-3.5 w-3.5"})},r))})}function TM(){const e=_a(),{projects:t,loading:n,error:r,fetchProjects:s,addProject:o,updateProject:i,removeProject:a}=am(),l=xr(N=>N.clearToken),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[y,w]=p.useState(new Set),x=p.useRef(new Map),[S,m]=p.useState(new Map),g=p.useRef(0),[v,E]=p.useState(!!document.fullscreenElement),[C,T]=p.useState(!1),[k,b]=p.useState(""),[A,P]=p.useState([]),[D,L]=p.useState(!1);p.useEffect(()=>{if(!k.trim()||k.trim().length<2){P([]);return}const N=setTimeout(()=>{L(!0),xx(k).then(B=>P(B)).catch(()=>P([])).finally(()=>L(!1))},400);return()=>clearTimeout(N)},[k]);const Q=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()};p.useEffect(()=>{const N=()=>E(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]),p.useEffect(()=>{s()},[s]),p.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]);const le=2e3,ge=3,z=8e3,re=p.useCallback(N=>{if(N.status){const ee=am.getState().projects.find(ue=>ue.id===N.projectId);ee&&ee.status!==N.status&&i({...ee,status:N.status})}const B=Date.now(),Y=x.current;if(B-N.lastActivityAt<le){w(ye=>ye.has(N.projectId)?ye:new Set(ye).add(N.projectId));const ee=Y.get(N.projectId)??[];let ue=!1;if(N.semantic){const ye=ee[ee.length-1],Zn=`${N.semantic.phase}:${N.semantic.detail??""}`,fn=ye?`${ye.phase}:${ye.detail??""}`:"";Zn!==fn?(ee.push({id:g.current++,phase:N.semantic.phase,detail:N.semantic.detail,ts:B}),ue=!0):ye&&(ye.ts=B)}const Pe=ee.filter(ye=>B-ye.ts<z),Ge=Pe.length>ge?Pe.slice(-ge):Pe;Ge.length!==ee.length&&(ue=!0),Y.set(N.projectId,Ge),ue&&m(new Map(Y))}else w(ee=>{if(!ee.has(N.projectId))return ee;const ue=new Set(ee);return ue.delete(N.projectId),ue}),Y.has(N.projectId)&&Y.get(N.projectId).length>0&&(Y.set(N.projectId,[]),m(new Map(Y)))},[]),j=p.useCallback((N,B)=>{"Notification"in window&&Notification.permission==="granted"&&new Notification("Claude 已完成",{body:`项目「${B}」的任务已完成`,icon:"/terminal.svg"})},[]);gM({onActivityUpdate:re,onProjectStopped:j}),p.useEffect(()=>{const N=setInterval(()=>{const B=Date.now(),Y=x.current;let ee=!1;for(const[ue,Pe]of Y){const Ge=Pe.filter(ye=>B-ye.ts<z);Ge.length!==Pe.length&&(Y.set(ue,Ge),ee=!0)}ee&&m(new Map(Y)),w(ue=>{let Pe=!1;const Ge=new Set(ue);for(const ye of ue){const Zn=Y.get(ye);(!Zn||Zn.length===0)&&(Ge.delete(ye),Pe=!0)}return Pe?Ge:ue})},3e3);return()=>clearInterval(N)},[]);const _=()=>{l(),e("/login")},V=N=>{o(N)},$=N=>{o(N)},se=async N=>{try{await lx(N),a(N)}catch(B){Di.error(B instanceof Error?B.message:"Failed to delete project")}},H=async N=>{try{const B=await ux(N);i(B)}catch(B){Di.error(B instanceof Error?B.message:"Failed to archive project")}},Z=async N=>{try{const B=await cx(N);i(B)}catch(B){Di.error(B instanceof Error?B.message:"Failed to restore project")}},K=p.useMemo(()=>t.filter(N=>!N.archived),[t]),pe=p.useMemo(()=>t.filter(N=>N.archived),[t]),Je=p.useMemo(()=>Array.from(new Set(t.flatMap(N=>N.tags??[]))),[t]),[J,Xt]=p.useState([]),cn=p.useMemo(()=>J.length===0?K:K.filter(N=>J.some(B=>{var Y;return(Y=N.tags)==null?void 0:Y.includes(B)})),[K,J]),[Qt,It]=AP(Zr.projectOrder,[],{parse:!0}),[gs,Xn]=p.useState(null),[Za,Qn]=p.useState(null);p.useEffect(()=>{if(K.length===0)return;const N=K.map(B=>B.id);It(B=>{const Y=B.filter(Pe=>N.includes(Pe)),ee=N.filter(Pe=>!B.includes(Pe)),ue=[...Y,...ee];return ue.join(",")===B.join(",")?B:ue})},[K]);const dn=p.useMemo(()=>Qt.length===0?cn:[...cn].sort((N,B)=>{const Y=Qt.indexOf(N.id),ee=Qt.indexOf(B.id);return Y===-1?1:ee===-1?-1:Y-ee}),[cn,Qt]),Ao=p.useCallback(N=>Xn(N),[]),kt=p.useCallback(()=>{Xn(null),Qn(null)},[]),qa=p.useCallback((N,B)=>{N.preventDefault(),Qn(B)},[]),Ja=p.useCallback((N,B,Y)=>{if(N.preventDefault(),!Y||Y===B){Qn(null);return}It(ee=>{const ue=[...ee],Pe=ue.indexOf(Y),Ge=ue.indexOf(B);return Pe===-1||Ge===-1?ee:(ue.splice(Pe,1),ue.splice(Ge,0,Y),ue)}),Xn(null),Qn(null)},[It]),ze={onDelete:N=>void se(N),onArchive:N=>void H(N),onUnarchive:N=>void Z(N),onUpdated:i};return h.jsxs("div",{className:"min-h-screen bg-background",children:[h.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:h.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(um,{className:"h-5 w-5"}),h.jsx("span",{className:"font-semibold text-lg",children:"CC Web"})]}),h.jsx(xM,{}),h.jsxs("div",{className:"relative",children:[h.jsx(UN,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),h.jsx(go,{placeholder:"搜索历史对话…",value:k,onChange:N=>b(N.target.value),className:"pl-8 h-8 text-xs w-48"}),k.trim().length>=2&&h.jsxs("div",{className:"absolute top-full mt-1 right-0 w-96 max-h-80 overflow-y-auto bg-popover border border-border rounded-lg shadow-xl z-50",children:[D&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"搜索中…"}),!D&&A.length===0&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"无结果"}),A.map((N,B)=>h.jsxs("button",{className:"w-full text-left px-4 py-2.5 hover:bg-muted transition-colors border-b border-border last:border-0",onClick:()=>{e(`/project/${N.projectId}`),b("")},children:[h.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[h.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:N.projectName}),h.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:new Date(N.startedAt).toLocaleDateString("zh-CN")})]}),h.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:N.snippet})]},B))]})]}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"SkillHub",children:h.jsx(HN,{className:"h-4 w-4"})}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:h.jsx(WN,{className:"h-4 w-4"})}),h.jsx(ie,{variant:"ghost",size:"sm",onClick:Q,title:v?"Exit fullscreen":"Fullscreen",children:v?h.jsx(FN,{className:"h-4 w-4"}):h.jsx(VN,{className:"h-4 w-4"})}),h.jsx(CM,{}),h.jsxs(ie,{variant:"ghost",size:"sm",onClick:_,children:[h.jsx(IN,{className:"h-4 w-4 mr-2"}),"Logout"]})]})}),h.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[h.jsxs("div",{className:"flex items-center justify-between mb-6",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold",children:"Projects"}),h.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(ie,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Ec,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(ie,{onClick:()=>d(!0),children:[h.jsx(ma,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),n&&h.jsx("div",{className:"text-center text-muted-foreground py-12",children:"Loading projects..."}),r&&h.jsx("div",{className:"text-center text-destructive py-12",children:r}),!n&&!r&&t.length===0&&h.jsxs("div",{className:"text-center py-20",children:[h.jsx(um,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),h.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),h.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),h.jsxs("div",{className:"flex gap-2 justify-center",children:[h.jsxs(ie,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Ec,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(ie,{onClick:()=>d(!0),children:[h.jsx(ma,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!n&&!r&&Je.length>0&&h.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[Je.map(N=>h.jsxs("button",{onClick:()=>Xt(B=>B.includes(N)?B.filter(Y=>Y!==N):[...B,N]),className:q("px-2 py-0.5 rounded-full text-xs border transition-colors",J.includes(N)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",N]},N)),J.length>0&&h.jsx("button",{onClick:()=>Xt([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&dn.length>0&&h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:dn.map((N,B)=>h.jsx(Vn.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:B*.05,ease:"easeOut"},draggable:!0,onDragStart:()=>Ao(N.id),onDragOver:Y=>qa(Y,N.id),onDrop:Y=>Ja(Y,N.id,gs),onDragEnd:kt,style:{opacity:gs===N.id?.4:1,cursor:"grab"},className:q(Za===N.id&&gs!==N.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:h.jsx(km,{project:N,active:y.has(N.id),statusStack:S.get(N.id)??[],...ze})},N.id))}),!n&&!r&&pe.length>0&&h.jsxs("div",{className:"mt-10",children:[h.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>T(N=>!N),children:[h.jsx(Vn.span,{animate:{rotate:C?90:0},transition:{duration:.2},children:h.jsx(wx,{className:"h-4 w-4"})}),h.jsx("span",{className:"font-medium",children:"Archived"}),h.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:pe.length})]}),h.jsx(qd,{children:C&&h.jsx(Vn.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.25,ease:"easeInOut"},className:"overflow-hidden",children:h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:pe.map(N=>h.jsx(km,{project:N,active:!1,...ze},N.id))})})})]}),h.jsx(wM,{})]}),h.jsx(BR,{open:c,onOpenChange:d,onCreated:V}),h.jsx($R,{open:u,onOpenChange:f,onOpened:$})]})}class PM extends R.Component{constructor(){super(...arguments);tl(this,"state",{hasError:!1,error:null});tl(this,"handleReset",()=>{var n,r;this.setState({hasError:!1,error:null}),(r=(n=this.props).onReset)==null||r.call(n)})}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("[ErrorBoundary]",n,r.componentStack),Di.error(n.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[h.jsx("p",{children:"出错了"}),h.jsx("button",{onClick:this.handleReset,className:"px-3 py-1.5 text-xs rounded-md border border-border hover:bg-muted transition-colors",children:"重新加载"})]}):this.props.children}}const NM=R.lazy(()=>bo(()=>import("./ProjectPage-CxmRkD_s.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ProjectPage}))),jM=R.lazy(()=>bo(()=>import("./SettingsPage-C4AwXw1s.js"),__vite__mapDeps([7,3,1])).then(e=>({default:e.SettingsPage}))),RM=R.lazy(()=>bo(()=>import("./SkillHubPage-BUlWl5RI.js"),__vite__mapDeps([8,5,2,3])).then(e=>({default:e.SkillHubPage}))),MM=R.lazy(()=>bo(()=>import("./ShareViewPage-T2Z7Bx3L.js"),__vite__mapDeps([9,5,4])).then(e=>({default:e.ShareViewPage})));function AM(){return h.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function ci({children:e}){const[t,n]=p.useState(!1),r=xr(o=>o.token),s=xr(o=>o.setToken);return p.useEffect(()=>{if(r){n(!0);return}pa()?lf().then(o=>s(o)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),!t&&!r?null:r?h.jsx(h.Fragment,{children:e}):h.jsx(ev,{to:"/login",replace:!0})}function DM(){return h.jsxs(kM,{children:[h.jsx(mM,{richColors:!0,position:"bottom-right"}),h.jsx(PM,{children:h.jsx(IE,{children:h.jsx(p.Suspense,{fallback:h.jsx(AM,{}),children:h.jsxs(LE,{children:[h.jsx(yn,{path:"/login",element:h.jsx(TN,{})}),h.jsx(yn,{path:"/",element:h.jsx(ci,{children:h.jsx(TM,{})})}),h.jsx(yn,{path:"/projects/:id",element:h.jsx(ci,{children:h.jsx(NM,{})})}),h.jsx(yn,{path:"/settings",element:h.jsx(ci,{children:h.jsx(jM,{})})}),h.jsx(yn,{path:"/skillhub",element:h.jsx(ci,{children:h.jsx(RM,{})})}),h.jsx(yn,{path:"/share/:token",element:h.jsx(MM,{})}),h.jsx(yn,{path:"*",element:h.jsx(ev,{to:"/",replace:!0})})]})})})})]})}nu.createRoot(document.getElementById("root")).render(h.jsx(R.StrictMode,{children:h.jsx(DM,{})}));export{EN as $,qd as A,ie as B,wx as C,HP as D,DN as E,Ec as F,dx as G,Kl as H,go as I,YP as J,hf as K,Ga as L,FN as M,Ka as N,Xa as O,Sx as P,Qa as Q,R,Zr as S,jn as T,Ya as U,KP as V,GP as W,uf as X,QP as Y,cm as Z,bo as _,OM as a,$P as a0,kN as a1,UP as a2,_a as a3,MN as a4,rr as a5,CM as a6,uN as a7,BP as a8,UN as a9,lN as aA,nf as aB,rf as aC,sf as aD,of as aE,Ex as aF,mN as aG,oN as aH,cN as aI,fN as aJ,pN as aK,aN as aL,hN as aM,dN as aN,gN as aO,XP as aP,ZP as aQ,bN as aR,IM as aS,MP as aa,BM as ab,xM as ac,VM as ad,AP as ae,am as af,um as ag,yo as ah,kr as ai,ej as aj,un as ak,Fn as al,XN as am,Ba as an,Yl as ao,vo as ap,Ua as aq,Sd as ar,Nx as as,gR as at,Rj as au,Ox as av,Tx as aw,bx as ax,sN as ay,iN as az,Mo as b,ne as c,eN as d,q as e,VN as f,Nm as g,qP as h,RP as i,h as j,yx as k,$N as l,JP as m,lm as n,Vn as o,yN as p,AN as q,p as r,tx as s,Di as t,bM as u,ma as v,tN as w,vN as x,xN as y,wN as z};