@tom2012/cc-web 1.5.76 → 1.5.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/frontend/dist/assets/{GraphPreview-CiL6ZjdW.js → GraphPreview-BsCfScZY.js} +1 -1
- package/frontend/dist/assets/{OfficePreview-laIUc98k.js → OfficePreview-DZcYVDW8.js} +3 -3
- package/frontend/dist/assets/{ProjectPage-BmYhTTYq.js → ProjectPage-DqyRyuGy.js} +3 -3
- package/frontend/dist/assets/{SettingsPage-C30iHtBo.js → SettingsPage-DibjvDz7.js} +1 -1
- package/frontend/dist/assets/{ShareViewPage-BGAvzqO1.js → ShareViewPage-BfltjUod.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-BSb-9jya.js → SkillHubPage-BuCfJoFJ.js} +1 -1
- package/frontend/dist/assets/{bot-hRRV5XmX.js → bot-BX6StWTe.js} +1 -1
- package/frontend/dist/assets/{chevron-down-BR0IMbA9.js → chevron-down-X-5t7_tL.js} +1 -1
- package/frontend/dist/assets/{download-UC5GvInE.js → download-Bil13d6m.js} +1 -1
- package/frontend/dist/assets/{index-D7mCoW2r.js → index-BhyoV38M.js} +2 -2
- package/frontend/dist/assets/{index-BiYAwwZA.js → index-CPD5Wb59.js} +1 -1
- package/frontend/dist/assets/{jszip.min-YWYO5s4l.js → jszip.min-CxKrPvTL.js} +1 -1
- package/frontend/dist/assets/{save-CdDjQhdC.js → save-p2K0zXBn.js} +1 -1
- package/frontend/dist/assets/{user-Bv38vpTL.js → user-Dl8SCDzt.js} +1 -1
- package/frontend/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Pe,r as l,am as re,an as Y,ao as He,j as r,ap as K,aq as z,ar as _e,e as J,as as an,R as Ce,at as We,au as jt,av as Zo,aw as Rt,ax as Qo,ay as Jo,az as er,aA as tr,aB as nr,aC as or,v as rr,aD as sr,L as ir,N as ar,O as cr,Q as lr,T as dr,B as ee,U as ue,I as je,V as ur,aE as $t,aF as mt,aG as fr,aH as pr,aI as mr,a6 as cn,aJ as hr,m as ln,aK as xr,a4 as gr,aL as vr,aM as yr,a5 as wr,aN as Ht,x as br,A as Sr,p as Cr,X as Nr,aO as jr,aP as Rr,aQ as Ar,aR as Tr,aS as Pr,aT as Er,aU as Vt,aV as Ir,t as lt,s as Or,S as kr}from"./index-
|
|
1
|
+
import{c as Pe,r as l,am as re,an as Y,ao as He,j as r,ap as K,aq as z,ar as _e,e as J,as as an,R as Ce,at as We,au as jt,av as Zo,aw as Rt,ax as Qo,ay as Jo,az as er,aA as tr,aB as nr,aC as or,v as rr,aD as sr,L as ir,N as ar,O as cr,Q as lr,T as dr,B as ee,U as ue,I as je,V as ur,aE as $t,aF as mt,aG as fr,aH as pr,aI as mr,a6 as cn,aJ as hr,m as ln,aK as xr,a4 as gr,aL as vr,aM as yr,a5 as wr,aN as Ht,x as br,A as Sr,p as Cr,X as Nr,aO as jr,aP as Rr,aQ as Ar,aR as Tr,aS as Pr,aT as Er,aU as Vt,aV as Ir,t as lt,s as Or,S as kr}from"./index-BhyoV38M.js";import{C as dn}from"./chevron-down-X-5t7_tL.js";import{a as _r,C as Dr,S as Wt}from"./save-p2K0zXBn.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{ai as f,r,b1 as g,j as e,e as a}from"./index-
|
|
1
|
+
import{ai as f,r,b1 as g,j as e,e as a}from"./index-BhyoV38M.js";import{U as j}from"./user-Dl8SCDzt.js";import{B as p}from"./bot-BX6StWTe.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,4 +1,4 @@
|
|
|
1
|
-
import{c as U,a4 as Q,r as n,aW as M,aX as V,t as m,aY as ee,aZ as se,a_ as te,j as e,B as x,a5 as ae,e as i,a$ as A,ab as ne,I as re,aK as le,p as b,J as de,A as ie,b0 as oe}from"./index-
|
|
1
|
+
import{c as U,a4 as Q,r as n,aW as M,aX as V,t as m,aY as ee,aZ as se,a_ as te,j as e,B as x,a5 as ae,e as i,a$ as A,ab as ne,I as re,aK as le,p as b,J as de,A as ie,b0 as oe}from"./index-BhyoV38M.js";import{D as w}from"./download-Bil13d6m.js";import{U as ce}from"./user-Dl8SCDzt.js";import{C as me}from"./chevron-down-X-5t7_tL.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-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-DqyRyuGy.js","assets/save-p2K0zXBn.js","assets/download-Bil13d6m.js","assets/chevron-down-X-5t7_tL.js","assets/bot-BX6StWTe.js","assets/user-Dl8SCDzt.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-DibjvDz7.js","assets/SkillHubPage-BuCfJoFJ.js","assets/ShareViewPage-BfltjUod.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var ww=Object.defineProperty;var Sw=(e,t,n)=>t in e?ww(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ul=(e,t,n)=>Sw(e,typeof t!="symbol"?t+"":t,n);function bw(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 aD=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Am(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function lD(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 Lm={exports:{}},wa={},_m={exports:{}},K={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -292,4 +292,4 @@ Error generating stack: `+o.message+`
|
|
|
292
292
|
|
|
293
293
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
294
294
|
|
|
295
|
-
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},GR="DialogDescriptionWarning",KR=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sw(GR).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},YR=Hx,XR=Yx,ow=Xx,iw=Qx,aw=qx,lw=ew,QR=nw;const yf=YR,ZR=XR,uw=p.forwardRef(({className:e,...t},n)=>h.jsx(ow,{ref:n,className:X("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}));uw.displayName=ow.displayName;const el=p.forwardRef(({className:e,children:t,noOverlay:n,...r},s)=>h.jsxs(ZR,{children:[!n&&h.jsx(uw,{}),h.jsxs(iw,{ref:s,className:X("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),...r,children:[t,h.jsxs(QR,{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(Qa,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));el.displayName=iw.displayName;const tl=({className:e,...t})=>h.jsx("div",{className:X("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});tl.displayName="DialogHeader";const nl=({className:e,...t})=>h.jsx("div",{className:X("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});nl.displayName="DialogFooter";const rl=p.forwardRef(({className:e,...t},n)=>h.jsx(aw,{ref:n,className:X("text-lg font-semibold leading-none tracking-tight",e),...t}));rl.displayName=aw.displayName;const sl=p.forwardRef(({className:e,...t},n)=>h.jsx(lw,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));sl.displayName=lw.displayName;function qR({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 m=!1;return ux().then(w=>{m||a(w)}).catch(()=>{}),()=>{m=!0}},[t,e.id]);const f=new Set(s.map(m=>m.username)),y=i.filter(m=>m!==e.owner&&!f.has(m)),x=m=>{o(w=>[...w,{username:m,permission:"view"}])},v=m=>{o(w=>w.filter(b=>b.username!==m))},S=m=>{o(w=>w.map(b=>b.username===m?{...b,permission:b.permission==="view"?"edit":"view"}:b))},g=async()=>{c(!0),u(null);try{const m=await cx(e.id,s);r(m),n(!1)}catch(m){u(m instanceof Error?m.message:"Failed to update shares")}finally{c(!1)}};return h.jsx(yf,{open:t,onOpenChange:n,children:h.jsxs(el,{className:"sm:max-w-md",children:[h.jsxs(tl,{children:[h.jsxs(rl,{className:"flex items-center gap-2",children:[h.jsx(Mc,{className:"h-4 w-4"}),"共享设置"]}),h.jsx(sl,{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(m=>h.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[h.jsx("span",{className:"text-sm font-medium",children:m.username}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{onClick:()=>S(m.username),className:"focus:outline-none",children:h.jsx(rr,{variant:m.permission==="edit"?"default":"secondary",className:"cursor-pointer text-xs",children:m.permission==="edit"?"可编辑":"可见"})}),h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>v(m.username),children:h.jsx(jx,{className:"h-3.5 w-3.5"})})]})]},m.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(m=>h.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>x(m),children:[h.jsx(ya,{className:"h-3 w-3"}),m]},m))})]}),d&&h.jsx("p",{className:"text-sm text-destructive",children:d}),h.jsxs(nl,{children:[h.jsx(le,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),h.jsx(le,{onClick:()=>void g(),disabled:l,children:l?"保存中...":"保存"})]})]})})}function JR(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 eM({status:e}){return h.jsx("span",{className:X("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 jm=M.memo(function({project:t,active:n=!1,statusStack:r=[],onDelete:s,onArchive:o,onUnarchive:i,onUpdated:a}){var m,w;const l=za(),[c,d]=p.useState(!1),u=!!t._sharedPermission,f=t._sharedPermission==="view",y=b=>{b.stopPropagation(),confirm(`Delete project "${t.name}"? This cannot be undone.`)&&s(t.id)},x=b=>{b.stopPropagation(),o(t.id)},v=b=>{b.stopPropagation(),i(t.id)},S=h.jsx(Yt.div,{whileHover:!t.archived&&!n?{y:-2}:{},transition:{duration:.2},children:h.jsxs(lf,{className:X("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(uf,{className:"pb-2",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx(cf,{className:X("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(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:v,title:"Restore project",children:h.jsx(zj,{className:"h-3.5 w-3.5"})}):h.jsxs(h.Fragment,{children:[h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:b=>{b.stopPropagation(),d(!0)},title:"共享设置",children:h.jsx(Mc,{className:"h-3.5 w-3.5"})}),h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:x,title:"Archive project",children:h.jsx(Bj,{className:"h-3.5 w-3.5"})})]}),h.jsx(le,{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(jx,{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(eM,{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(Ha,{mode:"wait",children:r.slice(-1).map(b=>h.jsx(Yt.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:JR(b.phase,b.detail)})},b.id))})})]})})]}),h.jsxs(df,{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[h.jsx(Rc,{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(Wj,{className:"h-3 w-3"}):h.jsx(Tx,{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(Mc,{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(b=>h.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",b]},b)),(((m=t.tags)==null?void 0:m.length)??0)>3&&h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",(((w=t.tags)==null?void 0:w.length)??0)-3]})]})]})]})}),g=n&&!t.archived?h.jsx("div",{className:"card-active-glow rounded-lg",children:S}):S;return h.jsxs(h.Fragment,{children:[g,!u&&a&&h.jsx(qR,{project:t,open:c,onOpenChange:d,onUpdated:a})]})});function cw({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,x]=p.useState(""),[v,S]=p.useState(null),[g,m]=p.useState(!1),w=p.useRef(null),b=async A=>{l(!0),d(null);try{const L=await bx(A);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(()=>{b()},[]),p.useEffect(()=>{u&&setTimeout(()=>{var A;return(A=w.current)==null?void 0:A.focus()},0)},[u]);const C=()=>{x(""),S(null),f(!0)},P=()=>{f(!1),x(""),S(null)},E=async()=>{const A=y.trim();if(A){m(!0),S(null);try{const{path:L}=await Ex(t,A);f(!1),x(""),await b(t),b(L)}catch(L){S(L instanceof Error?L.message:"Failed to create folder")}finally{m(!1)}}},k=A=>{A.key==="Enter"?(A.preventDefault(),E()):A.key==="Escape"&&P()},j=t.split("/").filter(Boolean),T=A=>{const L="/"+j.slice(0,A+1).join("/");b(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(le,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>void b(),title:"Home",children:h.jsx(Yj,{className:"h-3 w-3"})}),h.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:j.map((A,L)=>h.jsxs(M.Fragment,{children:[h.jsx(Px,{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:()=>T(L),children:A})]},L))}),h.jsxs(le,{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(Gj,{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 b(r),children:[h.jsx($j,{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(hm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),h.jsx("input",{ref:w,className:X("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",v&&"border-destructive"),placeholder:"Folder name",value:y,onChange:A=>{x(A.target.value),S(null)},onKeyDown:k,disabled:g}),h.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>void E(),disabled:!y.trim()||g,title:"Create",children:h.jsx(Uj,{className:"h-3.5 w-3.5 text-green-600"})}),h.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:P,disabled:g,title:"Cancel",children:h.jsx(Qa,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),v&&h.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:v}),o.length===0&&!u&&h.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),o.map(A=>h.jsxs("button",{className:X("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left",A.type==="dir"?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{A.type==="dir"&&b(A.path)},disabled:A.type==="file",children:[A.type==="dir"?h.jsx(hm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):h.jsx(Hj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:"truncate",children:A.name})]},A.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(le,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const tM=[{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)"}],Nm={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 nM({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,x]=p.useState(!1),[v,S]=p.useState(null),g=()=>{s("name"),i(""),l(""),d("claude"),f("limited"),S(null),x(!1)},m=k=>{k||g(),t(k)},w=()=>{if(!o.trim()){S("Please enter a project name");return}S(null),s("folder")},b=k=>{l(k),s("settings")},C=async()=>{x(!0),S(null);try{const k=await dx({name:o.trim(),folderPath:a,permissionMode:u,cliTool:c});n(k),m(!1)}catch(k){S(k instanceof Error?k.message:"Failed to create project")}finally{x(!1)}},P={name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"},E=["name","folder","settings"];return h.jsx(yf,{open:e,onOpenChange:m,children:h.jsxs(el,{className:"sm:max-w-lg",children:[h.jsxs(tl,{children:[h.jsx(rl,{children:P[r]}),h.jsxs(sl,{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:E.map((k,j)=>h.jsx("div",{className:`h-1.5 flex-1 rounded-full ${r===k?"bg-primary":E.indexOf(r)>j?"bg-primary/40":"bg-muted"}`},k))}),r==="name"&&h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{htmlFor:"project-name",children:"Project Name"}),h.jsx(xo,{id:"project-name",placeholder:"My Project",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.key==="Enter"&&w()},autoFocus:!0})]}),v&&h.jsx("p",{className:"text-sm text-destructive",children:v})]}),r==="folder"&&h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{children:"Working Directory"}),h.jsx(cw,{onSelect:b})]}),r==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{children:"AI Coding Tool"}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:tM.map(k=>h.jsxs("label",{className:`flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors ${c===k.value?"border-primary bg-primary/5":"hover:bg-accent"}`,children:[h.jsx("input",{type:"radio",name:"cliTool",value:k.value,checked:c===k.value,onChange:()=>d(k.value),className:"accent-primary"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:k.label}),h.jsx("div",{className:"text-xs text-muted-foreground",children:k.desc})]})]},k.value))})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{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:Nm[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:Nm[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})]}),v&&h.jsx("p",{className:"text-sm text-destructive",children:v})]}),h.jsxs(nl,{children:[r!=="name"&&h.jsx(le,{variant:"outline",onClick:()=>s(r==="settings"?"folder":"name"),disabled:y,children:"Back"}),r==="name"&&h.jsx(le,{onClick:w,children:"Next"}),r==="folder"&&h.jsx(le,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r==="settings"&&h.jsx(le,{onClick:()=>void C(),disabled:y,children:y?"Creating...":"Create Project"})]})]})})}function rM({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 fx(f);n(y),d(!1)}catch(y){l(y instanceof Error?y.message:"Failed to open project"),i(!1)}};return h.jsx(yf,{open:e,onOpenChange:d,children:h.jsxs(el,{className:"sm:max-w-lg",children:[h.jsxs(tl,{children:[h.jsx(rl,{children:"Open Existing Project"}),h.jsxs(sl,{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(Rn,{children:"Project Folder"}),h.jsx(cw,{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(nl,{children:h.jsx(le,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"})})]})})}function sM(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 oM=e=>{switch(e){case"success":return lM;case"info":return cM;case"warning":return uM;case"error":return dM;default:return null}},iM=Array(12).fill(0),aM=({visible:e,className:t})=>M.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},M.createElement("div",{className:"sonner-spinner"},iM.map((n,r)=>M.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),lM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),uM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},M.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"})),cM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),dM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),fM=M.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"},M.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),M.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),hM=()=>{const[e,t]=M.useState(document.hidden);return M.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Lc=1;class pM{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:Lc++,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],M.isValidElement(c))o=!1,this.create({id:r,type:"default",message:c});else if(gM(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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...x})}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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...x})}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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:f,...x})}}).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"&&!M.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)||Lc++;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 pM,mM=(e,t)=>{const n=(t==null?void 0:t.id)||Lc++;return et.addToast({title:e,...t,id:n}),n},gM=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",yM=mM,vM=()=>et.toasts,xM=()=>et.getActiveToasts(),_s=Object.assign(yM,{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:vM,getToasts:xM});sM("[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 ci(e){return e.label!==void 0}const wM=3,SM="24px",bM="16px",Rm=4e3,EM=356,kM=14,CM=45,PM=200;function Ft(...e){return e.filter(Boolean).join(" ")}function TM(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const jM=e=>{var t,n,r,s,o,i,a,l,c;const{invert:d,toast:u,unstyled:f,interacting:y,setHeights:x,visibleToasts:v,heights:S,index:g,toasts:m,expanded:w,removeToast:b,defaultRichColors:C,closeButton:P,style:E,cancelButtonStyle:k,actionButtonStyle:j,className:T="",descriptionClassName:A="",duration:L,position:G,gap:oe,expandByDefault:ae,classNames:z,icons:Q,closeButtonAriaLabel:N="Close toast"}=e,[_,I]=M.useState(null),[B,ne]=M.useState(null),[U,Z]=M.useState(!1),[Y,me]=M.useState(!1),[Je,te]=M.useState(!1),[Qt,dn]=M.useState(!1),[Zt,It]=M.useState(!1),[ys,Xn]=M.useState(0),[ol,Qn]=M.useState(0),fn=M.useRef(u.duration||L||Rm),Lo=M.useRef(null),Et=M.useRef(null),il=g===0,al=g+1<=v,ze=u.type,R=u.dismissible!==!1,$=u.className||"",q=u.descriptionClassName||"",re=M.useMemo(()=>S.findIndex(W=>W.toastId===u.id)||0,[S,u.id]),ce=M.useMemo(()=>{var W;return(W=u.closeButton)!=null?W:P},[u.closeButton,P]),Te=M.useMemo(()=>u.duration||L||Rm,[u.duration,L]),Ge=M.useRef(0),ye=M.useRef(0),Zn=M.useRef(0),hn=M.useRef(null),[mw,gw]=G.split("-"),xf=M.useMemo(()=>S.reduce((W,Me,Be)=>Be>=re?W:W+Me.height,0),[S,re]),wf=hM(),yw=u.invert||d,ll=ze==="loading";ye.current=M.useMemo(()=>re*oe+xf,[re,xf]),M.useEffect(()=>{fn.current=Te},[Te]),M.useEffect(()=>{Z(!0)},[]),M.useEffect(()=>{const W=Et.current;if(W){const Me=W.getBoundingClientRect().height;return Qn(Me),x(Be=>[{toastId:u.id,height:Me,position:u.position},...Be]),()=>x(Be=>Be.filter(it=>it.toastId!==u.id))}},[x,u.id]),M.useLayoutEffect(()=>{if(!U)return;const W=Et.current,Me=W.style.height;W.style.height="auto";const Be=W.getBoundingClientRect().height;W.style.height=Me,Qn(Be),x(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])},[U,u.title,u.description,x,u.id,u.jsx,u.action,u.cancel]);const pn=M.useCallback(()=>{me(!0),Xn(ye.current),x(W=>W.filter(Me=>Me.toastId!==u.id)),setTimeout(()=>{b(u)},PM)},[u,b,x,ye]);M.useEffect(()=>{if(u.promise&&ze==="loading"||u.duration===1/0||u.type==="loading")return;let W;return w||y||wf?(()=>{if(Zn.current<Ge.current){const it=new Date().getTime()-Ge.current;fn.current=fn.current-it}Zn.current=new Date().getTime()})():(()=>{fn.current!==1/0&&(Ge.current=new Date().getTime(),W=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),pn()},fn.current))})(),()=>clearTimeout(W)},[w,y,u,ze,wf,pn]),M.useEffect(()=>{u.delete&&(pn(),u.onDismiss==null||u.onDismiss.call(u,u))},[pn,u.delete]);function vw(){var W;if(Q!=null&&Q.loading){var Me;return M.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"},Q.loading)}return M.createElement(aM,{className:Ft(z==null?void 0:z.loader,u==null||(W=u.classNames)==null?void 0:W.loader),visible:ze==="loading"})}const xw=u.icon||(Q==null?void 0:Q[ze])||oM(ze);var Sf,bf;return M.createElement("li",{tabIndex:0,ref:Et,className:Ft(T,$,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":(Sf=u.richColors)!=null?Sf:C,"data-styled":!(u.jsx||u.unstyled||f),"data-mounted":U,"data-promise":!!u.promise,"data-swiped":Zt,"data-removed":Y,"data-visible":al,"data-y-position":mw,"data-x-position":gw,"data-index":g,"data-front":il,"data-swiping":Je,"data-dismissible":R,"data-type":ze,"data-invert":yw,"data-swipe-out":Qt,"data-swipe-direction":B,"data-expanded":!!(w||ae&&U),"data-testid":u.testId,style:{"--index":g,"--toasts-before":g,"--z-index":m.length-g,"--offset":`${Y?ys:ye.current}px`,"--initial-height":ae?"auto":`${ol}px`,...E,...u.style},onDragEnd:()=>{te(!1),I(null),hn.current=null},onPointerDown:W=>{W.button!==2&&(ll||!R||(Lo.current=new Date,Xn(ye.current),W.target.setPointerCapture(W.pointerId),W.target.tagName!=="BUTTON"&&(te(!0),hn.current={x:W.clientX,y:W.clientY})))},onPointerUp:()=>{var W,Me,Be;if(Qt||!R)return;hn.current=null;const it=Number(((W=Et.current)==null?void 0:W.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),_o=Number(((Me=Et.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Be=Lo.current)==null?void 0:Be.getTime()),pt=_==="x"?it:_o,Oo=Math.abs(pt)/Le;if(Math.abs(pt)>=CM||Oo>.11){Xn(ye.current),u.onDismiss==null||u.onDismiss.call(u,u),ne(_==="x"?it>0?"right":"left":_o>0?"down":"up"),pn(),dn(!0);return}else{var kt,Ct;(kt=Et.current)==null||kt.style.setProperty("--swipe-amount-x","0px"),(Ct=Et.current)==null||Ct.style.setProperty("--swipe-amount-y","0px")}It(!1),te(!1),I(null)},onPointerMove:W=>{var Me,Be,it;if(!hn.current||!R||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;const Le=W.clientY-hn.current.y,pt=W.clientX-hn.current.x;var Oo;const kt=(Oo=e.swipeDirections)!=null?Oo:TM(G);!_&&(Math.abs(pt)>1||Math.abs(Le)>1)&&I(Math.abs(pt)>Math.abs(Le)?"x":"y");let Ct={x:0,y:0};const Ef=qn=>1/(1.5+Math.abs(qn)/20);if(_==="y"){if(kt.includes("top")||kt.includes("bottom"))if(kt.includes("top")&&Le<0||kt.includes("bottom")&&Le>0)Ct.y=Le;else{const qn=Le*Ef(Le);Ct.y=Math.abs(qn)<Math.abs(Le)?qn:Le}}else if(_==="x"&&(kt.includes("left")||kt.includes("right")))if(kt.includes("left")&&pt<0||kt.includes("right")&&pt>0)Ct.x=pt;else{const qn=pt*Ef(pt);Ct.x=Math.abs(qn)<Math.abs(pt)?qn:pt}(Math.abs(Ct.x)>0||Math.abs(Ct.y)>0)&&It(!0),(Be=Et.current)==null||Be.style.setProperty("--swipe-amount-x",`${Ct.x}px`),(it=Et.current)==null||it.style.setProperty("--swipe-amount-y",`${Ct.y}px`)}},ce&&!u.jsx&&ze!=="loading"?M.createElement("button",{"aria-label":N,"data-disabled":ll,"data-close-button":!0,onClick:ll||!R?()=>{}:()=>{pn(),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)},(bf=Q==null?void 0:Q.close)!=null?bf:fM):null,(ze||u.icon||u.promise)&&u.icon!==null&&((Q==null?void 0:Q[ze])!==null||u.icon)?M.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||vw():null,u.type!=="loading"?xw:null):null,M.createElement("div",{"data-content":"",className:Ft(z==null?void 0:z.content,u==null||(o=u.classNames)==null?void 0:o.content)},M.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?M.createElement("div",{"data-description":"",className:Ft(A,q,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),M.isValidElement(u.cancel)?u.cancel:u.cancel&&ci(u.cancel)?M.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||k,onClick:W=>{ci(u.cancel)&&R&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,W),pn())},className:Ft(z==null?void 0:z.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,M.isValidElement(u.action)?u.action:u.action&&ci(u.action)?M.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||j,onClick:W=>{ci(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,W),!W.defaultPrevented&&pn())},className:Ft(z==null?void 0:z.actionButton,u==null||(c=u.classNames)==null?void 0:c.actionButton)},u.action.label):null)};function Mm(){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 NM(e,t){const n={};return[e,t].forEach((r,s)=>{const o=s===1,i=o?"--mobile-offset":"--offset",a=o?bM:SM;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 RM=M.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:x,style:v,visibleToasts:S=wM,toastOptions:g,dir:m=Mm(),gap:w=kM,icons:b,containerAriaLabel:C="Notifications"}=t,[P,E]=M.useState([]),k=M.useMemo(()=>r?P.filter(U=>U.toasterId===r):P.filter(U=>!U.toasterId),[P,r]),j=M.useMemo(()=>Array.from(new Set([o].concat(k.filter(U=>U.position).map(U=>U.position)))),[k,o]),[T,A]=M.useState([]),[L,G]=M.useState(!1),[oe,ae]=M.useState(!1),[z,Q]=M.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),N=M.useRef(null),_=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=M.useRef(null),B=M.useRef(!1),ne=M.useCallback(U=>{E(Z=>{var Y;return(Y=Z.find(me=>me.id===U.id))!=null&&Y.delete||et.dismiss(U.id),Z.filter(({id:me})=>me!==U.id)})},[]);return M.useEffect(()=>et.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{E(Z=>Z.map(Y=>Y.id===U.id?{...Y,delete:!0}:Y))});return}setTimeout(()=>{Gy.flushSync(()=>{E(Z=>{const Y=Z.findIndex(me=>me.id===U.id);return Y!==-1?[...Z.slice(0,Y),{...Z[Y],...U},...Z.slice(Y+1)]:[U,...Z]})})})}),[P]),M.useEffect(()=>{if(f!=="system"){Q(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Q("dark"):Q("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:Z})=>{Q(Z?"dark":"light")})}catch{U.addListener(({matches:Y})=>{try{Q(Y?"dark":"light")}catch(me){console.error(me)}})}},[f]),M.useEffect(()=>{P.length<=1&&G(!1)},[P]),M.useEffect(()=>{const U=Z=>{var Y;if(i.every(te=>Z[te]||Z.code===te)){var Je;G(!0),(Je=N.current)==null||Je.focus()}Z.code==="Escape"&&(document.activeElement===N.current||(Y=N.current)!=null&&Y.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),M.useEffect(()=>{if(N.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,B.current=!1)}},[N.current]),M.createElement("section",{ref:n,"aria-label":`${C} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((U,Z)=>{var Y;const[me,Je]=U.split("-");return k.length?M.createElement("ol",{key:U,dir:m==="auto"?Mm():m,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":me,"data-x-position":Je,style:{"--front-toast-height":`${((Y=T[0])==null?void 0:Y.height)||0}px`,"--width":`${EM}px`,"--gap":`${w}px`,...v,...NM(d,u)},onBlur:te=>{B.current&&!te.currentTarget.contains(te.relatedTarget)&&(B.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||B.current||(B.current=!0,I.current=te.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{oe||G(!1)},onDragEnd:()=>G(!1),onPointerDown:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},k.filter(te=>!te.position&&Z===0||te.position===U).map((te,Qt)=>{var dn,Zt;return M.createElement(jM,{key:te.id,icons:b,index:Qt,toast:te,defaultRichColors:y,duration:(dn=g==null?void 0:g.duration)!=null?dn:x,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:s,visibleToasts:S,closeButton:(Zt=g==null?void 0:g.closeButton)!=null?Zt:l,interacting:oe,position:U,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,closeButtonAriaLabel:g==null?void 0:g.closeButtonAriaLabel,removeToast:ne,toasts:k.filter(It=>It.position==te.position),heights:T.filter(It=>It.position==te.position),setHeights:A,expandByDefault:a,gap:w,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),dw=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,fw=5,hw=3e3;function hD(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(x=>{var v;((v=n.current)==null?void 0:v.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(x))},[]),c=p.useCallback((x,v)=>{var S;((S=n.current)==null?void 0:S.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:x,rows:v})),a.current=!1):a.current=!0},[]),d=p.useCallback(x=>{l({type:"terminal_input",data:x})},[l]),u=p.useCallback((x,v)=>{l({type:"terminal_resize",cols:x,rows:v})},[l]),f=p.useCallback(()=>{l({type:"chat_subscribe"})},[l]),y=p.useCallback(()=>{if(!s.current||o.current)return;const x=gs();if(!x){window.location.href="/login";return}o.current=!0;const v=new WebSocket(`${dw}/ws/projects/${e}`);n.current=v,v.onopen=()=>{o.current=!1,r.current=0,v.send(JSON.stringify({type:"auth",token:x}))},v.onmessage=S=>{var m,w,b,C,P,E,k,j;let g;try{g=JSON.parse(S.data)}catch{return}switch(g.type){case"connected":a.current=!1,(w=(m=i.current).onConnected)==null||w.call(m);break;case"terminal_data":(C=(b=i.current).onTerminalData)==null||C.call(b,g.data);break;case"status":(E=(P=i.current).onStatus)==null||E.call(P,g.status);break;case"chat_message":{const T=g;(j=(k=i.current).onChatMessage)==null||j.call(k,T);break}case"error":console.error("[WS] Server error:",g.message);break}},v.onclose=()=>{o.current=!1,n.current=null,s.current&&r.current<fw&&(r.current++,setTimeout(y,hw))},v.onerror=S=>{o.current=!1,console.error("[WS] WebSocket error:",S)}},[e]);return p.useEffect(()=>(s.current=!0,y(),()=>{var x;s.current=!1,(x=n.current)==null||x.close(),n.current=null}),[y]),{subscribeTerminal:c,sendTerminalInput:d,sendTerminalResize:u,subscribeChatMessages:f}}function MM(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=gs();if(!a)return;s.current=!0;const l=new WebSocket(`${dw}/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<fw&&(n.current++,setTimeout(i,hw))},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 DM(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 Dm=5*36e5;function AM(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=Dm-t;return n<=0?null:Math.round(e.utilization/(n/Dm))}function di({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=DM(t.resetAt);return h.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",h.jsxs("span",{className:X("font-medium",r),children:[n,"%"]}),s&&h.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",s,")"]})]})}function LM({className:e}){const[t,n]=p.useState("loading"),[r,s]=p.useState(!1);p.useEffect(()=>{const f=async()=>{try{n(await wx())}catch{n(null)}};f();const y=setInterval(()=>void f(),5*60*1e3);return()=>clearInterval(y)},[]);const o=async()=>{s(!0);try{n(await Sx())}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=AM(t.fiveHour);return h.jsxs("div",{className:X("flex items-center gap-1.5 text-xs",e),children:[u!==null&&h.jsxs("span",{className:X("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(di,{label:"5h",bucket:t.fiveHour}),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{label:"7d",bucket:t.sevenDay})]}),l&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{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(nN,{className:X("h-3 w-3",r&&"animate-spin")})})]})}function _M(){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(""),[x,v]=p.useState(""),[S,g]=p.useState(""),m=p.useRef(null),w=p.useRef(null);p.useEffect(()=>{gx().then(t).catch(()=>t([]))},[]),p.useEffect(()=>{n&&setTimeout(()=>{var E;return(E=m.current)==null?void 0:E.focus()},0)},[n]),p.useEffect(()=>{d&&setTimeout(()=>{var E;return(E=w.current)==null?void 0:E.focus()},0)},[d]);const b=async()=>{const E=i.trim();if(E)try{const k=await yx({label:s.trim()||E,command:E,...l?{parentId:l}:{}});t(j=>[...j,k]),o(""),a(""),c(""),r(!1)}catch(k){console.error("[GlobalShortcuts] Failed to add:",k)}},C=async E=>{try{await xx(E),t(k=>k.filter(j=>j.id!==E)),d===E&&u(null)}catch(k){console.error("[GlobalShortcuts] Failed to delete:",k)}},P=async()=>{const E=x.trim();if(!(!E||!d))try{const k=await vx(d,{label:f.trim()||E,command:E,parentId:S||null});t(j=>j.map(T=>T.id===d?k:T)),u(null)}catch(k){console.error("[GlobalShortcuts] Failed to save:",k)}};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(mm,{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(E=>!E),u(null)},className:X("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(ya,{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:m,placeholder:"名称(可选)",value:s,onChange:E=>o(E.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:E=>a(E.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:E=>{E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),b()),E.key==="Escape"&&(r(!1),o(""),a(""),c(""))}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(tu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:l,onChange:E=>c(E.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(E=>h.jsx("option",{value:E.id,children:E.label},E.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 b(),disabled:!i.trim(),className:X("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(mm,{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(E=>d===E.id?h.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[h.jsx("input",{ref:w,value:f,onChange:k=>y(k.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:x,onChange:k=>v(k.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:k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),P()),k.key==="Escape"&&u(null)}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(tu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:S,onChange:k=>g(k.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(k=>k.id!==E.id).map(k=>h.jsx("option",{value:k.id,children:k.label},k.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 P(),disabled:!x.trim(),className:X("text-xs px-2.5 py-1 rounded transition-colors text-white",x.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},E.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:E.label}),E.parentId&&(()=>{const k=e.find(j=>j.id===E.parentId);return k?h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(tu,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",k.label]})]}):null})(),!E.parentId&&E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:E.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(E.id),y(E.label),v(E.command),g(E.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:h.jsx(Tx,{className:"h-3.5 w-3.5"})}),h.jsx("button",{onClick:()=>void C(E.id),className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:h.jsx(Qa,{className:"h-3.5 w-3.5"})})]})]},E.id))})]})}const pw=p.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function OM(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function IM(){return p.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>OM())}function VM({children:e}){const[t,n]=p.useState(()=>ox(pr.theme,"system")),r=IM(),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),ix(pr.theme,i)};return h.jsx(pw.Provider,{value:{theme:t,resolved:s,setTheme:o},children:e})}function FM(){return p.useContext(pw)}function zM(){const{theme:e,setTheme:t}=FM(),n=[{value:"light",icon:iN,label:"浅色"},{value:"dark",icon:eN,label:"深色"},{value:"system",icon:Jj,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:X("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))})}const BM={workMinutes:30,breakMinutes:5};function xa(){return ox(pr.pomodoroConfig,BM,!0)}function $M(e){Notification.permission==="granted"&&new Notification("番茄钟",{body:e,icon:"/favicon.ico"})}const vf=Ya(e=>({running:!1,phase:"work",secondsLeft:xa().workMinutes*60,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function UM(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:s}=vf(),o=p.useCallback(i=>{const a=xa();r(i),s(i==="work"?a.workMinutes*60:a.breakMinutes*60),$M(i==="break"?"休息一下 ☕":"该工作了 💻")},[r,s]);return p.useEffect(()=>{if(!e)return;if(n===0){o(t==="work"?"break":"work");return}const i=setTimeout(()=>s(n-1),1e3);return()=>clearTimeout(i)},[e,n,t,o,s]),null}function WM(){const{running:e,phase:t,secondsLeft:n}=vf(),r=Math.floor(n/60),s=n%60,o=`${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`;return e?Ia.createPortal(h.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none",style:{opacity:t==="work"?.1:.6},children:[h.jsx("div",{className:X("font-mono font-bold tabular-nums leading-none",t==="work"?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:"clamp(180px, 45vw, 550px)"},children:o}),h.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:t==="work"?"专注工作":"休息一下"})]}),document.body):null}function HM(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:s,setSecondsLeft:o}=vf(),i=Math.floor(n/60),a=n%60,l=`${String(i).padStart(2,"0")}:${String(a).padStart(2,"0")}`,c=()=>{if(e){const d=xa();s("work"),o(d.workMinutes*60)}else{const d=xa();s("work"),o(d.workMinutes*60),Notification.permission==="default"&&Notification.requestPermission()}r(!e)};return h.jsx("button",{onClick:c,className:X("p-1 rounded transition-colors",e?t==="work"?"text-red-500 bg-red-500/10 hover:bg-red-500/20":"text-green-500 bg-green-500/10 hover:bg-green-500/20":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:e?t==="work"?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:h.jsx(aN,{className:"h-4 w-4"})})}function GM(){const e=za(),{projects:t,loading:n,error:r,fetchProjects:s,addProject:o,updateProject:i,removeProject:a}=fm(),l=wr(R=>R.clearToken),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[y,x]=p.useState(new Set),v=p.useRef(new Map),[S,g]=p.useState(new Map),m=p.useRef(0),[w,b]=p.useState(!!document.fullscreenElement),[C,P]=p.useState(!1),[E,k]=p.useState(""),[j,T]=p.useState([]),[A,L]=p.useState(!1);p.useEffect(()=>{if(!E.trim()||E.trim().length<2){T([]);return}const R=setTimeout(()=>{L(!0),kx(E).then($=>T($)).catch(()=>T([])).finally(()=>L(!1))},400);return()=>clearTimeout(R)},[E]);const G=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()};p.useEffect(()=>{const R=()=>b(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",R),()=>document.removeEventListener("fullscreenchange",R)},[]),p.useEffect(()=>{s()},[s]),p.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]);const oe=2e3,ae=3,z=8e3,Q=p.useCallback(R=>{if(R.status){const re=fm.getState().projects.find(ce=>ce.id===R.projectId);re&&re.status!==R.status&&i({...re,status:R.status})}const $=Date.now(),q=v.current;if($-R.lastActivityAt<oe){x(ye=>ye.has(R.projectId)?ye:new Set(ye).add(R.projectId));const re=q.get(R.projectId)??[];let ce=!1;if(R.semantic){const ye=re[re.length-1],Zn=`${R.semantic.phase}:${R.semantic.detail??""}`,hn=ye?`${ye.phase}:${ye.detail??""}`:"";Zn!==hn?(re.push({id:m.current++,phase:R.semantic.phase,detail:R.semantic.detail,ts:$}),ce=!0):ye&&(ye.ts=$)}const Te=re.filter(ye=>$-ye.ts<z),Ge=Te.length>ae?Te.slice(-ae):Te;Ge.length!==re.length&&(ce=!0),q.set(R.projectId,Ge),ce&&g(new Map(q))}else x(re=>{if(!re.has(R.projectId))return re;const ce=new Set(re);return ce.delete(R.projectId),ce}),q.has(R.projectId)&&q.get(R.projectId).length>0&&(q.set(R.projectId,[]),g(new Map(q)))},[]),N=p.useCallback((R,$)=>{"Notification"in window&&Notification.permission==="granted"?new Notification("Claude 已完成",{body:`项目「${$}」的任务已完成`,icon:"/terminal.svg"}):_s.success(`项目「${$}」的任务已完成`,{duration:8e3})},[]);MM({onActivityUpdate:Q,onProjectStopped:N}),p.useEffect(()=>{const R=setInterval(()=>{const $=Date.now(),q=v.current;let re=!1;for(const[ce,Te]of q){const Ge=Te.filter(ye=>$-ye.ts<z);Ge.length!==Te.length&&(q.set(ce,Ge),re=!0)}re&&g(new Map(q)),x(ce=>{let Te=!1;const Ge=new Set(ce);for(const ye of ce){const Zn=q.get(ye);(!Zn||Zn.length===0)&&(Ge.delete(ye),Te=!0)}return Te?Ge:ce})},3e3);return()=>clearInterval(R)},[]);const _=()=>{l(),e("/login")},I=R=>{o(R)},B=R=>{o(R)},ne=async R=>{try{await hx(R),a(R)}catch($){_s.error($ instanceof Error?$.message:"Failed to delete project")}},U=async R=>{try{const $=await px(R);i($)}catch($){_s.error($ instanceof Error?$.message:"Failed to archive project")}},Z=async R=>{try{const $=await mx(R);i($)}catch($){_s.error($ instanceof Error?$.message:"Failed to restore project")}},Y=p.useMemo(()=>t.filter(R=>!R.archived),[t]),me=p.useMemo(()=>t.filter(R=>R.archived),[t]),Je=p.useMemo(()=>Array.from(new Set(t.flatMap(R=>R.tags??[]))),[t]),[te,Qt]=p.useState([]),dn=p.useMemo(()=>te.length===0?Y:Y.filter(R=>te.some($=>{var q;return(q=R.tags)==null?void 0:q.includes($)})),[Y,te]),[Zt,It]=IT(pr.projectOrder,[],{parse:!0}),[ys,Xn]=p.useState(null),[ol,Qn]=p.useState(null);p.useEffect(()=>{if(Y.length===0)return;const R=Y.map($=>$.id);It($=>{const q=$.filter(Te=>R.includes(Te)),re=R.filter(Te=>!$.includes(Te)),ce=[...q,...re];return ce.join(",")===$.join(",")?$:ce})},[Y]);const fn=p.useMemo(()=>Zt.length===0?dn:[...dn].sort((R,$)=>{const q=Zt.indexOf(R.id),re=Zt.indexOf($.id);return q===-1?1:re===-1?-1:q-re}),[dn,Zt]),Lo=p.useCallback(R=>Xn(R),[]),Et=p.useCallback(()=>{Xn(null),Qn(null)},[]),il=p.useCallback((R,$)=>{R.preventDefault(),Qn($)},[]),al=p.useCallback((R,$,q)=>{if(R.preventDefault(),!q||q===$){Qn(null);return}It(re=>{const ce=[...re],Te=ce.indexOf(q),Ge=ce.indexOf($);return Te===-1||Ge===-1?re:(ce.splice(Te,1),ce.splice(Ge,0,q),ce)}),Xn(null),Qn(null)},[It]),ze={onDelete:R=>void ne(R),onArchive:R=>void U(R),onUnarchive:R=>void Z(R),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(pm,{className:"h-5 w-5"}),h.jsx("span",{className:"font-semibold text-lg",children:"CC Web"})]}),h.jsx(LM,{}),h.jsxs("div",{className:"relative",children:[h.jsx(rN,{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(xo,{placeholder:"搜索历史对话…",value:E,onChange:R=>k(R.target.value),className:"pl-8 h-8 text-xs w-48"}),E.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:[A&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"搜索中…"}),!A&&j.length===0&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"无结果"}),j.map((R,$)=>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/${R.projectId}`),k("")},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:R.projectName}),h.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:new Date(R.startedAt).toLocaleDateString("zh-CN")})]}),h.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:R.snippet})]},$))]})]}),h.jsx(le,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"SkillHub",children:h.jsx(oN,{className:"h-4 w-4"})}),h.jsx(le,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:h.jsx(sN,{className:"h-4 w-4"})}),h.jsx(le,{variant:"ghost",size:"sm",onClick:G,title:w?"Exit fullscreen":"Fullscreen",children:w?h.jsx(Zj,{className:"h-4 w-4"}):h.jsx(Qj,{className:"h-4 w-4"})}),h.jsx(HM,{}),h.jsx(zM,{}),h.jsxs(le,{variant:"ghost",size:"sm",onClick:_,children:[h.jsx(Xj,{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(le,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(le,{onClick:()=>d(!0),children:[h.jsx(ya,{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(pm,{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(le,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(le,{onClick:()=>d(!0),children:[h.jsx(ya,{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(R=>h.jsxs("button",{onClick:()=>Qt($=>$.includes(R)?$.filter(q=>q!==R):[...$,R]),className:X("px-2 py-0.5 rounded-full text-xs border transition-colors",te.includes(R)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",R]},R)),te.length>0&&h.jsx("button",{onClick:()=>Qt([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&fn.length>0&&h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:fn.map((R,$)=>h.jsx(Yt.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:$*.05,ease:"easeOut"},draggable:!0,onDragStart:()=>Lo(R.id),onDragOver:q=>il(q,R.id),onDrop:q=>al(q,R.id,ys),onDragEnd:Et,style:{opacity:ys===R.id?.4:1,cursor:"grab"},className:X(ol===R.id&&ys!==R.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:h.jsx(jm,{project:R,active:y.has(R.id),statusStack:S.get(R.id)??[],...ze})},R.id))}),!n&&!r&&me.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:()=>P(R=>!R),children:[h.jsx(Yt.span,{animate:{rotate:C?90:0},transition:{duration:.2},children:h.jsx(Px,{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:me.length})]}),h.jsx(Ha,{children:C&&h.jsx(Yt.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:me.map(R=>h.jsx(jm,{project:R,active:!1,...ze},R.id))})})})]}),h.jsx(_M,{})]}),h.jsx(nM,{open:c,onOpenChange:d,onCreated:I}),h.jsx(rM,{open:u,onOpenChange:f,onOpened:B})]})}class KM extends M.Component{constructor(){super(...arguments);ul(this,"state",{hasError:!1,error:null});ul(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),_s.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}}function YM({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:s}=e,[o,i]=p.useState(()=>{var P,E;return{x:((P=s.floatPosition)==null?void 0:P.x)??window.innerWidth*.5-r.defaultWidth/2,y:((E=s.floatPosition)==null?void 0:E.y)??window.innerHeight*.3}}),[a,l]=p.useState(()=>{var P,E;return{w:((P=s.floatSize)==null?void 0:P.w)??r.defaultWidth,h:((E=s.floatSize)==null?void 0:E.h)??r.defaultHeight}}),[c,d]=p.useState(!1),[u,f]=p.useState(100),y=p.useRef(null),x=p.useRef(null),v=p.useCallback(()=>{f(Date.now()%1e5+100)},[]),S=p.useRef(null),g=p.useCallback(P=>{P.preventDefault(),v(),S.current={sx:P.clientX,sy:P.clientY,ox:o.x,oy:o.y},x.current&&(x.current.style.pointerEvents="none");const E=j=>{if(!S.current)return;const T=Math.max(0,Math.min(window.innerWidth-100,S.current.ox+j.clientX-S.current.sx)),A=Math.max(0,Math.min(window.innerHeight-40,S.current.oy+j.clientY-S.current.sy));y.current&&(y.current.style.left=T+"px",y.current.style.top=A+"px")},k=j=>{if(!S.current)return;const T=Math.max(0,Math.min(window.innerWidth-100,S.current.ox+j.clientX-S.current.sx)),A=Math.max(0,Math.min(window.innerHeight-40,S.current.oy+j.clientY-S.current.sy));S.current=null,x.current&&(x.current.style.pointerEvents=""),i({x:T,y:A}),t(e.id,{floatPosition:{x:T,y:A}}),window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",k)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",k)},[o,v,e.id,t]),m=p.useRef(null),w=p.useCallback(P=>{if(!r.resizable)return;P.preventDefault(),P.stopPropagation(),v(),m.current={sx:P.clientX,sy:P.clientY,ow:a.w,oh:a.h},x.current&&(x.current.style.pointerEvents="none");const E=r.minWidth??150,k=r.minHeight??100,j=A=>{if(!m.current)return;const L=Math.max(E,m.current.ow+A.clientX-m.current.sx),G=Math.max(k,m.current.oh+A.clientY-m.current.sy);y.current&&(y.current.style.width=L+"px",y.current.style.height=G+"px")},T=A=>{if(!m.current)return;const L=Math.max(E,m.current.ow+A.clientX-m.current.sx),G=Math.max(k,m.current.oh+A.clientY-m.current.sy);m.current=null,x.current&&(x.current.style.pointerEvents=""),l({w:L,h:G}),t(e.id,{floatSize:{w:L,h:G}}),window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",T)},[a,r,v,e.id,t]);p.useEffect(()=>{const P=async E=>{var A,L,G,oe,ae;if(E.source!==((A=x.current)==null?void 0:A.contentWindow))return;const{callId:k,method:j,args:T}=E.data;if(!(!k||!j))try{const z=gs(),Q={"Content-Type":"application/json","X-Plugin-Id":e.id};z&&(Q.Authorization=`Bearer ${z}`);let N,_;if(j==="storage:get")N=`/api/plugin-bridge/storage/${e.id}`,_={method:"GET",headers:Q};else if(j==="storage:set")N=`/api/plugin-bridge/storage/${e.id}`,_={method:"PUT",headers:Q,body:JSON.stringify(T)};else{const ne={"project:status":{path:`/api/plugin-bridge/project/status/${T.projectId}`,httpMethod:"GET"},"project:list":{path:"/api/plugin-bridge/project/list",httpMethod:"GET"},"terminal:send":{path:"/api/plugin-bridge/terminal/send",httpMethod:"POST"},"session:read":{path:`/api/plugin-bridge/session/${T.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if(j==="backend:api"){const{method:U,path:Z,body:Y}=T;N=`/api/plugins/${e.id}${Z}`,_={method:U||"GET",headers:Q},Y&&(U==="POST"||U==="PUT")&&(_.body=JSON.stringify(Y))}else{const U=ne[j];if(!U)throw new Error(`Unknown method: ${j}`);N=U.path,_={method:U.httpMethod,headers:Q},U.httpMethod==="POST"&&(_.body=JSON.stringify(T))}}const B=await(await fetch(N,_)).json();(G=(L=x.current)==null?void 0:L.contentWindow)==null||G.postMessage({callId:k,result:B,error:null},"*")}catch(z){const Q=z instanceof Error?z.message:"Bridge error";(ae=(oe=x.current)==null?void 0:oe.contentWindow)==null||ae.postMessage({callId:k,result:null,error:Q},"*")}};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[e.id]);const b=s.clickable??r.clickable.default,C=`/plugins/${e.id}/${e.float?"index.html":""}`;return h.jsxs(Yt.div,{ref:y,className:X("fixed rounded-lg border border-border shadow-xl overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:o.x,top:o.y,width:c?200:a.w,height:c?32:a.h,zIndex:u},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:v,children:[h.jsxs("div",{className:"h-8 flex items-center gap-1 px-2 bg-muted/50 border-b border-border cursor-grab active:cursor-grabbing flex-shrink-0 select-none",onMouseDown:g,children:[h.jsx(Kj,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),h.jsx("button",{onClick:()=>d(P=>!P),className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground/60 hover:text-foreground transition-colors",children:h.jsx(qj,{className:"h-3 w-3"})}),h.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 rounded hover:bg-red-500/20 text-muted-foreground/60 hover:text-red-400 transition-colors",children:h.jsx(Qa,{className:"h-3 w-3"})})]}),!c&&h.jsxs("div",{className:"flex-1 min-h-0 relative",children:[h.jsx("iframe",{ref:x,src:C,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:b?"auto":"none"}}),r.resizable&&h.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:w,children:h.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[h.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),h.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function XM({plugins:e,onPluginsChange:t,onClose:n}){const r=p.useCallback(async(s,o)=>{t(i=>i.map(a=>a.id===s?{...a,userConfig:{...a.userConfig,...o}}:a));try{await Cx(s,o)}catch{}},[t]);return e.length===0?null:h.jsx(Ha,{children:e.map(s=>h.jsx(YM,{plugin:s,onConfigChange:r,onClose:n},s.id))})}function QM({onTogglePlugin:e,activeIds:t}){const[n,r]=p.useState([]);return p.useEffect(()=>{ga().then(s=>r(s.filter(o=>o.enabled))).catch(()=>r([]))},[]),p.useEffect(()=>{const s=()=>{ga().then(o=>r(o.filter(i=>i.enabled))).catch(()=>{})};return window.addEventListener("focus",s),()=>window.removeEventListener("focus",s)},[]),n.length===0?null:h.jsx("div",{className:"border-b border-border bg-muted/30 px-4",children:h.jsxs("div",{className:"max-w-6xl mx-auto flex items-center gap-1 h-9 overflow-x-auto",children:[h.jsx(tN,{className:"h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0 mr-1"}),n.map(s=>{const o=t.has(s.id);return h.jsxs(Yt.button,{onClick:()=>e(s),className:X("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs transition-colors flex-shrink-0",o?"bg-blue-500/15 text-blue-400 border border-blue-500/30":"text-muted-foreground hover:text-foreground hover:bg-muted"),whileHover:{scale:1.02},whileTap:{scale:.98},title:s.description,children:[h.jsx("span",{className:X("h-1.5 w-1.5 rounded-full flex-shrink-0",o?"bg-blue-400":"bg-muted-foreground/30")}),s.name]},s.id)})]})})}const ZM=M.lazy(()=>To(()=>import("./ProjectPage-BmYhTTYq.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ProjectPage}))),qM=M.lazy(()=>To(()=>import("./SettingsPage-C30iHtBo.js"),__vite__mapDeps([7,3,1])).then(e=>({default:e.SettingsPage}))),JM=M.lazy(()=>To(()=>import("./SkillHubPage-BSb-9jya.js"),__vite__mapDeps([8,2,5,3])).then(e=>({default:e.SkillHubPage}))),eD=M.lazy(()=>To(()=>import("./ShareViewPage-BGAvzqO1.js"),__vite__mapDeps([9,5,4])).then(e=>({default:e.ShareViewPage})));function tD(){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 fi({children:e}){const[t,n]=p.useState(!1),r=wr(o=>o.token),s=wr(o=>o.setToken);return p.useEffect(()=>{if(r){n(!0);return}ma()?hf().then(o=>s(o)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),!t&&!r?null:r?h.jsx(h.Fragment,{children:e}):h.jsx(ov,{to:"/login",replace:!0})}function nD(){const[e,t]=p.useState([]),[n,r]=p.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),s=Fa();p.useEffect(()=>{ga().then(t).catch(()=>t([]))},[]);const o=p.useCallback(d=>{r(u=>{const f=new Set(u);f.has(d.id)?f.delete(d.id):f.add(d.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...f]))}catch{}return f})},[]),i=p.useCallback(d=>{r(u=>{const f=new Set(u);f.delete(d);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...f]))}catch{}return f})},[]),a=rD(s.pathname),l=e.filter(d=>{if(!d.enabled||!n.has(d.id))return!1;switch(d.userConfig.scope??d.float.scope.default){case"global":return!0;case"dashboard":return a.type==="dashboard";case"project":return a.type==="project";case"project:specific":return a.type==="project"&&(d.userConfig.projectIds??[]).includes(a.projectId??"");default:return!1}}),c=s.pathname==="/login";return h.jsxs(h.Fragment,{children:[!c&&h.jsx(QM,{onTogglePlugin:o,activeIds:n}),h.jsx(XM,{plugins:l,onPluginsChange:t,onClose:i})]})}function rD(e){if(e==="/"||e==="/dashboard")return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}function sD(){return h.jsxs(VM,{children:[h.jsx(RM,{richColors:!0,position:"bottom-right"}),h.jsx(UM,{}),h.jsx(WM,{}),h.jsx(KM,{children:h.jsxs(Ub,{children:[h.jsx(nD,{}),h.jsx(p.Suspense,{fallback:h.jsx(tD,{}),children:h.jsxs(zb,{children:[h.jsx(vn,{path:"/login",element:h.jsx(Ij,{})}),h.jsx(vn,{path:"/",element:h.jsx(fi,{children:h.jsx(GM,{})})}),h.jsx(vn,{path:"/projects/:id",element:h.jsx(fi,{children:h.jsx(ZM,{})})}),h.jsx(vn,{path:"/settings",element:h.jsx(fi,{children:h.jsx(qM,{})})}),h.jsx(vn,{path:"/skillhub",element:h.jsx(fi,{children:h.jsx(JM,{})})}),h.jsx(vn,{path:"/share/:token",element:h.jsx(eD,{})}),h.jsx(vn,{path:"*",element:h.jsx(ov,{to:"/",replace:!0})})]})})]})})]})}cu.createRoot(document.getElementById("root")).render(h.jsx(M.StrictMode,{children:h.jsx(sD,{})}));export{tj as $,Ha as A,le as B,Px as C,Cj as D,Wj as E,Rc as F,QT as G,gx as H,xo as I,tu as J,JT as K,yf as L,Zj as M,el as N,tl as O,Tx as P,rl as Q,M as R,pr as S,sl as T,Rn as U,nl as V,qT as W,Qa as X,ZT as Y,mm as Z,To as _,aD as a,tN as a$,Tj as a0,KT as a1,YT as a2,jj as a3,za as a4,$j as a5,rr as a6,HM as a7,zM as a8,pj as a9,$x as aA,Dx as aB,Rx as aC,uj as aD,dj as aE,hj as aF,lf as aG,uf as aH,cf as aI,df as aJ,jx as aK,xa as aL,wj as aM,aN,cj as aO,mj as aP,yj as aQ,xj as aR,fj as aS,vj as aT,gj as aU,Sj as aV,ga as aW,Dj as aX,Aj as aY,_j as aZ,ej as a_,GT as aa,rN as ab,Rj as ac,OT as ad,Mj as ae,oN as af,hD as ag,LM as ah,uD as ai,IT as aj,fm as ak,pm as al,wo as am,kr as an,mN as ao,cn as ap,Fn as aq,cN as ar,Ka as as,nu as at,So as au,Za as av,Ia as aw,Lx as ax,MR as ay,HN as az,gs as b,nj as b0,Nj as b1,lD as b2,ee as c,oj as d,X as e,Qj as f,Am as g,rj as h,ox as i,h as j,dD as k,bx as l,nN as m,sj as n,hm as o,Yt as p,bj as q,p as r,ix as s,_s as t,FM as u,Uj as v,ij as w,ya as x,Ej as y,kj as z};
|
|
295
|
+
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},GR="DialogDescriptionWarning",KR=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sw(GR).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},YR=Hx,XR=Yx,ow=Xx,iw=Qx,aw=qx,lw=ew,QR=nw;const yf=YR,ZR=XR,uw=p.forwardRef(({className:e,...t},n)=>h.jsx(ow,{ref:n,className:X("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}));uw.displayName=ow.displayName;const el=p.forwardRef(({className:e,children:t,noOverlay:n,...r},s)=>h.jsxs(ZR,{children:[!n&&h.jsx(uw,{}),h.jsxs(iw,{ref:s,className:X("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),...r,children:[t,h.jsxs(QR,{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(Qa,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));el.displayName=iw.displayName;const tl=({className:e,...t})=>h.jsx("div",{className:X("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});tl.displayName="DialogHeader";const nl=({className:e,...t})=>h.jsx("div",{className:X("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});nl.displayName="DialogFooter";const rl=p.forwardRef(({className:e,...t},n)=>h.jsx(aw,{ref:n,className:X("text-lg font-semibold leading-none tracking-tight",e),...t}));rl.displayName=aw.displayName;const sl=p.forwardRef(({className:e,...t},n)=>h.jsx(lw,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));sl.displayName=lw.displayName;function qR({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 m=!1;return ux().then(w=>{m||a(w)}).catch(()=>{}),()=>{m=!0}},[t,e.id]);const f=new Set(s.map(m=>m.username)),y=i.filter(m=>m!==e.owner&&!f.has(m)),x=m=>{o(w=>[...w,{username:m,permission:"view"}])},v=m=>{o(w=>w.filter(b=>b.username!==m))},S=m=>{o(w=>w.map(b=>b.username===m?{...b,permission:b.permission==="view"?"edit":"view"}:b))},g=async()=>{c(!0),u(null);try{const m=await cx(e.id,s);r(m),n(!1)}catch(m){u(m instanceof Error?m.message:"Failed to update shares")}finally{c(!1)}};return h.jsx(yf,{open:t,onOpenChange:n,children:h.jsxs(el,{className:"sm:max-w-md",children:[h.jsxs(tl,{children:[h.jsxs(rl,{className:"flex items-center gap-2",children:[h.jsx(Mc,{className:"h-4 w-4"}),"共享设置"]}),h.jsx(sl,{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(m=>h.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[h.jsx("span",{className:"text-sm font-medium",children:m.username}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{onClick:()=>S(m.username),className:"focus:outline-none",children:h.jsx(rr,{variant:m.permission==="edit"?"default":"secondary",className:"cursor-pointer text-xs",children:m.permission==="edit"?"可编辑":"可见"})}),h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>v(m.username),children:h.jsx(jx,{className:"h-3.5 w-3.5"})})]})]},m.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(m=>h.jsxs(le,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>x(m),children:[h.jsx(ya,{className:"h-3 w-3"}),m]},m))})]}),d&&h.jsx("p",{className:"text-sm text-destructive",children:d}),h.jsxs(nl,{children:[h.jsx(le,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),h.jsx(le,{onClick:()=>void g(),disabled:l,children:l?"保存中...":"保存"})]})]})})}function JR(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 eM({status:e}){return h.jsx("span",{className:X("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 jm=M.memo(function({project:t,active:n=!1,statusStack:r=[],onDelete:s,onArchive:o,onUnarchive:i,onUpdated:a}){var m,w;const l=za(),[c,d]=p.useState(!1),u=!!t._sharedPermission,f=t._sharedPermission==="view",y=b=>{b.stopPropagation(),confirm(`Delete project "${t.name}"? This cannot be undone.`)&&s(t.id)},x=b=>{b.stopPropagation(),o(t.id)},v=b=>{b.stopPropagation(),i(t.id)},S=h.jsx(Yt.div,{whileHover:!t.archived&&!n?{y:-2}:{},transition:{duration:.2},children:h.jsxs(lf,{className:X("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(uf,{className:"pb-2",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsx(cf,{className:X("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(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:v,title:"Restore project",children:h.jsx(zj,{className:"h-3.5 w-3.5"})}):h.jsxs(h.Fragment,{children:[h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:b=>{b.stopPropagation(),d(!0)},title:"共享设置",children:h.jsx(Mc,{className:"h-3.5 w-3.5"})}),h.jsx(le,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:x,title:"Archive project",children:h.jsx(Bj,{className:"h-3.5 w-3.5"})})]}),h.jsx(le,{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(jx,{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(eM,{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(Ha,{mode:"wait",children:r.slice(-1).map(b=>h.jsx(Yt.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:JR(b.phase,b.detail)})},b.id))})})]})})]}),h.jsxs(df,{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[h.jsx(Rc,{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(Wj,{className:"h-3 w-3"}):h.jsx(Tx,{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(Mc,{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(b=>h.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",b]},b)),(((m=t.tags)==null?void 0:m.length)??0)>3&&h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",(((w=t.tags)==null?void 0:w.length)??0)-3]})]})]})]})}),g=n&&!t.archived?h.jsx("div",{className:"card-active-glow rounded-lg",children:S}):S;return h.jsxs(h.Fragment,{children:[g,!u&&a&&h.jsx(qR,{project:t,open:c,onOpenChange:d,onUpdated:a})]})});function cw({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,x]=p.useState(""),[v,S]=p.useState(null),[g,m]=p.useState(!1),w=p.useRef(null),b=async A=>{l(!0),d(null);try{const L=await bx(A);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(()=>{b()},[]),p.useEffect(()=>{u&&setTimeout(()=>{var A;return(A=w.current)==null?void 0:A.focus()},0)},[u]);const C=()=>{x(""),S(null),f(!0)},P=()=>{f(!1),x(""),S(null)},E=async()=>{const A=y.trim();if(A){m(!0),S(null);try{const{path:L}=await Ex(t,A);f(!1),x(""),await b(t),b(L)}catch(L){S(L instanceof Error?L.message:"Failed to create folder")}finally{m(!1)}}},k=A=>{A.key==="Enter"?(A.preventDefault(),E()):A.key==="Escape"&&P()},j=t.split("/").filter(Boolean),T=A=>{const L="/"+j.slice(0,A+1).join("/");b(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(le,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>void b(),title:"Home",children:h.jsx(Yj,{className:"h-3 w-3"})}),h.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:j.map((A,L)=>h.jsxs(M.Fragment,{children:[h.jsx(Px,{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:()=>T(L),children:A})]},L))}),h.jsxs(le,{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(Gj,{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 b(r),children:[h.jsx($j,{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(hm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),h.jsx("input",{ref:w,className:X("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",v&&"border-destructive"),placeholder:"Folder name",value:y,onChange:A=>{x(A.target.value),S(null)},onKeyDown:k,disabled:g}),h.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>void E(),disabled:!y.trim()||g,title:"Create",children:h.jsx(Uj,{className:"h-3.5 w-3.5 text-green-600"})}),h.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:P,disabled:g,title:"Cancel",children:h.jsx(Qa,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),v&&h.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:v}),o.length===0&&!u&&h.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),o.map(A=>h.jsxs("button",{className:X("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left",A.type==="dir"?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{A.type==="dir"&&b(A.path)},disabled:A.type==="file",children:[A.type==="dir"?h.jsx(hm,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}):h.jsx(Hj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:"truncate",children:A.name})]},A.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(le,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}const tM=[{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)"}],Nm={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 nM({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,x]=p.useState(!1),[v,S]=p.useState(null),g=()=>{s("name"),i(""),l(""),d("claude"),f("limited"),S(null),x(!1)},m=k=>{k||g(),t(k)},w=()=>{if(!o.trim()){S("Please enter a project name");return}S(null),s("folder")},b=k=>{l(k),s("settings")},C=async()=>{x(!0),S(null);try{const k=await dx({name:o.trim(),folderPath:a,permissionMode:u,cliTool:c});n(k),m(!1)}catch(k){S(k instanceof Error?k.message:"Failed to create project")}finally{x(!1)}},P={name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"},E=["name","folder","settings"];return h.jsx(yf,{open:e,onOpenChange:m,children:h.jsxs(el,{className:"sm:max-w-lg",children:[h.jsxs(tl,{children:[h.jsx(rl,{children:P[r]}),h.jsxs(sl,{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:E.map((k,j)=>h.jsx("div",{className:`h-1.5 flex-1 rounded-full ${r===k?"bg-primary":E.indexOf(r)>j?"bg-primary/40":"bg-muted"}`},k))}),r==="name"&&h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{htmlFor:"project-name",children:"Project Name"}),h.jsx(xo,{id:"project-name",placeholder:"My Project",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.key==="Enter"&&w()},autoFocus:!0})]}),v&&h.jsx("p",{className:"text-sm text-destructive",children:v})]}),r==="folder"&&h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{children:"Working Directory"}),h.jsx(cw,{onSelect:b})]}),r==="settings"&&h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{children:"AI Coding Tool"}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:tM.map(k=>h.jsxs("label",{className:`flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors ${c===k.value?"border-primary bg-primary/5":"hover:bg-accent"}`,children:[h.jsx("input",{type:"radio",name:"cliTool",value:k.value,checked:c===k.value,onChange:()=>d(k.value),className:"accent-primary"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium text-sm",children:k.label}),h.jsx("div",{className:"text-xs text-muted-foreground",children:k.desc})]})]},k.value))})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Rn,{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:Nm[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:Nm[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})]}),v&&h.jsx("p",{className:"text-sm text-destructive",children:v})]}),h.jsxs(nl,{children:[r!=="name"&&h.jsx(le,{variant:"outline",onClick:()=>s(r==="settings"?"folder":"name"),disabled:y,children:"Back"}),r==="name"&&h.jsx(le,{onClick:w,children:"Next"}),r==="folder"&&h.jsx(le,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r==="settings"&&h.jsx(le,{onClick:()=>void C(),disabled:y,children:y?"Creating...":"Create Project"})]})]})})}function rM({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 fx(f);n(y),d(!1)}catch(y){l(y instanceof Error?y.message:"Failed to open project"),i(!1)}};return h.jsx(yf,{open:e,onOpenChange:d,children:h.jsxs(el,{className:"sm:max-w-lg",children:[h.jsxs(tl,{children:[h.jsx(rl,{children:"Open Existing Project"}),h.jsxs(sl,{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(Rn,{children:"Project Folder"}),h.jsx(cw,{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(nl,{children:h.jsx(le,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"})})]})})}function sM(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 oM=e=>{switch(e){case"success":return lM;case"info":return cM;case"warning":return uM;case"error":return dM;default:return null}},iM=Array(12).fill(0),aM=({visible:e,className:t})=>M.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},M.createElement("div",{className:"sonner-spinner"},iM.map((n,r)=>M.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),lM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),uM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},M.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"})),cM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),dM=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),fM=M.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"},M.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),M.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),hM=()=>{const[e,t]=M.useState(document.hidden);return M.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Lc=1;class pM{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:Lc++,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],M.isValidElement(c))o=!1,this.create({id:r,type:"default",message:c});else if(gM(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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...x})}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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:f,...x})}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,x=typeof u=="object"&&!M.isValidElement(u)?u:{message:u};this.create({id:r,type:"success",description:f,...x})}}).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"&&!M.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)||Lc++;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 pM,mM=(e,t)=>{const n=(t==null?void 0:t.id)||Lc++;return et.addToast({title:e,...t,id:n}),n},gM=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",yM=mM,vM=()=>et.toasts,xM=()=>et.getActiveToasts(),_s=Object.assign(yM,{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:vM,getToasts:xM});sM("[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 ci(e){return e.label!==void 0}const wM=3,SM="24px",bM="16px",Rm=4e3,EM=356,kM=14,CM=45,PM=200;function Ft(...e){return e.filter(Boolean).join(" ")}function TM(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const jM=e=>{var t,n,r,s,o,i,a,l,c;const{invert:d,toast:u,unstyled:f,interacting:y,setHeights:x,visibleToasts:v,heights:S,index:g,toasts:m,expanded:w,removeToast:b,defaultRichColors:C,closeButton:P,style:E,cancelButtonStyle:k,actionButtonStyle:j,className:T="",descriptionClassName:A="",duration:L,position:G,gap:oe,expandByDefault:ae,classNames:z,icons:Q,closeButtonAriaLabel:N="Close toast"}=e,[_,I]=M.useState(null),[B,ne]=M.useState(null),[U,Z]=M.useState(!1),[Y,me]=M.useState(!1),[Je,te]=M.useState(!1),[Qt,dn]=M.useState(!1),[Zt,It]=M.useState(!1),[ys,Xn]=M.useState(0),[ol,Qn]=M.useState(0),fn=M.useRef(u.duration||L||Rm),Lo=M.useRef(null),Et=M.useRef(null),il=g===0,al=g+1<=v,ze=u.type,R=u.dismissible!==!1,$=u.className||"",q=u.descriptionClassName||"",re=M.useMemo(()=>S.findIndex(W=>W.toastId===u.id)||0,[S,u.id]),ce=M.useMemo(()=>{var W;return(W=u.closeButton)!=null?W:P},[u.closeButton,P]),Te=M.useMemo(()=>u.duration||L||Rm,[u.duration,L]),Ge=M.useRef(0),ye=M.useRef(0),Zn=M.useRef(0),hn=M.useRef(null),[mw,gw]=G.split("-"),xf=M.useMemo(()=>S.reduce((W,Me,Be)=>Be>=re?W:W+Me.height,0),[S,re]),wf=hM(),yw=u.invert||d,ll=ze==="loading";ye.current=M.useMemo(()=>re*oe+xf,[re,xf]),M.useEffect(()=>{fn.current=Te},[Te]),M.useEffect(()=>{Z(!0)},[]),M.useEffect(()=>{const W=Et.current;if(W){const Me=W.getBoundingClientRect().height;return Qn(Me),x(Be=>[{toastId:u.id,height:Me,position:u.position},...Be]),()=>x(Be=>Be.filter(it=>it.toastId!==u.id))}},[x,u.id]),M.useLayoutEffect(()=>{if(!U)return;const W=Et.current,Me=W.style.height;W.style.height="auto";const Be=W.getBoundingClientRect().height;W.style.height=Me,Qn(Be),x(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])},[U,u.title,u.description,x,u.id,u.jsx,u.action,u.cancel]);const pn=M.useCallback(()=>{me(!0),Xn(ye.current),x(W=>W.filter(Me=>Me.toastId!==u.id)),setTimeout(()=>{b(u)},PM)},[u,b,x,ye]);M.useEffect(()=>{if(u.promise&&ze==="loading"||u.duration===1/0||u.type==="loading")return;let W;return w||y||wf?(()=>{if(Zn.current<Ge.current){const it=new Date().getTime()-Ge.current;fn.current=fn.current-it}Zn.current=new Date().getTime()})():(()=>{fn.current!==1/0&&(Ge.current=new Date().getTime(),W=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),pn()},fn.current))})(),()=>clearTimeout(W)},[w,y,u,ze,wf,pn]),M.useEffect(()=>{u.delete&&(pn(),u.onDismiss==null||u.onDismiss.call(u,u))},[pn,u.delete]);function vw(){var W;if(Q!=null&&Q.loading){var Me;return M.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"},Q.loading)}return M.createElement(aM,{className:Ft(z==null?void 0:z.loader,u==null||(W=u.classNames)==null?void 0:W.loader),visible:ze==="loading"})}const xw=u.icon||(Q==null?void 0:Q[ze])||oM(ze);var Sf,bf;return M.createElement("li",{tabIndex:0,ref:Et,className:Ft(T,$,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":(Sf=u.richColors)!=null?Sf:C,"data-styled":!(u.jsx||u.unstyled||f),"data-mounted":U,"data-promise":!!u.promise,"data-swiped":Zt,"data-removed":Y,"data-visible":al,"data-y-position":mw,"data-x-position":gw,"data-index":g,"data-front":il,"data-swiping":Je,"data-dismissible":R,"data-type":ze,"data-invert":yw,"data-swipe-out":Qt,"data-swipe-direction":B,"data-expanded":!!(w||ae&&U),"data-testid":u.testId,style:{"--index":g,"--toasts-before":g,"--z-index":m.length-g,"--offset":`${Y?ys:ye.current}px`,"--initial-height":ae?"auto":`${ol}px`,...E,...u.style},onDragEnd:()=>{te(!1),I(null),hn.current=null},onPointerDown:W=>{W.button!==2&&(ll||!R||(Lo.current=new Date,Xn(ye.current),W.target.setPointerCapture(W.pointerId),W.target.tagName!=="BUTTON"&&(te(!0),hn.current={x:W.clientX,y:W.clientY})))},onPointerUp:()=>{var W,Me,Be;if(Qt||!R)return;hn.current=null;const it=Number(((W=Et.current)==null?void 0:W.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),_o=Number(((Me=Et.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Be=Lo.current)==null?void 0:Be.getTime()),pt=_==="x"?it:_o,Oo=Math.abs(pt)/Le;if(Math.abs(pt)>=CM||Oo>.11){Xn(ye.current),u.onDismiss==null||u.onDismiss.call(u,u),ne(_==="x"?it>0?"right":"left":_o>0?"down":"up"),pn(),dn(!0);return}else{var kt,Ct;(kt=Et.current)==null||kt.style.setProperty("--swipe-amount-x","0px"),(Ct=Et.current)==null||Ct.style.setProperty("--swipe-amount-y","0px")}It(!1),te(!1),I(null)},onPointerMove:W=>{var Me,Be,it;if(!hn.current||!R||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;const Le=W.clientY-hn.current.y,pt=W.clientX-hn.current.x;var Oo;const kt=(Oo=e.swipeDirections)!=null?Oo:TM(G);!_&&(Math.abs(pt)>1||Math.abs(Le)>1)&&I(Math.abs(pt)>Math.abs(Le)?"x":"y");let Ct={x:0,y:0};const Ef=qn=>1/(1.5+Math.abs(qn)/20);if(_==="y"){if(kt.includes("top")||kt.includes("bottom"))if(kt.includes("top")&&Le<0||kt.includes("bottom")&&Le>0)Ct.y=Le;else{const qn=Le*Ef(Le);Ct.y=Math.abs(qn)<Math.abs(Le)?qn:Le}}else if(_==="x"&&(kt.includes("left")||kt.includes("right")))if(kt.includes("left")&&pt<0||kt.includes("right")&&pt>0)Ct.x=pt;else{const qn=pt*Ef(pt);Ct.x=Math.abs(qn)<Math.abs(pt)?qn:pt}(Math.abs(Ct.x)>0||Math.abs(Ct.y)>0)&&It(!0),(Be=Et.current)==null||Be.style.setProperty("--swipe-amount-x",`${Ct.x}px`),(it=Et.current)==null||it.style.setProperty("--swipe-amount-y",`${Ct.y}px`)}},ce&&!u.jsx&&ze!=="loading"?M.createElement("button",{"aria-label":N,"data-disabled":ll,"data-close-button":!0,onClick:ll||!R?()=>{}:()=>{pn(),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)},(bf=Q==null?void 0:Q.close)!=null?bf:fM):null,(ze||u.icon||u.promise)&&u.icon!==null&&((Q==null?void 0:Q[ze])!==null||u.icon)?M.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||vw():null,u.type!=="loading"?xw:null):null,M.createElement("div",{"data-content":"",className:Ft(z==null?void 0:z.content,u==null||(o=u.classNames)==null?void 0:o.content)},M.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?M.createElement("div",{"data-description":"",className:Ft(A,q,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),M.isValidElement(u.cancel)?u.cancel:u.cancel&&ci(u.cancel)?M.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||k,onClick:W=>{ci(u.cancel)&&R&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,W),pn())},className:Ft(z==null?void 0:z.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,M.isValidElement(u.action)?u.action:u.action&&ci(u.action)?M.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||j,onClick:W=>{ci(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,W),!W.defaultPrevented&&pn())},className:Ft(z==null?void 0:z.actionButton,u==null||(c=u.classNames)==null?void 0:c.actionButton)},u.action.label):null)};function Mm(){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 NM(e,t){const n={};return[e,t].forEach((r,s)=>{const o=s===1,i=o?"--mobile-offset":"--offset",a=o?bM:SM;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 RM=M.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:x,style:v,visibleToasts:S=wM,toastOptions:g,dir:m=Mm(),gap:w=kM,icons:b,containerAriaLabel:C="Notifications"}=t,[P,E]=M.useState([]),k=M.useMemo(()=>r?P.filter(U=>U.toasterId===r):P.filter(U=>!U.toasterId),[P,r]),j=M.useMemo(()=>Array.from(new Set([o].concat(k.filter(U=>U.position).map(U=>U.position)))),[k,o]),[T,A]=M.useState([]),[L,G]=M.useState(!1),[oe,ae]=M.useState(!1),[z,Q]=M.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),N=M.useRef(null),_=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=M.useRef(null),B=M.useRef(!1),ne=M.useCallback(U=>{E(Z=>{var Y;return(Y=Z.find(me=>me.id===U.id))!=null&&Y.delete||et.dismiss(U.id),Z.filter(({id:me})=>me!==U.id)})},[]);return M.useEffect(()=>et.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{E(Z=>Z.map(Y=>Y.id===U.id?{...Y,delete:!0}:Y))});return}setTimeout(()=>{Gy.flushSync(()=>{E(Z=>{const Y=Z.findIndex(me=>me.id===U.id);return Y!==-1?[...Z.slice(0,Y),{...Z[Y],...U},...Z.slice(Y+1)]:[U,...Z]})})})}),[P]),M.useEffect(()=>{if(f!=="system"){Q(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Q("dark"):Q("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:Z})=>{Q(Z?"dark":"light")})}catch{U.addListener(({matches:Y})=>{try{Q(Y?"dark":"light")}catch(me){console.error(me)}})}},[f]),M.useEffect(()=>{P.length<=1&&G(!1)},[P]),M.useEffect(()=>{const U=Z=>{var Y;if(i.every(te=>Z[te]||Z.code===te)){var Je;G(!0),(Je=N.current)==null||Je.focus()}Z.code==="Escape"&&(document.activeElement===N.current||(Y=N.current)!=null&&Y.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),M.useEffect(()=>{if(N.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,B.current=!1)}},[N.current]),M.createElement("section",{ref:n,"aria-label":`${C} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((U,Z)=>{var Y;const[me,Je]=U.split("-");return k.length?M.createElement("ol",{key:U,dir:m==="auto"?Mm():m,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":me,"data-x-position":Je,style:{"--front-toast-height":`${((Y=T[0])==null?void 0:Y.height)||0}px`,"--width":`${EM}px`,"--gap":`${w}px`,...v,...NM(d,u)},onBlur:te=>{B.current&&!te.currentTarget.contains(te.relatedTarget)&&(B.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||B.current||(B.current=!0,I.current=te.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{oe||G(!1)},onDragEnd:()=>G(!1),onPointerDown:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},k.filter(te=>!te.position&&Z===0||te.position===U).map((te,Qt)=>{var dn,Zt;return M.createElement(jM,{key:te.id,icons:b,index:Qt,toast:te,defaultRichColors:y,duration:(dn=g==null?void 0:g.duration)!=null?dn:x,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:s,visibleToasts:S,closeButton:(Zt=g==null?void 0:g.closeButton)!=null?Zt:l,interacting:oe,position:U,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,closeButtonAriaLabel:g==null?void 0:g.closeButtonAriaLabel,removeToast:ne,toasts:k.filter(It=>It.position==te.position),heights:T.filter(It=>It.position==te.position),setHeights:A,expandByDefault:a,gap:w,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),dw=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,fw=5,hw=3e3;function hD(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(x=>{var v;((v=n.current)==null?void 0:v.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(x))},[]),c=p.useCallback((x,v)=>{var S;((S=n.current)==null?void 0:S.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:x,rows:v})),a.current=!1):a.current=!0},[]),d=p.useCallback(x=>{l({type:"terminal_input",data:x})},[l]),u=p.useCallback((x,v)=>{l({type:"terminal_resize",cols:x,rows:v})},[l]),f=p.useCallback(()=>{l({type:"chat_subscribe"})},[l]),y=p.useCallback(()=>{if(!s.current||o.current)return;const x=gs();if(!x){window.location.href="/login";return}o.current=!0;const v=new WebSocket(`${dw}/ws/projects/${e}`);n.current=v,v.onopen=()=>{o.current=!1,r.current=0,v.send(JSON.stringify({type:"auth",token:x}))},v.onmessage=S=>{var m,w,b,C,P,E,k,j;let g;try{g=JSON.parse(S.data)}catch{return}switch(g.type){case"connected":a.current=!1,(w=(m=i.current).onConnected)==null||w.call(m);break;case"terminal_data":(C=(b=i.current).onTerminalData)==null||C.call(b,g.data);break;case"status":(E=(P=i.current).onStatus)==null||E.call(P,g.status);break;case"chat_message":{const T=g;(j=(k=i.current).onChatMessage)==null||j.call(k,T);break}case"error":console.error("[WS] Server error:",g.message);break}},v.onclose=()=>{o.current=!1,n.current=null,s.current&&r.current<fw&&(r.current++,setTimeout(y,hw))},v.onerror=S=>{o.current=!1,console.error("[WS] WebSocket error:",S)}},[e]);return p.useEffect(()=>(s.current=!0,y(),()=>{var x;s.current=!1,(x=n.current)==null||x.close(),n.current=null}),[y]),{subscribeTerminal:c,sendTerminalInput:d,sendTerminalResize:u,subscribeChatMessages:f}}function MM(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=gs();if(!a)return;s.current=!0;const l=new WebSocket(`${dw}/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<fw&&(n.current++,setTimeout(i,hw))},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 DM(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 Dm=5*36e5;function AM(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=Dm-t;return n<=0?null:Math.round(e.utilization/(n/Dm))}function di({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=DM(t.resetAt);return h.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",h.jsxs("span",{className:X("font-medium",r),children:[n,"%"]}),s&&h.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",s,")"]})]})}function LM({className:e}){const[t,n]=p.useState("loading"),[r,s]=p.useState(!1);p.useEffect(()=>{const f=async()=>{try{n(await wx())}catch{n(null)}};f();const y=setInterval(()=>void f(),5*60*1e3);return()=>clearInterval(y)},[]);const o=async()=>{s(!0);try{n(await Sx())}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=AM(t.fiveHour);return h.jsxs("div",{className:X("flex items-center gap-1.5 text-xs",e),children:[u!==null&&h.jsxs("span",{className:X("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(di,{label:"5h",bucket:t.fiveHour}),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{label:"7d",bucket:t.sevenDay})]}),l&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h.jsx(di,{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(nN,{className:X("h-3 w-3",r&&"animate-spin")})})]})}function _M(){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(""),[x,v]=p.useState(""),[S,g]=p.useState(""),m=p.useRef(null),w=p.useRef(null);p.useEffect(()=>{gx().then(t).catch(()=>t([]))},[]),p.useEffect(()=>{n&&setTimeout(()=>{var E;return(E=m.current)==null?void 0:E.focus()},0)},[n]),p.useEffect(()=>{d&&setTimeout(()=>{var E;return(E=w.current)==null?void 0:E.focus()},0)},[d]);const b=async()=>{const E=i.trim();if(E)try{const k=await yx({label:s.trim()||E,command:E,...l?{parentId:l}:{}});t(j=>[...j,k]),o(""),a(""),c(""),r(!1)}catch(k){console.error("[GlobalShortcuts] Failed to add:",k)}},C=async E=>{try{await xx(E),t(k=>k.filter(j=>j.id!==E)),d===E&&u(null)}catch(k){console.error("[GlobalShortcuts] Failed to delete:",k)}},P=async()=>{const E=x.trim();if(!(!E||!d))try{const k=await vx(d,{label:f.trim()||E,command:E,parentId:S||null});t(j=>j.map(T=>T.id===d?k:T)),u(null)}catch(k){console.error("[GlobalShortcuts] Failed to save:",k)}};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(mm,{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(E=>!E),u(null)},className:X("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(ya,{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:m,placeholder:"名称(可选)",value:s,onChange:E=>o(E.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:E=>a(E.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:E=>{E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),b()),E.key==="Escape"&&(r(!1),o(""),a(""),c(""))}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(tu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:l,onChange:E=>c(E.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(E=>h.jsx("option",{value:E.id,children:E.label},E.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 b(),disabled:!i.trim(),className:X("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(mm,{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(E=>d===E.id?h.jsxs("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2",children:[h.jsx("input",{ref:w,value:f,onChange:k=>y(k.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:x,onChange:k=>v(k.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:k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),P()),k.key==="Escape"&&u(null)}}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(tu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),h.jsxs("select",{value:S,onChange:k=>g(k.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(k=>k.id!==E.id).map(k=>h.jsx("option",{value:k.id,children:k.label},k.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 P(),disabled:!x.trim(),className:X("text-xs px-2.5 py-1 rounded transition-colors text-white",x.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},E.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:E.label}),E.parentId&&(()=>{const k=e.find(j=>j.id===E.parentId);return k?h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(tu,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",k.label]})]}):null})(),!E.parentId&&E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:E.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(E.id),y(E.label),v(E.command),g(E.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:h.jsx(Tx,{className:"h-3.5 w-3.5"})}),h.jsx("button",{onClick:()=>void C(E.id),className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:h.jsx(Qa,{className:"h-3.5 w-3.5"})})]})]},E.id))})]})}const pw=p.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function OM(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function IM(){return p.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>OM())}function VM({children:e}){const[t,n]=p.useState(()=>ox(pr.theme,"system")),r=IM(),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),ix(pr.theme,i)};return h.jsx(pw.Provider,{value:{theme:t,resolved:s,setTheme:o},children:e})}function FM(){return p.useContext(pw)}function zM(){const{theme:e,setTheme:t}=FM(),n=[{value:"light",icon:iN,label:"浅色"},{value:"dark",icon:eN,label:"深色"},{value:"system",icon:Jj,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:X("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))})}const BM={workMinutes:30,breakMinutes:5};function xa(){return ox(pr.pomodoroConfig,BM,!0)}function $M(e){Notification.permission==="granted"&&new Notification("番茄钟",{body:e,icon:"/favicon.ico"})}const vf=Ya(e=>({running:!1,phase:"work",secondsLeft:xa().workMinutes*60,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function UM(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:s}=vf(),o=p.useCallback(i=>{const a=xa();r(i),s(i==="work"?a.workMinutes*60:a.breakMinutes*60),$M(i==="break"?"休息一下 ☕":"该工作了 💻")},[r,s]);return p.useEffect(()=>{if(!e)return;if(n===0){o(t==="work"?"break":"work");return}const i=setTimeout(()=>s(n-1),1e3);return()=>clearTimeout(i)},[e,n,t,o,s]),null}function WM(){const{running:e,phase:t,secondsLeft:n}=vf(),r=Math.floor(n/60),s=n%60,o=`${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`;return e?Ia.createPortal(h.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none",style:{opacity:t==="work"?.1:.6},children:[h.jsx("div",{className:X("font-mono font-bold tabular-nums leading-none",t==="work"?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:"clamp(360px, 90vw, 1100px)"},children:o}),h.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:t==="work"?"专注工作":"休息一下"})]}),document.body):null}function HM(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:s,setSecondsLeft:o}=vf(),i=Math.floor(n/60),a=n%60,l=`${String(i).padStart(2,"0")}:${String(a).padStart(2,"0")}`,c=()=>{if(e){const d=xa();s("work"),o(d.workMinutes*60)}else{const d=xa();s("work"),o(d.workMinutes*60),Notification.permission==="default"&&Notification.requestPermission()}r(!e)};return h.jsx("button",{onClick:c,className:X("p-1 rounded transition-colors",e?t==="work"?"text-red-500 bg-red-500/10 hover:bg-red-500/20":"text-green-500 bg-green-500/10 hover:bg-green-500/20":"text-muted-foreground hover:text-foreground hover:bg-muted"),title:e?t==="work"?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:h.jsx(aN,{className:"h-4 w-4"})})}function GM(){const e=za(),{projects:t,loading:n,error:r,fetchProjects:s,addProject:o,updateProject:i,removeProject:a}=fm(),l=wr(R=>R.clearToken),[c,d]=p.useState(!1),[u,f]=p.useState(!1),[y,x]=p.useState(new Set),v=p.useRef(new Map),[S,g]=p.useState(new Map),m=p.useRef(0),[w,b]=p.useState(!!document.fullscreenElement),[C,P]=p.useState(!1),[E,k]=p.useState(""),[j,T]=p.useState([]),[A,L]=p.useState(!1);p.useEffect(()=>{if(!E.trim()||E.trim().length<2){T([]);return}const R=setTimeout(()=>{L(!0),kx(E).then($=>T($)).catch(()=>T([])).finally(()=>L(!1))},400);return()=>clearTimeout(R)},[E]);const G=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()};p.useEffect(()=>{const R=()=>b(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",R),()=>document.removeEventListener("fullscreenchange",R)},[]),p.useEffect(()=>{s()},[s]),p.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]);const oe=2e3,ae=3,z=8e3,Q=p.useCallback(R=>{if(R.status){const re=fm.getState().projects.find(ce=>ce.id===R.projectId);re&&re.status!==R.status&&i({...re,status:R.status})}const $=Date.now(),q=v.current;if($-R.lastActivityAt<oe){x(ye=>ye.has(R.projectId)?ye:new Set(ye).add(R.projectId));const re=q.get(R.projectId)??[];let ce=!1;if(R.semantic){const ye=re[re.length-1],Zn=`${R.semantic.phase}:${R.semantic.detail??""}`,hn=ye?`${ye.phase}:${ye.detail??""}`:"";Zn!==hn?(re.push({id:m.current++,phase:R.semantic.phase,detail:R.semantic.detail,ts:$}),ce=!0):ye&&(ye.ts=$)}const Te=re.filter(ye=>$-ye.ts<z),Ge=Te.length>ae?Te.slice(-ae):Te;Ge.length!==re.length&&(ce=!0),q.set(R.projectId,Ge),ce&&g(new Map(q))}else x(re=>{if(!re.has(R.projectId))return re;const ce=new Set(re);return ce.delete(R.projectId),ce}),q.has(R.projectId)&&q.get(R.projectId).length>0&&(q.set(R.projectId,[]),g(new Map(q)))},[]),N=p.useCallback((R,$)=>{"Notification"in window&&Notification.permission==="granted"?new Notification("Claude 已完成",{body:`项目「${$}」的任务已完成`,icon:"/terminal.svg"}):_s.success(`项目「${$}」的任务已完成`,{duration:8e3})},[]);MM({onActivityUpdate:Q,onProjectStopped:N}),p.useEffect(()=>{const R=setInterval(()=>{const $=Date.now(),q=v.current;let re=!1;for(const[ce,Te]of q){const Ge=Te.filter(ye=>$-ye.ts<z);Ge.length!==Te.length&&(q.set(ce,Ge),re=!0)}re&&g(new Map(q)),x(ce=>{let Te=!1;const Ge=new Set(ce);for(const ye of ce){const Zn=q.get(ye);(!Zn||Zn.length===0)&&(Ge.delete(ye),Te=!0)}return Te?Ge:ce})},3e3);return()=>clearInterval(R)},[]);const _=()=>{l(),e("/login")},I=R=>{o(R)},B=R=>{o(R)},ne=async R=>{try{await hx(R),a(R)}catch($){_s.error($ instanceof Error?$.message:"Failed to delete project")}},U=async R=>{try{const $=await px(R);i($)}catch($){_s.error($ instanceof Error?$.message:"Failed to archive project")}},Z=async R=>{try{const $=await mx(R);i($)}catch($){_s.error($ instanceof Error?$.message:"Failed to restore project")}},Y=p.useMemo(()=>t.filter(R=>!R.archived),[t]),me=p.useMemo(()=>t.filter(R=>R.archived),[t]),Je=p.useMemo(()=>Array.from(new Set(t.flatMap(R=>R.tags??[]))),[t]),[te,Qt]=p.useState([]),dn=p.useMemo(()=>te.length===0?Y:Y.filter(R=>te.some($=>{var q;return(q=R.tags)==null?void 0:q.includes($)})),[Y,te]),[Zt,It]=IT(pr.projectOrder,[],{parse:!0}),[ys,Xn]=p.useState(null),[ol,Qn]=p.useState(null);p.useEffect(()=>{if(Y.length===0)return;const R=Y.map($=>$.id);It($=>{const q=$.filter(Te=>R.includes(Te)),re=R.filter(Te=>!$.includes(Te)),ce=[...q,...re];return ce.join(",")===$.join(",")?$:ce})},[Y]);const fn=p.useMemo(()=>Zt.length===0?dn:[...dn].sort((R,$)=>{const q=Zt.indexOf(R.id),re=Zt.indexOf($.id);return q===-1?1:re===-1?-1:q-re}),[dn,Zt]),Lo=p.useCallback(R=>Xn(R),[]),Et=p.useCallback(()=>{Xn(null),Qn(null)},[]),il=p.useCallback((R,$)=>{R.preventDefault(),Qn($)},[]),al=p.useCallback((R,$,q)=>{if(R.preventDefault(),!q||q===$){Qn(null);return}It(re=>{const ce=[...re],Te=ce.indexOf(q),Ge=ce.indexOf($);return Te===-1||Ge===-1?re:(ce.splice(Te,1),ce.splice(Ge,0,q),ce)}),Xn(null),Qn(null)},[It]),ze={onDelete:R=>void ne(R),onArchive:R=>void U(R),onUnarchive:R=>void Z(R),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(pm,{className:"h-5 w-5"}),h.jsx("span",{className:"font-semibold text-lg",children:"CC Web"})]}),h.jsx(LM,{}),h.jsxs("div",{className:"relative",children:[h.jsx(rN,{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(xo,{placeholder:"搜索历史对话…",value:E,onChange:R=>k(R.target.value),className:"pl-8 h-8 text-xs w-48"}),E.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:[A&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"搜索中…"}),!A&&j.length===0&&h.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"无结果"}),j.map((R,$)=>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/${R.projectId}`),k("")},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:R.projectName}),h.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:new Date(R.startedAt).toLocaleDateString("zh-CN")})]}),h.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed line-clamp-2",children:R.snippet})]},$))]})]}),h.jsx(le,{variant:"ghost",size:"sm",onClick:()=>e("/skillhub"),title:"SkillHub",children:h.jsx(oN,{className:"h-4 w-4"})}),h.jsx(le,{variant:"ghost",size:"sm",onClick:()=>e("/settings"),title:"设置",children:h.jsx(sN,{className:"h-4 w-4"})}),h.jsx(le,{variant:"ghost",size:"sm",onClick:G,title:w?"Exit fullscreen":"Fullscreen",children:w?h.jsx(Zj,{className:"h-4 w-4"}):h.jsx(Qj,{className:"h-4 w-4"})}),h.jsx(HM,{}),h.jsx(zM,{}),h.jsxs(le,{variant:"ghost",size:"sm",onClick:_,children:[h.jsx(Xj,{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(le,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(le,{onClick:()=>d(!0),children:[h.jsx(ya,{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(pm,{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(le,{variant:"outline",onClick:()=>f(!0),children:[h.jsx(Rc,{className:"h-4 w-4 mr-2"}),"Open Project"]}),h.jsxs(le,{onClick:()=>d(!0),children:[h.jsx(ya,{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(R=>h.jsxs("button",{onClick:()=>Qt($=>$.includes(R)?$.filter(q=>q!==R):[...$,R]),className:X("px-2 py-0.5 rounded-full text-xs border transition-colors",te.includes(R)?"bg-blue-500/20 text-blue-400 border-blue-500/40":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",R]},R)),te.length>0&&h.jsx("button",{onClick:()=>Qt([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:"清除"})]}),!n&&!r&&fn.length>0&&h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:fn.map((R,$)=>h.jsx(Yt.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,delay:$*.05,ease:"easeOut"},draggable:!0,onDragStart:()=>Lo(R.id),onDragOver:q=>il(q,R.id),onDrop:q=>al(q,R.id,ys),onDragEnd:Et,style:{opacity:ys===R.id?.4:1,cursor:"grab"},className:X(ol===R.id&&ys!==R.id&&"ring-2 ring-blue-500/50 rounded-xl"),children:h.jsx(jm,{project:R,active:y.has(R.id),statusStack:S.get(R.id)??[],...ze})},R.id))}),!n&&!r&&me.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:()=>P(R=>!R),children:[h.jsx(Yt.span,{animate:{rotate:C?90:0},transition:{duration:.2},children:h.jsx(Px,{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:me.length})]}),h.jsx(Ha,{children:C&&h.jsx(Yt.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:me.map(R=>h.jsx(jm,{project:R,active:!1,...ze},R.id))})})})]}),h.jsx(_M,{})]}),h.jsx(nM,{open:c,onOpenChange:d,onCreated:I}),h.jsx(rM,{open:u,onOpenChange:f,onOpened:B})]})}class KM extends M.Component{constructor(){super(...arguments);ul(this,"state",{hasError:!1,error:null});ul(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),_s.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}}function YM({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:s}=e,[o,i]=p.useState(()=>{var P,E;return{x:((P=s.floatPosition)==null?void 0:P.x)??window.innerWidth*.5-r.defaultWidth/2,y:((E=s.floatPosition)==null?void 0:E.y)??window.innerHeight*.3}}),[a,l]=p.useState(()=>{var P,E;return{w:((P=s.floatSize)==null?void 0:P.w)??r.defaultWidth,h:((E=s.floatSize)==null?void 0:E.h)??r.defaultHeight}}),[c,d]=p.useState(!1),[u,f]=p.useState(100),y=p.useRef(null),x=p.useRef(null),v=p.useCallback(()=>{f(Date.now()%1e5+100)},[]),S=p.useRef(null),g=p.useCallback(P=>{P.preventDefault(),v(),S.current={sx:P.clientX,sy:P.clientY,ox:o.x,oy:o.y},x.current&&(x.current.style.pointerEvents="none");const E=j=>{if(!S.current)return;const T=Math.max(0,Math.min(window.innerWidth-100,S.current.ox+j.clientX-S.current.sx)),A=Math.max(0,Math.min(window.innerHeight-40,S.current.oy+j.clientY-S.current.sy));y.current&&(y.current.style.left=T+"px",y.current.style.top=A+"px")},k=j=>{if(!S.current)return;const T=Math.max(0,Math.min(window.innerWidth-100,S.current.ox+j.clientX-S.current.sx)),A=Math.max(0,Math.min(window.innerHeight-40,S.current.oy+j.clientY-S.current.sy));S.current=null,x.current&&(x.current.style.pointerEvents=""),i({x:T,y:A}),t(e.id,{floatPosition:{x:T,y:A}}),window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",k)};window.addEventListener("mousemove",E),window.addEventListener("mouseup",k)},[o,v,e.id,t]),m=p.useRef(null),w=p.useCallback(P=>{if(!r.resizable)return;P.preventDefault(),P.stopPropagation(),v(),m.current={sx:P.clientX,sy:P.clientY,ow:a.w,oh:a.h},x.current&&(x.current.style.pointerEvents="none");const E=r.minWidth??150,k=r.minHeight??100,j=A=>{if(!m.current)return;const L=Math.max(E,m.current.ow+A.clientX-m.current.sx),G=Math.max(k,m.current.oh+A.clientY-m.current.sy);y.current&&(y.current.style.width=L+"px",y.current.style.height=G+"px")},T=A=>{if(!m.current)return;const L=Math.max(E,m.current.ow+A.clientX-m.current.sx),G=Math.max(k,m.current.oh+A.clientY-m.current.sy);m.current=null,x.current&&(x.current.style.pointerEvents=""),l({w:L,h:G}),t(e.id,{floatSize:{w:L,h:G}}),window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",T)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",T)},[a,r,v,e.id,t]);p.useEffect(()=>{const P=async E=>{var A,L,G,oe,ae;if(E.source!==((A=x.current)==null?void 0:A.contentWindow))return;const{callId:k,method:j,args:T}=E.data;if(!(!k||!j))try{const z=gs(),Q={"Content-Type":"application/json","X-Plugin-Id":e.id};z&&(Q.Authorization=`Bearer ${z}`);let N,_;if(j==="storage:get")N=`/api/plugin-bridge/storage/${e.id}`,_={method:"GET",headers:Q};else if(j==="storage:set")N=`/api/plugin-bridge/storage/${e.id}`,_={method:"PUT",headers:Q,body:JSON.stringify(T)};else{const ne={"project:status":{path:`/api/plugin-bridge/project/status/${T.projectId}`,httpMethod:"GET"},"project:list":{path:"/api/plugin-bridge/project/list",httpMethod:"GET"},"terminal:send":{path:"/api/plugin-bridge/terminal/send",httpMethod:"POST"},"session:read":{path:`/api/plugin-bridge/session/${T.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if(j==="backend:api"){const{method:U,path:Z,body:Y}=T;N=`/api/plugins/${e.id}${Z}`,_={method:U||"GET",headers:Q},Y&&(U==="POST"||U==="PUT")&&(_.body=JSON.stringify(Y))}else{const U=ne[j];if(!U)throw new Error(`Unknown method: ${j}`);N=U.path,_={method:U.httpMethod,headers:Q},U.httpMethod==="POST"&&(_.body=JSON.stringify(T))}}const B=await(await fetch(N,_)).json();(G=(L=x.current)==null?void 0:L.contentWindow)==null||G.postMessage({callId:k,result:B,error:null},"*")}catch(z){const Q=z instanceof Error?z.message:"Bridge error";(ae=(oe=x.current)==null?void 0:oe.contentWindow)==null||ae.postMessage({callId:k,result:null,error:Q},"*")}};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[e.id]);const b=s.clickable??r.clickable.default,C=`/plugins/${e.id}/${e.float?"index.html":""}`;return h.jsxs(Yt.div,{ref:y,className:X("fixed rounded-lg border border-border shadow-xl overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:o.x,top:o.y,width:c?200:a.w,height:c?32:a.h,zIndex:u},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:v,children:[h.jsxs("div",{className:"h-8 flex items-center gap-1 px-2 bg-muted/50 border-b border-border cursor-grab active:cursor-grabbing flex-shrink-0 select-none",onMouseDown:g,children:[h.jsx(Kj,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),h.jsx("button",{onClick:()=>d(P=>!P),className:"p-0.5 rounded hover:bg-white/10 text-muted-foreground/60 hover:text-foreground transition-colors",children:h.jsx(qj,{className:"h-3 w-3"})}),h.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 rounded hover:bg-red-500/20 text-muted-foreground/60 hover:text-red-400 transition-colors",children:h.jsx(Qa,{className:"h-3 w-3"})})]}),!c&&h.jsxs("div",{className:"flex-1 min-h-0 relative",children:[h.jsx("iframe",{ref:x,src:C,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:b?"auto":"none"}}),r.resizable&&h.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:w,children:h.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[h.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),h.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function XM({plugins:e,onPluginsChange:t,onClose:n}){const r=p.useCallback(async(s,o)=>{t(i=>i.map(a=>a.id===s?{...a,userConfig:{...a.userConfig,...o}}:a));try{await Cx(s,o)}catch{}},[t]);return e.length===0?null:h.jsx(Ha,{children:e.map(s=>h.jsx(YM,{plugin:s,onConfigChange:r,onClose:n},s.id))})}function QM({onTogglePlugin:e,activeIds:t}){const[n,r]=p.useState([]);return p.useEffect(()=>{ga().then(s=>r(s.filter(o=>o.enabled))).catch(()=>r([]))},[]),p.useEffect(()=>{const s=()=>{ga().then(o=>r(o.filter(i=>i.enabled))).catch(()=>{})};return window.addEventListener("focus",s),()=>window.removeEventListener("focus",s)},[]),n.length===0?null:h.jsx("div",{className:"border-b border-border bg-muted/30 px-4",children:h.jsxs("div",{className:"max-w-6xl mx-auto flex items-center gap-1 h-9 overflow-x-auto",children:[h.jsx(tN,{className:"h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0 mr-1"}),n.map(s=>{const o=t.has(s.id);return h.jsxs(Yt.button,{onClick:()=>e(s),className:X("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs transition-colors flex-shrink-0",o?"bg-blue-500/15 text-blue-400 border border-blue-500/30":"text-muted-foreground hover:text-foreground hover:bg-muted"),whileHover:{scale:1.02},whileTap:{scale:.98},title:s.description,children:[h.jsx("span",{className:X("h-1.5 w-1.5 rounded-full flex-shrink-0",o?"bg-blue-400":"bg-muted-foreground/30")}),s.name]},s.id)})]})})}const ZM=M.lazy(()=>To(()=>import("./ProjectPage-DqyRyuGy.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ProjectPage}))),qM=M.lazy(()=>To(()=>import("./SettingsPage-DibjvDz7.js"),__vite__mapDeps([7,3,1])).then(e=>({default:e.SettingsPage}))),JM=M.lazy(()=>To(()=>import("./SkillHubPage-BuCfJoFJ.js"),__vite__mapDeps([8,2,5,3])).then(e=>({default:e.SkillHubPage}))),eD=M.lazy(()=>To(()=>import("./ShareViewPage-BfltjUod.js"),__vite__mapDeps([9,5,4])).then(e=>({default:e.ShareViewPage})));function tD(){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 fi({children:e}){const[t,n]=p.useState(!1),r=wr(o=>o.token),s=wr(o=>o.setToken);return p.useEffect(()=>{if(r){n(!0);return}ma()?hf().then(o=>s(o)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),!t&&!r?null:r?h.jsx(h.Fragment,{children:e}):h.jsx(ov,{to:"/login",replace:!0})}function nD(){const[e,t]=p.useState([]),[n,r]=p.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),s=Fa();p.useEffect(()=>{ga().then(t).catch(()=>t([]))},[]);const o=p.useCallback(d=>{r(u=>{const f=new Set(u);f.has(d.id)?f.delete(d.id):f.add(d.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...f]))}catch{}return f})},[]),i=p.useCallback(d=>{r(u=>{const f=new Set(u);f.delete(d);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...f]))}catch{}return f})},[]),a=rD(s.pathname),l=e.filter(d=>{if(!d.enabled||!n.has(d.id))return!1;switch(d.userConfig.scope??d.float.scope.default){case"global":return!0;case"dashboard":return a.type==="dashboard";case"project":return a.type==="project";case"project:specific":return a.type==="project"&&(d.userConfig.projectIds??[]).includes(a.projectId??"");default:return!1}}),c=s.pathname==="/login";return h.jsxs(h.Fragment,{children:[!c&&h.jsx(QM,{onTogglePlugin:o,activeIds:n}),h.jsx(XM,{plugins:l,onPluginsChange:t,onClose:i})]})}function rD(e){if(e==="/"||e==="/dashboard")return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}function sD(){return h.jsxs(VM,{children:[h.jsx(RM,{richColors:!0,position:"bottom-right"}),h.jsx(UM,{}),h.jsx(WM,{}),h.jsx(KM,{children:h.jsxs(Ub,{children:[h.jsx(nD,{}),h.jsx(p.Suspense,{fallback:h.jsx(tD,{}),children:h.jsxs(zb,{children:[h.jsx(vn,{path:"/login",element:h.jsx(Ij,{})}),h.jsx(vn,{path:"/",element:h.jsx(fi,{children:h.jsx(GM,{})})}),h.jsx(vn,{path:"/projects/:id",element:h.jsx(fi,{children:h.jsx(ZM,{})})}),h.jsx(vn,{path:"/settings",element:h.jsx(fi,{children:h.jsx(qM,{})})}),h.jsx(vn,{path:"/skillhub",element:h.jsx(fi,{children:h.jsx(JM,{})})}),h.jsx(vn,{path:"/share/:token",element:h.jsx(eD,{})}),h.jsx(vn,{path:"*",element:h.jsx(ov,{to:"/",replace:!0})})]})})]})})]})}cu.createRoot(document.getElementById("root")).render(h.jsx(M.StrictMode,{children:h.jsx(sD,{})}));export{tj as $,Ha as A,le as B,Px as C,Cj as D,Wj as E,Rc as F,QT as G,gx as H,xo as I,tu as J,JT as K,yf as L,Zj as M,el as N,tl as O,Tx as P,rl as Q,M as R,pr as S,sl as T,Rn as U,nl as V,qT as W,Qa as X,ZT as Y,mm as Z,To as _,aD as a,tN as a$,Tj as a0,KT as a1,YT as a2,jj as a3,za as a4,$j as a5,rr as a6,HM as a7,zM as a8,pj as a9,$x as aA,Dx as aB,Rx as aC,uj as aD,dj as aE,hj as aF,lf as aG,uf as aH,cf as aI,df as aJ,jx as aK,xa as aL,wj as aM,aN,cj as aO,mj as aP,yj as aQ,xj as aR,fj as aS,vj as aT,gj as aU,Sj as aV,ga as aW,Dj as aX,Aj as aY,_j as aZ,ej as a_,GT as aa,rN as ab,Rj as ac,OT as ad,Mj as ae,oN as af,hD as ag,LM as ah,uD as ai,IT as aj,fm as ak,pm as al,wo as am,kr as an,mN as ao,cn as ap,Fn as aq,cN as ar,Ka as as,nu as at,So as au,Za as av,Ia as aw,Lx as ax,MR as ay,HN as az,gs as b,nj as b0,Nj as b1,lD as b2,ee as c,oj as d,X as e,Qj as f,Am as g,rj as h,ox as i,h as j,dD as k,bx as l,nN as m,sj as n,hm as o,Yt as p,bj as q,p as r,ix as s,_s as t,FM as u,Uj as v,ij as w,ya as x,Ej as y,kj as z};
|