@tom2012/cc-web 2026.4.27-e → 2026.4.27-f

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.
Files changed (21) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/terminal-manager.d.ts +8 -0
  3. package/backend/dist/terminal-manager.d.ts.map +1 -1
  4. package/backend/dist/terminal-manager.js +45 -3
  5. package/backend/dist/terminal-manager.js.map +1 -1
  6. package/frontend/dist/assets/{AssistantMessageContent-fk_C4oct.js → AssistantMessageContent-BiJL4SGC.js} +1 -1
  7. package/frontend/dist/assets/{GraphPreview-jBgcKX7j.js → GraphPreview-CRoeiBR8.js} +1 -1
  8. package/frontend/dist/assets/{MobilePage-Cy7KRgH_.js → MobilePage-TPNnMQ27.js} +3 -3
  9. package/frontend/dist/assets/{OfficePreview-DrS64ehu.js → OfficePreview-Bg2tz3fQ.js} +2 -2
  10. package/frontend/dist/assets/{ProjectPage-ByY_pKon.js → ProjectPage-C3ooYpFP.js} +3 -3
  11. package/frontend/dist/assets/{SettingsPage-DCsamoIN.js → SettingsPage-DroQY7ar.js} +1 -1
  12. package/frontend/dist/assets/{SkillHubPage-ChEG3UXF.js → SkillHubPage-B4txwD4F.js} +1 -1
  13. package/frontend/dist/assets/{chevron-down-CxkiZ1SD.js → chevron-down-CFYwGxZ7.js} +1 -1
  14. package/frontend/dist/assets/{chevron-up-BZkUJHec.js → chevron-up-D91KEb_P.js} +1 -1
  15. package/frontend/dist/assets/{index-DsCTP_lW.js → index-9M6XORRc.js} +1 -1
  16. package/frontend/dist/assets/{index-Bi0Lxaim.js → index-Bd6-XRQN.js} +2 -2
  17. package/frontend/dist/assets/{index-DupxITkq.js → index-FD2TeOOr.js} +1 -1
  18. package/frontend/dist/assets/{jszip.min-Cm3MH9ZY.js → jszip.min-DVUOeoIr.js} +1 -1
  19. package/frontend/dist/assets/{search-CSdU5BiW.js → search-D2ccvP_R.js} +1 -1
  20. package/frontend/dist/index.html +1 -1
  21. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-ByY_pKon.js","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-fk_C4oct.js","assets/chevron-down-CxkiZ1SD.js","assets/chevron-up-BZkUJHec.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-DsCTP_lW.js","assets/search-CSdU5BiW.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-DCsamoIN.js","assets/SkillHubPage-ChEG3UXF.js","assets/MobilePage-Cy7KRgH_.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProjectPage-C3ooYpFP.js","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-BiJL4SGC.js","assets/chevron-down-CFYwGxZ7.js","assets/chevron-up-D91KEb_P.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-9M6XORRc.js","assets/search-D2ccvP_R.js","assets/ProjectPage-9CEnUXvW.css","assets/SettingsPage-DroQY7ar.js","assets/SkillHubPage-B4txwD4F.js","assets/MobilePage-TPNnMQ27.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);function n(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?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(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var s={exports:{}},i={},l={exports:{}},c={},u=Symbol.for("react.element"),d=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),g=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),w=Symbol.iterator;var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,E={};function C(e,t,n){this.props=e,this.context=t,this.refs=E,this.updater=n||k}function j(){}function P(e,t,n){this.props=e,this.context=t,this.refs=E,this.updater=n||k}C.prototype.isReactComponent={},C.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},C.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},j.prototype=C.prototype;var N=P.prototype=new j;N.constructor=P,S(N,C.prototype),N.isPureReactComponent=!0;var _=Array.isArray,T=Object.prototype.hasOwnProperty,R={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function M(e,t,n){var r,o={},a=null,s=null;if(null!=t)for(r in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(a=""+t.key),t)T.call(t,r)&&!L.hasOwnProperty(r)&&(o[r]=t[r]);var i=arguments.length-2;if(1===i)o.children=n;else if(1<i){for(var l=Array(i),c=0;c<i;c++)l[c]=arguments[c+2];o.children=l}if(e&&e.defaultProps)for(r in i=e.defaultProps)void 0===o[r]&&(o[r]=i[r]);return{$$typeof:u,type:e,key:a,ref:s,props:o,_owner:R.current}}function O(e){return"object"==typeof e&&null!==e&&e.$$typeof===u}var D=/\/+/g;function A(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function I(e,t,n,r,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var s=!1;if(null===e)s=!0;else switch(a){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case u:case d:s=!0}}if(s)return o=o(s=e),e=""===r?"."+A(s,0):r,_(o)?(n="",null!=e&&(n=e.replace(D,"$&/")+"/"),I(o,t,n,"",function(e){return e})):null!=o&&(O(o)&&(o=function(e,t){return{$$typeof:u,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,n+(!o.key||s&&s.key===o.key?"":(""+o.key).replace(D,"$&/")+"/")+e)),t.push(o)),1;if(s=0,r=""===r?".":r+":",_(e))for(var i=0;i<e.length;i++){var l=r+A(a=e[i],i);s+=I(a,t,n,l,o)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=w&&e[w]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),i=0;!(a=e.next()).done;)s+=I(a=a.value,t,n,l=r+A(a,i++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function F(e,t,n){if(null==e)return e;var r=[],o=0;return I(e,r,"","",function(e){return t.call(n,e,o++)}),r}function z(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var $={current:null},V={transition:null},U={ReactCurrentDispatcher:$,ReactCurrentBatchConfig:V,ReactCurrentOwner:R};function B(){throw Error("act(...) is not supported in production builds of React.")}c.Children={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},c.Component=C,c.Fragment=p,c.Profiler=f,c.PureComponent=P,c.StrictMode=h,c.Suspense=y,c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U,c.act=B,c.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=S({},e.props),o=e.key,a=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,s=R.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(l in t)T.call(t,l)&&!L.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==i?i[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=n;else if(1<l){i=Array(l);for(var c=0;c<l;c++)i[c]=arguments[c+2];r.children=i}return{$$typeof:u,type:e.type,key:o,ref:a,props:r,_owner:s}},c.createContext=function(e){return(e={$$typeof:g,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:m,_context:e},e.Consumer=e},c.createElement=M,c.createFactory=function(e){var t=M.bind(null,e);return t.type=e,t},c.createRef=function(){return{current:null}},c.forwardRef=function(e){return{$$typeof:v,render:e}},c.isValidElement=O,c.lazy=function(e){return{$$typeof:x,_payload:{_status:-1,_result:e},_init:z}},c.memo=function(e,t){return{$$typeof:b,type:e,compare:void 0===t?null:t}},c.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}},c.unstable_act=B,c.useCallback=function(e,t){return $.current.useCallback(e,t)},c.useContext=function(e){return $.current.useContext(e)},c.useDebugValue=function(){},c.useDeferredValue=function(e){return $.current.useDeferredValue(e)},c.useEffect=function(e,t){return $.current.useEffect(e,t)},c.useId=function(){return $.current.useId()},c.useImperativeHandle=function(e,t,n){return $.current.useImperativeHandle(e,t,n)},c.useInsertionEffect=function(e,t){return $.current.useInsertionEffect(e,t)},c.useLayoutEffect=function(e,t){return $.current.useLayoutEffect(e,t)},c.useMemo=function(e,t){return $.current.useMemo(e,t)},c.useReducer=function(e,t,n){return $.current.useReducer(e,t,n)},c.useRef=function(e){return $.current.useRef(e)},c.useState=function(e){return $.current.useState(e)},c.useSyncExternalStore=function(e,t,n){return $.current.useSyncExternalStore(e,t,n)},c.useTransition=function(){return $.current.useTransition()},c.version="18.3.1",l.exports=c;var W=l.exports;const H=o(W),q=n({__proto__:null,default:H},[W]);
3
3
  /**
4
4
  * @license React
@@ -72,4 +72,4 @@ function Zd(){return Zd=Object.assign?Object.assign.bind():function(e){for(var t
72
72
  *
73
73
  * This source code is licensed under the ISC license.
74
74
  * See the LICENSE file in the root directory of this source tree.
75
- */const kj=(e,t)=>{const n=W.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:a,className:s="",children:i,...l},c)=>{return W.createElement("svg",{ref:c,...wj,width:r,height:r,stroke:n,strokeWidth:a?24*Number(o)/Number(r):o,className:["lucide",`lucide-${u=e,u.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()}`,s].join(" "),...l},[...t.map(([e,t])=>W.createElement(e,t)),...Array.isArray(i)?i:[i]]);var u});return n.displayName=`${e}`,n},Sj=kj("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),Ej=kj("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),Cj=kj("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),jj=kj("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),Pj=kj("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Nj=kj("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),_j=kj("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Tj=kj("File",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),Rj=kj("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),Lj=kj("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Mj=kj("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]),Oj=kj("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Dj=kj("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),Aj=kj("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),Ij=kj("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),Fj=kj("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),zj=kj("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]]),$j=kj("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),Vj=kj("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Uj=kj("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Bj=kj("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),Wj=kj("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),Hj=kj("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),qj=kj("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),Gj=kj("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),Kj=kj("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Yj=kj("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Xj=kj("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),Qj=kj("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]),Jj=kj("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Zj=kj("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),eP=kj("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),tP=kj("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),nP=kj("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),rP=kj("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),oP=kj("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),aP=kj("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),sP=kj("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),iP=kj("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),lP=kj("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function cP({className:e,...t}){return ee.jsx("div",{className:XS("animate-pulse rounded-md bg-muted",e),...t})}const uP=gE("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function dP({className:e,variant:t,...n}){return ee.jsx("div",{className:XS(uP({variant:t}),e),...n})}function pP(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}function hP(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>W.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return W.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const o=W.createContext(r),a=n.length;n=[...n,r];const s=t=>{var n;const{scope:r,children:s,...i}=t,l=(null==(n=null==r?void 0:r[e])?void 0:n[a])||o,c=W.useMemo(()=>i,Object.values(i));return ee.jsx(l.Provider,{value:c,children:s})};return s.displayName=t+"Provider",[s,function(n,s){var i;const l=(null==(i=null==s?void 0:s[e])?void 0:i[a])||o,c=W.useContext(l);if(c)return c;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},fP(r,...t)]}function fP(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return W.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var mP=(null==globalThis?void 0:globalThis.document)?W.useLayoutEffect:()=>{},gP=q[" useId ".trim().toString()]||(()=>{}),vP=0;function yP(e){const[t,n]=W.useState(gP());return mP(()=>{n(e=>e??String(vP++))},[e]),e||(t?`radix-${t}`:"")}var bP=q[" useInsertionEffect ".trim().toString()]||mP;function xP({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,s]=function({defaultProp:e,onChange:t}){const[n,r]=W.useState(e),o=W.useRef(n),a=W.useRef(t);return bP(()=>{a.current=t},[t]),W.useEffect(()=>{var e;o.current!==n&&(null==(e=a.current)||e.call(a,n),o.current=n)},[n,o]),[n,r,a]}({defaultProp:t,onChange:n}),i=void 0!==e,l=i?e:o;{const t=W.useRef(void 0!==e);W.useEffect(()=>{const e=t.current;if(e!==i){const t=e?"controlled":"uncontrolled",n=i?"controlled":"uncontrolled";console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=i},[i,r])}const c=W.useCallback(t=>{var n;if(i){const r=function(e){return"function"==typeof e}(t)?t(e):t;r!==e&&(null==(n=s.current)||n.call(s,r))}else a(t)},[i,e,a,s]);return[l,c]}function wP(e){const t=kP(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),s=a.find(EP);if(s){const e=s.props.children,r=a.map(t=>t===s?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function kP(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?oE(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SP=Symbol("radix.slottable");function EP(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===SP}var CP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=wP(`Primitive.${t}`),r=W.forwardRef((e,r)=>{const{asChild:o,...a}=e,s=o?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),ee.jsx(s,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function jP(e,t){e&&ld.flushSync(()=>e.dispatchEvent(t))}function PP(e){const t=W.useRef(e);return W.useEffect(()=>{t.current=e}),W.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}var NP,_P="dismissableLayer.update",TP="dismissableLayer.pointerDownOutside",RP="dismissableLayer.focusOutside",LP=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),MP=W.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:i,...l}=e,c=W.useContext(LP),[u,d]=W.useState(null),p=(null==u?void 0:u.ownerDocument)??(null==globalThis?void 0:globalThis.document),[,h]=W.useState({}),f=aE(t,e=>d(e)),m=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),y=u?m.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,w=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e),r=W.useRef(!1),o=W.useRef(()=>{});return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){DP(TP,n,a,{discrete:!0})};const a={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",o.current),o.current=r,t.addEventListener("click",o.current,{once:!0})):r()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",e),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...c.branches].some(e=>e.contains(t));x&&!n&&(null==o||o(e),null==s||s(e),e.defaultPrevented||null==i||i())},p),k=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e),r=W.useRef(!1);return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){DP(RP,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(null==a||a(e),null==s||s(e),e.defaultPrevented||null==i||i())},p);return function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e);W.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{y===c.layers.size-1&&(null==r||r(e),!e.defaultPrevented&&i&&(e.preventDefault(),i()))},p),W.useEffect(()=>{if(u)return n&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(NP=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),OP(),()=>{n&&1===c.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=NP)}},[u,p,n,c]),W.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),OP())},[u,c]),W.useEffect(()=>{const e=()=>h({});return document.addEventListener(_P,e),()=>document.removeEventListener(_P,e)},[]),ee.jsx(CP.div,{...l,ref:f,style:{pointerEvents:b?x?"auto":"none":void 0,...e.style},onFocusCapture:pP(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pP(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pP(e.onPointerDownCapture,w.onPointerDownCapture)})});MP.displayName="DismissableLayer";function OP(){const e=new CustomEvent(_P);document.dispatchEvent(e)}function DP(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?jP(o,a):o.dispatchEvent(a)}W.forwardRef((e,t)=>{const n=W.useContext(LP),r=W.useRef(null),o=aE(t,r);return W.useEffect(()=>{const e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),ee.jsx(CP.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var AP="focusScope.autoFocusOnMount",IP="focusScope.autoFocusOnUnmount",FP={bubbles:!1,cancelable:!0},zP=W.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=e,[i,l]=W.useState(null),c=PP(o),u=PP(a),d=W.useRef(null),p=aE(t,e=>l(e)),h=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(r){let e=function(e){if(h.paused||!i)return;const t=e.target;i.contains(t)?d.current=t:BP(d.current,{select:!0})},t=function(e){if(h.paused||!i)return;const t=e.relatedTarget;null!==t&&(i.contains(t)||BP(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&BP(i)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return i&&r.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[r,i,h.paused]),W.useEffect(()=>{if(i){WP.add(h);const t=document.activeElement;if(!i.contains(t)){const n=new CustomEvent(AP,FP);i.addEventListener(AP,c),i.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(BP(r,{select:t}),document.activeElement!==n)return}((e=$P(i),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&BP(i))}return()=>{i.removeEventListener(AP,c),setTimeout(()=>{const e=new CustomEvent(IP,FP);i.addEventListener(IP,u),i.dispatchEvent(e),e.defaultPrevented||BP(t??document.body,{select:!0}),i.removeEventListener(IP,u),WP.remove(h)},0)}}var e},[i,c,u,h]);const f=W.useCallback(e=>{if(!n&&!r)return;if(h.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,o=document.activeElement;if(t&&o){const t=e.currentTarget,[r,a]=function(e){const t=$P(e),n=VP(t,e),r=VP(t.reverse(),e);return[n,r]}(t);r&&a?e.shiftKey||o!==a?e.shiftKey&&o===r&&(e.preventDefault(),n&&BP(a,{select:!0})):(e.preventDefault(),n&&BP(r,{select:!0})):o===t&&e.preventDefault()}},[n,r,h.paused]);return ee.jsx(CP.div,{tabIndex:-1,...s,ref:p,onKeyDown:f})});function $P(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function VP(e,t){for(const n of e)if(!UP(n,{upTo:t}))return n}function UP(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function BP(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}zP.displayName="FocusScope";var WP=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=HP(e,t),e.unshift(t)},remove(t){var n;e=HP(e,t),null==(n=e[0])||n.resume()}}}();function HP(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var qP=W.forwardRef((e,t)=>{var n;const{container:r,...o}=e,[a,s]=W.useState(!1);mP(()=>s(!0),[]);const i=r||a&&(null==(n=null==globalThis?void 0:globalThis.document)?void 0:n.body);return i?cd.createPortal(ee.jsx(CP.div,{...o,ref:t}),i):null});qP.displayName="Portal";var GP=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=W.useState(),r=W.useRef(null),o=W.useRef(e),a=W.useRef("none"),s=e?"mounted":"unmounted",[i,l]=function(e,t){return W.useReducer((e,n)=>t[e][n]??e,e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W.useEffect(()=>{const e=KP(r.current);a.current="mounted"===i?e:"none"},[i]),mP(()=>{const t=r.current,n=o.current;if(n!==e){const r=a.current,s=KP(t);if(e)l("MOUNT");else if("none"===s||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}o.current=e}},[e,l]),mP(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=a=>{const s=KP(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&s&&(l("ANIMATION_END"),!o.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},i=e=>{e.target===t&&(a.current=KP(r.current))};return t.addEventListener("animationstart",i),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",i),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:W.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),o="function"==typeof n?n({present:r.isPresent}):W.Children.only(n),a=aE(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof n||r.isPresent?W.cloneElement(o,{ref:a}):null};function KP(e){return(null==e?void 0:e.animationName)||"none"}GP.displayName="Presence";var YP=0;function XP(){W.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??QP()),document.body.insertAdjacentElement("beforeend",e[1]??QP()),YP++,()=>{1===YP&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),YP--}},[])}function QP(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var JP=function(){return JP=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},JP.apply(this,arguments)};function ZP(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var eN="right-scroll-bar-position",tN="width-before-scroll-bar";function nN(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var rN="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,oN=new WeakMap;function aN(e,t){var n,r,o,a=(n=null,r=function(t){return e.forEach(function(e){return nN(e,t)})},(o=W.useState(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return rN(function(){var t=oN.get(a);if(t){var n=new Set(t),r=new Set(e),o=a.current;n.forEach(function(e){r.has(e)||nN(e,null)}),r.forEach(function(e){n.has(e)||nN(e,o)})}oN.set(a,e)},[e]),a}function sN(e){return e}var iN=function(e){var t=e.sideCar,n=ZP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return W.createElement(r,JP({},n))};iN.isSideCarExport=!0;var lN=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=sN);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var o=t(e,r);return n.push(o),function(){n=n.filter(function(e){return e!==o})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var o=n;n=[],o.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(a)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=JP({async:!0,ssr:!1},e),t}(),cN=function(){},uN=W.forwardRef(function(e,t){var n=W.useRef(null),r=W.useState({onScrollCapture:cN,onWheelCapture:cN,onTouchMoveCapture:cN}),o=r[0],a=r[1],s=e.forwardProps,i=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,p=e.sideCar,h=e.noRelative,f=e.noIsolation,m=e.inert,g=e.allowPinchZoom,v=e.as,y=void 0===v?"div":v,b=e.gapMode,x=ZP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=p,k=aN([n,t]),S=JP(JP({},x),o);return W.createElement(W.Fragment,null,u&&W.createElement(w,{sideCar:lN,removeScrollBar:c,shards:d,noRelative:h,noIsolation:f,inert:m,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),s?W.cloneElement(W.Children.only(i),JP(JP({},S),{ref:k})):W.createElement(y,JP({},S,{className:l,ref:k}),i))});uN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},uN.classNames={fullWidth:tN,zeroRight:eN};function dN(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var pN=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=dN())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},hN=function(){var e,t=(e=pN(),function(t,n){W.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},fN={left:0,top:0,right:0,gap:0},mN=function(e){return parseInt(e||"",10)||0},gN=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return fN;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[mN(n),mN(r),mN(o)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},vN=hN(),yN="data-scroll-locked",bN=function(e,t,n,r){var o=e.left,a=e.top,s=e.right,i=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(i,"px ").concat(r,";\n }\n body[").concat(yN,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(i,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(i,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(eN," {\n right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(tN," {\n margin-right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(eN," .").concat(eN," {\n right: 0 ").concat(r,";\n }\n \n .").concat(tN," .").concat(tN," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(yN,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(i,"px;\n }\n")},xN=function(){var e=parseInt(document.body.getAttribute(yN)||"0",10);return isFinite(e)?e:0},wN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=void 0===r?"margin":r;W.useEffect(function(){return document.body.setAttribute(yN,(xN()+1).toString()),function(){var e=xN()-1;e<=0?document.body.removeAttribute(yN):document.body.setAttribute(yN,e.toString())}},[]);var a=W.useMemo(function(){return gN(o)},[o]);return W.createElement(vN,{styles:bN(a,!t,o,n?"":"!important")})},kN=!1;if("undefined"!=typeof window)try{var SN=Object.defineProperty({},"passive",{get:function(){return kN=!0,!0}});window.addEventListener("test",SN,SN),window.removeEventListener("test",SN,SN)}catch(kR){kN=!1}var EN=!!kN&&{passive:!1},CN=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},jN=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),PN(e,r)){var o=NN(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},PN=function(e,t){return"v"===e?function(e){return CN(e,"overflowY")}(t):function(e){return CN(e,"overflowX")}(t)},NN=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},_N=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},TN=function(e){return[e.deltaX,e.deltaY]},RN=function(e){return e&&"current"in e?e.current:e},LN=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},MN=0,ON=[];function DN(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const AN=(IN=function(e){var t=W.useRef([]),n=W.useRef([0,0]),r=W.useRef(),o=W.useState(MN++)[0],a=W.useState(hN)[0],s=W.useRef(e);W.useEffect(function(){s.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(RN),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=W.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!s.current.allowPinchZoom;var o,a=_N(e),i=n.current,l="deltaX"in e?e.deltaX:i[0]-a[0],c="deltaY"in e?e.deltaY:i[1]-a[1],u=e.target,d=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===d&&"range"===u.type)return!1;var p=window.getSelection(),h=p&&p.anchorNode;if(h&&(h===u||h.contains(u)))return!1;var f=jN(d,u);if(!f)return!0;if(f?o=d:(o="v"===d?"h":"v",f=jN(d,u)),!f)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=o),!o)return!0;var m=r.current||o;return function(e,t,n,r){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,i=t.contains(s),l=!1,c=a>0,u=0,d=0;do{if(!s)break;var p=NN(e,s),h=p[0],f=p[1]-p[2]-o*h;(h||f)&&PN(e,s)&&(u+=f,d+=h);var m=s.parentNode;s=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!i&&s!==document.body||i&&(t.contains(s)||t===s));return(c&&Math.abs(u)<1||!c&&Math.abs(d)<1)&&(l=!0),l}(m,t,e,"h"===m?l:c)},[]),l=W.useCallback(function(e){var n=e;if(ON.length&&ON[ON.length-1]===a){var r="deltaY"in n?TN(n):_N(n),o=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,o=r,t[0]===o[0]&&t[1]===o[1]);var t,o})[0];if(o&&o.should)n.cancelable&&n.preventDefault();else if(!o){var l=(s.current.shards||[]).map(RN).filter(Boolean).filter(function(e){return e.contains(n.target)});(l.length>0?i(n,l[0]):!s.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),c=W.useCallback(function(e,n,r,o){var a={name:e,delta:n,target:r,should:o,shadowParent:DN(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=W.useCallback(function(e){n.current=_N(e),r.current=void 0},[]),d=W.useCallback(function(t){c(t.type,TN(t),t.target,i(t,e.lockRef.current))},[]),p=W.useCallback(function(t){c(t.type,_N(t),t.target,i(t,e.lockRef.current))},[]);W.useEffect(function(){return ON.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:p}),document.addEventListener("wheel",l,EN),document.addEventListener("touchmove",l,EN),document.addEventListener("touchstart",u,EN),function(){ON=ON.filter(function(e){return e!==a}),document.removeEventListener("wheel",l,EN),document.removeEventListener("touchmove",l,EN),document.removeEventListener("touchstart",u,EN)}},[]);var h=e.removeScrollBar,f=e.inert;return W.createElement(W.Fragment,null,f?W.createElement(a,{styles:LN(o)}):null,h?W.createElement(wN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},lN.useMedium(IN),iN);var IN,FN=W.forwardRef(function(e,t){return W.createElement(uN,JP({},e,{ref:t,sideCar:AN}))});FN.classNames=uN.classNames;var zN=new WeakMap,$N=new WeakMap,VN={},UN=0,BN=function(e){return e&&(e.host||BN(e.parentNode))},WN=function(e,t,n,r){var o=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=BN(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);VN[n]||(VN[n]=new WeakMap);var a=VN[n],s=[],i=new Set,l=new Set(o),c=function(e){e&&!i.has(e)&&(i.add(e),c(e.parentNode))};o.forEach(c);var u=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(i.has(e))u(e);else try{var t=e.getAttribute(r),o=null!==t&&"false"!==t,l=(zN.get(e)||0)+1,c=(a.get(e)||0)+1;zN.set(e,l),a.set(e,c),s.push(e),1===l&&o&&$N.set(e,!0),1===c&&e.setAttribute(n,"true"),o||e.setAttribute(r,"true")}catch(wR){console.error("aria-hidden: cannot operate on ",e,wR)}})};return u(t),i.clear(),UN++,function(){s.forEach(function(e){var t=zN.get(e)-1,o=a.get(e)-1;zN.set(e,t),a.set(e,o),t||($N.has(e)||e.removeAttribute(r),$N.delete(e)),o||e.removeAttribute(n)}),--UN||(zN=new WeakMap,zN=new WeakMap,$N=new WeakMap,VN={})}},HN=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),WN(r,o,n,"aria-hidden")):function(){return null}};function qN(e){const t=GN(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),s=a.find(YN);if(s){const e=s.props.children,r=a.map(t=>t===s?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function GN(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?oE(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var KN=Symbol("radix.slottable");function YN(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===KN}var XN="Dialog",[QN]=hP(XN),[JN,ZN]=QN(XN),e_=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=e,i=W.useRef(null),l=W.useRef(null),[c,u]=xP({prop:r,defaultProp:o??!1,onChange:a,caller:XN});return ee.jsx(JN,{scope:t,triggerRef:i,contentRef:l,contentId:yP(),titleId:yP(),descriptionId:yP(),open:c,onOpenChange:u,onOpenToggle:W.useCallback(()=>u(e=>!e),[u]),modal:s,children:n})};e_.displayName=XN;var t_="DialogTrigger";W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(t_,n),a=aE(t,o.triggerRef);return ee.jsx(CP.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":w_(o.open),...r,ref:a,onClick:pP(e.onClick,o.onOpenToggle)})}).displayName=t_;var n_="DialogPortal",[r_,o_]=QN(n_,{forceMount:void 0}),a_=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ZN(n_,t);return ee.jsx(r_,{scope:t,forceMount:n,children:W.Children.map(r,e=>ee.jsx(GP,{present:n||a.open,children:ee.jsx(qP,{asChild:!0,container:o,children:e})}))})};a_.displayName=n_;var s_="DialogOverlay",i_=W.forwardRef((e,t)=>{const n=o_(s_,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ZN(s_,e.__scopeDialog);return a.modal?ee.jsx(GP,{present:r||a.open,children:ee.jsx(c_,{...o,ref:t})}):null});i_.displayName=s_;var l_=qN("DialogOverlay.RemoveScroll"),c_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(s_,n);return ee.jsx(FN,{as:l_,allowPinchZoom:!0,shards:[o.contentRef],children:ee.jsx(CP.div,{"data-state":w_(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),u_="DialogContent",d_=W.forwardRef((e,t)=>{const n=o_(u_,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ZN(u_,e.__scopeDialog);return ee.jsx(GP,{present:r||a.open,children:a.modal?ee.jsx(p_,{...o,ref:t}):ee.jsx(h_,{...o,ref:t})})});d_.displayName=u_;var p_=W.forwardRef((e,t)=>{const n=ZN(u_,e.__scopeDialog),r=W.useRef(null),o=aE(t,n.contentRef,r);return W.useEffect(()=>{const e=r.current;if(e)return HN(e)},[]),ee.jsx(f_,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pP(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:pP(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:pP(e.onFocusOutside,e=>e.preventDefault())})}),h_=W.forwardRef((e,t)=>{const n=ZN(u_,e.__scopeDialog),r=W.useRef(!1),o=W.useRef(!1);return ee.jsx(f_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var a,s;null==(a=e.onCloseAutoFocus)||a.call(e,t),t.defaultPrevented||(r.current||null==(s=n.triggerRef.current)||s.focus(),t.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:t=>{var a,s;null==(a=e.onInteractOutside)||a.call(e,t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const i=t.target;(null==(s=n.triggerRef.current)?void 0:s.contains(i))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),f_=W.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=e,i=ZN(u_,n),l=W.useRef(null),c=aE(t,l);return XP(),ee.jsxs(ee.Fragment,{children:[ee.jsx(zP,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:ee.jsx(MP,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":w_(i.open),...s,ref:c,onDismiss:()=>i.onOpenChange(!1)})}),ee.jsxs(ee.Fragment,{children:[ee.jsx(C_,{titleId:i.titleId}),ee.jsx(j_,{contentRef:l,descriptionId:i.descriptionId})]})]})}),m_="DialogTitle",g_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(m_,n);return ee.jsx(CP.h2,{id:o.titleId,...r,ref:t})});g_.displayName=m_;var v_="DialogDescription",y_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(v_,n);return ee.jsx(CP.p,{id:o.descriptionId,...r,ref:t})});y_.displayName=v_;var b_="DialogClose",x_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(b_,n);return ee.jsx(CP.button,{type:"button",...r,ref:t,onClick:pP(e.onClick,()=>o.onOpenChange(!1))})});function w_(e){return e?"open":"closed"}x_.displayName=b_;var k_="DialogTitleWarning",[S_,E_]=function(e,t){const n=W.createContext(t),r=e=>{const{children:t,...r}=e,o=W.useMemo(()=>r,Object.values(r));return ee.jsx(n.Provider,{value:o,children:t})};return r.displayName=e+"Provider",[r,function(r){const o=W.useContext(n);if(o)return o;if(void 0!==t)return t;throw new Error(`\`${r}\` must be used within \`${e}\``)}]}(k_,{contentName:u_,titleName:m_,docsSlug:"dialog"}),C_=({titleId:e})=>{const t=E_(k_),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return W.useEffect(()=>{if(e){document.getElementById(e)||console.error(n)}},[n,e]),null},j_=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${E_("DialogDescriptionWarning").contentName}}.`;return W.useEffect(()=>{var r;const o=null==(r=e.current)?void 0:r.getAttribute("aria-describedby");if(t&&o){document.getElementById(t)||console.warn(n)}},[n,e,t]),null},P_=i_,N_=d_,__=g_,T_=y_,R_=x_;const L_=e_,M_=a_,O_=W.forwardRef(({className:e,...t},n)=>ee.jsx(P_,{ref:n,className:XS("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}));O_.displayName=P_.displayName;const D_=W.forwardRef(({className:e,children:t,noOverlay:n,...r},o)=>ee.jsxs(M_,{children:[!n&&ee.jsx(O_,{}),ee.jsxs(N_,{ref:o,className:XS("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-xl",e),...r,children:[t,ee.jsxs(R_,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[ee.jsx(iP,{className:"h-4 w-4"}),ee.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));D_.displayName=N_.displayName;const A_=({className:e,...t})=>ee.jsx("div",{className:XS("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});A_.displayName="DialogHeader";const I_=({className:e,...t})=>ee.jsx("div",{className:XS("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});I_.displayName="DialogFooter";const F_=W.forwardRef(({className:e,...t},n)=>ee.jsx(__,{ref:n,className:XS("text-lg font-semibold leading-none tracking-tight",e),...t}));F_.displayName=__.displayName;const z_=W.forwardRef(({className:e,...t},n)=>ee.jsx(T_,{ref:n,className:XS("text-sm text-muted-foreground",e),...t}));function $_({project:e,open:t,onOpenChange:n,onUpdated:r}){const[o,a]=W.useState([]),[s,i]=W.useState([]),[l,c]=W.useState(!1),[u,d]=W.useState(null);W.useEffect(()=>{if(!t)return;a(e.shares?[...e.shares]:[]),d(null);let n=!1;return GE().then(e=>{n||i(e)}).catch(()=>{}),()=>{n=!0}},[t,e.id]);const p=new Set(o.map(e=>e.username)),h=s.filter(t=>t!==e.owner&&!p.has(t));return ee.jsx(L_,{open:t,onOpenChange:n,children:ee.jsxs(D_,{className:"sm:max-w-md",children:[ee.jsxs(A_,{children:[ee.jsxs(F_,{className:"flex items-center gap-2",children:[ee.jsx(sP,{className:"h-4 w-4"}),"共享设置"]}),ee.jsx(z_,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),ee.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[0===o.length&&ee.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),o.map(e=>ee.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[ee.jsx("span",{className:"text-sm font-medium",children:e.username}),ee.jsxs("div",{className:"flex items-center gap-1.5",children:[ee.jsx("button",{onClick:()=>{return t=e.username,void a(e=>e.map(e=>e.username===t?{...e,permission:"view"===e.permission?"edit":"view"}:e));var t},className:"focus:outline-none",children:ee.jsx(dP,{variant:"edit"===e.permission?"default":"secondary",className:"cursor-pointer text-xs",children:"edit"===e.permission?"可编辑":"可见"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>{return t=e.username,void a(e=>e.filter(e=>e.username!==t));var t},children:ee.jsx(aP,{className:"h-3.5 w-3.5"})})]})]},e.username))]}),h.length>0&&ee.jsxs("div",{className:"border-t pt-3",children:[ee.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),ee.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>ee.jsxs(yE,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>{return t=e,void a(e=>[...e,{username:t,permission:"view"}]);var t},children:[ee.jsx(Yj,{className:"h-3 w-3"}),e]},e))})]}),u&&ee.jsx("p",{className:"text-sm text-destructive",children:u}),ee.jsxs(I_,{children:[ee.jsx(yE,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),ee.jsx(yE,{onClick:()=>{(async()=>{c(!0),d(null);try{const t=await KE(e.id,o);r(t),n(!1)}catch(kR){d(kR instanceof Error?kR.message:"Failed to update shares")}finally{c(!1)}})()},disabled:l,children:l?"保存中...":"保存"})]})]})})}z_.displayName=T_.displayName;const V_=Array(12).fill(0),U_=({visible:e,className:t})=>H.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},H.createElement("div",{className:"sonner-spinner"},V_.map((e,t)=>H.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),B_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),W_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},H.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"})),H_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),q_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),G_=H.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"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let K_=1;const Y_=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n,...r}=e,o="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:K_++,a=this.toasts.find(e=>e.id===o),s=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(t=>t.id===o?(this.publish({...t,...e,id:o,title:n}),{...t,...e,id:o,dismissible:s,title:n}):t):this.addToast({title:n,...r,dismissible:s,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o,a=void 0!==n;const s=r.then(async e=>{o=["resolve",e];if(H.isValidElement(e))a=!1,this.create({id:n,type:"default",message:e});else if(X_(e)&&!e.ok){a=!1;const r="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,o="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}else if(e instanceof Error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}else if(void 0!==t.success){a=!1;const r="function"==typeof t.success?await t.success(e):t.success,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"success",description:o,...s})}}).catch(async e=>{if(o=["reject",e],void 0!==t.error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),i=()=>new Promise((e,t)=>s.then(()=>"reject"===o[0]?t(o[1]):e(o[1])).catch(t));return"string"!=typeof n&&"number"!=typeof n?{unwrap:i}:Object.assign(n,{unwrap:i})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||K_++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},X_=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,Q_=(e,t)=>{const n=(null==t?void 0:t.id)||K_++;return Y_.addToast({title:e,...t,id:n}),n},J_=Object.assign(Q_,{success:Y_.success,info:Y_.info,warning:Y_.warning,error:Y_.error,custom:Y_.custom,message:Y_.message,promise:Y_.promise,dismiss:Y_.dismiss,loading:Y_.loading},{getHistory:()=>Y_.toasts,getToasts:()=>Y_.getActiveToasts()});function Z_(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)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))}("[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%)}");const eT=3,tT=14;function nT(...e){return e.filter(Boolean).join(" ")}const rT=e=>{var t,n,r,o,a,s,i,l,c;const{invert:u,toast:d,unstyled:p,interacting:h,setHeights:f,visibleToasts:m,heights:g,index:v,toasts:y,expanded:b,removeToast:x,defaultRichColors:w,closeButton:k,style:S,cancelButtonStyle:E,actionButtonStyle:C,className:j="",descriptionClassName:P="",duration:N,position:_,gap:T,expandByDefault:R,classNames:L,icons:M,closeButtonAriaLabel:O="Close toast"}=e,[D,A]=H.useState(null),[I,F]=H.useState(null),[z,$]=H.useState(!1),[V,U]=H.useState(!1),[B,W]=H.useState(!1),[q,G]=H.useState(!1),[K,Y]=H.useState(!1),[X,Q]=H.useState(0),[J,Z]=H.useState(0),ee=H.useRef(d.duration||N||4e3),te=H.useRef(null),ne=H.useRef(null),re=0===v,oe=v+1<=m,ae=d.type,se=!1!==d.dismissible,ie=d.className||"",le=d.descriptionClassName||"",ce=H.useMemo(()=>g.findIndex(e=>e.toastId===d.id)||0,[g,d.id]),ue=H.useMemo(()=>{var e;return null!=(e=d.closeButton)?e:k},[d.closeButton,k]),de=H.useMemo(()=>d.duration||N||4e3,[d.duration,N]),pe=H.useRef(0),he=H.useRef(0),fe=H.useRef(0),me=H.useRef(null),[ge,ve]=_.split("-"),ye=H.useMemo(()=>g.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[g,ce]),be=(()=>{const[e,t]=H.useState(document.hidden);return H.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),xe=d.invert||u,we="loading"===ae;he.current=H.useMemo(()=>ce*T+ye,[ce,ye]),H.useEffect(()=>{ee.current=de},[de]),H.useEffect(()=>{$(!0)},[]),H.useEffect(()=>{const e=ne.current;if(e){const t=e.getBoundingClientRect().height;return Z(t),f(e=>[{toastId:d.id,height:t,position:d.position},...e]),()=>f(e=>e.filter(e=>e.toastId!==d.id))}},[f,d.id]),H.useLayoutEffect(()=>{if(!z)return;const e=ne.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,Z(n),f(e=>e.find(e=>e.toastId===d.id)?e.map(e=>e.toastId===d.id?{...e,height:n}:e):[{toastId:d.id,height:n,position:d.position},...e])},[z,d.title,d.description,f,d.id,d.jsx,d.action,d.cancel]);const ke=H.useCallback(()=>{U(!0),Q(he.current),f(e=>e.filter(e=>e.toastId!==d.id)),setTimeout(()=>{x(d)},200)},[d,x,f,he]);H.useEffect(()=>{if(d.promise&&"loading"===ae||d.duration===1/0||"loading"===d.type)return;let e;return b||h||be?(()=>{if(fe.current<pe.current){const e=(new Date).getTime()-pe.current;ee.current=ee.current-e}fe.current=(new Date).getTime()})():ee.current!==1/0&&(pe.current=(new Date).getTime(),e=setTimeout(()=>{null==d.onAutoClose||d.onAutoClose.call(d,d),ke()},ee.current)),()=>clearTimeout(e)},[b,h,d,ae,be,ke]),H.useEffect(()=>{d.delete&&(ke(),null==d.onDismiss||d.onDismiss.call(d,d))},[ke,d.delete]);const Se=d.icon||(null==M?void 0:M[ae])||(e=>{switch(e){case"success":return B_;case"info":return H_;case"warning":return W_;case"error":return q_;default:return null}})(ae);var Ee,Ce,je,Pe;return H.createElement("li",{tabIndex:0,ref:ne,className:nT(j,ie,null==L?void 0:L.toast,null==d||null==(t=d.classNames)?void 0:t.toast,null==L?void 0:L.default,null==L?void 0:L[ae],null==d||null==(n=d.classNames)?void 0:n[ae]),"data-sonner-toast":"","data-rich-colors":null!=(Ee=d.richColors)?Ee:w,"data-styled":!Boolean(d.jsx||d.unstyled||p),"data-mounted":z,"data-promise":Boolean(d.promise),"data-swiped":K,"data-removed":V,"data-visible":oe,"data-y-position":ge,"data-x-position":ve,"data-index":v,"data-front":re,"data-swiping":B,"data-dismissible":se,"data-type":ae,"data-invert":xe,"data-swipe-out":q,"data-swipe-direction":I,"data-expanded":Boolean(b||R&&z),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${V?X:he.current}px`,"--initial-height":R?"auto":`${J}px`,...S,...d.style},onDragEnd:()=>{W(!1),A(null),me.current=null},onPointerDown:e=>{2!==e.button&&!we&&se&&(te.current=new Date,Q(he.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(W(!0),me.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(q||!se)return;me.current=null;const r=Number((null==(e=ne.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),o=Number((null==(t=ne.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(n=te.current)?void 0:n.getTime()),s="x"===D?r:o,i=Math.abs(s)/a;if(Math.abs(s)>=45||i>.11)return Q(he.current),null==d.onDismiss||d.onDismiss.call(d,d),F("x"===D?r>0?"right":"left":o>0?"down":"up"),ke(),void G(!0);var l,c;null==(l=ne.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(c=ne.current)||c.style.setProperty("--swipe-amount-y","0px"),Y(!1),W(!1),A(null)},onPointerMove:t=>{var n,r,o;if(!me.current||!se)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const a=t.clientY-me.current.y,s=t.clientX-me.current.x;var i;const l=null!=(i=e.swipeDirections)?i:function(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}(_);!D&&(Math.abs(s)>1||Math.abs(a)>1)&&A(Math.abs(s)>Math.abs(a)?"x":"y");let c={x:0,y:0};const u=e=>1/(1.5+Math.abs(e)/20);if("y"===D){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)c.y=a;else{const e=a*u(a);c.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===D&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&s<0||l.includes("right")&&s>0)c.x=s;else{const e=s*u(s);c.x=Math.abs(e)<Math.abs(s)?e:s}(Math.abs(c.x)>0||Math.abs(c.y)>0)&&Y(!0),null==(r=ne.current)||r.style.setProperty("--swipe-amount-x",`${c.x}px`),null==(o=ne.current)||o.style.setProperty("--swipe-amount-y",`${c.y}px`)}},ue&&!d.jsx&&"loading"!==ae?H.createElement("button",{"aria-label":O,"data-disabled":we,"data-close-button":!0,onClick:we||!se?()=>{}:()=>{ke(),null==d.onDismiss||d.onDismiss.call(d,d)},className:nT(null==L?void 0:L.closeButton,null==d||null==(r=d.classNames)?void 0:r.closeButton)},null!=(Ce=null==M?void 0:M.close)?Ce:G_):null,(ae||d.icon||d.promise)&&null!==d.icon&&(null!==(null==M?void 0:M[ae])||d.icon)?H.createElement("div",{"data-icon":"",className:nT(null==L?void 0:L.icon,null==d||null==(o=d.classNames)?void 0:o.icon)},d.promise||"loading"===d.type&&!d.icon?d.icon||((null==M?void 0:M.loading)?H.createElement("div",{className:nT(null==L?void 0:L.loader,null==d||null==(Pe=d.classNames)?void 0:Pe.loader,"sonner-loader"),"data-visible":"loading"===ae},M.loading):H.createElement(U_,{className:nT(null==L?void 0:L.loader,null==d||null==(je=d.classNames)?void 0:je.loader),visible:"loading"===ae})):null,"loading"!==d.type?Se:null):null,H.createElement("div",{"data-content":"",className:nT(null==L?void 0:L.content,null==d||null==(a=d.classNames)?void 0:a.content)},H.createElement("div",{"data-title":"",className:nT(null==L?void 0:L.title,null==d||null==(s=d.classNames)?void 0:s.title)},d.jsx?d.jsx:"function"==typeof d.title?d.title():d.title),d.description?H.createElement("div",{"data-description":"",className:nT(P,le,null==L?void 0:L.description,null==d||null==(i=d.classNames)?void 0:i.description)},"function"==typeof d.description?d.description():d.description):null),H.isValidElement(d.cancel)?d.cancel:d.cancel&&Z_(d.cancel)?H.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:e=>{Z_(d.cancel)&&se&&(null==d.cancel.onClick||d.cancel.onClick.call(d.cancel,e),ke())},className:nT(null==L?void 0:L.cancelButton,null==d||null==(l=d.classNames)?void 0:l.cancelButton)},d.cancel.label):null,H.isValidElement(d.action)?d.action:d.action&&Z_(d.action)?H.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||C,onClick:e=>{Z_(d.action)&&(null==d.action.onClick||d.action.onClick.call(d.action,e),e.defaultPrevented||ke())},className:nT(null==L?void 0:L.actionButton,null==d||null==(c=d.classNames)?void 0:c.actionButton)},d.action.label):null)};function oT(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function aT(e,t){const n={};return[e,t].forEach((e,t)=>{const r=1===t,o=r?"--mobile-offset":"--offset",a=r?"16px":"24px";function s(e){["top","right","bottom","left"].forEach(t=>{n[`${o}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?s(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n[`${o}-${t}`]=a:n[`${o}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):s(a)}),n}const sT=H.forwardRef(function(e,t){const{id:n,invert:r,position:o="bottom-right",hotkey:a=["altKey","KeyT"],expand:s,closeButton:i,className:l,offset:c,mobileOffset:u,theme:d="light",richColors:p,duration:h,style:f,visibleToasts:m=eT,toastOptions:g,dir:v=oT(),gap:y=tT,icons:b,containerAriaLabel:x="Notifications"}=e,[w,k]=H.useState([]),S=H.useMemo(()=>n?w.filter(e=>e.toasterId===n):w.filter(e=>!e.toasterId),[w,n]),E=H.useMemo(()=>Array.from(new Set([o].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,o]),[C,j]=H.useState([]),[P,N]=H.useState(!1),[_,T]=H.useState(!1),[R,L]=H.useState("system"!==d?d:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=H.useRef(null),O=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=H.useRef(null),A=H.useRef(!1),I=H.useCallback(e=>{k(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||Y_.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return H.useEffect(()=>Y_.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{cd.flushSync(()=>{k(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]:[e,...t]})})})}),[w]),H.useEffect(()=>{if("system"!==d)return void L(d);if("system"===d&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{L(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{L(e?"dark":"light")}catch(wR){console.error(wR)}})}},[d]),H.useEffect(()=>{w.length<=1&&N(!1)},[w]),H.useEffect(()=>{const e=e=>{var t;var n;a.every(t=>e[t]||e.code===t)&&(N(!0),null==(n=M.current)||n.focus());"Escape"!==e.code||document.activeElement!==M.current&&!(null==(t=M.current)?void 0:t.contains(document.activeElement))||N(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),H.useEffect(()=>{if(M.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,A.current=!1)}},[M.current]),H.createElement("section",{ref:t,"aria-label":`${x} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((t,n)=>{var o;const[a,d]=t.split("-");return S.length?H.createElement("ol",{key:t,dir:"auto"===v?oT():v,tabIndex:-1,ref:M,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":d,style:{"--front-toast-height":`${(null==(o=C[0])?void 0:o.height)||0}px`,"--width":"356px","--gap":`${y}px`,...f,...aT(c,u)},onBlur:e=>{A.current&&!e.currentTarget.contains(e.relatedTarget)&&(A.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||A.current||(A.current=!0,D.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{_||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||T(!0)},onPointerUp:()=>T(!1)},S.filter(e=>!e.position&&0===n||e.position===t).map((n,o)=>{var a,l;return H.createElement(rT,{key:n.id,icons:b,index:o,toast:n,defaultRichColors:p,duration:null!=(a=null==g?void 0:g.duration)?a:h,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:i,interacting:_,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:I,toasts:S.filter(e=>e.position==n.position),heights:C.filter(e=>e.position==n.position),setHeights:j,expandByDefault:s,gap:y,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),iT=W.createContext(null);function lT({children:e}){const[t,n]=W.useState(!1),[r,o]=W.useState({}),a=W.useRef(null),s=W.useCallback(e=>(o(e),n(!0),new Promise(e=>{a.current=e})),[]),i=W.useCallback(e=>{n(!1);const t=a.current;a.current=null,t&&t(e)},[]);return ee.jsxs(iT.Provider,{value:s,children:[e,ee.jsx(L_,{open:t,onOpenChange:e=>{e||i(!1)},children:ee.jsxs(D_,{className:"max-w-md",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:r.title??"确认"}),void 0!==r.description&&ee.jsx(z_,{asChild:!0,children:ee.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),ee.jsxs(I_,{children:[ee.jsx(yE,{variant:"outline",onClick:()=>i(!1),children:r.cancelLabel??"取消"}),ee.jsx(cT,{destructive:r.destructive,onClick:()=>i(!0),children:r.confirmLabel??"确定"})]})]})})]})}function cT({destructive:e,onClick:t,children:n}){const r=W.useRef(null);return W.useEffect(()=>{var e;null==(e=r.current)||e.focus()},[]),ee.jsx(yE,{ref:r,onClick:t,className:XS(e&&"bg-red-600 hover:bg-red-700 text-white"),children:n})}function uT(){const e=W.useContext(iT);if(!e)throw new Error("useConfirm must be used within <ConfirmProvider>");return e}function dT(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 pT({status:e}){return ee.jsx("span",{className:XS("inline-block w-2 h-2 rounded-full",{"bg-green-500":"running"===e,"bg-zinc-400":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})})}const hT=H.memo(function({project:e,active:t=!1,statusStack:n=[],onDelete:r,onArchive:o,onUnarchive:a,onUpdated:s}){var i,l;const c=cp(),u=uT(),[d,p]=W.useState(!1),[h,f]=W.useState(null),[m,g]=W.useState(!1),[v,y]=W.useState(e.name),b=W.useRef(null),x=!!e._sharedPermission;W.useEffect(()=>{let t=!1;return XC(e.id).then(({bytes:e})=>{t||f(e)}).catch(()=>{}),()=>{t=!0}},[e.id]);const w="view"===e._sharedPermission,k=t=>{t.stopPropagation(),y(e.name),g(!0),setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.select()},0)},S=async()=>{const t=v.trim();if(t&&t!==e.name)try{const n=await KC(e.id,t);null==s||s(n),g(!1)}catch(kR){J_.error("Rename failed",{description:null==kR?void 0:kR.message})}else g(!1)},E=ee.jsx(tS.div,{whileHover:e.archived||t?{}:{y:-2},transition:bj.fast,children:ee.jsxs(QS,{className:XS("group cursor-pointer transition-colors relative",e.archived?"opacity-60 hover:opacity-80 hover:border-muted-foreground/40":t?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-muted-foreground/40"),onClick:()=>!e.archived&&c(`/projects/${e.id}`),children:[ee.jsxs(JS,{className:"pb-2",children:[ee.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m?ee.jsx("input",{ref:b,className:"text-base leading-tight font-semibold bg-transparent border-b border-primary outline-none w-full min-w-0",value:v,onChange:e=>y(e.target.value),onBlur:()=>{S()},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S()),"Escape"===e.key&&g(!1)},onClick:e=>e.stopPropagation()}):ee.jsx(ZS,{className:XS("text-base leading-tight",e.archived&&"text-muted-foreground"),onDoubleClick:x||e.archived?void 0:k,children:e.name}),ee.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!x&&ee.jsxs(ee.Fragment,{children:[e.archived?ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),a(e.id)},title:"Restore project",children:ee.jsx(Sj,{className:"h-3.5 w-3.5"})}):ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:k,title:"Rename project",children:ee.jsx(Kj,{className:"h-3.5 w-3.5"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:e=>{e.stopPropagation(),p(!0)},title:"共享设置",children:ee.jsx(sP,{className:"h-3.5 w-3.5"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),o(e.id)},title:"Archive project",children:ee.jsx(Ej,{className:"h-3.5 w-3.5"})})]}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:async t=>{t.stopPropagation();await u({title:"删除项目",description:`确认删除项目 "${e.name}"?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"})&&r(e.id)},title:"Delete project",children:ee.jsx(aP,{className:"h-3.5 w-3.5"})})]})})]}),ee.jsx("div",{className:"flex items-center gap-1.5",children:e.archived?ee.jsx(dP,{variant:"secondary",className:"text-xs",children:"Archived"}):ee.jsxs(ee.Fragment,{children:[ee.jsx(pT,{status:e.status}),ee.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:e.status}),t&&n.length>0&&ee.jsx("div",{className:"ml-auto",children:ee.jsx(Iw,{mode:"wait",children:n.slice(-1).map(e=>ee.jsx(tS.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:bj.default,children:ee.jsx(dP,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:dT(e.phase,e.detail)})},e.id))})})]})})]}),ee.jsxs(tE,{className:"space-y-2",children:[ee.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[ee.jsx(Rj,{className:"h-3.5 w-3.5 flex-shrink-0"}),ee.jsx("span",{className:"truncate font-mono",children:e.folderPath}),null!==h&&ee.jsx("span",{className:"flex-shrink-0 ml-auto text-muted-foreground/70",children:(C=h,C>=1073741824?(C/1073741824).toFixed(1)+" GB":C>=1048576?(C/1048576).toFixed(1)+" MB":Math.round(C/1024)+" KB")})]}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(dP,{variant:"outline",className:"text-xs font-mono",children:e.cliTool??"claude"}),ee.jsx(dP,{variant:"unlimited"===e.permissionMode?"destructive":"secondary",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),x&&ee.jsxs(dP,{variant:"outline",className:"text-xs gap-0.5",children:[w?ee.jsx(_j,{className:"h-3 w-3"}):ee.jsx(Kj,{className:"h-3 w-3"}),w?"可见":"可编辑"]}),!x&&e.shares&&e.shares.length>0&&ee.jsxs(dP,{variant:"outline",className:"text-xs gap-0.5",children:[ee.jsx(sP,{className:"h-3 w-3"}),e.shares.length]}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleDateString()})]}),(e.tags??[]).length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(e.tags??[]).slice(0,3).map(e=>ee.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",e]},e)),((null==(i=e.tags)?void 0:i.length)??0)>3&&ee.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",((null==(l=e.tags)?void 0:l.length)??0)-3]})]})]})]})});var C;const j=t&&!e.archived?ee.jsx("div",{className:"card-active-glow rounded-xl",children:E}):E;return ee.jsxs(ee.Fragment,{children:[j,!x&&s&&ee.jsx($_,{project:e,open:d,onOpenChange:p,onUpdated:s})]})});function fT({onSelect:e}){const[t,n]=W.useState(""),[r,o]=W.useState(null),[a,s]=W.useState([]),[i,l]=W.useState(!0),[c,u]=W.useState(null),[d,p]=W.useState(!1),[h,f]=W.useState(""),[m,g]=W.useState(null),[v,y]=W.useState(!1),b=W.useRef(null),x=async e=>{l(!0),u(null);try{const t=await _C(e);n(t.path),o(t.parent),s(t.entries)}catch(kR){u(kR instanceof Error?kR.message:"Failed to load directory")}finally{l(!1)}};W.useEffect(()=>{x()},[]),W.useEffect(()=>{d&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[d]);const w=()=>{p(!1),f(""),g(null)},k=async()=>{const e=h.trim();if(e){y(!0),g(null);try{const{path:n}=await LC(t,e);p(!1),f(""),await x(t),x(n)}catch(kR){g(kR instanceof Error?kR.message:"Failed to create folder")}finally{y(!1)}}},S=t.split("/").filter(Boolean);return ee.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[ee.jsx(yE,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>{x()},title:"Home",children:ee.jsx(Fj,{className:"h-3 w-3"})}),ee.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:S.map((e,t)=>ee.jsxs(H.Fragment,{children:[ee.jsx(Pj,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ee.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>(e=>{const t="/"+S.slice(0,e+1).join("/");x(t)})(t),children:e})]},t))}),ee.jsxs(yE,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:()=>{f(""),g(null),p(!0)},disabled:d||i||!!c,title:"New folder",children:[ee.jsx(Lj,{className:"h-3.5 w-3.5"}),ee.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),ee.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),c&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:c}),!i&&!c&&ee.jsxs("div",{className:"p-1",children:[r&&ee.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:()=>{x(r)},children:[ee.jsx(Cj,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("span",{children:".."})]}),d&&ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[ee.jsx(Oj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("input",{ref:b,className:XS("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",m&&"border-destructive"),placeholder:"Folder name",value:h,onChange:e=>{f(e.target.value),g(null)},onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),k()):"Escape"===e.key&&w()},disabled:v}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>{k()},disabled:!h.trim()||v,title:"Create",children:ee.jsx(jj,{className:"h-3.5 w-3.5 text-green-600"})}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:w,disabled:v,title:"Cancel",children:ee.jsx(iP,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),m&&ee.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:m}),0===a.length&&!d&&ee.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),a.map(e=>ee.jsxs("button",{className:XS("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left","dir"===e.type?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{"dir"===e.type&&x(e.path)},disabled:"file"===e.type,children:["dir"===e.type?ee.jsx(Oj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}):ee.jsx(Tj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("span",{className:"truncate",children:e.name})]},e.path))]})]}),ee.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),ee.jsx(yE,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}function mT(e,t="shift"){return W.useCallback(n=>{if("Enter"!==n.key)return;if(n.nativeEvent.isComposing||229===n.keyCode)return;("shift"===t?!n.shiftKey:n.shiftKey)&&(n.preventDefault(),e())},[e,t])}const gT=[{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)"},{value:"gemini",label:"Gemini",desc:"Google Gemini CLI"},{value:"terminal",label:"Terminal",desc:"Plain shell (no AI CLI)"}],vT={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"},gemini:{limited:"gemini",unlimited:"gemini --yolo"},terminal:{limited:"$SHELL (interactive)",unlimited:"$SHELL (interactive)"}};function yT({open:e,onOpenChange:t,onCreated:n}){const[r,o]=W.useState("name"),[a,s]=W.useState(""),[i,l]=W.useState(""),[c,u]=W.useState("claude"),[d,p]=W.useState("limited"),[h,f]=W.useState(!1),[m,g]=W.useState(null),v=e=>{e||(o("name"),s(""),l(""),u("claude"),p("limited"),g(null),f(!1)),t(e)},y=()=>{a.trim()?(g(null),o("folder")):g("Please enter a project name")},b=mT(y,"shift"),x=["name","folder","settings"];return ee.jsx(L_,{open:e,onOpenChange:v,children:ee.jsxs(D_,{className:"sm:max-w-lg",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:{name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"}[r]}),ee.jsxs(z_,{children:["name"===r&&"Give your project a name.","folder"===r&&"Choose the working directory for this project.","settings"===r&&"Choose the AI coding tool and run mode."]})]}),ee.jsx("div",{className:"flex gap-2 mb-2",children:x.map((e,t)=>ee.jsx("div",{className:"h-1.5 flex-1 rounded-full "+(r===e?"bg-primary":x.indexOf(r)>t?"bg-primary/40":"bg-muted")},e))}),"name"===r&&ee.jsxs("div",{className:"space-y-4",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{htmlFor:"project-name",children:"Project Name"}),ee.jsx(bE,{id:"project-name",placeholder:"My Project",value:a,onChange:e=>s(e.target.value),onKeyDown:b,autoFocus:!0})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),"folder"===r&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Working Directory"}),ee.jsx(fT,{onSelect:e=>{l(e),o("settings")}})]}),"settings"===r&&ee.jsxs("div",{className:"space-y-5",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"AI Coding Tool"}),ee.jsx("div",{className:"grid grid-cols-2 gap-2",children:gT.map(e=>ee.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors "+(c===e.value?"border-primary bg-primary/5":"hover:bg-accent"),children:[ee.jsx("input",{type:"radio",name:"cliTool",value:e.value,checked:c===e.value,onChange:()=>u(e.value),className:"accent-primary"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:e.label}),ee.jsx("div",{className:"text-xs text-muted-foreground",children:e.desc})]})]},e.value))})]}),"terminal"!==c&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Permission Mode"}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:"limited"===d,onChange:()=>p("limited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Limited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:vT[c].limited})," — asks for permission before file changes."]})]})]}),ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:"unlimited"===d,onChange:()=>p("unlimited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:vT[c].unlimited})," — acts autonomously."]})]})]})]})]}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:[ee.jsx("span",{className:"font-medium",children:"Folder:"})," ",ee.jsx("span",{className:"font-mono",children:i})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),ee.jsxs(I_,{children:["name"!==r&&ee.jsx(yE,{variant:"outline",onClick:()=>o("settings"===r?"folder":"name"),disabled:h,children:"Back"}),"name"===r&&ee.jsx(yE,{onClick:y,children:"Next"}),"folder"===r&&ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),"settings"===r&&ee.jsx(yE,{onClick:()=>{(async()=>{f(!0),g(null);try{const e=await YE({name:a.trim(),folderPath:i,permissionMode:d,cliTool:c});n(e),v(!1)}catch(kR){g(kR instanceof Error?kR.message:"Failed to create project")}finally{f(!1)}})()},disabled:h,children:h?"Creating...":"Create Project"})]})]})})}function bT({open:e,onOpenChange:t,onOpened:n}){const[r,o]=W.useState(""),[a,s]=W.useState(!1),[i,l]=W.useState(null),c=e=>{e||(o(""),l(null),s(!1)),t(e)};return ee.jsx(L_,{open:e,onOpenChange:c,children:ee.jsxs(D_,{className:"sm:max-w-lg",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:"Open Existing Project"}),ee.jsxs(z_,{children:["Select a folder that contains a ",ee.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Project Folder"}),ee.jsx(fT,{onSelect:e=>{(async e=>{o(e),s(!0),l(null);try{const t=await XE(e);n(t),c(!1)}catch(kR){l(kR instanceof Error?kR.message:"Failed to open project"),s(!1)}})(e)}})]}),i&&ee.jsx("p",{className:"text-sm text-destructive",children:i}),r&&!i&&a&&ee.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),ee.jsx(I_,{children:ee.jsx(yE,{variant:"outline",onClick:()=>c(!1),disabled:a,children:"Cancel"})})]})})}const xT=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}`;function wT(e){return 3e3*Math.min(e,4)+2e3*Math.random()}function kT(e,t){const n=W.useRef(null),r=W.useRef(0),o=W.useRef(!0),a=W.useRef(!1),s=W.useRef(null),i=W.useRef(t);i.current=t;const[l,c]=W.useState(!1),[u,d]=W.useState(0),p=W.useRef(!1),h=W.useRef([]),f=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(e))},[]),m=W.useCallback(()=>{var e;if((null==(e=n.current)?void 0:e.readyState)===WebSocket.OPEN)for(;h.current.length>0;){const e=h.current.shift();n.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),g=W.useCallback((e,t)=>{var r;(null==(r=n.current)?void 0:r.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:e,rows:t})),p.current=!1):p.current=!0},[]),v=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN?n.current.send(JSON.stringify({type:"terminal_input",data:e})):h.current.push(e)},[]),y=W.useCallback((e,t)=>{f({type:"terminal_resize",cols:e,rows:t})},[f]),b=W.useCallback(()=>{f({type:"chat_subscribe",replay:50})},[f]),x=W.useCallback(()=>{if(!o.current)return;if(a.current)return;const t=zE();if(!t)return void(window.location.href="/login");a.current=!0;const l=new WebSocket(`${xT}/ws/projects/${e}`);n.current=l,l.onopen=()=>{a.current=!1,r.current=0,l.send(JSON.stringify({type:"auth",token:t}))},l.onmessage=e=>{var t,n,r,o,a,s,l,u,h,f,g,v,y,b,x,w,k,S,E,C;let j;try{j=JSON.parse(e.data)}catch{return}switch(j.type){case"connected":p.current=!1,c(!0),d(e=>e+1),m(),null==(n=(t=i.current).onConnected)||n.call(t);break;case"terminal_data":null==(o=(r=i.current).onTerminalData)||o.call(r,j.data);break;case"terminal_reset":null==(s=(a=i.current).onTerminalReset)||s.call(a,j.cliTool);break;case"status":null==(u=(l=i.current).onStatus)||u.call(l,j.status);break;case"chat_message":{const e=j;null==(f=(h=i.current).onChatMessage)||f.call(h,e);break}case"project_stopped":{const e=j;null==(v=(g=i.current).onProjectStopped)||v.call(g,e.projectId,e.projectName);break}case"context_update":null==(b=(y=i.current).onContextUpdate)||b.call(y,j);break;case"semantic_update":null==(w=(x=i.current).onSemanticUpdate)||w.call(x,j);break;case"approval_request":null==(S=(k=i.current).onApprovalRequest)||S.call(k,j);break;case"approval_resolved":null==(C=(E=i.current).onApprovalResolved)||C.call(E,j);break;case"error":console.error("[WS] Server error:",j.message)}},l.onclose=()=>{var e,t;a.current=!1,n.current===l&&(n.current=null),c(!1),null==(t=(e=i.current).onDisconnected)||t.call(e),o.current&&r.current<5&&(r.current++,s.current=window.setTimeout(x,wT(r.current)))},l.onerror=e=>{a.current=!1,console.error("[WS] WebSocket error:",e)}},[e]);return W.useEffect(()=>(o.current=!0,x(),()=>{var e;o.current=!1,s.current&&(clearTimeout(s.current),s.current=null),null==(e=n.current)||e.close(),n.current=null,h.current=[]}),[x]),{subscribeTerminal:g,sendTerminalInput:v,sendTerminalResize:y,subscribeChatMessages:b,connected:l,readyTick:u}}function ST(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),s=W.useRef(e);s.current=e;const i=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=zE();if(!e)return;o.current=!0;const l=new WebSocket(`${xT}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n;try{const r=JSON.parse(e.data);"activity_update"===r.type?s.current.onActivityUpdate(r):"project_stopped"===r.type&&(null==(n=(t=s.current).onProjectStopped)||n.call(t,r.projectId,r.projectName))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(i,wT(n.current)))},l.onerror=e=>{o.current=!1,console.error("[DashboardWS] Error:",e)}},[]);W.useEffect(()=>(r.current=!0,i(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[i])}function ET(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),s=W.useRef(e);s.current=e;const i=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=zE();if(!e)return;o.current=!0;const l=new WebSocket(`${xT}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n,r,o,a,i;try{const l=JSON.parse(e.data);if(!l.type||!l.type.startsWith("sync."))return;"sync.start"===l.type?null==(n=(t=s.current).onStart)||n.call(t,l):"sync.progress"===l.type?null==(o=(r=s.current).onProgress)||o.call(r,l):"sync.done"===l.type&&(null==(i=(a=s.current).onDone)||i.call(a,l))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(i,wT(n.current)))},l.onerror=()=>{o.current=!1}},[]);W.useEffect(()=>(r.current=!0,i(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[i])}function CT({projectId:e,enabled:t,onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i}){const l=W.useRef(null),c=W.useRef(!0),u=W.useRef(0),d=W.useRef(null),p=W.useRef(!1),h=W.useRef(!1),f=W.useRef([]),m=W.useRef({onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i});m.current={onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i};const[g,v]=W.useState(!1),[y,b]=W.useState(0),x=W.useCallback(()=>{if(h.current&&l.current&&l.current.readyState===WebSocket.OPEN)for(;f.current.length>0;){const e=f.current.shift();l.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),w=W.useCallback(e=>{var t;h.current&&(null==(t=l.current)?void 0:t.readyState)===WebSocket.OPEN?l.current.send(JSON.stringify({type:"terminal_input",data:e})):f.current.push(e)},[]),k=W.useCallback(()=>{if(!c.current||!t)return;if(p.current)return;const n=zE();if(!n)return;p.current=!0,h.current=!1;const r=new WebSocket(`${xT}/ws/projects/${e}`);l.current=r,r.onopen=()=>{p.current=!1,u.current=0,r.send(JSON.stringify({type:"auth",token:n}))},r.onmessage=e=>{var t,n,o,a,s,i,l,c,u,d,p,f;try{const g=JSON.parse(e.data);"connected"===g.type?(r.send(JSON.stringify({type:"chat_subscribe",replay:50})),h.current=!0,v(!0),b(e=>e+1),x()):"chat_message"===g.type?m.current.onChatMessage(g):"status"===g.type&&g.status?null==(n=(t=m.current).onStatusChange)||n.call(t,g.status):"project_stopped"===g.type?null==(a=(o=m.current).onStatusChange)||a.call(o,"stopped"):"context_update"===g.type?null==(i=(s=m.current).onContextUpdate)||i.call(s,g):"approval_request"===g.type?null==(c=(l=m.current).onApprovalRequest)||c.call(l,g):"approval_resolved"===g.type?null==(d=(u=m.current).onApprovalResolved)||d.call(u,g):"semantic_update"===g.type&&(null==(f=(p=m.current).onSemanticUpdate)||f.call(p,g))}catch{}},r.onclose=()=>{p.current=!1,h.current=!1,v(!1),l.current===r&&(l.current=null),c.current&&t&&(u.current<5?(u.current++,d.current=window.setTimeout(k,wT(u.current))):f.current.length>0&&(console.warn("[MonitorWS] Retries exhausted, dropping",f.current.length,"queued messages"),f.current=[]))},r.onerror=()=>{p.current=!1}},[e,t,x]);return W.useEffect(()=>(c.current=!0,()=>{c.current=!1,f.current=[]}),[]),W.useEffect(()=>(u.current=0,k(),()=>{var e;h.current=!1,d.current&&(clearTimeout(d.current),d.current=null),null==(e=l.current)||e.close(),l.current=null}),[k,t]),{sendInput:w,connected:g,readyTick:y}}const jT="cc_project_order_cache";function PT(){try{const e=localStorage.getItem(jT);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[]}catch{return[]}}function NT(e){try{localStorage.setItem(jT,JSON.stringify(e))}catch{}}function _T(){const[e,t]=W.useState(PT),n=W.useRef(!1),r=W.useRef(null),o=W.useRef(null),a=W.useRef(!1),s=W.useRef(!0);W.useEffect(()=>{s.current=!0;let e=!1;return HE().then(r=>{e||n.current||(t(e=>function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,r)?e:r),NT(r))}).catch(()=>{}),()=>{e=!0,s.current=!1,o.current&&(clearTimeout(o.current),o.current=null)}},[]);const i=W.useCallback(async()=>{for(;r.current;){const e=r.current;r.current=null,a.current=!0;try{await qE(e)}catch{}a.current=!1}},[]),l=W.useCallback(e=>{n.current=!0,t(e),NT(e),r.current=e,o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,s.current&&(a.current||i())},400)},[i]),c=W.useCallback(t=>{const n=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>{const r=n.get(e.id)??1/0,o=n.get(t.id)??1/0;return r===o?0:r-o})},[e]);return W.useMemo(()=>({order:e,setOrder:l,applyOrder:c}),[e,l,c])}const TT=18e6,RT=6048e5;function LT(e,t=18e6){if(!e||void 0===e.utilization||e.utilization<=0||!e.resetAt)return null;const n=new Date(e.resetAt).getTime()-Date.now();if(n<=0)return null;const r=t-n;return r<=0?null:Math.round(e.utilization/(r/t))}function MT({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",o=function(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`}(t.resetAt);return ee.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",ee.jsxs("span",{className:XS("font-medium",r),children:[n,"%"]}),o&&ee.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",o,")"]})]})}function OT({className:e}){const[t,n]=W.useState("loading"),[r,o]=W.useState(!1),a=()=>TE(_E.usageMonitorTool,"claude");W.useEffect(()=>{const e=async()=>{try{n(await PC(a()))}catch{n(null)}};e();const t=setInterval(()=>{e()},3e5),r=()=>{e()},o=t=>{t.key===_E.usageMonitorTool&&e()};return window.addEventListener("ccweb:usage-tool-change",r),window.addEventListener("storage",o),()=>{clearInterval(t),window.removeEventListener("ccweb:usage-tool-change",r),window.removeEventListener("storage",o)}},[]);if("loading"===t)return null;if(!t)return null;const s=!!t.fiveHour,i=!!t.sevenDay,l=!!t.sevenDaySonnet,c=!!t.sevenDayOpus,u=s||i||l||c,d=LT(t.fiveHour,TT),p=LT(t.sevenDay,RT),h=LT(t.sevenDaySonnet,RT),f=null!==d||null!==p||null!==h;return ee.jsxs("div",{className:XS("flex items-center gap-1.5 text-xs",e),children:[f&&ee.jsxs("span",{className:"flex items-center gap-1",children:[null!==d&&ee.jsxs("span",{className:XS("font-medium",d<=100?"text-green-400":"text-orange-400"),title:`5h 配速:按当前速率,窗口结束时预计使用 ${d}%`,children:[d,"%"]}),null!==p&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:XS("font-medium",p<=100?"text-green-400":"text-orange-400"),title:`7d 配速:按当前速率,窗口结束时预计使用 ${p}%`,children:[p,"%"]})]}),null!==h&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:XS("font-medium",h<=100?"text-green-400":"text-orange-400"),title:`7d Sonnet 配速:按当前速率,窗口结束时预计使用 ${h}%`,children:[h,"%"]})]})]}),t.planName&&ee.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),u&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"|"}),ee.jsx(MT,{label:"5h",bucket:t.fiveHour}),i&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d",bucket:t.sevenDay})]}),l&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),ee.jsx("button",{onClick:()=>{(async()=>{o(!0);try{n(await NC(a()))}catch{n(null)}finally{o(!1)}})()},className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:ee.jsx(Xj,{className:XS("h-3 w-3",r&&"animate-spin")})})]})}function DT({open:e,onOpenChange:t,kind:n,label:r,content:o}){const a=cp(),[s,i]=W.useState(()=>TE(_E.skillhubAuthor,"")),[l,c]=W.useState(""),[u,d]=W.useState(""),[p,h]=W.useState(!1),[f,m]=W.useState(null),[g,v]=W.useState(!0);W.useEffect(()=>{e&&(i(TE(_E.skillhubAuthor,"")),c(""),d(""),v(!0),SC().then(m).catch(()=>m({configured:!1,needsReset:!1})).finally(()=>v(!1)))},[e]);const y=()=>{t(!1),a("/settings?tab=hub")},b="quick-prompt"===n?"快捷 Prompt":"Agent Prompt",x=!g&&f&&!f.configured;return ee.jsx(L_,{open:e,onOpenChange:t,children:ee.jsxs(D_,{className:XS("sm:max-w-lg"),children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:"共享到 ccweb-hub"}),ee.jsxs(z_,{children:["「",r,"」将以 GitHub Issue 形式提交到 ",ee.jsx("code",{children:"zbc0315/ccweb-hub"}),", 使用你配置的 GitHub token。审核通过后会合入为社区 prompt。"]})]}),g?ee.jsxs("div",{className:"py-8 flex items-center justify-center text-sm text-muted-foreground",children:[ee.jsx(Vj,{className:"h-4 w-4 mr-2 animate-spin"}),"检查 token 配置…"]}):x?ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs",children:ee.jsxs("div",{className:"flex items-start gap-2",children:[ee.jsx(zj,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5"}),ee.jsxs("div",{className:"space-y-1",children:[ee.jsx("div",{className:"font-medium text-foreground",children:(null==f?void 0:f.needsReset)?"之前配置的 token 已失效(服务端密钥可能已轮换),请重新设置":"还没配置 GitHub token"}),ee.jsxs("div",{className:"text-muted-foreground",children:["为保护你的 GitHub 账号,ccweb 不自带 token,需要你用自己的 GitHub fine-grained PAT(只勾 ",ee.jsx("code",{children:"ccweb-hub"})," 仓库的",ee.jsx("code",{children:" Issues: Read and write"}),")。"]})]})]})}),ee.jsxs("div",{className:"flex gap-2 pt-1",children:[ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),className:"flex-1",children:"稍后"}),ee.jsx(yE,{onClick:y,className:"flex-1",children:"去设置页配置"})]})]}):ee.jsxs(ee.Fragment,{children:[ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-author",className:"text-xs",children:"GitHub 用户名(可选,用于作者标注)"}),ee.jsx(bE,{id:"share-author",placeholder:"zbc0315",value:s,onChange:e=>i(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-desc",className:"text-xs",children:"一句话描述(可选)"}),ee.jsx(bE,{id:"share-desc",placeholder:"quick-prompt"===n?"这个命令用来...":"这段 prompt 让 Claude...",value:l,onChange:e=>c(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-tags",className:"text-xs",children:"标签(逗号分隔,可选)"}),ee.jsx(bE,{id:"share-tags",placeholder:"review, 中文, 代码",value:u,onChange:e=>d(e.target.value)})]})]}),ee.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[ee.jsxs("div",{className:"font-medium text-foreground mb-1",children:["预览:",b," · ",r]}),ee.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-snug max-h-32 overflow-y-auto",children:[Array.from(o).slice(0,500).join(""),Array.from(o).length>500&&"…"]})]}),ee.jsxs(I_,{children:[ee.jsxs(yE,{variant:"ghost",size:"sm",onClick:y,className:"mr-auto",title:"更换或清除 token",children:[ee.jsx(zj,{className:"h-3.5 w-3.5 mr-1"}),"管理 token"]}),ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),disabled:p,children:"取消"}),ee.jsx(yE,{onClick:()=>{(async()=>{if(!p){h(!0),RE(_E.skillhubAuthor,s);try{const e=await jC({kind:n,label:r,body:o,description:l.trim()||void 0,author:s.trim()||void 0,tags:u.split(",").map(e=>e.trim()).filter(Boolean)});J_.success(`已提交:Issue #${e.issueNumber}`,{action:{label:"查看",onClick:()=>window.open(e.issueUrl,"_blank","noopener,noreferrer")}}),t(!1)}catch(kR){const t=kR.message;J_.error(t),/invalid|expired|401/.test(t)&&m({configured:!1,needsReset:!0})}finally{h(!1)}}})()},disabled:p,children:p?ee.jsxs(ee.Fragment,{children:[ee.jsx(Vj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"提交中"]}):ee.jsxs(ee.Fragment,{children:[ee.jsx(Qj,{className:"h-3.5 w-3.5 mr-1.5"}),"直接提交"]})})]})]})]})})}function AT(){const[e,t]=W.useState([]),[n,r]=W.useState(!1),[o,a]=W.useState(""),[s,i]=W.useState(""),[l,c]=W.useState(""),[u,d]=W.useState(null),[p,h]=W.useState(""),[f,m]=W.useState(""),[g,v]=W.useState(""),y=W.useRef(null),b=W.useRef(null),[x,w]=W.useState(null);W.useEffect(()=>{nC().then(t).catch(()=>t([]))},[]),W.useEffect(()=>{n&&setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},0)},[n]),W.useEffect(()=>{u&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[u]);const k=async()=>{const e=s.trim();if(e)try{const n=await rC({label:o.trim()||e,command:e,...l?{parentId:l}:{}});t(e=>[...e,n]),a(""),i(""),c(""),r(!1)}catch(kR){console.error("[GlobalShortcuts] Failed to add:",kR)}},S=async()=>{const e=f.trim();if(e&&u)try{const n=await oC(u,{label:p.trim()||e,command:e,parentId:g||null});t(e=>e.map(e=>e.id===u?n:e)),d(null)}catch(kR){console.error("[GlobalShortcuts] Failed to save:",kR)}};return ee.jsxs("section",{className:"mt-10",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-4",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(lP,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷 Prompts"}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),ee.jsxs("button",{onClick:()=>{r(e=>!e),d(null)},className:XS("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:[ee.jsx(Yj,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&ee.jsxs("div",{className:"mb-4 p-4 rounded-xl border border-border bg-background space-y-3",children:[ee.jsx("input",{ref:y,placeholder:"名称(可选)",value:o,onChange:e=>a(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"}),ee.jsx("textarea",{placeholder:"命令内容…",value:s,onChange:e=>i(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=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k()),"Escape"===e.key&&(r(!1),a(""),i(""),c(""))}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Dj,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.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:[ee.jsx("option",{value:"",children:"无继承"}),e.map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex items-center justify-between",children:[ee.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsx("button",{onClick:()=>{r(!1),a(""),i("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{k()},disabled:!s.trim(),className:XS("text-sm px-3 py-1 rounded transition-colors text-white",s.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),0!==e.length||n?ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(n=>u===n.id?ee.jsxs("div",{className:"rounded-xl border border-border bg-background p-3 space-y-2",children:[ee.jsx("input",{ref:b,value:p,onChange:e=>h(e.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"}),ee.jsx("textarea",{value:f,onChange:e=>m(e.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:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S()),"Escape"===e.key&&d(null)}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Dj,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:g,onChange:e=>v(e.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:[ee.jsx("option",{value:"",children:"无继承"}),e.filter(e=>e.id!==n.id).map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex gap-2 justify-end",children:[ee.jsx("button",{onClick:()=>d(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{S()},disabled:!f.trim(),className:XS("text-xs px-2.5 py-1 rounded transition-colors text-white",f.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},n.id):ee.jsxs("div",{className:"group relative rounded-xl border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[ee.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:n.label}),n.parentId&&(()=>{const t=e.find(e=>e.id===n.parentId);return t?ee.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[ee.jsx(Dj,{className:"h-3 w-3 text-muted-foreground"}),ee.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",t.label]})]}):null})(),!n.parentId&&n.label!==n.command&&ee.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:n.command}),ee.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[ee.jsx("button",{onClick:()=>w({label:n.label,content:n.command}),className:"p-1 rounded text-muted-foreground hover:text-green-400 transition-colors",title:"共享到 ccweb-hub",children:ee.jsx(Zj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{d(n.id),h(n.label),m(n.command),v(n.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:ee.jsx(Kj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{(async e=>{try{await aC(e),t(t=>t.filter(t=>t.id!==e)),u===e&&d(null)}catch(kR){console.error("[GlobalShortcuts] Failed to delete:",kR)}})(n.id)},className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:ee.jsx(iP,{className:"h-3.5 w-3.5"})})]})]},n.id))}):ee.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-xl",children:[ee.jsx(lP,{className:"h-6 w-6"}),ee.jsx("p",{className:"text-sm",children:"还没有全局快捷 Prompts"})]}),ee.jsx(DT,{open:!!x,onOpenChange:e=>{e||w(null)},kind:"quick-prompt",label:(null==x?void 0:x.label)??"",content:(null==x?void 0:x.content)??""})]})}const IT=W.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function FT(){return W.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function zT({children:e}){const[t,n]=W.useState(()=>TE(_E.theme,"system")),r=FT(),o="system"===t?r:t;W.useEffect(()=>{const e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(o)},[o]);return ee.jsx(IT.Provider,{value:{theme:t,resolved:o,setTheme:e=>{n(e),RE(_E.theme,e)}},children:e})}function $T(){return W.useContext(IT)}function VT(){const{theme:e,setTheme:t}=$T(),n=[{value:"light",icon:nP,label:"浅色"},{value:"dark",icon:Gj,label:"深色"},{value:"system",icon:qj,label:"系统"}];return ee.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:n,icon:r,label:o})=>ee.jsx("button",{onClick:()=>t(n),className:XS("p-1 rounded-sm transition-colors",e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:ee.jsx(r,{className:"h-3.5 w-3.5"})},n))})}const UT={workMinutes:30,breakMinutes:5};function BT(){return TE(_E.pomodoroConfig,UT,!0)}const WT=NE(e=>({running:!1,phase:"work",secondsLeft:60*BT().workMinutes,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function HT(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:o}=WT(),a=W.useCallback(e=>{const t=BT();var n;r(e),o("work"===e?60*t.workMinutes:60*t.breakMinutes),n="break"===e?"休息一下 ☕":"该工作了 💻",J_.info(`番茄钟: ${n}`)},[r,o]);return W.useEffect(()=>{if(!e)return;if(0===n)return void a("work"===t?"break":"work");const r=setTimeout(()=>o(n-1),1e3);return()=>clearTimeout(r)},[e,n,t,a,o]),null}function qT(){const{running:e,phase:t,secondsLeft:n}=WT(),r=Math.floor(n/60),o=n%60,a=`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`,s=W.useRef(null),[i,l]=W.useState(()=>"undefined"==typeof window?360:Math.max(40,Math.floor(window.innerWidth/2.9)));return W.useEffect(()=>{if(!e)return;const t=()=>{const e=s.current;if(!e)return;const t=getComputedStyle(e),n=document.createElement("canvas").getContext("2d");if(!n)return;n.font=`${t.fontWeight} 100px ${t.fontFamily}`;const r=n.measureText(a).width;r&&l(Math.max(40,Math.floor(window.innerWidth/r*100)))},n=requestAnimationFrame(t);return window.addEventListener("resize",t),()=>{cancelAnimationFrame(n),window.removeEventListener("resize",t)}},[e,a.length]),e?ld.createPortal(ee.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none overflow-hidden",style:{opacity:"work"===t?.1:.6},children:[ee.jsx("div",{ref:s,className:XS("font-mono font-bold tabular-nums leading-none","work"===t?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:`${i}px`},children:a}),ee.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:"work"===t?"专注工作":"休息一下"})]}),document.body):null}function GT(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:o,setSecondsLeft:a}=WT(),s=Math.floor(n/60),i=n%60,l=`${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}`;return ee.jsx("button",{onClick:()=>{if(e){const e=BT();o("work"),a(60*e.workMinutes)}else{const e=BT();o("work"),a(60*e.workMinutes)}r(!e)},className:XS("p-1 rounded transition-colors",e?"work"===t?"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?"work"===t?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:ee.jsx(oP,{className:"h-4 w-4"})})}const KT="v2026.4.27-e",YT=!!window.electronUpdater;function XT(){const[e,t]=W.useState("idle"),[n,r]=W.useState(!1),[o,a]=W.useState(""),[s,i]=W.useState(0),[l,c]=W.useState(null),[u,d]=W.useState(null);W.useEffect(()=>{if(!window.electronUpdater)return;return window.electronUpdater.onUpdateStatus(e=>{switch(e.type){case"progress":{const t=e.info;i(Math.round((null==t?void 0:t.percent)??0));break}case"downloaded":t("downloaded");break;case"error":c(e.info||"Download failed"),t("error")}})},[]);const p=W.useCallback(async()=>{t("checking"),c(null),r(!0);try{if(YT){const e=await window.electronUpdater.checkForUpdate();if(e.error)throw new Error(e.error);if(!e.available)return void t("no_update");a(e.version?`v${e.version}`:"new version")}else{const e=await AC();if(!e.updateAvailable)return void t("no_update");a(`v${e.latest}`)}t("update_available")}catch(kR){c(kR instanceof Error?kR.message:"Check failed"),t("error")}},[]),h=W.useCallback(()=>{const e=3e3,n=Date.now(),r=()=>{if(Date.now()-n>3e5)return c("更新超时(5 分钟)— 请检查服务器状态"),void t("update_failed");FC().then(n=>{n?n.success?(a(n.newVersion?`v${n.newVersion}`:"new version"),t("update_complete")):(c(n.error||"Update failed"),t("update_failed")):setTimeout(r,e)}).catch(()=>{setTimeout(r,e)})};setTimeout(r,e)},[]),f=()=>{r(!1),setTimeout(()=>{t("idle"),a(""),c(null),i(0),d(null)},200)};return ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{p()},disabled:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e,title:"检查更新",children:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e?ee.jsx(Vj,{className:"h-4 w-4 animate-spin"}):ee.jsx(Nj,{className:"h-4 w-4"})}),ee.jsx(L_,{open:n,onOpenChange:e=>{e||f()},children:ee.jsxs(D_,{className:"sm:max-w-md",children:[ee.jsxs(A_,{children:[ee.jsxs(F_,{children:["checking"===e&&"Checking for updates...","no_update"===e&&"Up to date","update_available"===e&&`Update ${o} available`,"downloading"===e&&"Downloading update...","downloaded"===e&&"Update ready to install","executing"===e&&"Updating server...","reconnecting"===e&&"Waiting for server restart...","update_complete"===e&&`Updated to ${o}`,"update_failed"===e&&"Update failed","error"===e&&"Update error"]}),ee.jsxs(z_,{children:["checking"===e&&"Checking for the latest version...","no_update"===e&&`Current version ${KT} is the latest.`,"update_available"===e&&"A new version is available. "+(YT?"Click download to update automatically.":""),"downloading"===e&&`Downloading... ${s}%`,"downloaded"===e&&"The update has been downloaded. Click install to restart and apply.","executing"===e&&"Server is shutting down and installing the update. Please wait...","reconnecting"===e&&"Update installed. Waiting for server to restart...","update_complete"===e&&`Successfully updated from ${KT} to ${o}. Click reload to use the new version.`,"update_failed"===e&&(l||"Update failed. You may need to restart the server manually."),"error"===e&&(l||"An error occurred.")]})]}),"downloading"===e&&ee.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:ee.jsx("div",{className:"bg-primary h-full transition-all duration-300",style:{width:`${s}%`}})}),("executing"===e||"reconnecting"===e)&&ee.jsx("div",{className:"flex items-center justify-center py-6",children:ee.jsx(Vj,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),ee.jsxs(I_,{children:["no_update"===e&&ee.jsx(yE,{onClick:f,children:"OK"}),"update_available"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"outline",onClick:f,children:"Later"}),ee.jsx(yE,{onClick:()=>{(async()=>{if(YT){t("downloading"),i(0);const e=await window.electronUpdater.downloadUpdate();e.success?e.path&&d(e.path):(c(e.error||"Download failed"),t("error"))}else{t("executing");try{await IC(),t("reconnecting"),h()}catch(kR){c(kR instanceof Error?kR.message:"Execute failed"),t("error")}}})()},children:YT?"Download & Install":`Update to ${o}`})]}),"downloaded"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"outline",onClick:f,children:"Later"}),ee.jsx(yE,{onClick:()=>{var e;null==(e=window.electronUpdater)||e.quitAndInstall(u||void 0)},children:"Restart & Install"})]}),"update_complete"===e&&ee.jsx(yE,{onClick:()=>window.location.reload(),children:"Reload Page"}),"update_failed"===e&&ee.jsx(yE,{onClick:f,children:"Close"}),"error"===e&&ee.jsx(yE,{onClick:f,children:"Close"})]})]})})]})}function QT(e){return e.map(e=>"text"===e.type?e.content:`\n\`\`\`${e.type}\n${e.content}\n\`\`\`\n`).join("")}function JT(e){return"[200~"+e.replace(/\x1b\[20[01]~/g,"").replace(/\n/g,"\r")+"[201~\r"}function ZT(e,t){return{id:e.id??t(),role:e.role,content:QT(e.blocks),blocks:e.blocks,ts:e.timestamp}}const eR=3e4;function tR({project:e,liveMessages:t,ws:n,historyLimit:r=20,liveWindow:o=50,historyEnabled:a=!0}){const s=e.id,[i,l]=W.useState("running"===e.status?"live":"stopped"),{history:c,hasMore:u,reload:d,loadMore:p}=function({projectId:e,historyLimit:t=20,enabled:n=!0}){const[r,o]=W.useState([]),[a,s]=W.useState(!1),[i,l]=W.useState(!1),c=W.useRef(0),u=W.useCallback(()=>"h"+ ++c.current,[]),d=W.useRef({projectId:e,enabled:n});d.current={projectId:e,enabled:n};const p=W.useCallback(async()=>{if(!d.current.enabled)return;const e=d.current.projectId;l(!0);try{const n=await YC(e,{limit:t});if(d.current.projectId!==e)return;const r=[];for(const e of n.blocks){const t=ZT(e,u);t.content.trim()&&r.push(t)}o(r),s(n.hasMore)}catch{}finally{l(!1)}},[t,u]),h=W.useCallback(async()=>{if(!a||i||0===r.length)return;if(!d.current.enabled)return;const e=d.current.projectId,n=r[0];if(n.id&&!n.id.startsWith("h")){l(!0);try{const r=await YC(e,{limit:t,before:n.id});if(d.current.projectId!==e)return;const a=[];for(const e of r.blocks){const t=ZT(e,u);t.content.trim()&&a.push(t)}o(e=>[...a,...e]),s(r.hasMore)}catch{}finally{l(!1)}}},[t,a,i,r,u]);return W.useEffect(()=>{n&&p()},[e,n]),{history:r,hasMore:a,isLoading:i,reload:p,loadMore:h}}({projectId:s,historyLimit:r,enabled:a}),[h,f]=W.useState([]),m=W.useRef(0),g=W.useCallback(()=>"m"+ ++m.current,[]),v=W.useRef([]),y=W.useRef(0),b=W.useCallback(()=>"p"+ ++y.current,[]),x=W.useRef(!1),w=W.useRef(0);W.useEffect(()=>{if(t.length<w.current&&(w.current=0),t.length<=w.current)return;const e=t.slice(w.current);w.current=t.length;for(const t of e){x.current=!0;const e=QT(t.blocks);if(e.trim()){if("user"===t.role){const n=e.trim(),r=v.current.findIndex(e=>"sent"===e.status&&e.text.trim()===n);if(-1!==r){const e=v.current[r];if(v.current.splice(r,1),e.timer&&(clearTimeout(e.timer),e.timer=null),e.displayId&&t.id){const n=t.id;f(t=>t.map(t=>t.id===e.displayId?{...t,id:n}:t))}e.resolve("delivered");continue}}f(n=>{if(t.id&&n.some(e=>e.id===t.id))return n;const r={id:t.id??g(),role:t.role,content:e,blocks:t.blocks,ts:t.timestamp};return[...n,r].slice(-o)})}}},[t,g,o]),W.useEffect(()=>{if("live"!==i)return void(x.current=!1);const e=setTimeout(()=>{x.current||d()},3e3);return()=>clearTimeout(e)},[i,d]),W.useEffect(()=>{"running"!==e.status||"stopped"!==i&&"error"!==i?"stopped"===e.status&&"live"===i&&l("stopped"):(f([]),l("live"))},[e.status]);const k=W.useRef(null),S=W.useRef(0),E=W.useCallback(e=>{e&&f(t=>t.filter(t=>t.id!==e))},[]),C=W.useCallback(()=>{const e=v.current;v.current=[];for(const t of e)t.timer&&(clearTimeout(t.timer),t.timer=null),"sent"===t.status&&E(t.displayId),t.resolve("failed")},[E]),j=W.useCallback(e=>{const t=g();e.displayId=t,e.status="sent",f(n=>[...n,{id:t,role:"user",content:e.text,ts:(new Date).toISOString()}].slice(-o)),n.send(e.isSlashCommand?e.text.replace(/\n/g,"\r")+"\r":JT(e.text))},[n,g,o]);W.useEffect(()=>{if(!n.connected)return;if("live"!==i)return;const e=v.current.filter(e=>"queued"===e.status);if(0!==e.length)for(const t of e)if(j(t),t.isSlashCommand){const e=v.current.indexOf(t);-1!==e&&v.current.splice(e,1),t.timer&&(clearTimeout(t.timer),t.timer=null),t.resolve("delivered")}},[n.connected,i,j]),W.useEffect(()=>()=>{k.current&&clearTimeout(k.current);for(const e of v.current)e.timer&&(clearTimeout(e.timer),e.timer=null),e.resolve("failed");v.current=[]},[]);const P=W.useCallback(e=>new Promise(t=>{const r=e.trimStart().startsWith("/");if(v.current.length>=20){const e=v.current.shift();e&&(e.timer&&clearTimeout(e.timer),"sent"===e.status&&E(e.displayId),e.resolve("failed"))}const o={id:b(),text:e,isSlashCommand:r,status:"queued",resolve:t,timer:null};if(v.current.push(o),r){if("live"===i&&n.connected){j(o);const e=v.current.indexOf(o);return-1!==e&&v.current.splice(e,1),void t("delivered")}o.timer=setTimeout(()=>{const e=v.current.indexOf(o);-1!==e&&v.current.splice(e,1),o.timer=null,"sent"===o.status&&E(o.displayId),t("failed")},eR)}else o.timer=setTimeout(()=>{const e=v.current.indexOf(o);-1!==e&&v.current.splice(e,1),o.timer=null,"sent"===o.status&&E(o.displayId),t("failed")},eR);if("live"===i&&n.connected)j(o);else if("waking"===i||"live"===i);else{const e=++S.current;l("waking"),JE(s).then(()=>{e===S.current&&(k.current&&clearTimeout(k.current),l("live"))}).catch(t=>{e===S.current&&(J_.error(`启动失败: ${t instanceof Error?t.message:String(t)}`),l("error"),C())}),k.current=setTimeout(()=>{e===S.current&&v.current.some(e=>"queued"===e.status)&&(J_.error("启动超时(10s)"),l("error"),C())},1e4)}}),[i,n,s,j,C,E,b]),N=W.useCallback(e=>{const t=e.replace(/\r$/,"").trim();if(!t)return;const n=g();f(e=>[...e,{id:n,role:"user",content:t,ts:(new Date).toISOString()}].slice(-o));const r={id:b(),text:t,isSlashCommand:!1,status:"sent",displayId:n,resolve:()=>{},timer:setTimeout(()=>{const e=v.current.indexOf(r);-1!==e&&v.current.splice(e,1),r.timer=null},eR)};v.current.push(r)},[g,b,o]),_=W.useMemo(()=>{const e=new Set;for(const t of h)t.id&&e.add(t.id);return[...c.filter(t=>!t.id||!e.has(t.id)),...h]},[c,h]);return{state:i,setState:l,messages:_,historyMessages:c,displayMessages:h,setDisplayMessages:f,hasMoreHistory:u,loadMoreHistory:p,reloadHistory:d,liveReceivedRef:x,sendMessage:P,appendUserMessage:N,isWaking:"waking"===i,isRunning:"live"===i}}function nR(e,t,n){const r=W.useRef(!0),o=W.useRef(0),a=W.useCallback(()=>{const t=e.current;t&&(t.scrollHeight<=t.clientHeight||(o.current=performance.now(),t.scrollTop=t.scrollHeight))},[e]);return W.useEffect(()=>{const t=e.current;t&&(t.style.overflowAnchor="none")},[e]),W.useEffect(()=>{const t=e.current;if(!t)return;const n=()=>{if(performance.now()-o.current<80)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<80;r.current=e};return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)},[e]),W.useLayoutEffect(()=>{r.current&&a()},[a,...n]),W.useEffect(()=>{const e=t.current;if(!e)return;const n=new ResizeObserver(()=>{r.current&&a()});return n.observe(e),()=>n.disconnect()},[t,a]),{pinnedRef:r,scrollToBottom:a}}const rR=H.memo(function({project:e,externalStatus:t,active:n=!1}){const r=cp(),[o,a]=W.useState(""),[s,i]=W.useState(!1),l=W.useRef(null),c=W.useRef(null),[u,d]=W.useState([]),p=W.useRef(0),h=W.useCallback(e=>{d(t=>{const n=[...t,e];return n.length>200?n.slice(-200):n}),"assistant"===e.role&&(i(!0),setTimeout(()=>i(!1),1e3))},[]),f=W.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),{sendInput:m,connected:g}=CT({projectId:e.id,enabled:!0,onChatMessage:h,onStatusChange:f}),{state:v,setState:y,messages:b,sendMessage:x,isRunning:w,isWaking:k}=tR({project:e,liveMessages:u,ws:{send:m,connected:g},historyLimit:4,liveWindow:4}),S=W.useRef(y);S.current=y,W.useEffect(()=>{"stopped"===v&&(d([]),p.current=0)},[v]),W.useEffect(()=>{t&&("running"!==t||"stopped"!==v&&"error"!==v?"stopped"===t&&"live"===v&&y("stopped"):(d([]),y("live")))},[t]),nR(l,c,[b]);const[E,C]=W.useState(!1),j=mT(W.useCallback(async()=>{const e=o.trim();if(!e||E)return;C(!0);const t=await x(e);C(!1),"delivered"===t&&a("")},[o,E,x]),"enter"),P="stopped"===v,N=b.slice(-4),_=ee.jsxs("div",{className:XS("flex flex-col h-full rounded-xl overflow-hidden bg-background transition-colors duration-300",n?"border-transparent bg-transparent shadow-none":s?"border border-blue-500":"border border-border","error"===v&&"border border-red-500/50"),children:[ee.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border bg-muted/30 transition-colors",children:[ee.jsx(Ij,{className:"h-3.5 w-3.5 text-muted-foreground/40 flex-shrink-0 cursor-grab active:cursor-grabbing"}),ee.jsx("span",{className:"font-medium text-sm truncate flex-1 cursor-pointer hover:text-blue-400 transition-colors",onClick:()=>r(`/projects/${e.id}`),title:"打开项目详情",children:e.name}),ee.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.cliTool??"claude"}),ee.jsx("span",{className:XS("w-2 h-2 rounded-full flex-shrink-0",w?"bg-green-500":k?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),ee.jsx("div",{ref:l,className:"flex-1 overflow-y-auto min-h-0 text-xs",children:ee.jsxs("div",{ref:c,className:"p-2 space-y-2 min-h-full",children:[N.map(e=>{const t="user"===e.role;return ee.jsx("div",{className:XS("flex",t?"justify-end":"justify-start"),children:ee.jsx("div",{className:XS("max-w-[85%] rounded-2xl px-2.5 py-1.5 whitespace-pre-wrap break-words leading-relaxed",t?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm dark:bg-blue-500/20 dark:border-blue-500/25":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:ee.jsx("div",{className:"line-clamp-6",children:e.content})})},e.id)}),P&&0===N.length&&ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-xs",children:"无对话记录"}),k&&ee.jsx("div",{className:"flex items-center justify-center h-full text-yellow-400 text-xs animate-pulse",children:"启动中..."})]})}),ee.jsx("div",{className:"border-t border-border p-1.5",children:ee.jsx("input",{type:"text",value:o,onChange:e=>a(e.target.value),onKeyDown:j,disabled:k||E,placeholder:k?"启动中...":E?"发送中…":P?"输入命令(自动启动)... Shift+⏎":"输入命令... Shift+⏎",className:XS("w-full bg-transparent text-xs font-mono outline-none placeholder:text-muted-foreground/40 px-1.5 py-1",(k||E)&&"opacity-50 cursor-not-allowed")})})]});return n?ee.jsx("div",{className:"card-active-glow rounded-xl h-full",children:_}):_});function oR({projects:e,projectStatuses:t,activeProjectIds:n}){const r=W.useMemo(()=>e.filter(e=>!e.archived),[e]),{order:o,setOrder:a,applyOrder:s}=_T(),[i,l]=W.useState(null),[c,u]=W.useState(null),d=W.useRef(null),p=W.useMemo(()=>s(r),[r,s]),h=W.useCallback((e,t)=>{l(t),e.dataTransfer.effectAllowed="move";const n=document.createElement("div");n.style.width="1px",n.style.height="1px",n.style.opacity="0.01",document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),d.current=n},[]),f=W.useCallback((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",u(t)},[]),m=W.useCallback((e,t)=>{if(e.preventDefault(),!i||i===t)return l(null),void u(null);const n=p.map(e=>e.id),r=o.length?[...o]:n;for(const o of n)r.includes(o)||r.push(o);const s=r.indexOf(i),c=r.indexOf(t);if(-1===s||-1===c)return l(null),void u(null);r.splice(s,1),r.splice(c,0,i),a(r),l(null),u(null)},[i,p,o,a]),g=W.useCallback(()=>{l(null),u(null),d.current&&(d.current.remove(),d.current=null)},[]),{cols:v,rows:y}=(b=p.length)<=1?{cols:1,rows:1}:b<=2?{cols:2,rows:1}:b<=4?{cols:2,rows:2}:b<=6?{cols:3,rows:2}:b<=9?{cols:3,rows:3}:b<=12?{cols:4,rows:3}:{cols:4,rows:Math.ceil(b/4)};var b;if(0===p.length)return ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/50 text-sm",children:"没有活跃项目"});const x=y<=3;return ee.jsx("div",{className:"h-full w-full p-2 gap-2 overflow-y-auto",style:{display:"grid",gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`,gridAutoRows:x?`minmax(180px, min(${Math.floor(100/y)}vh, 350px))`:"280px"},children:p.map(e=>ee.jsx("div",{draggable:!0,onDragStart:t=>h(t,e.id),onDragOver:t=>f(t,e.id),onDrop:t=>m(t,e.id),onDragEnd:g,className:XS("transition-all duration-200",i===e.id&&"opacity-40 scale-95",c===e.id&&i!==e.id&&"ring-2 ring-ring/50 rounded-xl"),children:ee.jsx(rR,{project:e,externalStatus:t.get(e.id),active:n.has(e.id)})},e.id))})}function aR(){const{t:e}=Yh(),t=cp(),{projects:n,loading:r,error:o,hasFetched:a,fetchProjects:s,addProject:i,updateProject:l,removeProject:c}=AE(),u=OE(e=>e.clearToken),[d,p]=W.useState(!1),[h,f]=W.useState(!1),[m,g]=W.useState(new Set),v=W.useRef(new Map),[y,b]=W.useState(new Map),x=W.useRef(0),[w,k]=W.useState(!!document.fullscreenElement),[S,E]=W.useState(!1),[C,j]=ME(_E.monitorMode,!1,{parse:!0}),[P,N]=W.useState(new Map);W.useEffect(()=>{const e=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),W.useEffect(()=>{s()},[s]);ST({onActivityUpdate:W.useCallback(e=>{if(e.status){const t=AE.getState().projects.find(t=>t.id===e.projectId);t&&t.status!==e.status&&l({...t,status:e.status}),N(t=>{const n=new Map(t);return n.set(e.projectId,e.status),n})}const t=Date.now(),n=v.current;if(e.active){g(t=>t.has(e.projectId)?t:new Set(t).add(e.projectId));const r=n.get(e.projectId)??[];let o=!1;if(e.semantic){const n=r[r.length-1];`${e.semantic.phase}:${e.semantic.detail??""}`!==(n?`${n.phase}:${n.detail??""}`:"")?(r.push({id:x.current++,phase:e.semantic.phase,detail:e.semantic.detail,ts:t}),o=!0):n&&(n.ts=t)}const a=r.filter(e=>t-e.ts<8e3),s=a.length>3?a.slice(-3):a;s.length!==r.length&&(o=!0),n.set(e.projectId,s),o&&b(new Map(n))}else g(t=>{if(!t.has(e.projectId))return t;const n=new Set(t);return n.delete(e.projectId),n}),n.has(e.projectId)&&n.get(e.projectId).length>0&&(n.set(e.projectId,[]),b(new Map(n)))},[l])}),W.useEffect(()=>{const e=setInterval(()=>{const e=Date.now(),t=v.current;let n=!1;for(const[r,o]of t){const a=o.filter(t=>e-t.ts<8e3);a.length!==o.length&&(t.set(r,a),n=!0)}n&&b(new Map(t)),g(e=>{let n=!1;const r=new Set(e);for(const o of e){const e=t.get(o);e&&0!==e.length||(r.delete(o),n=!0)}return n?r:e})},3e3);return()=>clearInterval(e)},[]);const _=W.useMemo(()=>n.filter(e=>!e.archived),[n]),T=W.useMemo(()=>n.filter(e=>e.archived),[n]),R=W.useMemo(()=>Array.from(new Set(n.flatMap(e=>e.tags??[]))),[n]),[L,M]=W.useState([]),O=W.useMemo(()=>0===L.length?_:_.filter(e=>L.some(t=>{var n;return null==(n=e.tags)?void 0:n.includes(t)})),[_,L]),[D,A]=W.useState(!1),I=W.useCallback(async()=>{if(!D){A(!0);try{const t=await mj(),n=t.results.filter(e=>e.ok).length,r=t.results.filter(e=>e.skipped).length,o=t.total-n-r;J_.success(e("dashboard.sync_done_toast",{ok:n,skipped:r,failed:o}))}catch(kR){J_.error(e("dashboard.sync_failed_toast",{message:kR.message}))}finally{A(!1)}}},[D]),{order:F,setOrder:z,applyOrder:$}=_T(),[V,U]=W.useState(null),[B,H]=W.useState(null),q=W.useMemo(()=>$(O),[O,$]),G=W.useCallback(e=>U(e),[]),K=W.useCallback(()=>{U(null),H(null)},[]),Y=W.useCallback((e,t)=>{e.preventDefault(),H(t)},[]),X=W.useCallback((e,t,n)=>{if(e.preventDefault(),!n||n===t)return void H(null);const r=q.map(e=>e.id),o=F.length?[...F]:r;for(const i of r)o.includes(i)||o.push(i);const a=o.indexOf(n),s=o.indexOf(t);if(-1===a||-1===s)return U(null),void H(null);o.splice(a,1),o.splice(s,0,n),z(o),U(null),H(null)},[q,F,z]),Q={onDelete:e=>{(async e=>{try{await QE(e),c(e)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to delete project")}})(e)},onArchive:e=>{(async e=>{try{const t=await ZE(e);l(t)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to archive project")}})(e)},onUnarchive:e=>{(async e=>{try{const t=await tC(e);l(t)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to restore project")}})(e)},onUpdated:l};return ee.jsxs("div",{className:"min-h-screen bg-background",children:[ee.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:ee.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(rP,{className:"h-5 w-5"}),ee.jsxs("div",{children:[ee.jsx("span",{className:"font-semibold text-lg leading-tight block",children:"CC Web"}),ee.jsx("span",{className:"text-[10px] text-muted-foreground leading-none",children:KT})]})]}),ee.jsx(OT,{}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/skillhub"),title:e("dashboard.skillhub_title"),children:ee.jsx(tP,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/mobile"),title:e("dashboard.mobile_title"),children:ee.jsx(eP,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/settings"),title:e("dashboard.settings_title"),children:ee.jsx(Jj,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>j(!C),title:e(C?"dashboard.monitor_title_grid":"dashboard.monitor_title_monitor"),className:XS(C&&"bg-accent font-medium"),children:C?ee.jsx($j,{className:"h-4 w-4"}):ee.jsx(qj,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:e(w?"dashboard.fullscreen_exit":"dashboard.fullscreen_enter"),children:w?ee.jsx(Wj,{className:"h-4 w-4"}):ee.jsx(Bj,{className:"h-4 w-4"})}),ee.jsx(XT,{}),ee.jsx(GT,{}),ee.jsx(VT,{}),ee.jsxs(yE,{variant:"ghost",size:"sm",onClick:()=>{u(),t("/login")},children:[ee.jsx(Uj,{className:"h-4 w-4 mr-2"}),e("dashboard.logout")]})]})}),C&&ee.jsx("div",{className:"flex-1 min-h-0",children:ee.jsx(oR,{projects:n,projectStatuses:P,activeProjectIds:m})}),!C&&ee.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-6",children:[ee.jsxs("div",{children:[ee.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Projects"}),ee.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsxs(yE,{variant:"outline",onClick:()=>{I()},disabled:D,title:e("dashboard.sync_all_title"),children:[D?ee.jsx(Vj,{className:"h-4 w-4 mr-2 animate-spin"}):ee.jsx(Mj,{className:"h-4 w-4 mr-2"}),e("dashboard.sync_all")]}),ee.jsxs(yE,{variant:"outline",onClick:()=>f(!0),children:[ee.jsx(Rj,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(yE,{onClick:()=>p(!0),children:[ee.jsx(Yj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),r&&!a&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:3}).map((e,t)=>ee.jsx(cP,{className:"h-32 rounded-xl"},t))}),o&&ee.jsx("div",{className:"text-center text-destructive py-12",children:o}),a&&!r&&!o&&0===n.length&&ee.jsxs("div",{className:"text-center py-20",children:[ee.jsx(rP,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),ee.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),ee.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),ee.jsxs("div",{className:"flex gap-2 justify-center",children:[ee.jsxs(yE,{variant:"outline",onClick:()=>f(!0),children:[ee.jsx(Rj,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(yE,{onClick:()=>p(!0),children:[ee.jsx(Yj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!r&&!o&&R.length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[R.map(e=>ee.jsxs("button",{onClick:()=>M(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:XS("px-2 py-0.5 rounded-full text-xs border transition-colors",L.includes(e)?"bg-primary text-primary-foreground border-transparent font-medium":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",e]},e)),L.length>0&&ee.jsx("button",{onClick:()=>M([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:e("dashboard.tags_clear")})]}),!r&&!o&&q.length>0&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:q.map((e,t)=>ee.jsx(tS.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{...bj.slow,delay:Math.min(.05*t,.3),ease:"easeOut"},draggable:!0,onDragStart:()=>G(e.id),onDragOver:t=>Y(t,e.id),onDrop:t=>X(t,e.id,V),onDragEnd:K,style:{opacity:V===e.id?.4:1,cursor:"grab"},className:XS(B===e.id&&V!==e.id&&"ring-2 ring-ring/50 rounded-xl"),children:ee.jsx(hT,{project:e,active:m.has(e.id),statusStack:y.get(e.id)??[],...Q})},e.id))}),!r&&!o&&T.length>0&&ee.jsxs("div",{className:"mt-10",children:[ee.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>E(e=>!e),children:[ee.jsx(tS.span,{animate:{rotate:S?90:0},transition:bj.default,children:ee.jsx(Pj,{className:"h-4 w-4"})}),ee.jsx("span",{className:"font-medium",children:"Archived"}),ee.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:T.length})]}),ee.jsx(Iw,{children:S&&ee.jsx(tS.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:bj.slow,className:"overflow-hidden",children:ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:T.map(e=>ee.jsx(hT,{project:e,active:!1,...Q},e.id))})})})]}),ee.jsx(AT,{})]}),ee.jsx(yT,{open:d,onOpenChange:p,onCreated:e=>{i(e)}}),ee.jsx(bT,{open:h,onOpenChange:f,onOpened:e=>{i(e)}})]})}class sR extends H.Component{constructor(){super(...arguments),t(this,"state",{hasError:!1,error:null}),t(this,"handleReset",()=>{var e,t;this.setState({hasError:!1,error:null}),null==(t=(e=this.props).onReset)||t.call(e)})}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack),J_.error(e.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ee.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[ee.jsx("p",{children:"出错了"}),ee.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 iR({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:o}=e,[a,s]=W.useState(()=>{var e,t;return{x:(null==(e=o.floatPosition)?void 0:e.x)??.5*window.innerWidth-r.defaultWidth/2,y:(null==(t=o.floatPosition)?void 0:t.y)??.3*window.innerHeight}}),[i,l]=W.useState(()=>{var e,t;return{w:(null==(e=o.floatSize)?void 0:e.w)??r.defaultWidth,h:(null==(t=o.floatSize)?void 0:t.h)??r.defaultHeight}}),[c,u]=W.useState(!1),[d,p]=W.useState(100),h=W.useRef(null),f=W.useRef(null),[m,g]=W.useState(null),v=W.useRef(null);W.useEffect(()=>{v.current=m},[m]),W.useEffect(()=>{let t=!1,n=null;const r=async(o=0)=>{try{const n=zE(),r={"Content-Type":"application/json"};n&&(r.Authorization=`Bearer ${n}`);const o=await fetch(`/api/plugins/${e.id}/session`,{method:"POST",headers:r});if(!o.ok)throw new Error(`status ${o.status}`);const{token:a}=await o.json();t||g(a)}catch(kR){if(t)return;const s=Math.min(3e4,1e3*2**o);console.warn(`[plugin ${e.id}] session token fetch failed (${String(kR)}); retrying in ${s}ms`),n=window.setTimeout(()=>{r(o+1)},s)}};r();const o=window.setInterval(()=>{r()},63e5);return()=>{t=!0,window.clearInterval(o),null!==n&&window.clearTimeout(n)}},[e.id]);const y=W.useCallback(()=>{p(Date.now()%1e5+100)},[]),b=W.useRef(null),x=W.useCallback(n=>{n.preventDefault(),y(),b.current={sx:n.clientX,sy:n.clientY,ox:a.x,oy:a.y},f.current&&(f.current.style.pointerEvents="none");const r=e=>{if(!b.current)return;const t=Math.max(0,Math.min(window.innerWidth-100,b.current.ox+e.clientX-b.current.sx)),n=Math.max(0,Math.min(window.innerHeight-40,b.current.oy+e.clientY-b.current.sy));h.current&&(h.current.style.left=t+"px",h.current.style.top=n+"px")},o=n=>{if(!b.current)return;const a=Math.max(0,Math.min(window.innerWidth-100,b.current.ox+n.clientX-b.current.sx)),i=Math.max(0,Math.min(window.innerHeight-40,b.current.oy+n.clientY-b.current.sy));b.current=null,f.current&&(f.current.style.pointerEvents=""),s({x:a,y:i}),t(e.id,{floatPosition:{x:a,y:i}}),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[a,y,e.id,t]),w=W.useRef(null),k=W.useCallback(n=>{if(!r.resizable)return;n.preventDefault(),n.stopPropagation(),y(),w.current={sx:n.clientX,sy:n.clientY,ow:i.w,oh:i.h},f.current&&(f.current.style.pointerEvents="none");const o=r.minWidth??150,a=r.minHeight??100,s=e=>{if(!w.current)return;const t=Math.max(o,w.current.ow+e.clientX-w.current.sx),n=Math.max(a,w.current.oh+e.clientY-w.current.sy);h.current&&(h.current.style.width=t+"px",h.current.style.height=n+"px")},c=n=>{if(!w.current)return;const r=Math.max(o,w.current.ow+n.clientX-w.current.sx),i=Math.max(a,w.current.oh+n.clientY-w.current.sy);w.current=null,f.current&&(f.current.style.pointerEvents=""),l({w:r,h:i}),t(e.id,{floatSize:{w:r,h:i}}),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",c)};window.addEventListener("mousemove",s),window.addEventListener("mouseup",c)},[i,r,y,e.id,t]);W.useEffect(()=>{const t=async t=>{var n,r,o,a,s;if(t.source!==(null==(n=f.current)?void 0:n.contentWindow))return;const{callId:i,method:l,args:c}=t.data;if(i&&l)try{const t=zE(),n=v.current,a={"Content-Type":"application/json"};let s,u;if(n&&(a["X-Plugin-Session"]=n),t&&(a.Authorization=`Bearer ${t}`),"storage:get"===l)s=`/api/plugin-bridge/storage/${e.id}`,u={method:"GET",headers:a};else if("storage:set"===l)s=`/api/plugin-bridge/storage/${e.id}`,u={method:"PUT",headers:a,body:JSON.stringify(c)};else{const t={"project:status":{path:`/api/plugin-bridge/project/status/${c.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/${c.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if("backend:api"===l){const{method:t,path:n,body:r}=c;if(!n||!n.startsWith("/")||n.includes(".."))throw new Error("Invalid API path");s=`/api/plugins/${e.id}${n}`,u={method:t||"GET",headers:a},!r||"POST"!==t&&"PUT"!==t||(u.body=JSON.stringify(r))}else{const e=t[l];if(!e)throw new Error(`Unknown method: ${l}`);s=e.path,u={method:e.httpMethod,headers:a},"POST"===e.httpMethod&&(u.body=JSON.stringify(c))}}const d=await fetch(s,u),p=await d.json();null==(o=null==(r=f.current)?void 0:r.contentWindow)||o.postMessage({callId:i,result:p,error:null},window.location.origin)}catch(kR){const t=kR instanceof Error?kR.message:"Bridge error";null==(s=null==(a=f.current)?void 0:a.contentWindow)||s.postMessage({callId:i,result:null,error:t},window.location.origin)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e.id]);const S=o.clickable??r.clickable.default,E=`/plugins/${e.id}/${e.float?"index.html":""}`;return ee.jsxs(tS.div,{ref:h,className:XS("fixed rounded-xl border border-border shadow-sm overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:a.x,top:a.y,width:c?200:i.w,height:c?32:i.h,zIndex:d},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:y,children:[ee.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:x,children:[ee.jsx(Aj,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),ee.jsx("button",{onClick:()=>u(e=>!e),className:"p-0.5 rounded-md hover:bg-accent text-muted-foreground/60 hover:text-foreground transition-colors",children:ee.jsx(Hj,{className:"h-3 w-3"})}),ee.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:ee.jsx(iP,{className:"h-3 w-3"})})]}),!c&&ee.jsxs("div",{className:"flex-1 min-h-0 relative",children:[m?ee.jsx("iframe",{ref:f,src:E,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:S?"auto":"none"}}):ee.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-muted-foreground",children:"Loading…"}),r.resizable&&ee.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:k,children:ee.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[ee.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),ee.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function lR({plugins:e,onPluginsChange:t,onClose:n}){const r=W.useCallback(async(e,n)=>{t(t=>t.map(t=>t.id===e?{...t,userConfig:{...t.userConfig,...n}}:t));try{await ij(e,n)}catch{}},[t]);return 0===e.length?null:ee.jsx(Iw,{children:e.map(e=>ee.jsx(iR,{plugin:e,onConfigChange:r,onClose:n},e.id))})}function cR({onTogglePlugin:e,activeIds:t}){const[n,r]=W.useState([]);return W.useEffect(()=>{oj().then(e=>r(e.filter(e=>e.enabled))).catch(()=>r([]))},[]),W.useEffect(()=>{const e=()=>{oj().then(e=>r(e.filter(e=>e.enabled))).catch(()=>{})};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[]),0===n.length?null:ee.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:ee.jsx(tS.div,{className:"pointer-events-auto flex items-center gap-1 px-2 py-1 rounded-full bg-background/60 backdrop-blur-md border border-border/50 shadow-md",initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:n.map(n=>{const r=t.has(n.id),o=n.name.slice(0,2);return ee.jsxs(tS.button,{onClick:()=>e(n),className:XS("relative flex items-center justify-center w-7 h-7 rounded-full text-[10px] font-medium transition-colors",r?"bg-blue-500/20 text-blue-400":"text-muted-foreground/70 hover:text-foreground hover:bg-muted/80"),whileHover:{scale:1.12},whileTap:{scale:.92},title:n.name+(n.description?` — ${n.description}`:""),children:[o,ee.jsx(Iw,{children:r&&ee.jsx(tS.span,{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 h-1 w-1 rounded-full bg-blue-400",initial:{scale:0},animate:{scale:1},exit:{scale:0}})})]},n.id)})})})}const uR=H.lazy(()=>pd(()=>import("./ProjectPage-ByY_pKon.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.ProjectPage}))),dR=H.lazy(()=>pd(()=>import("./SettingsPage-DCsamoIN.js"),__vite__mapDeps([9,6,3,4])).then(e=>({default:e.SettingsPage}))),pR=H.lazy(()=>pd(()=>import("./SkillHubPage-ChEG3UXF.js"),__vite__mapDeps([10,7,3])).then(e=>({default:e.SkillHubPage}))),hR=H.lazy(()=>pd(()=>import("./MobilePage-Cy7KRgH_.js"),__vite__mapDeps([11,2,3,4,5])).then(e=>({default:e.MobilePage})));function fR(){return ee.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:ee.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function mR({children:e}){const[t,n]=W.useState(!1),r=OE(e=>e.token),o=OE(e=>e.setToken);return W.useEffect(()=>{r?n(!0):BE()?WE().then(e=>o(e)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),t||r?r?ee.jsx(ee.Fragment,{children:e}):ee.jsx(xp,{to:"/login",replace:!0}):null}const gR=window.matchMedia("(pointer: coarse)").matches&&window.innerWidth<768;function vR(){const[e,t]=W.useState([]),[n,r]=W.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),o=ip();W.useEffect(()=>{oj().then(t).catch(()=>t([]))},[]);const a=W.useCallback(e=>{r(t=>{const n=new Set(t);n.has(e.id)?n.delete(e.id):n.add(e.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),s=W.useCallback(e=>{r(t=>{const n=new Set(t);n.delete(e);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),i=function(e){if("/"===e||"/dashboard"===e)return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}(o.pathname),l=e.filter(e=>{if(!e.enabled||!n.has(e.id))return!1;switch(e.userConfig.scope??e.float.scope.default){case"global":return!0;case"dashboard":return"dashboard"===i.type;case"project":return"project"===i.type;case"project:specific":return"project"===i.type&&(e.userConfig.projectIds??[]).includes(i.projectId??"");default:return!1}}),c="/login"===o.pathname,u="/mobile"===o.pathname;return ee.jsxs(ee.Fragment,{children:[!c&&!u&&!gR&&ee.jsx(cR,{onTogglePlugin:a,activeIds:n}),ee.jsx(lR,{plugins:l,onPluginsChange:t,onClose:s})]})}function yR(){const e=OE(e=>e.token);return W.useEffect(()=>{if(!e)return;let t=!1;return zC().then(({language:e})=>{if(!t&&e&&bf.includes(e)&&wh.language!==e){try{localStorage.setItem(xf,e)}catch{}wh.changeLanguage(e)}}).catch(()=>{}),()=>{t=!0}},[e]),null}function bR({children:e}){const t=ip();return gR&&"/"===t.pathname?ee.jsx(xp,{to:"/mobile",replace:!0}):ee.jsx(ee.Fragment,{children:e})}function xR(){return ee.jsx(zT,{children:ee.jsxs(lT,{children:[ee.jsx(sT,{richColors:!0,position:"bottom-right"}),ee.jsx(HT,{}),ee.jsx(qT,{}),ee.jsx(sR,{children:ee.jsxs(Pp,{children:[ee.jsx(yR,{}),ee.jsx(vR,{}),ee.jsx(bR,{children:ee.jsx(W.Suspense,{fallback:ee.jsx(fR,{}),children:ee.jsxs(Sp,{children:[ee.jsx(wp,{path:"/login",element:ee.jsx(xj,{})}),ee.jsx(wp,{path:"/",element:ee.jsx(mR,{children:ee.jsx(aR,{})})}),ee.jsx(wp,{path:"/projects/:id",element:ee.jsx(mR,{children:ee.jsx(uR,{})})}),ee.jsx(wp,{path:"/settings",element:ee.jsx(mR,{children:ee.jsx(dR,{})})}),ee.jsx(wp,{path:"/skillhub",element:ee.jsx(mR,{children:ee.jsx(pR,{})})}),ee.jsx(wp,{path:"/mobile",element:ee.jsx(mR,{children:ee.jsx(hR,{})})}),ee.jsx(wp,{path:"*",element:ee.jsx(xp,{to:"/",replace:!0})})]})})})]})})]})})}te.createRoot(document.getElementById("root")).render(ee.jsx(H.StrictMode,{children:ee.jsx(xR,{})}));export{aE as $,Iw as A,yE as B,Pj as C,Nj as D,_j as E,Rj as F,HC as G,qC as H,bE as I,QC as J,oP as K,JC as L,Wj as M,ZC as N,Ej as O,Kj as P,ME as Q,H as R,_E as S,aP as T,oE as U,PP as V,hP as W,iP as X,GP as Y,qP as Z,pd as _,$T as a,rj as a$,pP as a0,CP as a1,HN as a2,jP as a3,XP as a4,FN as a5,zP as a6,MP as a7,Zj as a8,uC as a9,xC as aA,lP as aB,tP as aC,cE as aD,Yh as aE,cp as aF,ET as aG,AE as aH,Cj as aI,dP as aJ,GT as aK,VT as aL,Vj as aM,Mj as aN,gj as aO,fj as aP,eC as aQ,JE as aR,kT as aS,OT as aT,mP as aU,cj as aV,tR as aW,nj as aX,ej as aY,nR as aZ,LE as a_,sC as aa,nC as ab,Dj as ac,DT as ad,cC as ae,aC as af,L_ as ag,D_ as ah,A_ as ai,F_ as aj,z_ as ak,EE as al,I_ as am,rC as an,iC as ao,oC as ap,lC as aq,mC as ar,wC as as,pC as at,gC as au,hC as av,vC as aw,fC as ax,yC as ay,bC as az,MC as b,tj as b0,Qj as b1,up as b2,JT as b3,rP as b4,xP as b5,yP as b6,ld as b7,dj as b8,pj as b9,CT as bA,mT as bB,Tj as bC,PC as bD,pb as bE,fb as bF,db as bG,r as bH,o as bI,uj as bJ,sP as bK,a as bL,yj as bM,hj as ba,mj as bb,vj as bc,SC as bd,CC as be,EC as bf,bf as bg,xf as bh,$C as bi,Lp as bj,BT as bk,VC as bl,UC as bm,oj as bn,aj as bo,sj as bp,lj as bq,kC as br,dC as bs,OE as bt,ST as bu,_T as bv,XT as bw,Jj as bx,Uj as by,qj as bz,kj as c,XS as d,Bj as e,TC as f,zE as g,TE as h,FE as i,ee as j,_C as k,Xj as l,DC as m,RC as n,Oj as o,tS as p,BC as q,W as r,RE as s,J_ as t,uT as u,GC as v,OC as w,jj as x,Yj as y,WC as z};
75
+ */const kj=(e,t)=>{const n=W.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:a,className:s="",children:i,...l},c)=>{return W.createElement("svg",{ref:c,...wj,width:r,height:r,stroke:n,strokeWidth:a?24*Number(o)/Number(r):o,className:["lucide",`lucide-${u=e,u.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim()}`,s].join(" "),...l},[...t.map(([e,t])=>W.createElement(e,t)),...Array.isArray(i)?i:[i]]);var u});return n.displayName=`${e}`,n},Sj=kj("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),Ej=kj("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),Cj=kj("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),jj=kj("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),Pj=kj("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Nj=kj("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),_j=kj("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Tj=kj("File",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),Rj=kj("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),Lj=kj("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Mj=kj("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]),Oj=kj("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Dj=kj("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),Aj=kj("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),Ij=kj("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),Fj=kj("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),zj=kj("KeyRound",[["path",{d:"M2 18v3c0 .6.4 1 1 1h4v-3h3v-3h2l1.4-1.4a6.5 6.5 0 1 0-4-4Z",key:"167ctg"}],["circle",{cx:"16.5",cy:"7.5",r:".5",key:"1kog09"}]]),$j=kj("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),Vj=kj("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Uj=kj("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Bj=kj("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),Wj=kj("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),Hj=kj("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),qj=kj("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),Gj=kj("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),Kj=kj("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Yj=kj("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Xj=kj("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),Qj=kj("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]),Jj=kj("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Zj=kj("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),eP=kj("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),tP=kj("Sparkles",[["path",{d:"m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z",key:"17u4zn"}],["path",{d:"M5 3v4",key:"bklmnn"}],["path",{d:"M19 17v4",key:"iiml17"}],["path",{d:"M3 5h4",key:"nem4j1"}],["path",{d:"M17 19h4",key:"lbex7p"}]]),nP=kj("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),rP=kj("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),oP=kj("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),aP=kj("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),sP=kj("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),iP=kj("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),lP=kj("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function cP({className:e,...t}){return ee.jsx("div",{className:XS("animate-pulse rounded-md bg-muted",e),...t})}const uP=gE("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function dP({className:e,variant:t,...n}){return ee.jsx("div",{className:XS(uP({variant:t}),e),...n})}function pP(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(null==e||e(r),!1===n||!r.defaultPrevented)return null==t?void 0:t(r)}}function hP(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>W.createContext(e));return function(n){const r=(null==n?void 0:n[e])||t;return W.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const o=W.createContext(r),a=n.length;n=[...n,r];const s=t=>{var n;const{scope:r,children:s,...i}=t,l=(null==(n=null==r?void 0:r[e])?void 0:n[a])||o,c=W.useMemo(()=>i,Object.values(i));return ee.jsx(l.Provider,{value:c,children:s})};return s.displayName=t+"Provider",[s,function(n,s){var i;const l=(null==(i=null==s?void 0:s[e])?void 0:i[a])||o,c=W.useContext(l);if(c)return c;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},fP(r,...t)]}function fP(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return W.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var mP=(null==globalThis?void 0:globalThis.document)?W.useLayoutEffect:()=>{},gP=q[" useId ".trim().toString()]||(()=>{}),vP=0;function yP(e){const[t,n]=W.useState(gP());return mP(()=>{n(e=>e??String(vP++))},[e]),e||(t?`radix-${t}`:"")}var bP=q[" useInsertionEffect ".trim().toString()]||mP;function xP({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,s]=function({defaultProp:e,onChange:t}){const[n,r]=W.useState(e),o=W.useRef(n),a=W.useRef(t);return bP(()=>{a.current=t},[t]),W.useEffect(()=>{var e;o.current!==n&&(null==(e=a.current)||e.call(a,n),o.current=n)},[n,o]),[n,r,a]}({defaultProp:t,onChange:n}),i=void 0!==e,l=i?e:o;{const t=W.useRef(void 0!==e);W.useEffect(()=>{const e=t.current;if(e!==i){const t=e?"controlled":"uncontrolled",n=i?"controlled":"uncontrolled";console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=i},[i,r])}const c=W.useCallback(t=>{var n;if(i){const r=function(e){return"function"==typeof e}(t)?t(e):t;r!==e&&(null==(n=s.current)||n.call(s,r))}else a(t)},[i,e,a,s]);return[l,c]}function wP(e){const t=kP(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),s=a.find(EP);if(s){const e=s.props.children,r=a.map(t=>t===s?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function kP(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?oE(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SP=Symbol("radix.slottable");function EP(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===SP}var CP=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=wP(`Primitive.${t}`),r=W.forwardRef((e,r)=>{const{asChild:o,...a}=e,s=o?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),ee.jsx(s,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function jP(e,t){e&&ld.flushSync(()=>e.dispatchEvent(t))}function PP(e){const t=W.useRef(e);return W.useEffect(()=>{t.current=e}),W.useMemo(()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)},[])}var NP,_P="dismissableLayer.update",TP="dismissableLayer.pointerDownOutside",RP="dismissableLayer.focusOutside",LP=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),MP=W.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:i,...l}=e,c=W.useContext(LP),[u,d]=W.useState(null),p=(null==u?void 0:u.ownerDocument)??(null==globalThis?void 0:globalThis.document),[,h]=W.useState({}),f=aE(t,e=>d(e)),m=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(g),y=u?m.indexOf(u):-1,b=c.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,w=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e),r=W.useRef(!1),o=W.useRef(()=>{});return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){DP(TP,n,a,{discrete:!0})};const a={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",o.current),o.current=r,t.addEventListener("click",o.current,{once:!0})):r()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",e),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...c.branches].some(e=>e.contains(t));x&&!n&&(null==o||o(e),null==s||s(e),e.defaultPrevented||null==i||i())},p),k=function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e),r=W.useRef(!1);return W.useEffect(()=>{const e=e=>{if(e.target&&!r.current){DP(RP,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(null==a||a(e),null==s||s(e),e.defaultPrevented||null==i||i())},p);return function(e,t=(null==globalThis?void 0:globalThis.document)){const n=PP(e);W.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{y===c.layers.size-1&&(null==r||r(e),!e.defaultPrevented&&i&&(e.preventDefault(),i()))},p),W.useEffect(()=>{if(u)return n&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(NP=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),OP(),()=>{n&&1===c.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=NP)}},[u,p,n,c]),W.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),OP())},[u,c]),W.useEffect(()=>{const e=()=>h({});return document.addEventListener(_P,e),()=>document.removeEventListener(_P,e)},[]),ee.jsx(CP.div,{...l,ref:f,style:{pointerEvents:b?x?"auto":"none":void 0,...e.style},onFocusCapture:pP(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pP(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pP(e.onPointerDownCapture,w.onPointerDownCapture)})});MP.displayName="DismissableLayer";function OP(){const e=new CustomEvent(_P);document.dispatchEvent(e)}function DP(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?jP(o,a):o.dispatchEvent(a)}W.forwardRef((e,t)=>{const n=W.useContext(LP),r=W.useRef(null),o=aE(t,r);return W.useEffect(()=>{const e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),ee.jsx(CP.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var AP="focusScope.autoFocusOnMount",IP="focusScope.autoFocusOnUnmount",FP={bubbles:!1,cancelable:!0},zP=W.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=e,[i,l]=W.useState(null),c=PP(o),u=PP(a),d=W.useRef(null),p=aE(t,e=>l(e)),h=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(r){let e=function(e){if(h.paused||!i)return;const t=e.target;i.contains(t)?d.current=t:BP(d.current,{select:!0})},t=function(e){if(h.paused||!i)return;const t=e.relatedTarget;null!==t&&(i.contains(t)||BP(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&BP(i)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return i&&r.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[r,i,h.paused]),W.useEffect(()=>{if(i){WP.add(h);const t=document.activeElement;if(!i.contains(t)){const n=new CustomEvent(AP,FP);i.addEventListener(AP,c),i.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(BP(r,{select:t}),document.activeElement!==n)return}((e=$P(i),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&BP(i))}return()=>{i.removeEventListener(AP,c),setTimeout(()=>{const e=new CustomEvent(IP,FP);i.addEventListener(IP,u),i.dispatchEvent(e),e.defaultPrevented||BP(t??document.body,{select:!0}),i.removeEventListener(IP,u),WP.remove(h)},0)}}var e},[i,c,u,h]);const f=W.useCallback(e=>{if(!n&&!r)return;if(h.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,o=document.activeElement;if(t&&o){const t=e.currentTarget,[r,a]=function(e){const t=$P(e),n=VP(t,e),r=VP(t.reverse(),e);return[n,r]}(t);r&&a?e.shiftKey||o!==a?e.shiftKey&&o===r&&(e.preventDefault(),n&&BP(a,{select:!0})):(e.preventDefault(),n&&BP(r,{select:!0})):o===t&&e.preventDefault()}},[n,r,h.paused]);return ee.jsx(CP.div,{tabIndex:-1,...s,ref:p,onKeyDown:f})});function $P(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function VP(e,t){for(const n of e)if(!UP(n,{upTo:t}))return n}function UP(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function BP(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}zP.displayName="FocusScope";var WP=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=HP(e,t),e.unshift(t)},remove(t){var n;e=HP(e,t),null==(n=e[0])||n.resume()}}}();function HP(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var qP=W.forwardRef((e,t)=>{var n;const{container:r,...o}=e,[a,s]=W.useState(!1);mP(()=>s(!0),[]);const i=r||a&&(null==(n=null==globalThis?void 0:globalThis.document)?void 0:n.body);return i?cd.createPortal(ee.jsx(CP.div,{...o,ref:t}),i):null});qP.displayName="Portal";var GP=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=W.useState(),r=W.useRef(null),o=W.useRef(e),a=W.useRef("none"),s=e?"mounted":"unmounted",[i,l]=function(e,t){return W.useReducer((e,n)=>t[e][n]??e,e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return W.useEffect(()=>{const e=KP(r.current);a.current="mounted"===i?e:"none"},[i]),mP(()=>{const t=r.current,n=o.current;if(n!==e){const r=a.current,s=KP(t);if(e)l("MOUNT");else if("none"===s||"none"===(null==t?void 0:t.display))l("UNMOUNT");else{l(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}o.current=e}},[e,l]),mP(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=a=>{const s=KP(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&s&&(l("ANIMATION_END"),!o.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},i=e=>{e.target===t&&(a.current=KP(r.current))};return t.addEventListener("animationstart",i),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",i),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:W.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),o="function"==typeof n?n({present:r.isPresent}):W.Children.only(n),a=aE(r.ref,function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(o));return"function"==typeof n||r.isPresent?W.cloneElement(o,{ref:a}):null};function KP(e){return(null==e?void 0:e.animationName)||"none"}GP.displayName="Presence";var YP=0;function XP(){W.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??QP()),document.body.insertAdjacentElement("beforeend",e[1]??QP()),YP++,()=>{1===YP&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),YP--}},[])}function QP(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var JP=function(){return JP=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},JP.apply(this,arguments)};function ZP(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var eN="right-scroll-bar-position",tN="width-before-scroll-bar";function nN(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var rN="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,oN=new WeakMap;function aN(e,t){var n,r,o,a=(n=null,r=function(t){return e.forEach(function(e){return nN(e,t)})},(o=W.useState(function(){return{value:n,callback:r,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=r,o.facade);return rN(function(){var t=oN.get(a);if(t){var n=new Set(t),r=new Set(e),o=a.current;n.forEach(function(e){r.has(e)||nN(e,null)}),r.forEach(function(e){n.has(e)||nN(e,o)})}oN.set(a,e)},[e]),a}function sN(e){return e}var iN=function(e){var t=e.sideCar,n=ZP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return W.createElement(r,JP({},n))};iN.isSideCarExport=!0;var lN=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=sN);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var o=t(e,r);return n.push(o),function(){n=n.filter(function(e){return e!==o})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var o=n;n=[],o.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(a)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=JP({async:!0,ssr:!1},e),t}(),cN=function(){},uN=W.forwardRef(function(e,t){var n=W.useRef(null),r=W.useState({onScrollCapture:cN,onWheelCapture:cN,onTouchMoveCapture:cN}),o=r[0],a=r[1],s=e.forwardProps,i=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,p=e.sideCar,h=e.noRelative,f=e.noIsolation,m=e.inert,g=e.allowPinchZoom,v=e.as,y=void 0===v?"div":v,b=e.gapMode,x=ZP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=p,k=aN([n,t]),S=JP(JP({},x),o);return W.createElement(W.Fragment,null,u&&W.createElement(w,{sideCar:lN,removeScrollBar:c,shards:d,noRelative:h,noIsolation:f,inert:m,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),s?W.cloneElement(W.Children.only(i),JP(JP({},S),{ref:k})):W.createElement(y,JP({},S,{className:l,ref:k}),i))});uN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},uN.classNames={fullWidth:tN,zeroRight:eN};function dN(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var pN=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=dN())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},hN=function(){var e,t=(e=pN(),function(t,n){W.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},fN={left:0,top:0,right:0,gap:0},mN=function(e){return parseInt(e||"",10)||0},gN=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return fN;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],o=t["padding"===e?"paddingRight":"marginRight"];return[mN(n),mN(r),mN(o)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},vN=hN(),yN="data-scroll-locked",bN=function(e,t,n,r){var o=e.left,a=e.top,s=e.right,i=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(i,"px ").concat(r,";\n }\n body[").concat(yN,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(o,"px;\n padding-top: ").concat(a,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(i,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(i,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(eN," {\n right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(tN," {\n margin-right: ").concat(i,"px ").concat(r,";\n }\n \n .").concat(eN," .").concat(eN," {\n right: 0 ").concat(r,";\n }\n \n .").concat(tN," .").concat(tN," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(yN,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(i,"px;\n }\n")},xN=function(){var e=parseInt(document.body.getAttribute(yN)||"0",10);return isFinite(e)?e:0},wN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=void 0===r?"margin":r;W.useEffect(function(){return document.body.setAttribute(yN,(xN()+1).toString()),function(){var e=xN()-1;e<=0?document.body.removeAttribute(yN):document.body.setAttribute(yN,e.toString())}},[]);var a=W.useMemo(function(){return gN(o)},[o]);return W.createElement(vN,{styles:bN(a,!t,o,n?"":"!important")})},kN=!1;if("undefined"!=typeof window)try{var SN=Object.defineProperty({},"passive",{get:function(){return kN=!0,!0}});window.addEventListener("test",SN,SN),window.removeEventListener("test",SN,SN)}catch(kR){kN=!1}var EN=!!kN&&{passive:!1},CN=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},jN=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),PN(e,r)){var o=NN(e,r);if(o[1]>o[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},PN=function(e,t){return"v"===e?function(e){return CN(e,"overflowY")}(t):function(e){return CN(e,"overflowX")}(t)},NN=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},_N=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},TN=function(e){return[e.deltaX,e.deltaY]},RN=function(e){return e&&"current"in e?e.current:e},LN=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},MN=0,ON=[];function DN(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const AN=(IN=function(e){var t=W.useRef([]),n=W.useRef([0,0]),r=W.useRef(),o=W.useState(MN++)[0],a=W.useState(hN)[0],s=W.useRef(e);W.useEffect(function(){s.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var t=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(RN),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=W.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!s.current.allowPinchZoom;var o,a=_N(e),i=n.current,l="deltaX"in e?e.deltaX:i[0]-a[0],c="deltaY"in e?e.deltaY:i[1]-a[1],u=e.target,d=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===d&&"range"===u.type)return!1;var p=window.getSelection(),h=p&&p.anchorNode;if(h&&(h===u||h.contains(u)))return!1;var f=jN(d,u);if(!f)return!0;if(f?o=d:(o="v"===d?"h":"v",f=jN(d,u)),!f)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=o),!o)return!0;var m=r.current||o;return function(e,t,n,r){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=o*r,s=n.target,i=t.contains(s),l=!1,c=a>0,u=0,d=0;do{if(!s)break;var p=NN(e,s),h=p[0],f=p[1]-p[2]-o*h;(h||f)&&PN(e,s)&&(u+=f,d+=h);var m=s.parentNode;s=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!i&&s!==document.body||i&&(t.contains(s)||t===s));return(c&&Math.abs(u)<1||!c&&Math.abs(d)<1)&&(l=!0),l}(m,t,e,"h"===m?l:c)},[]),l=W.useCallback(function(e){var n=e;if(ON.length&&ON[ON.length-1]===a){var r="deltaY"in n?TN(n):_N(n),o=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,o=r,t[0]===o[0]&&t[1]===o[1]);var t,o})[0];if(o&&o.should)n.cancelable&&n.preventDefault();else if(!o){var l=(s.current.shards||[]).map(RN).filter(Boolean).filter(function(e){return e.contains(n.target)});(l.length>0?i(n,l[0]):!s.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),c=W.useCallback(function(e,n,r,o){var a={name:e,delta:n,target:r,should:o,shadowParent:DN(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=W.useCallback(function(e){n.current=_N(e),r.current=void 0},[]),d=W.useCallback(function(t){c(t.type,TN(t),t.target,i(t,e.lockRef.current))},[]),p=W.useCallback(function(t){c(t.type,_N(t),t.target,i(t,e.lockRef.current))},[]);W.useEffect(function(){return ON.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:p}),document.addEventListener("wheel",l,EN),document.addEventListener("touchmove",l,EN),document.addEventListener("touchstart",u,EN),function(){ON=ON.filter(function(e){return e!==a}),document.removeEventListener("wheel",l,EN),document.removeEventListener("touchmove",l,EN),document.removeEventListener("touchstart",u,EN)}},[]);var h=e.removeScrollBar,f=e.inert;return W.createElement(W.Fragment,null,f?W.createElement(a,{styles:LN(o)}):null,h?W.createElement(wN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},lN.useMedium(IN),iN);var IN,FN=W.forwardRef(function(e,t){return W.createElement(uN,JP({},e,{ref:t,sideCar:AN}))});FN.classNames=uN.classNames;var zN=new WeakMap,$N=new WeakMap,VN={},UN=0,BN=function(e){return e&&(e.host||BN(e.parentNode))},WN=function(e,t,n,r){var o=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=BN(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);VN[n]||(VN[n]=new WeakMap);var a=VN[n],s=[],i=new Set,l=new Set(o),c=function(e){e&&!i.has(e)&&(i.add(e),c(e.parentNode))};o.forEach(c);var u=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(i.has(e))u(e);else try{var t=e.getAttribute(r),o=null!==t&&"false"!==t,l=(zN.get(e)||0)+1,c=(a.get(e)||0)+1;zN.set(e,l),a.set(e,c),s.push(e),1===l&&o&&$N.set(e,!0),1===c&&e.setAttribute(n,"true"),o||e.setAttribute(r,"true")}catch(wR){console.error("aria-hidden: cannot operate on ",e,wR)}})};return u(t),i.clear(),UN++,function(){s.forEach(function(e){var t=zN.get(e)-1,o=a.get(e)-1;zN.set(e,t),a.set(e,o),t||($N.has(e)||e.removeAttribute(r),$N.delete(e)),o||e.removeAttribute(n)}),--UN||(zN=new WeakMap,zN=new WeakMap,$N=new WeakMap,VN={})}},HN=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),WN(r,o,n,"aria-hidden")):function(){return null}};function qN(e){const t=GN(e),n=W.forwardRef((e,n)=>{const{children:r,...o}=e,a=W.Children.toArray(r),s=a.find(YN);if(s){const e=s.props.children,r=a.map(t=>t===s?W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null:t);return ee.jsx(t,{...o,ref:n,children:W.isValidElement(e)?W.cloneElement(e,void 0,r):null})}return ee.jsx(t,{...o,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function GN(e){const t=W.forwardRef((e,t)=>{const{children:n,...r}=e;if(W.isValidElement(n)){const e=function(e){var t,n;let r=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;if(o)return e.ref;if(r=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==W.Fragment&&(o.ref=t?oE(t,e):e),W.cloneElement(n,o)}return W.Children.count(n)>1?W.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var KN=Symbol("radix.slottable");function YN(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===KN}var XN="Dialog",[QN]=hP(XN),[JN,ZN]=QN(XN),e_=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=e,i=W.useRef(null),l=W.useRef(null),[c,u]=xP({prop:r,defaultProp:o??!1,onChange:a,caller:XN});return ee.jsx(JN,{scope:t,triggerRef:i,contentRef:l,contentId:yP(),titleId:yP(),descriptionId:yP(),open:c,onOpenChange:u,onOpenToggle:W.useCallback(()=>u(e=>!e),[u]),modal:s,children:n})};e_.displayName=XN;var t_="DialogTrigger";W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(t_,n),a=aE(t,o.triggerRef);return ee.jsx(CP.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":w_(o.open),...r,ref:a,onClick:pP(e.onClick,o.onOpenToggle)})}).displayName=t_;var n_="DialogPortal",[r_,o_]=QN(n_,{forceMount:void 0}),a_=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=ZN(n_,t);return ee.jsx(r_,{scope:t,forceMount:n,children:W.Children.map(r,e=>ee.jsx(GP,{present:n||a.open,children:ee.jsx(qP,{asChild:!0,container:o,children:e})}))})};a_.displayName=n_;var s_="DialogOverlay",i_=W.forwardRef((e,t)=>{const n=o_(s_,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ZN(s_,e.__scopeDialog);return a.modal?ee.jsx(GP,{present:r||a.open,children:ee.jsx(c_,{...o,ref:t})}):null});i_.displayName=s_;var l_=qN("DialogOverlay.RemoveScroll"),c_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(s_,n);return ee.jsx(FN,{as:l_,allowPinchZoom:!0,shards:[o.contentRef],children:ee.jsx(CP.div,{"data-state":w_(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),u_="DialogContent",d_=W.forwardRef((e,t)=>{const n=o_(u_,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=ZN(u_,e.__scopeDialog);return ee.jsx(GP,{present:r||a.open,children:a.modal?ee.jsx(p_,{...o,ref:t}):ee.jsx(h_,{...o,ref:t})})});d_.displayName=u_;var p_=W.forwardRef((e,t)=>{const n=ZN(u_,e.__scopeDialog),r=W.useRef(null),o=aE(t,n.contentRef,r);return W.useEffect(()=>{const e=r.current;if(e)return HN(e)},[]),ee.jsx(f_,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pP(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:pP(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:pP(e.onFocusOutside,e=>e.preventDefault())})}),h_=W.forwardRef((e,t)=>{const n=ZN(u_,e.__scopeDialog),r=W.useRef(!1),o=W.useRef(!1);return ee.jsx(f_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var a,s;null==(a=e.onCloseAutoFocus)||a.call(e,t),t.defaultPrevented||(r.current||null==(s=n.triggerRef.current)||s.focus(),t.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:t=>{var a,s;null==(a=e.onInteractOutside)||a.call(e,t),t.defaultPrevented||(r.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const i=t.target;(null==(s=n.triggerRef.current)?void 0:s.contains(i))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),f_=W.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=e,i=ZN(u_,n),l=W.useRef(null),c=aE(t,l);return XP(),ee.jsxs(ee.Fragment,{children:[ee.jsx(zP,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:ee.jsx(MP,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":w_(i.open),...s,ref:c,onDismiss:()=>i.onOpenChange(!1)})}),ee.jsxs(ee.Fragment,{children:[ee.jsx(C_,{titleId:i.titleId}),ee.jsx(j_,{contentRef:l,descriptionId:i.descriptionId})]})]})}),m_="DialogTitle",g_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(m_,n);return ee.jsx(CP.h2,{id:o.titleId,...r,ref:t})});g_.displayName=m_;var v_="DialogDescription",y_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(v_,n);return ee.jsx(CP.p,{id:o.descriptionId,...r,ref:t})});y_.displayName=v_;var b_="DialogClose",x_=W.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ZN(b_,n);return ee.jsx(CP.button,{type:"button",...r,ref:t,onClick:pP(e.onClick,()=>o.onOpenChange(!1))})});function w_(e){return e?"open":"closed"}x_.displayName=b_;var k_="DialogTitleWarning",[S_,E_]=function(e,t){const n=W.createContext(t),r=e=>{const{children:t,...r}=e,o=W.useMemo(()=>r,Object.values(r));return ee.jsx(n.Provider,{value:o,children:t})};return r.displayName=e+"Provider",[r,function(r){const o=W.useContext(n);if(o)return o;if(void 0!==t)return t;throw new Error(`\`${r}\` must be used within \`${e}\``)}]}(k_,{contentName:u_,titleName:m_,docsSlug:"dialog"}),C_=({titleId:e})=>{const t=E_(k_),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return W.useEffect(()=>{if(e){document.getElementById(e)||console.error(n)}},[n,e]),null},j_=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${E_("DialogDescriptionWarning").contentName}}.`;return W.useEffect(()=>{var r;const o=null==(r=e.current)?void 0:r.getAttribute("aria-describedby");if(t&&o){document.getElementById(t)||console.warn(n)}},[n,e,t]),null},P_=i_,N_=d_,__=g_,T_=y_,R_=x_;const L_=e_,M_=a_,O_=W.forwardRef(({className:e,...t},n)=>ee.jsx(P_,{ref:n,className:XS("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}));O_.displayName=P_.displayName;const D_=W.forwardRef(({className:e,children:t,noOverlay:n,...r},o)=>ee.jsxs(M_,{children:[!n&&ee.jsx(O_,{}),ee.jsxs(N_,{ref:o,className:XS("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-xl",e),...r,children:[t,ee.jsxs(R_,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[ee.jsx(iP,{className:"h-4 w-4"}),ee.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));D_.displayName=N_.displayName;const A_=({className:e,...t})=>ee.jsx("div",{className:XS("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});A_.displayName="DialogHeader";const I_=({className:e,...t})=>ee.jsx("div",{className:XS("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});I_.displayName="DialogFooter";const F_=W.forwardRef(({className:e,...t},n)=>ee.jsx(__,{ref:n,className:XS("text-lg font-semibold leading-none tracking-tight",e),...t}));F_.displayName=__.displayName;const z_=W.forwardRef(({className:e,...t},n)=>ee.jsx(T_,{ref:n,className:XS("text-sm text-muted-foreground",e),...t}));function $_({project:e,open:t,onOpenChange:n,onUpdated:r}){const[o,a]=W.useState([]),[s,i]=W.useState([]),[l,c]=W.useState(!1),[u,d]=W.useState(null);W.useEffect(()=>{if(!t)return;a(e.shares?[...e.shares]:[]),d(null);let n=!1;return GE().then(e=>{n||i(e)}).catch(()=>{}),()=>{n=!0}},[t,e.id]);const p=new Set(o.map(e=>e.username)),h=s.filter(t=>t!==e.owner&&!p.has(t));return ee.jsx(L_,{open:t,onOpenChange:n,children:ee.jsxs(D_,{className:"sm:max-w-md",children:[ee.jsxs(A_,{children:[ee.jsxs(F_,{className:"flex items-center gap-2",children:[ee.jsx(sP,{className:"h-4 w-4"}),"共享设置"]}),ee.jsx(z_,{children:"选择用户并设置权限:可见(只读)或可编辑(读写+终端)"})]}),ee.jsxs("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:[0===o.length&&ee.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"尚未共享给任何用户"}),o.map(e=>ee.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[ee.jsx("span",{className:"text-sm font-medium",children:e.username}),ee.jsxs("div",{className:"flex items-center gap-1.5",children:[ee.jsx("button",{onClick:()=>{return t=e.username,void a(e=>e.map(e=>e.username===t?{...e,permission:"view"===e.permission?"edit":"view"}:e));var t},className:"focus:outline-none",children:ee.jsx(dP,{variant:"edit"===e.permission?"default":"secondary",className:"cursor-pointer text-xs",children:"edit"===e.permission?"可编辑":"可见"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>{return t=e.username,void a(e=>e.filter(e=>e.username!==t));var t},children:ee.jsx(aP,{className:"h-3.5 w-3.5"})})]})]},e.username))]}),h.length>0&&ee.jsxs("div",{className:"border-t pt-3",children:[ee.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"添加用户"}),ee.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(e=>ee.jsxs(yE,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>{return t=e,void a(e=>[...e,{username:t,permission:"view"}]);var t},children:[ee.jsx(Yj,{className:"h-3 w-3"}),e]},e))})]}),u&&ee.jsx("p",{className:"text-sm text-destructive",children:u}),ee.jsxs(I_,{children:[ee.jsx(yE,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"取消"}),ee.jsx(yE,{onClick:()=>{(async()=>{c(!0),d(null);try{const t=await KE(e.id,o);r(t),n(!1)}catch(kR){d(kR instanceof Error?kR.message:"Failed to update shares")}finally{c(!1)}})()},disabled:l,children:l?"保存中...":"保存"})]})]})})}z_.displayName=T_.displayName;const V_=Array(12).fill(0),U_=({visible:e,className:t})=>H.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},H.createElement("div",{className:"sonner-spinner"},V_.map((e,t)=>H.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),B_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),W_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},H.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"})),H_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),q_=H.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},H.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"})),G_=H.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"},H.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),H.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let K_=1;const Y_=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n,...r}=e,o="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:K_++,a=this.toasts.find(e=>e.id===o),s=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),a?this.toasts=this.toasts.map(t=>t.id===o?(this.publish({...t,...e,id:o,title:n}),{...t,...e,id:o,dismissible:s,title:n}):t):this.addToast({title:n,...r,dismissible:s,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o,a=void 0!==n;const s=r.then(async e=>{o=["resolve",e];if(H.isValidElement(e))a=!1,this.create({id:n,type:"default",message:e});else if(X_(e)&&!e.ok){a=!1;const r="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,o="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}else if(e instanceof Error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}else if(void 0!==t.success){a=!1;const r="function"==typeof t.success?await t.success(e):t.success,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"success",description:o,...s})}}).catch(async e=>{if(o=["reject",e],void 0!==t.error){a=!1;const r="function"==typeof t.error?await t.error(e):t.error,o="function"==typeof t.description?await t.description(e):t.description,s="object"==typeof r&&!H.isValidElement(r)?r:{message:r};this.create({id:n,type:"error",description:o,...s})}}).finally(()=>{a&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),i=()=>new Promise((e,t)=>s.then(()=>"reject"===o[0]?t(o[1]):e(o[1])).catch(t));return"string"!=typeof n&&"number"!=typeof n?{unwrap:i}:Object.assign(n,{unwrap:i})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||K_++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},X_=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,Q_=(e,t)=>{const n=(null==t?void 0:t.id)||K_++;return Y_.addToast({title:e,...t,id:n}),n},J_=Object.assign(Q_,{success:Y_.success,info:Y_.info,warning:Y_.warning,error:Y_.error,custom:Y_.custom,message:Y_.message,promise:Y_.promise,dismiss:Y_.dismiss,loading:Y_.loading},{getHistory:()=>Y_.toasts,getToasts:()=>Y_.getActiveToasts()});function Z_(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)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))}("[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%)}");const eT=3,tT=14;function nT(...e){return e.filter(Boolean).join(" ")}const rT=e=>{var t,n,r,o,a,s,i,l,c;const{invert:u,toast:d,unstyled:p,interacting:h,setHeights:f,visibleToasts:m,heights:g,index:v,toasts:y,expanded:b,removeToast:x,defaultRichColors:w,closeButton:k,style:S,cancelButtonStyle:E,actionButtonStyle:C,className:j="",descriptionClassName:P="",duration:N,position:_,gap:T,expandByDefault:R,classNames:L,icons:M,closeButtonAriaLabel:O="Close toast"}=e,[D,A]=H.useState(null),[I,F]=H.useState(null),[z,$]=H.useState(!1),[V,U]=H.useState(!1),[B,W]=H.useState(!1),[q,G]=H.useState(!1),[K,Y]=H.useState(!1),[X,Q]=H.useState(0),[J,Z]=H.useState(0),ee=H.useRef(d.duration||N||4e3),te=H.useRef(null),ne=H.useRef(null),re=0===v,oe=v+1<=m,ae=d.type,se=!1!==d.dismissible,ie=d.className||"",le=d.descriptionClassName||"",ce=H.useMemo(()=>g.findIndex(e=>e.toastId===d.id)||0,[g,d.id]),ue=H.useMemo(()=>{var e;return null!=(e=d.closeButton)?e:k},[d.closeButton,k]),de=H.useMemo(()=>d.duration||N||4e3,[d.duration,N]),pe=H.useRef(0),he=H.useRef(0),fe=H.useRef(0),me=H.useRef(null),[ge,ve]=_.split("-"),ye=H.useMemo(()=>g.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[g,ce]),be=(()=>{const[e,t]=H.useState(document.hidden);return H.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),xe=d.invert||u,we="loading"===ae;he.current=H.useMemo(()=>ce*T+ye,[ce,ye]),H.useEffect(()=>{ee.current=de},[de]),H.useEffect(()=>{$(!0)},[]),H.useEffect(()=>{const e=ne.current;if(e){const t=e.getBoundingClientRect().height;return Z(t),f(e=>[{toastId:d.id,height:t,position:d.position},...e]),()=>f(e=>e.filter(e=>e.toastId!==d.id))}},[f,d.id]),H.useLayoutEffect(()=>{if(!z)return;const e=ne.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,Z(n),f(e=>e.find(e=>e.toastId===d.id)?e.map(e=>e.toastId===d.id?{...e,height:n}:e):[{toastId:d.id,height:n,position:d.position},...e])},[z,d.title,d.description,f,d.id,d.jsx,d.action,d.cancel]);const ke=H.useCallback(()=>{U(!0),Q(he.current),f(e=>e.filter(e=>e.toastId!==d.id)),setTimeout(()=>{x(d)},200)},[d,x,f,he]);H.useEffect(()=>{if(d.promise&&"loading"===ae||d.duration===1/0||"loading"===d.type)return;let e;return b||h||be?(()=>{if(fe.current<pe.current){const e=(new Date).getTime()-pe.current;ee.current=ee.current-e}fe.current=(new Date).getTime()})():ee.current!==1/0&&(pe.current=(new Date).getTime(),e=setTimeout(()=>{null==d.onAutoClose||d.onAutoClose.call(d,d),ke()},ee.current)),()=>clearTimeout(e)},[b,h,d,ae,be,ke]),H.useEffect(()=>{d.delete&&(ke(),null==d.onDismiss||d.onDismiss.call(d,d))},[ke,d.delete]);const Se=d.icon||(null==M?void 0:M[ae])||(e=>{switch(e){case"success":return B_;case"info":return H_;case"warning":return W_;case"error":return q_;default:return null}})(ae);var Ee,Ce,je,Pe;return H.createElement("li",{tabIndex:0,ref:ne,className:nT(j,ie,null==L?void 0:L.toast,null==d||null==(t=d.classNames)?void 0:t.toast,null==L?void 0:L.default,null==L?void 0:L[ae],null==d||null==(n=d.classNames)?void 0:n[ae]),"data-sonner-toast":"","data-rich-colors":null!=(Ee=d.richColors)?Ee:w,"data-styled":!Boolean(d.jsx||d.unstyled||p),"data-mounted":z,"data-promise":Boolean(d.promise),"data-swiped":K,"data-removed":V,"data-visible":oe,"data-y-position":ge,"data-x-position":ve,"data-index":v,"data-front":re,"data-swiping":B,"data-dismissible":se,"data-type":ae,"data-invert":xe,"data-swipe-out":q,"data-swipe-direction":I,"data-expanded":Boolean(b||R&&z),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":y.length-v,"--offset":`${V?X:he.current}px`,"--initial-height":R?"auto":`${J}px`,...S,...d.style},onDragEnd:()=>{W(!1),A(null),me.current=null},onPointerDown:e=>{2!==e.button&&!we&&se&&(te.current=new Date,Q(he.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(W(!0),me.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(q||!se)return;me.current=null;const r=Number((null==(e=ne.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),o=Number((null==(t=ne.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(n=te.current)?void 0:n.getTime()),s="x"===D?r:o,i=Math.abs(s)/a;if(Math.abs(s)>=45||i>.11)return Q(he.current),null==d.onDismiss||d.onDismiss.call(d,d),F("x"===D?r>0?"right":"left":o>0?"down":"up"),ke(),void G(!0);var l,c;null==(l=ne.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(c=ne.current)||c.style.setProperty("--swipe-amount-y","0px"),Y(!1),W(!1),A(null)},onPointerMove:t=>{var n,r,o;if(!me.current||!se)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const a=t.clientY-me.current.y,s=t.clientX-me.current.x;var i;const l=null!=(i=e.swipeDirections)?i:function(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}(_);!D&&(Math.abs(s)>1||Math.abs(a)>1)&&A(Math.abs(s)>Math.abs(a)?"x":"y");let c={x:0,y:0};const u=e=>1/(1.5+Math.abs(e)/20);if("y"===D){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)c.y=a;else{const e=a*u(a);c.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===D&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&s<0||l.includes("right")&&s>0)c.x=s;else{const e=s*u(s);c.x=Math.abs(e)<Math.abs(s)?e:s}(Math.abs(c.x)>0||Math.abs(c.y)>0)&&Y(!0),null==(r=ne.current)||r.style.setProperty("--swipe-amount-x",`${c.x}px`),null==(o=ne.current)||o.style.setProperty("--swipe-amount-y",`${c.y}px`)}},ue&&!d.jsx&&"loading"!==ae?H.createElement("button",{"aria-label":O,"data-disabled":we,"data-close-button":!0,onClick:we||!se?()=>{}:()=>{ke(),null==d.onDismiss||d.onDismiss.call(d,d)},className:nT(null==L?void 0:L.closeButton,null==d||null==(r=d.classNames)?void 0:r.closeButton)},null!=(Ce=null==M?void 0:M.close)?Ce:G_):null,(ae||d.icon||d.promise)&&null!==d.icon&&(null!==(null==M?void 0:M[ae])||d.icon)?H.createElement("div",{"data-icon":"",className:nT(null==L?void 0:L.icon,null==d||null==(o=d.classNames)?void 0:o.icon)},d.promise||"loading"===d.type&&!d.icon?d.icon||((null==M?void 0:M.loading)?H.createElement("div",{className:nT(null==L?void 0:L.loader,null==d||null==(Pe=d.classNames)?void 0:Pe.loader,"sonner-loader"),"data-visible":"loading"===ae},M.loading):H.createElement(U_,{className:nT(null==L?void 0:L.loader,null==d||null==(je=d.classNames)?void 0:je.loader),visible:"loading"===ae})):null,"loading"!==d.type?Se:null):null,H.createElement("div",{"data-content":"",className:nT(null==L?void 0:L.content,null==d||null==(a=d.classNames)?void 0:a.content)},H.createElement("div",{"data-title":"",className:nT(null==L?void 0:L.title,null==d||null==(s=d.classNames)?void 0:s.title)},d.jsx?d.jsx:"function"==typeof d.title?d.title():d.title),d.description?H.createElement("div",{"data-description":"",className:nT(P,le,null==L?void 0:L.description,null==d||null==(i=d.classNames)?void 0:i.description)},"function"==typeof d.description?d.description():d.description):null),H.isValidElement(d.cancel)?d.cancel:d.cancel&&Z_(d.cancel)?H.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:e=>{Z_(d.cancel)&&se&&(null==d.cancel.onClick||d.cancel.onClick.call(d.cancel,e),ke())},className:nT(null==L?void 0:L.cancelButton,null==d||null==(l=d.classNames)?void 0:l.cancelButton)},d.cancel.label):null,H.isValidElement(d.action)?d.action:d.action&&Z_(d.action)?H.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||C,onClick:e=>{Z_(d.action)&&(null==d.action.onClick||d.action.onClick.call(d.action,e),e.defaultPrevented||ke())},className:nT(null==L?void 0:L.actionButton,null==d||null==(c=d.classNames)?void 0:c.actionButton)},d.action.label):null)};function oT(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function aT(e,t){const n={};return[e,t].forEach((e,t)=>{const r=1===t,o=r?"--mobile-offset":"--offset",a=r?"16px":"24px";function s(e){["top","right","bottom","left"].forEach(t=>{n[`${o}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?s(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n[`${o}-${t}`]=a:n[`${o}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):s(a)}),n}const sT=H.forwardRef(function(e,t){const{id:n,invert:r,position:o="bottom-right",hotkey:a=["altKey","KeyT"],expand:s,closeButton:i,className:l,offset:c,mobileOffset:u,theme:d="light",richColors:p,duration:h,style:f,visibleToasts:m=eT,toastOptions:g,dir:v=oT(),gap:y=tT,icons:b,containerAriaLabel:x="Notifications"}=e,[w,k]=H.useState([]),S=H.useMemo(()=>n?w.filter(e=>e.toasterId===n):w.filter(e=>!e.toasterId),[w,n]),E=H.useMemo(()=>Array.from(new Set([o].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,o]),[C,j]=H.useState([]),[P,N]=H.useState(!1),[_,T]=H.useState(!1),[R,L]=H.useState("system"!==d?d:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=H.useRef(null),O=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=H.useRef(null),A=H.useRef(!1),I=H.useCallback(e=>{k(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||Y_.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return H.useEffect(()=>Y_.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{cd.flushSync(()=>{k(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]:[e,...t]})})})}),[w]),H.useEffect(()=>{if("system"!==d)return void L(d);if("system"===d&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{L(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{L(e?"dark":"light")}catch(wR){console.error(wR)}})}},[d]),H.useEffect(()=>{w.length<=1&&N(!1)},[w]),H.useEffect(()=>{const e=e=>{var t;var n;a.every(t=>e[t]||e.code===t)&&(N(!0),null==(n=M.current)||n.focus());"Escape"!==e.code||document.activeElement!==M.current&&!(null==(t=M.current)?void 0:t.contains(document.activeElement))||N(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),H.useEffect(()=>{if(M.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,A.current=!1)}},[M.current]),H.createElement("section",{ref:t,"aria-label":`${x} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((t,n)=>{var o;const[a,d]=t.split("-");return S.length?H.createElement("ol",{key:t,dir:"auto"===v?oT():v,tabIndex:-1,ref:M,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":d,style:{"--front-toast-height":`${(null==(o=C[0])?void 0:o.height)||0}px`,"--width":"356px","--gap":`${y}px`,...f,...aT(c,u)},onBlur:e=>{A.current&&!e.currentTarget.contains(e.relatedTarget)&&(A.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||A.current||(A.current=!0,D.current=e.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{_||N(!1)},onDragEnd:()=>N(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||T(!0)},onPointerUp:()=>T(!1)},S.filter(e=>!e.position&&0===n||e.position===t).map((n,o)=>{var a,l;return H.createElement(rT,{key:n.id,icons:b,index:o,toast:n,defaultRichColors:p,duration:null!=(a=null==g?void 0:g.duration)?a:h,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:i,interacting:_,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:I,toasts:S.filter(e=>e.position==n.position),heights:C.filter(e=>e.position==n.position),setHeights:j,expandByDefault:s,gap:y,expanded:P,swipeDirections:e.swipeDirections})})):null}))}),iT=W.createContext(null);function lT({children:e}){const[t,n]=W.useState(!1),[r,o]=W.useState({}),a=W.useRef(null),s=W.useCallback(e=>(o(e),n(!0),new Promise(e=>{a.current=e})),[]),i=W.useCallback(e=>{n(!1);const t=a.current;a.current=null,t&&t(e)},[]);return ee.jsxs(iT.Provider,{value:s,children:[e,ee.jsx(L_,{open:t,onOpenChange:e=>{e||i(!1)},children:ee.jsxs(D_,{className:"max-w-md",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:r.title??"确认"}),void 0!==r.description&&ee.jsx(z_,{asChild:!0,children:ee.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),ee.jsxs(I_,{children:[ee.jsx(yE,{variant:"outline",onClick:()=>i(!1),children:r.cancelLabel??"取消"}),ee.jsx(cT,{destructive:r.destructive,onClick:()=>i(!0),children:r.confirmLabel??"确定"})]})]})})]})}function cT({destructive:e,onClick:t,children:n}){const r=W.useRef(null);return W.useEffect(()=>{var e;null==(e=r.current)||e.focus()},[]),ee.jsx(yE,{ref:r,onClick:t,className:XS(e&&"bg-red-600 hover:bg-red-700 text-white"),children:n})}function uT(){const e=W.useContext(iT);if(!e)throw new Error("useConfirm must be used within <ConfirmProvider>");return e}function dT(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 pT({status:e}){return ee.jsx("span",{className:XS("inline-block w-2 h-2 rounded-full",{"bg-green-500":"running"===e,"bg-zinc-400":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})})}const hT=H.memo(function({project:e,active:t=!1,statusStack:n=[],onDelete:r,onArchive:o,onUnarchive:a,onUpdated:s}){var i,l;const c=cp(),u=uT(),[d,p]=W.useState(!1),[h,f]=W.useState(null),[m,g]=W.useState(!1),[v,y]=W.useState(e.name),b=W.useRef(null),x=!!e._sharedPermission;W.useEffect(()=>{let t=!1;return XC(e.id).then(({bytes:e})=>{t||f(e)}).catch(()=>{}),()=>{t=!0}},[e.id]);const w="view"===e._sharedPermission,k=t=>{t.stopPropagation(),y(e.name),g(!0),setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.select()},0)},S=async()=>{const t=v.trim();if(t&&t!==e.name)try{const n=await KC(e.id,t);null==s||s(n),g(!1)}catch(kR){J_.error("Rename failed",{description:null==kR?void 0:kR.message})}else g(!1)},E=ee.jsx(tS.div,{whileHover:e.archived||t?{}:{y:-2},transition:bj.fast,children:ee.jsxs(QS,{className:XS("group cursor-pointer transition-colors relative",e.archived?"opacity-60 hover:opacity-80 hover:border-muted-foreground/40":t?"border-transparent hover:border-transparent bg-transparent shadow-none":"hover:border-muted-foreground/40"),onClick:()=>!e.archived&&c(`/projects/${e.id}`),children:[ee.jsxs(JS,{className:"pb-2",children:[ee.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m?ee.jsx("input",{ref:b,className:"text-base leading-tight font-semibold bg-transparent border-b border-primary outline-none w-full min-w-0",value:v,onChange:e=>y(e.target.value),onBlur:()=>{S()},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),S()),"Escape"===e.key&&g(!1)},onClick:e=>e.stopPropagation()}):ee.jsx(ZS,{className:XS("text-base leading-tight",e.archived&&"text-muted-foreground"),onDoubleClick:x||e.archived?void 0:k,children:e.name}),ee.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:!x&&ee.jsxs(ee.Fragment,{children:[e.archived?ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),a(e.id)},title:"Restore project",children:ee.jsx(Sj,{className:"h-3.5 w-3.5"})}):ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:k,title:"Rename project",children:ee.jsx(Kj,{className:"h-3.5 w-3.5"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:e=>{e.stopPropagation(),p(!0)},title:"共享设置",children:ee.jsx(sP,{className:"h-3.5 w-3.5"})}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:t=>{t.stopPropagation(),o(e.id)},title:"Archive project",children:ee.jsx(Ej,{className:"h-3.5 w-3.5"})})]}),ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:async t=>{t.stopPropagation();await u({title:"删除项目",description:`确认删除项目 "${e.name}"?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"})&&r(e.id)},title:"Delete project",children:ee.jsx(aP,{className:"h-3.5 w-3.5"})})]})})]}),ee.jsx("div",{className:"flex items-center gap-1.5",children:e.archived?ee.jsx(dP,{variant:"secondary",className:"text-xs",children:"Archived"}):ee.jsxs(ee.Fragment,{children:[ee.jsx(pT,{status:e.status}),ee.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:e.status}),t&&n.length>0&&ee.jsx("div",{className:"ml-auto",children:ee.jsx(Iw,{mode:"wait",children:n.slice(-1).map(e=>ee.jsx(tS.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:bj.default,children:ee.jsx(dP,{variant:"outline",className:"text-xs font-normal whitespace-nowrap",children:dT(e.phase,e.detail)})},e.id))})})]})})]}),ee.jsxs(tE,{className:"space-y-2",children:[ee.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[ee.jsx(Rj,{className:"h-3.5 w-3.5 flex-shrink-0"}),ee.jsx("span",{className:"truncate font-mono",children:e.folderPath}),null!==h&&ee.jsx("span",{className:"flex-shrink-0 ml-auto text-muted-foreground/70",children:(C=h,C>=1073741824?(C/1073741824).toFixed(1)+" GB":C>=1048576?(C/1048576).toFixed(1)+" MB":Math.round(C/1024)+" KB")})]}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(dP,{variant:"outline",className:"text-xs font-mono",children:e.cliTool??"claude"}),ee.jsx(dP,{variant:"unlimited"===e.permissionMode?"destructive":"secondary",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),x&&ee.jsxs(dP,{variant:"outline",className:"text-xs gap-0.5",children:[w?ee.jsx(_j,{className:"h-3 w-3"}):ee.jsx(Kj,{className:"h-3 w-3"}),w?"可见":"可编辑"]}),!x&&e.shares&&e.shares.length>0&&ee.jsxs(dP,{variant:"outline",className:"text-xs gap-0.5",children:[ee.jsx(sP,{className:"h-3 w-3"}),e.shares.length]}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(e.createdAt).toLocaleDateString()})]}),(e.tags??[]).length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(e.tags??[]).slice(0,3).map(e=>ee.jsxs("span",{className:"px-1.5 py-0 rounded-full text-[10px] bg-muted text-muted-foreground border border-border",children:["#",e]},e)),((null==(i=e.tags)?void 0:i.length)??0)>3&&ee.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",((null==(l=e.tags)?void 0:l.length)??0)-3]})]})]})]})});var C;const j=t&&!e.archived?ee.jsx("div",{className:"card-active-glow rounded-xl",children:E}):E;return ee.jsxs(ee.Fragment,{children:[j,!x&&s&&ee.jsx($_,{project:e,open:d,onOpenChange:p,onUpdated:s})]})});function fT({onSelect:e}){const[t,n]=W.useState(""),[r,o]=W.useState(null),[a,s]=W.useState([]),[i,l]=W.useState(!0),[c,u]=W.useState(null),[d,p]=W.useState(!1),[h,f]=W.useState(""),[m,g]=W.useState(null),[v,y]=W.useState(!1),b=W.useRef(null),x=async e=>{l(!0),u(null);try{const t=await _C(e);n(t.path),o(t.parent),s(t.entries)}catch(kR){u(kR instanceof Error?kR.message:"Failed to load directory")}finally{l(!1)}};W.useEffect(()=>{x()},[]),W.useEffect(()=>{d&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[d]);const w=()=>{p(!1),f(""),g(null)},k=async()=>{const e=h.trim();if(e){y(!0),g(null);try{const{path:n}=await LC(t,e);p(!1),f(""),await x(t),x(n)}catch(kR){g(kR instanceof Error?kR.message:"Failed to create folder")}finally{y(!1)}}},S=t.split("/").filter(Boolean);return ee.jsxs("div",{className:"flex flex-col h-64 border rounded-md overflow-hidden",children:[ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 bg-muted border-b flex-shrink-0",children:[ee.jsx(yE,{variant:"ghost",size:"sm",className:"h-6 px-1 flex-shrink-0",onClick:()=>{x()},title:"Home",children:ee.jsx(Fj,{className:"h-3 w-3"})}),ee.jsx("div",{className:"flex items-center gap-1 flex-1 overflow-x-auto min-w-0",children:S.map((e,t)=>ee.jsxs(H.Fragment,{children:[ee.jsx(Pj,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ee.jsx("button",{className:"text-xs hover:text-foreground text-muted-foreground whitespace-nowrap",onClick:()=>(e=>{const t="/"+S.slice(0,e+1).join("/");x(t)})(t),children:e})]},t))}),ee.jsxs(yE,{variant:"ghost",size:"sm",className:"h-6 px-1.5 flex-shrink-0 gap-1 text-xs",onClick:()=>{f(""),g(null),p(!0)},disabled:d||i||!!c,title:"New folder",children:[ee.jsx(Lj,{className:"h-3.5 w-3.5"}),ee.jsx("span",{className:"hidden sm:inline",children:"New folder"})]})]}),ee.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading..."}),c&&ee.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive px-4 text-center",children:c}),!i&&!c&&ee.jsxs("div",{className:"p-1",children:[r&&ee.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:()=>{x(r)},children:[ee.jsx(Cj,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("span",{children:".."})]}),d&&ee.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[ee.jsx(Oj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("input",{ref:b,className:XS("flex-1 text-sm bg-background border rounded px-1.5 py-0.5 outline-none","focus:ring-1 focus:ring-ring",m&&"border-destructive"),placeholder:"Folder name",value:h,onChange:e=>{f(e.target.value),g(null)},onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),k()):"Escape"===e.key&&w()},disabled:v}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent disabled:opacity-50",onClick:()=>{k()},disabled:!h.trim()||v,title:"Create",children:ee.jsx(jj,{className:"h-3.5 w-3.5 text-green-600"})}),ee.jsx("button",{className:"p-1 rounded hover:bg-accent",onClick:w,disabled:v,title:"Cancel",children:ee.jsx(iP,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),m&&ee.jsx("p",{className:"px-3 pb-1 text-xs text-destructive",children:m}),0===a.length&&!d&&ee.jsx("div",{className:"text-sm text-muted-foreground px-2 py-4 text-center",children:"Empty directory"}),a.map(e=>ee.jsxs("button",{className:XS("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded text-left","dir"===e.type?"hover:bg-accent hover:text-accent-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),onClick:()=>{"dir"===e.type&&x(e.path)},disabled:"file"===e.type,children:["dir"===e.type?ee.jsx(Oj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}):ee.jsx(Tj,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),ee.jsx("span",{className:"truncate",children:e.name})]},e.path))]})]}),ee.jsxs("div",{className:"border-t px-3 py-2 flex items-center justify-between gap-2 flex-shrink-0 bg-background",children:[ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:t}),ee.jsx(yE,{size:"sm",onClick:()=>e(t),disabled:!t,children:"Select this folder"})]})]})}function mT(e,t="shift"){return W.useCallback(n=>{if("Enter"!==n.key)return;if(n.nativeEvent.isComposing||229===n.keyCode)return;("shift"===t?!n.shiftKey:n.shiftKey)&&(n.preventDefault(),e())},[e,t])}const gT=[{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)"},{value:"gemini",label:"Gemini",desc:"Google Gemini CLI"},{value:"terminal",label:"Terminal",desc:"Plain shell (no AI CLI)"}],vT={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"},gemini:{limited:"gemini",unlimited:"gemini --yolo"},terminal:{limited:"$SHELL (interactive)",unlimited:"$SHELL (interactive)"}};function yT({open:e,onOpenChange:t,onCreated:n}){const[r,o]=W.useState("name"),[a,s]=W.useState(""),[i,l]=W.useState(""),[c,u]=W.useState("claude"),[d,p]=W.useState("limited"),[h,f]=W.useState(!1),[m,g]=W.useState(null),v=e=>{e||(o("name"),s(""),l(""),u("claude"),p("limited"),g(null),f(!1)),t(e)},y=()=>{a.trim()?(g(null),o("folder")):g("Please enter a project name")},b=mT(y,"shift"),x=["name","folder","settings"];return ee.jsx(L_,{open:e,onOpenChange:v,children:ee.jsxs(D_,{className:"sm:max-w-lg",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:{name:"New Project — Name",folder:"New Project — Select Folder",settings:"New Project — Settings"}[r]}),ee.jsxs(z_,{children:["name"===r&&"Give your project a name.","folder"===r&&"Choose the working directory for this project.","settings"===r&&"Choose the AI coding tool and run mode."]})]}),ee.jsx("div",{className:"flex gap-2 mb-2",children:x.map((e,t)=>ee.jsx("div",{className:"h-1.5 flex-1 rounded-full "+(r===e?"bg-primary":x.indexOf(r)>t?"bg-primary/40":"bg-muted")},e))}),"name"===r&&ee.jsxs("div",{className:"space-y-4",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{htmlFor:"project-name",children:"Project Name"}),ee.jsx(bE,{id:"project-name",placeholder:"My Project",value:a,onChange:e=>s(e.target.value),onKeyDown:b,autoFocus:!0})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),"folder"===r&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Working Directory"}),ee.jsx(fT,{onSelect:e=>{l(e),o("settings")}})]}),"settings"===r&&ee.jsxs("div",{className:"space-y-5",children:[ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"AI Coding Tool"}),ee.jsx("div",{className:"grid grid-cols-2 gap-2",children:gT.map(e=>ee.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer p-3 rounded-md border transition-colors "+(c===e.value?"border-primary bg-primary/5":"hover:bg-accent"),children:[ee.jsx("input",{type:"radio",name:"cliTool",value:e.value,checked:c===e.value,onChange:()=>u(e.value),className:"accent-primary"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:e.label}),ee.jsx("div",{className:"text-xs text-muted-foreground",children:e.desc})]})]},e.value))})]}),"terminal"!==c&&ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Permission Mode"}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"limited",checked:"limited"===d,onChange:()=>p("limited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Limited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:vT[c].limited})," — asks for permission before file changes."]})]})]}),ee.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 rounded-md border hover:bg-accent transition-colors",children:[ee.jsx("input",{type:"radio",name:"permissionMode",value:"unlimited",checked:"unlimited"===d,onChange:()=>p("unlimited"),className:"mt-0.5"}),ee.jsxs("div",{children:[ee.jsx("div",{className:"font-medium text-sm",children:"Unlimited"}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:["Runs ",ee.jsx("code",{className:"bg-muted px-1 rounded",children:vT[c].unlimited})," — acts autonomously."]})]})]})]})]}),ee.jsxs("div",{className:"text-xs text-muted-foreground",children:[ee.jsx("span",{className:"font-medium",children:"Folder:"})," ",ee.jsx("span",{className:"font-mono",children:i})]}),m&&ee.jsx("p",{className:"text-sm text-destructive",children:m})]}),ee.jsxs(I_,{children:["name"!==r&&ee.jsx(yE,{variant:"outline",onClick:()=>o("settings"===r?"folder":"name"),disabled:h,children:"Back"}),"name"===r&&ee.jsx(yE,{onClick:y,children:"Next"}),"folder"===r&&ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),"settings"===r&&ee.jsx(yE,{onClick:()=>{(async()=>{f(!0),g(null);try{const e=await YE({name:a.trim(),folderPath:i,permissionMode:d,cliTool:c});n(e),v(!1)}catch(kR){g(kR instanceof Error?kR.message:"Failed to create project")}finally{f(!1)}})()},disabled:h,children:h?"Creating...":"Create Project"})]})]})})}function bT({open:e,onOpenChange:t,onOpened:n}){const[r,o]=W.useState(""),[a,s]=W.useState(!1),[i,l]=W.useState(null),c=e=>{e||(o(""),l(null),s(!1)),t(e)};return ee.jsx(L_,{open:e,onOpenChange:c,children:ee.jsxs(D_,{className:"sm:max-w-lg",children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:"Open Existing Project"}),ee.jsxs(z_,{children:["Select a folder that contains a ",ee.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:".ccweb/"})," configuration. The project's history and settings will be restored."]})]}),ee.jsxs("div",{className:"space-y-2",children:[ee.jsx(EE,{children:"Project Folder"}),ee.jsx(fT,{onSelect:e=>{(async e=>{o(e),s(!0),l(null);try{const t=await XE(e);n(t),c(!1)}catch(kR){l(kR instanceof Error?kR.message:"Failed to open project"),s(!1)}})(e)}})]}),i&&ee.jsx("p",{className:"text-sm text-destructive",children:i}),r&&!i&&a&&ee.jsxs("p",{className:"text-sm text-muted-foreground",children:["Opening project from ",r,"..."]}),ee.jsx(I_,{children:ee.jsx(yE,{variant:"outline",onClick:()=>c(!1),disabled:a,children:"Cancel"})})]})})}const xT=`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}`;function wT(e){return 3e3*Math.min(e,4)+2e3*Math.random()}function kT(e,t){const n=W.useRef(null),r=W.useRef(0),o=W.useRef(!0),a=W.useRef(!1),s=W.useRef(null),i=W.useRef(t);i.current=t;const[l,c]=W.useState(!1),[u,d]=W.useState(0),p=W.useRef(!1),h=W.useRef([]),f=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(e))},[]),m=W.useCallback(()=>{var e;if((null==(e=n.current)?void 0:e.readyState)===WebSocket.OPEN)for(;h.current.length>0;){const e=h.current.shift();n.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),g=W.useCallback((e,t)=>{var r;(null==(r=n.current)?void 0:r.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:e,rows:t})),p.current=!1):p.current=!0},[]),v=W.useCallback(e=>{var t;(null==(t=n.current)?void 0:t.readyState)===WebSocket.OPEN?n.current.send(JSON.stringify({type:"terminal_input",data:e})):h.current.push(e)},[]),y=W.useCallback((e,t)=>{f({type:"terminal_resize",cols:e,rows:t})},[f]),b=W.useCallback(()=>{f({type:"chat_subscribe",replay:50})},[f]),x=W.useCallback(()=>{if(!o.current)return;if(a.current)return;const t=zE();if(!t)return void(window.location.href="/login");a.current=!0;const l=new WebSocket(`${xT}/ws/projects/${e}`);n.current=l,l.onopen=()=>{a.current=!1,r.current=0,l.send(JSON.stringify({type:"auth",token:t}))},l.onmessage=e=>{var t,n,r,o,a,s,l,u,h,f,g,v,y,b,x,w,k,S,E,C;let j;try{j=JSON.parse(e.data)}catch{return}switch(j.type){case"connected":p.current=!1,c(!0),d(e=>e+1),m(),null==(n=(t=i.current).onConnected)||n.call(t);break;case"terminal_data":null==(o=(r=i.current).onTerminalData)||o.call(r,j.data);break;case"terminal_reset":null==(s=(a=i.current).onTerminalReset)||s.call(a,j.cliTool);break;case"status":null==(u=(l=i.current).onStatus)||u.call(l,j.status);break;case"chat_message":{const e=j;null==(f=(h=i.current).onChatMessage)||f.call(h,e);break}case"project_stopped":{const e=j;null==(v=(g=i.current).onProjectStopped)||v.call(g,e.projectId,e.projectName);break}case"context_update":null==(b=(y=i.current).onContextUpdate)||b.call(y,j);break;case"semantic_update":null==(w=(x=i.current).onSemanticUpdate)||w.call(x,j);break;case"approval_request":null==(S=(k=i.current).onApprovalRequest)||S.call(k,j);break;case"approval_resolved":null==(C=(E=i.current).onApprovalResolved)||C.call(E,j);break;case"error":console.error("[WS] Server error:",j.message)}},l.onclose=()=>{var e,t;a.current=!1,n.current===l&&(n.current=null),c(!1),null==(t=(e=i.current).onDisconnected)||t.call(e),o.current&&r.current<5&&(r.current++,s.current=window.setTimeout(x,wT(r.current)))},l.onerror=e=>{a.current=!1,console.error("[WS] WebSocket error:",e)}},[e]);return W.useEffect(()=>(o.current=!0,x(),()=>{var e;o.current=!1,s.current&&(clearTimeout(s.current),s.current=null),null==(e=n.current)||e.close(),n.current=null,h.current=[]}),[x]),{subscribeTerminal:g,sendTerminalInput:v,sendTerminalResize:y,subscribeChatMessages:b,connected:l,readyTick:u}}function ST(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),s=W.useRef(e);s.current=e;const i=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=zE();if(!e)return;o.current=!0;const l=new WebSocket(`${xT}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n;try{const r=JSON.parse(e.data);"activity_update"===r.type?s.current.onActivityUpdate(r):"project_stopped"===r.type&&(null==(n=(t=s.current).onProjectStopped)||n.call(t,r.projectId,r.projectName))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(i,wT(n.current)))},l.onerror=e=>{o.current=!1,console.error("[DashboardWS] Error:",e)}},[]);W.useEffect(()=>(r.current=!0,i(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[i])}function ET(e){const t=W.useRef(null),n=W.useRef(0),r=W.useRef(!0),o=W.useRef(!1),a=W.useRef(null),s=W.useRef(e);s.current=e;const i=W.useCallback(()=>{if(!r.current)return;if(o.current)return;const e=zE();if(!e)return;o.current=!0;const l=new WebSocket(`${xT}/ws/dashboard`);t.current=l,l.onopen=()=>{o.current=!1,n.current=0,l.send(JSON.stringify({type:"auth",token:e}))},l.onmessage=e=>{var t,n,r,o,a,i;try{const l=JSON.parse(e.data);if(!l.type||!l.type.startsWith("sync."))return;"sync.start"===l.type?null==(n=(t=s.current).onStart)||n.call(t,l):"sync.progress"===l.type?null==(o=(r=s.current).onProgress)||o.call(r,l):"sync.done"===l.type&&(null==(i=(a=s.current).onDone)||i.call(a,l))}catch{}},l.onclose=()=>{o.current=!1,t.current===l&&(t.current=null),r.current&&n.current<5&&(n.current++,a.current=window.setTimeout(i,wT(n.current)))},l.onerror=()=>{o.current=!1}},[]);W.useEffect(()=>(r.current=!0,i(),()=>{var e;r.current=!1,a.current&&(clearTimeout(a.current),a.current=null),null==(e=t.current)||e.close(),t.current=null}),[i])}function CT({projectId:e,enabled:t,onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i}){const l=W.useRef(null),c=W.useRef(!0),u=W.useRef(0),d=W.useRef(null),p=W.useRef(!1),h=W.useRef(!1),f=W.useRef([]),m=W.useRef({onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i});m.current={onChatMessage:n,onStatusChange:r,onContextUpdate:o,onApprovalRequest:a,onApprovalResolved:s,onSemanticUpdate:i};const[g,v]=W.useState(!1),[y,b]=W.useState(0),x=W.useCallback(()=>{if(h.current&&l.current&&l.current.readyState===WebSocket.OPEN)for(;f.current.length>0;){const e=f.current.shift();l.current.send(JSON.stringify({type:"terminal_input",data:e}))}},[]),w=W.useCallback(e=>{var t;h.current&&(null==(t=l.current)?void 0:t.readyState)===WebSocket.OPEN?l.current.send(JSON.stringify({type:"terminal_input",data:e})):f.current.push(e)},[]),k=W.useCallback(()=>{if(!c.current||!t)return;if(p.current)return;const n=zE();if(!n)return;p.current=!0,h.current=!1;const r=new WebSocket(`${xT}/ws/projects/${e}`);l.current=r,r.onopen=()=>{p.current=!1,u.current=0,r.send(JSON.stringify({type:"auth",token:n}))},r.onmessage=e=>{var t,n,o,a,s,i,l,c,u,d,p,f;try{const g=JSON.parse(e.data);"connected"===g.type?(r.send(JSON.stringify({type:"chat_subscribe",replay:50})),h.current=!0,v(!0),b(e=>e+1),x()):"chat_message"===g.type?m.current.onChatMessage(g):"status"===g.type&&g.status?null==(n=(t=m.current).onStatusChange)||n.call(t,g.status):"project_stopped"===g.type?null==(a=(o=m.current).onStatusChange)||a.call(o,"stopped"):"context_update"===g.type?null==(i=(s=m.current).onContextUpdate)||i.call(s,g):"approval_request"===g.type?null==(c=(l=m.current).onApprovalRequest)||c.call(l,g):"approval_resolved"===g.type?null==(d=(u=m.current).onApprovalResolved)||d.call(u,g):"semantic_update"===g.type&&(null==(f=(p=m.current).onSemanticUpdate)||f.call(p,g))}catch{}},r.onclose=()=>{p.current=!1,h.current=!1,v(!1),l.current===r&&(l.current=null),c.current&&t&&(u.current<5?(u.current++,d.current=window.setTimeout(k,wT(u.current))):f.current.length>0&&(console.warn("[MonitorWS] Retries exhausted, dropping",f.current.length,"queued messages"),f.current=[]))},r.onerror=()=>{p.current=!1}},[e,t,x]);return W.useEffect(()=>(c.current=!0,()=>{c.current=!1,f.current=[]}),[]),W.useEffect(()=>(u.current=0,k(),()=>{var e;h.current=!1,d.current&&(clearTimeout(d.current),d.current=null),null==(e=l.current)||e.close(),l.current=null}),[k,t]),{sendInput:w,connected:g,readyTick:y}}const jT="cc_project_order_cache";function PT(){try{const e=localStorage.getItem(jT);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[]}catch{return[]}}function NT(e){try{localStorage.setItem(jT,JSON.stringify(e))}catch{}}function _T(){const[e,t]=W.useState(PT),n=W.useRef(!1),r=W.useRef(null),o=W.useRef(null),a=W.useRef(!1),s=W.useRef(!0);W.useEffect(()=>{s.current=!0;let e=!1;return HE().then(r=>{e||n.current||(t(e=>function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,r)?e:r),NT(r))}).catch(()=>{}),()=>{e=!0,s.current=!1,o.current&&(clearTimeout(o.current),o.current=null)}},[]);const i=W.useCallback(async()=>{for(;r.current;){const e=r.current;r.current=null,a.current=!0;try{await qE(e)}catch{}a.current=!1}},[]),l=W.useCallback(e=>{n.current=!0,t(e),NT(e),r.current=e,o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,s.current&&(a.current||i())},400)},[i]),c=W.useCallback(t=>{const n=new Map(e.map((e,t)=>[e,t]));return[...t].sort((e,t)=>{const r=n.get(e.id)??1/0,o=n.get(t.id)??1/0;return r===o?0:r-o})},[e]);return W.useMemo(()=>({order:e,setOrder:l,applyOrder:c}),[e,l,c])}const TT=18e6,RT=6048e5;function LT(e,t=18e6){if(!e||void 0===e.utilization||e.utilization<=0||!e.resetAt)return null;const n=new Date(e.resetAt).getTime()-Date.now();if(n<=0)return null;const r=t-n;return r<=0?null:Math.round(e.utilization/(r/t))}function MT({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const n=t.utilization,r=n<50?"text-green-400":n<80?"text-yellow-400":"text-red-400",o=function(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`}(t.resetAt);return ee.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:[e," ",ee.jsxs("span",{className:XS("font-medium",r),children:[n,"%"]}),o&&ee.jsxs("span",{className:"text-muted-foreground/70 ml-0.5",children:["(",o,")"]})]})}function OT({className:e}){const[t,n]=W.useState("loading"),[r,o]=W.useState(!1),a=()=>TE(_E.usageMonitorTool,"claude");W.useEffect(()=>{const e=async()=>{try{n(await PC(a()))}catch{n(null)}};e();const t=setInterval(()=>{e()},3e5),r=()=>{e()},o=t=>{t.key===_E.usageMonitorTool&&e()};return window.addEventListener("ccweb:usage-tool-change",r),window.addEventListener("storage",o),()=>{clearInterval(t),window.removeEventListener("ccweb:usage-tool-change",r),window.removeEventListener("storage",o)}},[]);if("loading"===t)return null;if(!t)return null;const s=!!t.fiveHour,i=!!t.sevenDay,l=!!t.sevenDaySonnet,c=!!t.sevenDayOpus,u=s||i||l||c,d=LT(t.fiveHour,TT),p=LT(t.sevenDay,RT),h=LT(t.sevenDaySonnet,RT),f=null!==d||null!==p||null!==h;return ee.jsxs("div",{className:XS("flex items-center gap-1.5 text-xs",e),children:[f&&ee.jsxs("span",{className:"flex items-center gap-1",children:[null!==d&&ee.jsxs("span",{className:XS("font-medium",d<=100?"text-green-400":"text-orange-400"),title:`5h 配速:按当前速率,窗口结束时预计使用 ${d}%`,children:[d,"%"]}),null!==p&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:XS("font-medium",p<=100?"text-green-400":"text-orange-400"),title:`7d 配速:按当前速率,窗口结束时预计使用 ${p}%`,children:[p,"%"]})]}),null!==h&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/40",children:"/"}),ee.jsxs("span",{className:XS("font-medium",h<=100?"text-green-400":"text-orange-400"),title:`7d Sonnet 配速:按当前速率,窗口结束时预计使用 ${h}%`,children:[h,"%"]})]})]}),t.planName&&ee.jsx("span",{className:"font-medium text-foreground bg-muted border border-border px-2 py-0.5 rounded-full",children:t.planName}),u&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"|"}),ee.jsx(MT,{label:"5h",bucket:t.fiveHour}),i&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d",bucket:t.sevenDay})]}),l&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d Sonnet",bucket:t.sevenDaySonnet})]}),c&&ee.jsxs(ee.Fragment,{children:[ee.jsx("span",{className:"text-muted-foreground/50",children:"·"}),ee.jsx(MT,{label:"7d Opus",bucket:t.sevenDayOpus})]})]}),ee.jsx("button",{onClick:()=>{(async()=>{o(!0);try{n(await NC(a()))}catch{n(null)}finally{o(!1)}})()},className:"text-muted-foreground hover:text-foreground transition-colors",title:"刷新用量信息",children:ee.jsx(Xj,{className:XS("h-3 w-3",r&&"animate-spin")})})]})}function DT({open:e,onOpenChange:t,kind:n,label:r,content:o}){const a=cp(),[s,i]=W.useState(()=>TE(_E.skillhubAuthor,"")),[l,c]=W.useState(""),[u,d]=W.useState(""),[p,h]=W.useState(!1),[f,m]=W.useState(null),[g,v]=W.useState(!0);W.useEffect(()=>{e&&(i(TE(_E.skillhubAuthor,"")),c(""),d(""),v(!0),SC().then(m).catch(()=>m({configured:!1,needsReset:!1})).finally(()=>v(!1)))},[e]);const y=()=>{t(!1),a("/settings?tab=hub")},b="quick-prompt"===n?"快捷 Prompt":"Agent Prompt",x=!g&&f&&!f.configured;return ee.jsx(L_,{open:e,onOpenChange:t,children:ee.jsxs(D_,{className:XS("sm:max-w-lg"),children:[ee.jsxs(A_,{children:[ee.jsx(F_,{children:"共享到 ccweb-hub"}),ee.jsxs(z_,{children:["「",r,"」将以 GitHub Issue 形式提交到 ",ee.jsx("code",{children:"zbc0315/ccweb-hub"}),", 使用你配置的 GitHub token。审核通过后会合入为社区 prompt。"]})]}),g?ee.jsxs("div",{className:"py-8 flex items-center justify-center text-sm text-muted-foreground",children:[ee.jsx(Vj,{className:"h-4 w-4 mr-2 animate-spin"}),"检查 token 配置…"]}):x?ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsx("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs",children:ee.jsxs("div",{className:"flex items-start gap-2",children:[ee.jsx(zj,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5"}),ee.jsxs("div",{className:"space-y-1",children:[ee.jsx("div",{className:"font-medium text-foreground",children:(null==f?void 0:f.needsReset)?"之前配置的 token 已失效(服务端密钥可能已轮换),请重新设置":"还没配置 GitHub token"}),ee.jsxs("div",{className:"text-muted-foreground",children:["为保护你的 GitHub 账号,ccweb 不自带 token,需要你用自己的 GitHub fine-grained PAT(只勾 ",ee.jsx("code",{children:"ccweb-hub"})," 仓库的",ee.jsx("code",{children:" Issues: Read and write"}),")。"]})]})]})}),ee.jsxs("div",{className:"flex gap-2 pt-1",children:[ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),className:"flex-1",children:"稍后"}),ee.jsx(yE,{onClick:y,className:"flex-1",children:"去设置页配置"})]})]}):ee.jsxs(ee.Fragment,{children:[ee.jsxs("div",{className:"space-y-3 py-2",children:[ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-author",className:"text-xs",children:"GitHub 用户名(可选,用于作者标注)"}),ee.jsx(bE,{id:"share-author",placeholder:"zbc0315",value:s,onChange:e=>i(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-desc",className:"text-xs",children:"一句话描述(可选)"}),ee.jsx(bE,{id:"share-desc",placeholder:"quick-prompt"===n?"这个命令用来...":"这段 prompt 让 Claude...",value:l,onChange:e=>c(e.target.value)})]}),ee.jsxs("div",{className:"space-y-1.5",children:[ee.jsx(EE,{htmlFor:"share-tags",className:"text-xs",children:"标签(逗号分隔,可选)"}),ee.jsx(bE,{id:"share-tags",placeholder:"review, 中文, 代码",value:u,onChange:e=>d(e.target.value)})]})]}),ee.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[ee.jsxs("div",{className:"font-medium text-foreground mb-1",children:["预览:",b," · ",r]}),ee.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-snug max-h-32 overflow-y-auto",children:[Array.from(o).slice(0,500).join(""),Array.from(o).length>500&&"…"]})]}),ee.jsxs(I_,{children:[ee.jsxs(yE,{variant:"ghost",size:"sm",onClick:y,className:"mr-auto",title:"更换或清除 token",children:[ee.jsx(zj,{className:"h-3.5 w-3.5 mr-1"}),"管理 token"]}),ee.jsx(yE,{variant:"outline",onClick:()=>t(!1),disabled:p,children:"取消"}),ee.jsx(yE,{onClick:()=>{(async()=>{if(!p){h(!0),RE(_E.skillhubAuthor,s);try{const e=await jC({kind:n,label:r,body:o,description:l.trim()||void 0,author:s.trim()||void 0,tags:u.split(",").map(e=>e.trim()).filter(Boolean)});J_.success(`已提交:Issue #${e.issueNumber}`,{action:{label:"查看",onClick:()=>window.open(e.issueUrl,"_blank","noopener,noreferrer")}}),t(!1)}catch(kR){const t=kR.message;J_.error(t),/invalid|expired|401/.test(t)&&m({configured:!1,needsReset:!0})}finally{h(!1)}}})()},disabled:p,children:p?ee.jsxs(ee.Fragment,{children:[ee.jsx(Vj,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"提交中"]}):ee.jsxs(ee.Fragment,{children:[ee.jsx(Qj,{className:"h-3.5 w-3.5 mr-1.5"}),"直接提交"]})})]})]})]})})}function AT(){const[e,t]=W.useState([]),[n,r]=W.useState(!1),[o,a]=W.useState(""),[s,i]=W.useState(""),[l,c]=W.useState(""),[u,d]=W.useState(null),[p,h]=W.useState(""),[f,m]=W.useState(""),[g,v]=W.useState(""),y=W.useRef(null),b=W.useRef(null),[x,w]=W.useState(null);W.useEffect(()=>{nC().then(t).catch(()=>t([]))},[]),W.useEffect(()=>{n&&setTimeout(()=>{var e;return null==(e=y.current)?void 0:e.focus()},0)},[n]),W.useEffect(()=>{u&&setTimeout(()=>{var e;return null==(e=b.current)?void 0:e.focus()},0)},[u]);const k=async()=>{const e=s.trim();if(e)try{const n=await rC({label:o.trim()||e,command:e,...l?{parentId:l}:{}});t(e=>[...e,n]),a(""),i(""),c(""),r(!1)}catch(kR){console.error("[GlobalShortcuts] Failed to add:",kR)}},S=async()=>{const e=f.trim();if(e&&u)try{const n=await oC(u,{label:p.trim()||e,command:e,parentId:g||null});t(e=>e.map(e=>e.id===u?n:e)),d(null)}catch(kR){console.error("[GlobalShortcuts] Failed to save:",kR)}};return ee.jsxs("section",{className:"mt-10",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-4",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(lP,{className:"h-4 w-4 text-muted-foreground"}),ee.jsx("h2",{className:"text-lg font-semibold",children:"全局快捷 Prompts"}),ee.jsx("span",{className:"text-xs text-muted-foreground",children:"在所有项目的终端中可用"})]}),ee.jsxs("button",{onClick:()=>{r(e=>!e),d(null)},className:XS("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:[ee.jsx(Yj,{className:"h-3.5 w-3.5"}),"新建"]})]}),n&&ee.jsxs("div",{className:"mb-4 p-4 rounded-xl border border-border bg-background space-y-3",children:[ee.jsx("input",{ref:y,placeholder:"名称(可选)",value:o,onChange:e=>a(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"}),ee.jsx("textarea",{placeholder:"命令内容…",value:s,onChange:e=>i(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=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),k()),"Escape"===e.key&&(r(!1),a(""),i(""),c(""))}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Dj,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.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:[ee.jsx("option",{value:"",children:"无继承"}),e.map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex items-center justify-between",children:[ee.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存 · Esc 取消"}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsx("button",{onClick:()=>{r(!1),a(""),i("")},className:"text-sm px-3 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{k()},disabled:!s.trim(),className:XS("text-sm px-3 py-1 rounded transition-colors text-white",s.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]})]}),0!==e.length||n?ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(n=>u===n.id?ee.jsxs("div",{className:"rounded-xl border border-border bg-background p-3 space-y-2",children:[ee.jsx("input",{ref:b,value:p,onChange:e=>h(e.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"}),ee.jsx("textarea",{value:f,onChange:e=>m(e.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:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S()),"Escape"===e.key&&d(null)}}),ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(Dj,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),ee.jsxs("select",{value:g,onChange:e=>v(e.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:[ee.jsx("option",{value:"",children:"无继承"}),e.filter(e=>e.id!==n.id).map(e=>ee.jsx("option",{value:e.id,children:e.label},e.id))]})]}),ee.jsxs("div",{className:"flex gap-2 justify-end",children:[ee.jsx("button",{onClick:()=>d(null),className:"text-xs px-2.5 py-1 rounded bg-secondary hover:bg-accent text-foreground transition-colors",children:"取消"}),ee.jsx("button",{onClick:()=>{S()},disabled:!f.trim(),className:XS("text-xs px-2.5 py-1 rounded transition-colors text-white",f.trim()?"bg-blue-600 hover:bg-blue-500":"bg-secondary opacity-40 cursor-not-allowed"),children:"保存"})]})]},n.id):ee.jsxs("div",{className:"group relative rounded-xl border border-border bg-background hover:border-muted-foreground/30 transition-colors p-3",children:[ee.jsx("div",{className:"text-sm font-medium text-foreground truncate pr-14",children:n.label}),n.parentId&&(()=>{const t=e.find(e=>e.id===n.parentId);return t?ee.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[ee.jsx(Dj,{className:"h-3 w-3 text-muted-foreground"}),ee.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",t.label]})]}):null})(),!n.parentId&&n.label!==n.command&&ee.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-1 pr-14",children:n.command}),ee.jsxs("div",{className:"absolute top-2.5 right-2.5 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[ee.jsx("button",{onClick:()=>w({label:n.label,content:n.command}),className:"p-1 rounded text-muted-foreground hover:text-green-400 transition-colors",title:"共享到 ccweb-hub",children:ee.jsx(Zj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{d(n.id),h(n.label),m(n.command),v(n.parentId||""),r(!1)},className:"p-1 rounded text-muted-foreground hover:text-blue-400 transition-colors",title:"编辑",children:ee.jsx(Kj,{className:"h-3.5 w-3.5"})}),ee.jsx("button",{onClick:()=>{(async e=>{try{await aC(e),t(t=>t.filter(t=>t.id!==e)),u===e&&d(null)}catch(kR){console.error("[GlobalShortcuts] Failed to delete:",kR)}})(n.id)},className:"p-1 rounded text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:ee.jsx(iP,{className:"h-3.5 w-3.5"})})]})]},n.id))}):ee.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-muted-foreground/50 border border-dashed border-border rounded-xl",children:[ee.jsx(lP,{className:"h-6 w-6"}),ee.jsx("p",{className:"text-sm",children:"还没有全局快捷 Prompts"})]}),ee.jsx(DT,{open:!!x,onOpenChange:e=>{e||w(null)},kind:"quick-prompt",label:(null==x?void 0:x.label)??"",content:(null==x?void 0:x.content)??""})]})}const IT=W.createContext({theme:"system",resolved:"dark",setTheme:()=>{}});function FT(){return W.useSyncExternalStore(e=>{const t=window.matchMedia("(prefers-color-scheme: dark)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function zT({children:e}){const[t,n]=W.useState(()=>TE(_E.theme,"system")),r=FT(),o="system"===t?r:t;W.useEffect(()=>{const e=document.documentElement;e.classList.remove("light","dark"),e.classList.add(o)},[o]);return ee.jsx(IT.Provider,{value:{theme:t,resolved:o,setTheme:e=>{n(e),RE(_E.theme,e)}},children:e})}function $T(){return W.useContext(IT)}function VT(){const{theme:e,setTheme:t}=$T(),n=[{value:"light",icon:nP,label:"浅色"},{value:"dark",icon:Gj,label:"深色"},{value:"system",icon:qj,label:"系统"}];return ee.jsx("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:n.map(({value:n,icon:r,label:o})=>ee.jsx("button",{onClick:()=>t(n),className:XS("p-1 rounded-sm transition-colors",e===n?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:o,children:ee.jsx(r,{className:"h-3.5 w-3.5"})},n))})}const UT={workMinutes:30,breakMinutes:5};function BT(){return TE(_E.pomodoroConfig,UT,!0)}const WT=NE(e=>({running:!1,phase:"work",secondsLeft:60*BT().workMinutes,setRunning:t=>e({running:t}),setPhase:t=>e({phase:t}),setSecondsLeft:t=>e({secondsLeft:t})}));function HT(){const{running:e,phase:t,secondsLeft:n,setPhase:r,setSecondsLeft:o}=WT(),a=W.useCallback(e=>{const t=BT();var n;r(e),o("work"===e?60*t.workMinutes:60*t.breakMinutes),n="break"===e?"休息一下 ☕":"该工作了 💻",J_.info(`番茄钟: ${n}`)},[r,o]);return W.useEffect(()=>{if(!e)return;if(0===n)return void a("work"===t?"break":"work");const r=setTimeout(()=>o(n-1),1e3);return()=>clearTimeout(r)},[e,n,t,a,o]),null}function qT(){const{running:e,phase:t,secondsLeft:n}=WT(),r=Math.floor(n/60),o=n%60,a=`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`,s=W.useRef(null),[i,l]=W.useState(()=>"undefined"==typeof window?360:Math.max(40,Math.floor(window.innerWidth/2.9)));return W.useEffect(()=>{if(!e)return;const t=()=>{const e=s.current;if(!e)return;const t=getComputedStyle(e),n=document.createElement("canvas").getContext("2d");if(!n)return;n.font=`${t.fontWeight} 100px ${t.fontFamily}`;const r=n.measureText(a).width;r&&l(Math.max(40,Math.floor(window.innerWidth/r*100)))},n=requestAnimationFrame(t);return window.addEventListener("resize",t),()=>{cancelAnimationFrame(n),window.removeEventListener("resize",t)}},[e,a.length]),e?ld.createPortal(ee.jsxs("div",{className:"fixed inset-0 flex flex-col items-center justify-center pointer-events-none z-40 select-none overflow-hidden",style:{opacity:"work"===t?.1:.6},children:[ee.jsx("div",{ref:s,className:XS("font-mono font-bold tabular-nums leading-none","work"===t?"text-foreground":"text-blue-400 dark:text-blue-300"),style:{fontSize:`${i}px`},children:a}),ee.jsx("div",{className:"mt-3 text-muted-foreground font-medium tracking-widest uppercase",style:{fontSize:"clamp(12px, 1.5vw, 20px)"},children:"work"===t?"专注工作":"休息一下"})]}),document.body):null}function GT(){const{running:e,phase:t,secondsLeft:n,setRunning:r,setPhase:o,setSecondsLeft:a}=WT(),s=Math.floor(n/60),i=n%60,l=`${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}`;return ee.jsx("button",{onClick:()=>{if(e){const e=BT();o("work"),a(60*e.workMinutes)}else{const e=BT();o("work"),a(60*e.workMinutes)}r(!e)},className:XS("p-1 rounded transition-colors",e?"work"===t?"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?"work"===t?`工作中 ${l} — 点击停止`:`休息中 ${l} — 点击停止`:"启动番茄钟",children:ee.jsx(oP,{className:"h-4 w-4"})})}const KT="v2026.4.27-f",YT=!!window.electronUpdater;function XT(){const[e,t]=W.useState("idle"),[n,r]=W.useState(!1),[o,a]=W.useState(""),[s,i]=W.useState(0),[l,c]=W.useState(null),[u,d]=W.useState(null);W.useEffect(()=>{if(!window.electronUpdater)return;return window.electronUpdater.onUpdateStatus(e=>{switch(e.type){case"progress":{const t=e.info;i(Math.round((null==t?void 0:t.percent)??0));break}case"downloaded":t("downloaded");break;case"error":c(e.info||"Download failed"),t("error")}})},[]);const p=W.useCallback(async()=>{t("checking"),c(null),r(!0);try{if(YT){const e=await window.electronUpdater.checkForUpdate();if(e.error)throw new Error(e.error);if(!e.available)return void t("no_update");a(e.version?`v${e.version}`:"new version")}else{const e=await AC();if(!e.updateAvailable)return void t("no_update");a(`v${e.latest}`)}t("update_available")}catch(kR){c(kR instanceof Error?kR.message:"Check failed"),t("error")}},[]),h=W.useCallback(()=>{const e=3e3,n=Date.now(),r=()=>{if(Date.now()-n>3e5)return c("更新超时(5 分钟)— 请检查服务器状态"),void t("update_failed");FC().then(n=>{n?n.success?(a(n.newVersion?`v${n.newVersion}`:"new version"),t("update_complete")):(c(n.error||"Update failed"),t("update_failed")):setTimeout(r,e)}).catch(()=>{setTimeout(r,e)})};setTimeout(r,e)},[]),f=()=>{r(!1),setTimeout(()=>{t("idle"),a(""),c(null),i(0),d(null)},200)};return ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{p()},disabled:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e,title:"检查更新",children:"checking"===e||"downloading"===e||"executing"===e||"reconnecting"===e?ee.jsx(Vj,{className:"h-4 w-4 animate-spin"}):ee.jsx(Nj,{className:"h-4 w-4"})}),ee.jsx(L_,{open:n,onOpenChange:e=>{e||f()},children:ee.jsxs(D_,{className:"sm:max-w-md",children:[ee.jsxs(A_,{children:[ee.jsxs(F_,{children:["checking"===e&&"Checking for updates...","no_update"===e&&"Up to date","update_available"===e&&`Update ${o} available`,"downloading"===e&&"Downloading update...","downloaded"===e&&"Update ready to install","executing"===e&&"Updating server...","reconnecting"===e&&"Waiting for server restart...","update_complete"===e&&`Updated to ${o}`,"update_failed"===e&&"Update failed","error"===e&&"Update error"]}),ee.jsxs(z_,{children:["checking"===e&&"Checking for the latest version...","no_update"===e&&`Current version ${KT} is the latest.`,"update_available"===e&&"A new version is available. "+(YT?"Click download to update automatically.":""),"downloading"===e&&`Downloading... ${s}%`,"downloaded"===e&&"The update has been downloaded. Click install to restart and apply.","executing"===e&&"Server is shutting down and installing the update. Please wait...","reconnecting"===e&&"Update installed. Waiting for server to restart...","update_complete"===e&&`Successfully updated from ${KT} to ${o}. Click reload to use the new version.`,"update_failed"===e&&(l||"Update failed. You may need to restart the server manually."),"error"===e&&(l||"An error occurred.")]})]}),"downloading"===e&&ee.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:ee.jsx("div",{className:"bg-primary h-full transition-all duration-300",style:{width:`${s}%`}})}),("executing"===e||"reconnecting"===e)&&ee.jsx("div",{className:"flex items-center justify-center py-6",children:ee.jsx(Vj,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),ee.jsxs(I_,{children:["no_update"===e&&ee.jsx(yE,{onClick:f,children:"OK"}),"update_available"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"outline",onClick:f,children:"Later"}),ee.jsx(yE,{onClick:()=>{(async()=>{if(YT){t("downloading"),i(0);const e=await window.electronUpdater.downloadUpdate();e.success?e.path&&d(e.path):(c(e.error||"Download failed"),t("error"))}else{t("executing");try{await IC(),t("reconnecting"),h()}catch(kR){c(kR instanceof Error?kR.message:"Execute failed"),t("error")}}})()},children:YT?"Download & Install":`Update to ${o}`})]}),"downloaded"===e&&ee.jsxs(ee.Fragment,{children:[ee.jsx(yE,{variant:"outline",onClick:f,children:"Later"}),ee.jsx(yE,{onClick:()=>{var e;null==(e=window.electronUpdater)||e.quitAndInstall(u||void 0)},children:"Restart & Install"})]}),"update_complete"===e&&ee.jsx(yE,{onClick:()=>window.location.reload(),children:"Reload Page"}),"update_failed"===e&&ee.jsx(yE,{onClick:f,children:"Close"}),"error"===e&&ee.jsx(yE,{onClick:f,children:"Close"})]})]})})]})}function QT(e){return e.map(e=>"text"===e.type?e.content:`\n\`\`\`${e.type}\n${e.content}\n\`\`\`\n`).join("")}function JT(e){return"[200~"+e.replace(/\x1b\[20[01]~/g,"").replace(/\n/g,"\r")+"[201~\r"}function ZT(e,t){return{id:e.id??t(),role:e.role,content:QT(e.blocks),blocks:e.blocks,ts:e.timestamp}}const eR=3e4;function tR({project:e,liveMessages:t,ws:n,historyLimit:r=20,liveWindow:o=50,historyEnabled:a=!0}){const s=e.id,[i,l]=W.useState("running"===e.status?"live":"stopped"),{history:c,hasMore:u,reload:d,loadMore:p}=function({projectId:e,historyLimit:t=20,enabled:n=!0}){const[r,o]=W.useState([]),[a,s]=W.useState(!1),[i,l]=W.useState(!1),c=W.useRef(0),u=W.useCallback(()=>"h"+ ++c.current,[]),d=W.useRef({projectId:e,enabled:n});d.current={projectId:e,enabled:n};const p=W.useCallback(async()=>{if(!d.current.enabled)return;const e=d.current.projectId;l(!0);try{const n=await YC(e,{limit:t});if(d.current.projectId!==e)return;const r=[];for(const e of n.blocks){const t=ZT(e,u);t.content.trim()&&r.push(t)}o(r),s(n.hasMore)}catch{}finally{l(!1)}},[t,u]),h=W.useCallback(async()=>{if(!a||i||0===r.length)return;if(!d.current.enabled)return;const e=d.current.projectId,n=r[0];if(n.id&&!n.id.startsWith("h")){l(!0);try{const r=await YC(e,{limit:t,before:n.id});if(d.current.projectId!==e)return;const a=[];for(const e of r.blocks){const t=ZT(e,u);t.content.trim()&&a.push(t)}o(e=>[...a,...e]),s(r.hasMore)}catch{}finally{l(!1)}}},[t,a,i,r,u]);return W.useEffect(()=>{n&&p()},[e,n]),{history:r,hasMore:a,isLoading:i,reload:p,loadMore:h}}({projectId:s,historyLimit:r,enabled:a}),[h,f]=W.useState([]),m=W.useRef(0),g=W.useCallback(()=>"m"+ ++m.current,[]),v=W.useRef([]),y=W.useRef(0),b=W.useCallback(()=>"p"+ ++y.current,[]),x=W.useRef(!1),w=W.useRef(0);W.useEffect(()=>{if(t.length<w.current&&(w.current=0),t.length<=w.current)return;const e=t.slice(w.current);w.current=t.length;for(const t of e){x.current=!0;const e=QT(t.blocks);if(e.trim()){if("user"===t.role){const n=e.trim(),r=v.current.findIndex(e=>"sent"===e.status&&e.text.trim()===n);if(-1!==r){const e=v.current[r];if(v.current.splice(r,1),e.timer&&(clearTimeout(e.timer),e.timer=null),e.displayId&&t.id){const n=t.id;f(t=>t.map(t=>t.id===e.displayId?{...t,id:n}:t))}e.resolve("delivered");continue}}f(n=>{if(t.id&&n.some(e=>e.id===t.id))return n;const r={id:t.id??g(),role:t.role,content:e,blocks:t.blocks,ts:t.timestamp};return[...n,r].slice(-o)})}}},[t,g,o]),W.useEffect(()=>{if("live"!==i)return void(x.current=!1);const e=setTimeout(()=>{x.current||d()},3e3);return()=>clearTimeout(e)},[i,d]),W.useEffect(()=>{"running"!==e.status||"stopped"!==i&&"error"!==i?"stopped"===e.status&&"live"===i&&l("stopped"):(f([]),l("live"))},[e.status]);const k=W.useRef(null),S=W.useRef(0),E=W.useCallback(e=>{e&&f(t=>t.filter(t=>t.id!==e))},[]),C=W.useCallback(()=>{const e=v.current;v.current=[];for(const t of e)t.timer&&(clearTimeout(t.timer),t.timer=null),"sent"===t.status&&E(t.displayId),t.resolve("failed")},[E]),j=W.useCallback(e=>{const t=g();e.displayId=t,e.status="sent",f(n=>[...n,{id:t,role:"user",content:e.text,ts:(new Date).toISOString()}].slice(-o)),n.send(e.isSlashCommand?e.text.replace(/\n/g,"\r")+"\r":JT(e.text))},[n,g,o]);W.useEffect(()=>{if(!n.connected)return;if("live"!==i)return;const e=v.current.filter(e=>"queued"===e.status);if(0!==e.length)for(const t of e)if(j(t),t.isSlashCommand){const e=v.current.indexOf(t);-1!==e&&v.current.splice(e,1),t.timer&&(clearTimeout(t.timer),t.timer=null),t.resolve("delivered")}},[n.connected,i,j]),W.useEffect(()=>()=>{k.current&&clearTimeout(k.current);for(const e of v.current)e.timer&&(clearTimeout(e.timer),e.timer=null),e.resolve("failed");v.current=[]},[]);const P=W.useCallback(e=>new Promise(t=>{const r=e.trimStart().startsWith("/");if(v.current.length>=20){const e=v.current.shift();e&&(e.timer&&clearTimeout(e.timer),"sent"===e.status&&E(e.displayId),e.resolve("failed"))}const o={id:b(),text:e,isSlashCommand:r,status:"queued",resolve:t,timer:null};if(v.current.push(o),r){if("live"===i&&n.connected){j(o);const e=v.current.indexOf(o);return-1!==e&&v.current.splice(e,1),void t("delivered")}o.timer=setTimeout(()=>{const e=v.current.indexOf(o);-1!==e&&v.current.splice(e,1),o.timer=null,"sent"===o.status&&E(o.displayId),t("failed")},eR)}else o.timer=setTimeout(()=>{const e=v.current.indexOf(o);-1!==e&&v.current.splice(e,1),o.timer=null,"sent"===o.status&&E(o.displayId),t("failed")},eR);if("live"===i&&n.connected)j(o);else if("waking"===i||"live"===i);else{const e=++S.current;l("waking"),JE(s).then(()=>{e===S.current&&(k.current&&clearTimeout(k.current),l("live"))}).catch(t=>{e===S.current&&(J_.error(`启动失败: ${t instanceof Error?t.message:String(t)}`),l("error"),C())}),k.current=setTimeout(()=>{e===S.current&&v.current.some(e=>"queued"===e.status)&&(J_.error("启动超时(10s)"),l("error"),C())},1e4)}}),[i,n,s,j,C,E,b]),N=W.useCallback(e=>{const t=e.replace(/\r$/,"").trim();if(!t)return;const n=g();f(e=>[...e,{id:n,role:"user",content:t,ts:(new Date).toISOString()}].slice(-o));const r={id:b(),text:t,isSlashCommand:!1,status:"sent",displayId:n,resolve:()=>{},timer:setTimeout(()=>{const e=v.current.indexOf(r);-1!==e&&v.current.splice(e,1),r.timer=null},eR)};v.current.push(r)},[g,b,o]),_=W.useMemo(()=>{const e=new Set;for(const t of h)t.id&&e.add(t.id);return[...c.filter(t=>!t.id||!e.has(t.id)),...h]},[c,h]);return{state:i,setState:l,messages:_,historyMessages:c,displayMessages:h,setDisplayMessages:f,hasMoreHistory:u,loadMoreHistory:p,reloadHistory:d,liveReceivedRef:x,sendMessage:P,appendUserMessage:N,isWaking:"waking"===i,isRunning:"live"===i}}function nR(e,t,n){const r=W.useRef(!0),o=W.useRef(0),a=W.useCallback(()=>{const t=e.current;t&&(t.scrollHeight<=t.clientHeight||(o.current=performance.now(),t.scrollTop=t.scrollHeight))},[e]);return W.useEffect(()=>{const t=e.current;t&&(t.style.overflowAnchor="none")},[e]),W.useEffect(()=>{const t=e.current;if(!t)return;const n=()=>{if(performance.now()-o.current<80)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<80;r.current=e};return t.addEventListener("scroll",n,{passive:!0}),()=>t.removeEventListener("scroll",n)},[e]),W.useLayoutEffect(()=>{r.current&&a()},[a,...n]),W.useEffect(()=>{const e=t.current;if(!e)return;const n=new ResizeObserver(()=>{r.current&&a()});return n.observe(e),()=>n.disconnect()},[t,a]),{pinnedRef:r,scrollToBottom:a}}const rR=H.memo(function({project:e,externalStatus:t,active:n=!1}){const r=cp(),[o,a]=W.useState(""),[s,i]=W.useState(!1),l=W.useRef(null),c=W.useRef(null),[u,d]=W.useState([]),p=W.useRef(0),h=W.useCallback(e=>{d(t=>{const n=[...t,e];return n.length>200?n.slice(-200):n}),"assistant"===e.role&&(i(!0),setTimeout(()=>i(!1),1e3))},[]),f=W.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),{sendInput:m,connected:g}=CT({projectId:e.id,enabled:!0,onChatMessage:h,onStatusChange:f}),{state:v,setState:y,messages:b,sendMessage:x,isRunning:w,isWaking:k}=tR({project:e,liveMessages:u,ws:{send:m,connected:g},historyLimit:4,liveWindow:4}),S=W.useRef(y);S.current=y,W.useEffect(()=>{"stopped"===v&&(d([]),p.current=0)},[v]),W.useEffect(()=>{t&&("running"!==t||"stopped"!==v&&"error"!==v?"stopped"===t&&"live"===v&&y("stopped"):(d([]),y("live")))},[t]),nR(l,c,[b]);const[E,C]=W.useState(!1),j=mT(W.useCallback(async()=>{const e=o.trim();if(!e||E)return;C(!0);const t=await x(e);C(!1),"delivered"===t&&a("")},[o,E,x]),"enter"),P="stopped"===v,N=b.slice(-4),_=ee.jsxs("div",{className:XS("flex flex-col h-full rounded-xl overflow-hidden bg-background transition-colors duration-300",n?"border-transparent bg-transparent shadow-none":s?"border border-blue-500":"border border-border","error"===v&&"border border-red-500/50"),children:[ee.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 border-b border-border bg-muted/30 transition-colors",children:[ee.jsx(Ij,{className:"h-3.5 w-3.5 text-muted-foreground/40 flex-shrink-0 cursor-grab active:cursor-grabbing"}),ee.jsx("span",{className:"font-medium text-sm truncate flex-1 cursor-pointer hover:text-blue-400 transition-colors",onClick:()=>r(`/projects/${e.id}`),title:"打开项目详情",children:e.name}),ee.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.cliTool??"claude"}),ee.jsx("span",{className:XS("w-2 h-2 rounded-full flex-shrink-0",w?"bg-green-500":k?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),ee.jsx("div",{ref:l,className:"flex-1 overflow-y-auto min-h-0 text-xs",children:ee.jsxs("div",{ref:c,className:"p-2 space-y-2 min-h-full",children:[N.map(e=>{const t="user"===e.role;return ee.jsx("div",{className:XS("flex",t?"justify-end":"justify-start"),children:ee.jsx("div",{className:XS("max-w-[85%] rounded-2xl px-2.5 py-1.5 whitespace-pre-wrap break-words leading-relaxed",t?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm dark:bg-blue-500/20 dark:border-blue-500/25":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:ee.jsx("div",{className:"line-clamp-6",children:e.content})})},e.id)}),P&&0===N.length&&ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-xs",children:"无对话记录"}),k&&ee.jsx("div",{className:"flex items-center justify-center h-full text-yellow-400 text-xs animate-pulse",children:"启动中..."})]})}),ee.jsx("div",{className:"border-t border-border p-1.5",children:ee.jsx("input",{type:"text",value:o,onChange:e=>a(e.target.value),onKeyDown:j,disabled:k||E,placeholder:k?"启动中...":E?"发送中…":P?"输入命令(自动启动)... Shift+⏎":"输入命令... Shift+⏎",className:XS("w-full bg-transparent text-xs font-mono outline-none placeholder:text-muted-foreground/40 px-1.5 py-1",(k||E)&&"opacity-50 cursor-not-allowed")})})]});return n?ee.jsx("div",{className:"card-active-glow rounded-xl h-full",children:_}):_});function oR({projects:e,projectStatuses:t,activeProjectIds:n}){const r=W.useMemo(()=>e.filter(e=>!e.archived),[e]),{order:o,setOrder:a,applyOrder:s}=_T(),[i,l]=W.useState(null),[c,u]=W.useState(null),d=W.useRef(null),p=W.useMemo(()=>s(r),[r,s]),h=W.useCallback((e,t)=>{l(t),e.dataTransfer.effectAllowed="move";const n=document.createElement("div");n.style.width="1px",n.style.height="1px",n.style.opacity="0.01",document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),d.current=n},[]),f=W.useCallback((e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",u(t)},[]),m=W.useCallback((e,t)=>{if(e.preventDefault(),!i||i===t)return l(null),void u(null);const n=p.map(e=>e.id),r=o.length?[...o]:n;for(const o of n)r.includes(o)||r.push(o);const s=r.indexOf(i),c=r.indexOf(t);if(-1===s||-1===c)return l(null),void u(null);r.splice(s,1),r.splice(c,0,i),a(r),l(null),u(null)},[i,p,o,a]),g=W.useCallback(()=>{l(null),u(null),d.current&&(d.current.remove(),d.current=null)},[]),{cols:v,rows:y}=(b=p.length)<=1?{cols:1,rows:1}:b<=2?{cols:2,rows:1}:b<=4?{cols:2,rows:2}:b<=6?{cols:3,rows:2}:b<=9?{cols:3,rows:3}:b<=12?{cols:4,rows:3}:{cols:4,rows:Math.ceil(b/4)};var b;if(0===p.length)return ee.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/50 text-sm",children:"没有活跃项目"});const x=y<=3;return ee.jsx("div",{className:"h-full w-full p-2 gap-2 overflow-y-auto",style:{display:"grid",gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`,gridAutoRows:x?`minmax(180px, min(${Math.floor(100/y)}vh, 350px))`:"280px"},children:p.map(e=>ee.jsx("div",{draggable:!0,onDragStart:t=>h(t,e.id),onDragOver:t=>f(t,e.id),onDrop:t=>m(t,e.id),onDragEnd:g,className:XS("transition-all duration-200",i===e.id&&"opacity-40 scale-95",c===e.id&&i!==e.id&&"ring-2 ring-ring/50 rounded-xl"),children:ee.jsx(rR,{project:e,externalStatus:t.get(e.id),active:n.has(e.id)})},e.id))})}function aR(){const{t:e}=Yh(),t=cp(),{projects:n,loading:r,error:o,hasFetched:a,fetchProjects:s,addProject:i,updateProject:l,removeProject:c}=AE(),u=OE(e=>e.clearToken),[d,p]=W.useState(!1),[h,f]=W.useState(!1),[m,g]=W.useState(new Set),v=W.useRef(new Map),[y,b]=W.useState(new Map),x=W.useRef(0),[w,k]=W.useState(!!document.fullscreenElement),[S,E]=W.useState(!1),[C,j]=ME(_E.monitorMode,!1,{parse:!0}),[P,N]=W.useState(new Map);W.useEffect(()=>{const e=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),W.useEffect(()=>{s()},[s]);ST({onActivityUpdate:W.useCallback(e=>{if(e.status){const t=AE.getState().projects.find(t=>t.id===e.projectId);t&&t.status!==e.status&&l({...t,status:e.status}),N(t=>{const n=new Map(t);return n.set(e.projectId,e.status),n})}const t=Date.now(),n=v.current;if(e.active){g(t=>t.has(e.projectId)?t:new Set(t).add(e.projectId));const r=n.get(e.projectId)??[];let o=!1;if(e.semantic){const n=r[r.length-1];`${e.semantic.phase}:${e.semantic.detail??""}`!==(n?`${n.phase}:${n.detail??""}`:"")?(r.push({id:x.current++,phase:e.semantic.phase,detail:e.semantic.detail,ts:t}),o=!0):n&&(n.ts=t)}const a=r.filter(e=>t-e.ts<8e3),s=a.length>3?a.slice(-3):a;s.length!==r.length&&(o=!0),n.set(e.projectId,s),o&&b(new Map(n))}else g(t=>{if(!t.has(e.projectId))return t;const n=new Set(t);return n.delete(e.projectId),n}),n.has(e.projectId)&&n.get(e.projectId).length>0&&(n.set(e.projectId,[]),b(new Map(n)))},[l])}),W.useEffect(()=>{const e=setInterval(()=>{const e=Date.now(),t=v.current;let n=!1;for(const[r,o]of t){const a=o.filter(t=>e-t.ts<8e3);a.length!==o.length&&(t.set(r,a),n=!0)}n&&b(new Map(t)),g(e=>{let n=!1;const r=new Set(e);for(const o of e){const e=t.get(o);e&&0!==e.length||(r.delete(o),n=!0)}return n?r:e})},3e3);return()=>clearInterval(e)},[]);const _=W.useMemo(()=>n.filter(e=>!e.archived),[n]),T=W.useMemo(()=>n.filter(e=>e.archived),[n]),R=W.useMemo(()=>Array.from(new Set(n.flatMap(e=>e.tags??[]))),[n]),[L,M]=W.useState([]),O=W.useMemo(()=>0===L.length?_:_.filter(e=>L.some(t=>{var n;return null==(n=e.tags)?void 0:n.includes(t)})),[_,L]),[D,A]=W.useState(!1),I=W.useCallback(async()=>{if(!D){A(!0);try{const t=await mj(),n=t.results.filter(e=>e.ok).length,r=t.results.filter(e=>e.skipped).length,o=t.total-n-r;J_.success(e("dashboard.sync_done_toast",{ok:n,skipped:r,failed:o}))}catch(kR){J_.error(e("dashboard.sync_failed_toast",{message:kR.message}))}finally{A(!1)}}},[D]),{order:F,setOrder:z,applyOrder:$}=_T(),[V,U]=W.useState(null),[B,H]=W.useState(null),q=W.useMemo(()=>$(O),[O,$]),G=W.useCallback(e=>U(e),[]),K=W.useCallback(()=>{U(null),H(null)},[]),Y=W.useCallback((e,t)=>{e.preventDefault(),H(t)},[]),X=W.useCallback((e,t,n)=>{if(e.preventDefault(),!n||n===t)return void H(null);const r=q.map(e=>e.id),o=F.length?[...F]:r;for(const i of r)o.includes(i)||o.push(i);const a=o.indexOf(n),s=o.indexOf(t);if(-1===a||-1===s)return U(null),void H(null);o.splice(a,1),o.splice(s,0,n),z(o),U(null),H(null)},[q,F,z]),Q={onDelete:e=>{(async e=>{try{await QE(e),c(e)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to delete project")}})(e)},onArchive:e=>{(async e=>{try{const t=await ZE(e);l(t)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to archive project")}})(e)},onUnarchive:e=>{(async e=>{try{const t=await tC(e);l(t)}catch(kR){J_.error(kR instanceof Error?kR.message:"Failed to restore project")}})(e)},onUpdated:l};return ee.jsxs("div",{className:"min-h-screen bg-background",children:[ee.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:ee.jsxs("div",{className:"max-w-6xl mx-auto px-4 h-14 flex items-center justify-between",children:[ee.jsxs("div",{className:"flex items-center gap-2",children:[ee.jsx(rP,{className:"h-5 w-5"}),ee.jsxs("div",{children:[ee.jsx("span",{className:"font-semibold text-lg leading-tight block",children:"CC Web"}),ee.jsx("span",{className:"text-[10px] text-muted-foreground leading-none",children:KT})]})]}),ee.jsx(OT,{}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/skillhub"),title:e("dashboard.skillhub_title"),children:ee.jsx(tP,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/mobile"),title:e("dashboard.mobile_title"),children:ee.jsx(eP,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>t("/settings"),title:e("dashboard.settings_title"),children:ee.jsx(Jj,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>j(!C),title:e(C?"dashboard.monitor_title_grid":"dashboard.monitor_title_monitor"),className:XS(C&&"bg-accent font-medium"),children:C?ee.jsx($j,{className:"h-4 w-4"}):ee.jsx(qj,{className:"h-4 w-4"})}),ee.jsx(yE,{variant:"ghost",size:"sm",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:e(w?"dashboard.fullscreen_exit":"dashboard.fullscreen_enter"),children:w?ee.jsx(Wj,{className:"h-4 w-4"}):ee.jsx(Bj,{className:"h-4 w-4"})}),ee.jsx(XT,{}),ee.jsx(GT,{}),ee.jsx(VT,{}),ee.jsxs(yE,{variant:"ghost",size:"sm",onClick:()=>{u(),t("/login")},children:[ee.jsx(Uj,{className:"h-4 w-4 mr-2"}),e("dashboard.logout")]})]})}),C&&ee.jsx("div",{className:"flex-1 min-h-0",children:ee.jsx(oR,{projects:n,projectStatuses:P,activeProjectIds:m})}),!C&&ee.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[ee.jsxs("div",{className:"flex items-center justify-between mb-6",children:[ee.jsxs("div",{children:[ee.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Projects"}),ee.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Each project runs Claude CLI in a dedicated terminal session."})]}),ee.jsxs("div",{className:"flex gap-2",children:[ee.jsxs(yE,{variant:"outline",onClick:()=>{I()},disabled:D,title:e("dashboard.sync_all_title"),children:[D?ee.jsx(Vj,{className:"h-4 w-4 mr-2 animate-spin"}):ee.jsx(Mj,{className:"h-4 w-4 mr-2"}),e("dashboard.sync_all")]}),ee.jsxs(yE,{variant:"outline",onClick:()=>f(!0),children:[ee.jsx(Rj,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(yE,{onClick:()=>p(!0),children:[ee.jsx(Yj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),r&&!a&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:Array.from({length:3}).map((e,t)=>ee.jsx(cP,{className:"h-32 rounded-xl"},t))}),o&&ee.jsx("div",{className:"text-center text-destructive py-12",children:o}),a&&!r&&!o&&0===n.length&&ee.jsxs("div",{className:"text-center py-20",children:[ee.jsx(rP,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),ee.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No projects yet"}),ee.jsx("p",{className:"text-muted-foreground text-sm mb-6",children:"Create a new project or open an existing one."}),ee.jsxs("div",{className:"flex gap-2 justify-center",children:[ee.jsxs(yE,{variant:"outline",onClick:()=>f(!0),children:[ee.jsx(Rj,{className:"h-4 w-4 mr-2"}),"Open Project"]}),ee.jsxs(yE,{onClick:()=>p(!0),children:[ee.jsx(Yj,{className:"h-4 w-4 mr-2"}),"New Project"]})]})]}),!r&&!o&&R.length>0&&ee.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[R.map(e=>ee.jsxs("button",{onClick:()=>M(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:XS("px-2 py-0.5 rounded-full text-xs border transition-colors",L.includes(e)?"bg-primary text-primary-foreground border-transparent font-medium":"bg-muted text-muted-foreground border-border hover:border-muted-foreground/40"),children:["#",e]},e)),L.length>0&&ee.jsx("button",{onClick:()=>M([]),className:"px-2 py-0.5 rounded-full text-xs text-muted-foreground hover:text-foreground transition-colors",children:e("dashboard.tags_clear")})]}),!r&&!o&&q.length>0&&ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:q.map((e,t)=>ee.jsx(tS.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{...bj.slow,delay:Math.min(.05*t,.3),ease:"easeOut"},draggable:!0,onDragStart:()=>G(e.id),onDragOver:t=>Y(t,e.id),onDrop:t=>X(t,e.id,V),onDragEnd:K,style:{opacity:V===e.id?.4:1,cursor:"grab"},className:XS(B===e.id&&V!==e.id&&"ring-2 ring-ring/50 rounded-xl"),children:ee.jsx(hT,{project:e,active:m.has(e.id),statusStack:y.get(e.id)??[],...Q})},e.id))}),!r&&!o&&T.length>0&&ee.jsxs("div",{className:"mt-10",children:[ee.jsxs("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4 group",onClick:()=>E(e=>!e),children:[ee.jsx(tS.span,{animate:{rotate:S?90:0},transition:bj.default,children:ee.jsx(Pj,{className:"h-4 w-4"})}),ee.jsx("span",{className:"font-medium",children:"Archived"}),ee.jsx("span",{className:"text-xs bg-muted rounded-full px-2 py-0.5",children:T.length})]}),ee.jsx(Iw,{children:S&&ee.jsx(tS.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:bj.slow,className:"overflow-hidden",children:ee.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4",children:T.map(e=>ee.jsx(hT,{project:e,active:!1,...Q},e.id))})})})]}),ee.jsx(AT,{})]}),ee.jsx(yT,{open:d,onOpenChange:p,onCreated:e=>{i(e)}}),ee.jsx(bT,{open:h,onOpenChange:f,onOpened:e=>{i(e)}})]})}class sR extends H.Component{constructor(){super(...arguments),t(this,"state",{hasError:!1,error:null}),t(this,"handleReset",()=>{var e,t;this.setState({hasError:!1,error:null}),null==(t=(e=this.props).onReset)||t.call(e)})}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[ErrorBoundary]",e,t.componentStack),J_.error(e.message||"Something went wrong")}render(){return this.state.hasError?this.props.fallback?this.props.fallback:ee.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4 text-sm text-muted-foreground",children:[ee.jsx("p",{children:"出错了"}),ee.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 iR({plugin:e,onConfigChange:t,onClose:n}){const{float:r,userConfig:o}=e,[a,s]=W.useState(()=>{var e,t;return{x:(null==(e=o.floatPosition)?void 0:e.x)??.5*window.innerWidth-r.defaultWidth/2,y:(null==(t=o.floatPosition)?void 0:t.y)??.3*window.innerHeight}}),[i,l]=W.useState(()=>{var e,t;return{w:(null==(e=o.floatSize)?void 0:e.w)??r.defaultWidth,h:(null==(t=o.floatSize)?void 0:t.h)??r.defaultHeight}}),[c,u]=W.useState(!1),[d,p]=W.useState(100),h=W.useRef(null),f=W.useRef(null),[m,g]=W.useState(null),v=W.useRef(null);W.useEffect(()=>{v.current=m},[m]),W.useEffect(()=>{let t=!1,n=null;const r=async(o=0)=>{try{const n=zE(),r={"Content-Type":"application/json"};n&&(r.Authorization=`Bearer ${n}`);const o=await fetch(`/api/plugins/${e.id}/session`,{method:"POST",headers:r});if(!o.ok)throw new Error(`status ${o.status}`);const{token:a}=await o.json();t||g(a)}catch(kR){if(t)return;const s=Math.min(3e4,1e3*2**o);console.warn(`[plugin ${e.id}] session token fetch failed (${String(kR)}); retrying in ${s}ms`),n=window.setTimeout(()=>{r(o+1)},s)}};r();const o=window.setInterval(()=>{r()},63e5);return()=>{t=!0,window.clearInterval(o),null!==n&&window.clearTimeout(n)}},[e.id]);const y=W.useCallback(()=>{p(Date.now()%1e5+100)},[]),b=W.useRef(null),x=W.useCallback(n=>{n.preventDefault(),y(),b.current={sx:n.clientX,sy:n.clientY,ox:a.x,oy:a.y},f.current&&(f.current.style.pointerEvents="none");const r=e=>{if(!b.current)return;const t=Math.max(0,Math.min(window.innerWidth-100,b.current.ox+e.clientX-b.current.sx)),n=Math.max(0,Math.min(window.innerHeight-40,b.current.oy+e.clientY-b.current.sy));h.current&&(h.current.style.left=t+"px",h.current.style.top=n+"px")},o=n=>{if(!b.current)return;const a=Math.max(0,Math.min(window.innerWidth-100,b.current.ox+n.clientX-b.current.sx)),i=Math.max(0,Math.min(window.innerHeight-40,b.current.oy+n.clientY-b.current.sy));b.current=null,f.current&&(f.current.style.pointerEvents=""),s({x:a,y:i}),t(e.id,{floatPosition:{x:a,y:i}}),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)},[a,y,e.id,t]),w=W.useRef(null),k=W.useCallback(n=>{if(!r.resizable)return;n.preventDefault(),n.stopPropagation(),y(),w.current={sx:n.clientX,sy:n.clientY,ow:i.w,oh:i.h},f.current&&(f.current.style.pointerEvents="none");const o=r.minWidth??150,a=r.minHeight??100,s=e=>{if(!w.current)return;const t=Math.max(o,w.current.ow+e.clientX-w.current.sx),n=Math.max(a,w.current.oh+e.clientY-w.current.sy);h.current&&(h.current.style.width=t+"px",h.current.style.height=n+"px")},c=n=>{if(!w.current)return;const r=Math.max(o,w.current.ow+n.clientX-w.current.sx),i=Math.max(a,w.current.oh+n.clientY-w.current.sy);w.current=null,f.current&&(f.current.style.pointerEvents=""),l({w:r,h:i}),t(e.id,{floatSize:{w:r,h:i}}),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",c)};window.addEventListener("mousemove",s),window.addEventListener("mouseup",c)},[i,r,y,e.id,t]);W.useEffect(()=>{const t=async t=>{var n,r,o,a,s;if(t.source!==(null==(n=f.current)?void 0:n.contentWindow))return;const{callId:i,method:l,args:c}=t.data;if(i&&l)try{const t=zE(),n=v.current,a={"Content-Type":"application/json"};let s,u;if(n&&(a["X-Plugin-Session"]=n),t&&(a.Authorization=`Bearer ${t}`),"storage:get"===l)s=`/api/plugin-bridge/storage/${e.id}`,u={method:"GET",headers:a};else if("storage:set"===l)s=`/api/plugin-bridge/storage/${e.id}`,u={method:"PUT",headers:a,body:JSON.stringify(c)};else{const t={"project:status":{path:`/api/plugin-bridge/project/status/${c.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/${c.projectId}`,httpMethod:"GET"},"system:info":{path:"/api/plugin-bridge/system/info",httpMethod:"GET"}};if("backend:api"===l){const{method:t,path:n,body:r}=c;if(!n||!n.startsWith("/")||n.includes(".."))throw new Error("Invalid API path");s=`/api/plugins/${e.id}${n}`,u={method:t||"GET",headers:a},!r||"POST"!==t&&"PUT"!==t||(u.body=JSON.stringify(r))}else{const e=t[l];if(!e)throw new Error(`Unknown method: ${l}`);s=e.path,u={method:e.httpMethod,headers:a},"POST"===e.httpMethod&&(u.body=JSON.stringify(c))}}const d=await fetch(s,u),p=await d.json();null==(o=null==(r=f.current)?void 0:r.contentWindow)||o.postMessage({callId:i,result:p,error:null},window.location.origin)}catch(kR){const t=kR instanceof Error?kR.message:"Bridge error";null==(s=null==(a=f.current)?void 0:a.contentWindow)||s.postMessage({callId:i,result:null,error:t},window.location.origin)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e.id]);const S=o.clickable??r.clickable.default,E=`/plugins/${e.id}/${e.float?"index.html":""}`;return ee.jsxs(tS.div,{ref:h,className:XS("fixed rounded-xl border border-border shadow-sm overflow-hidden flex flex-col","bg-background/95 backdrop-blur-sm"),style:{left:a.x,top:a.y,width:c?200:i.w,height:c?32:i.h,zIndex:d},initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15},onMouseDown:y,children:[ee.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:x,children:[ee.jsx(Aj,{className:"h-3 w-3 text-muted-foreground/40 flex-shrink-0"}),ee.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.name}),ee.jsx("button",{onClick:()=>u(e=>!e),className:"p-0.5 rounded-md hover:bg-accent text-muted-foreground/60 hover:text-foreground transition-colors",children:ee.jsx(Hj,{className:"h-3 w-3"})}),ee.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:ee.jsx(iP,{className:"h-3 w-3"})})]}),!c&&ee.jsxs("div",{className:"flex-1 min-h-0 relative",children:[m?ee.jsx("iframe",{ref:f,src:E,sandbox:"allow-scripts allow-same-origin",className:"w-full h-full border-0",style:{pointerEvents:S?"auto":"none"}}):ee.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-muted-foreground",children:"Loading…"}),r.resizable&&ee.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize",onMouseDown:k,children:ee.jsxs("svg",{viewBox:"0 0 12 12",className:"w-3 h-3 text-muted-foreground/30",children:[ee.jsx("path",{d:"M11 1v10H1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),ee.jsx("path",{d:"M11 5v6H5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]})})]})]})}function lR({plugins:e,onPluginsChange:t,onClose:n}){const r=W.useCallback(async(e,n)=>{t(t=>t.map(t=>t.id===e?{...t,userConfig:{...t.userConfig,...n}}:t));try{await ij(e,n)}catch{}},[t]);return 0===e.length?null:ee.jsx(Iw,{children:e.map(e=>ee.jsx(iR,{plugin:e,onConfigChange:r,onClose:n},e.id))})}function cR({onTogglePlugin:e,activeIds:t}){const[n,r]=W.useState([]);return W.useEffect(()=>{oj().then(e=>r(e.filter(e=>e.enabled))).catch(()=>r([]))},[]),W.useEffect(()=>{const e=()=>{oj().then(e=>r(e.filter(e=>e.enabled))).catch(()=>{})};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[]),0===n.length?null:ee.jsx("div",{className:"fixed top-14 left-1/2 -translate-x-1/2 z-40 pointer-events-none",children:ee.jsx(tS.div,{className:"pointer-events-auto flex items-center gap-1 px-2 py-1 rounded-full bg-background/60 backdrop-blur-md border border-border/50 shadow-md",initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:n.map(n=>{const r=t.has(n.id),o=n.name.slice(0,2);return ee.jsxs(tS.button,{onClick:()=>e(n),className:XS("relative flex items-center justify-center w-7 h-7 rounded-full text-[10px] font-medium transition-colors",r?"bg-blue-500/20 text-blue-400":"text-muted-foreground/70 hover:text-foreground hover:bg-muted/80"),whileHover:{scale:1.12},whileTap:{scale:.92},title:n.name+(n.description?` — ${n.description}`:""),children:[o,ee.jsx(Iw,{children:r&&ee.jsx(tS.span,{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 h-1 w-1 rounded-full bg-blue-400",initial:{scale:0},animate:{scale:1},exit:{scale:0}})})]},n.id)})})})}const uR=H.lazy(()=>pd(()=>import("./ProjectPage-C3ooYpFP.js").then(e=>e.P),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.ProjectPage}))),dR=H.lazy(()=>pd(()=>import("./SettingsPage-DroQY7ar.js"),__vite__mapDeps([9,6,3,4])).then(e=>({default:e.SettingsPage}))),pR=H.lazy(()=>pd(()=>import("./SkillHubPage-B4txwD4F.js"),__vite__mapDeps([10,7,3])).then(e=>({default:e.SkillHubPage}))),hR=H.lazy(()=>pd(()=>import("./MobilePage-TPNnMQ27.js"),__vite__mapDeps([11,2,3,4,5])).then(e=>({default:e.MobilePage})));function fR(){return ee.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:ee.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})})}function mR({children:e}){const[t,n]=W.useState(!1),r=OE(e=>e.token),o=OE(e=>e.setToken);return W.useEffect(()=>{r?n(!0):BE()?WE().then(e=>o(e)).catch(()=>{}).finally(()=>n(!0)):n(!0)},[]),t||r?r?ee.jsx(ee.Fragment,{children:e}):ee.jsx(xp,{to:"/login",replace:!0}):null}const gR=window.matchMedia("(pointer: coarse)").matches&&window.innerWidth<768;function vR(){const[e,t]=W.useState([]),[n,r]=W.useState(()=>{try{return new Set(JSON.parse(localStorage.getItem("cc_plugin_open")||"[]"))}catch{return new Set}}),o=ip();W.useEffect(()=>{oj().then(t).catch(()=>t([]))},[]);const a=W.useCallback(e=>{r(t=>{const n=new Set(t);n.has(e.id)?n.delete(e.id):n.add(e.id);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),s=W.useCallback(e=>{r(t=>{const n=new Set(t);n.delete(e);try{localStorage.setItem("cc_plugin_open",JSON.stringify([...n]))}catch{}return n})},[]),i=function(e){if("/"===e||"/dashboard"===e)return{type:"dashboard"};const t=e.match(/^\/projects?\/([^/]+)/);return t?{type:"project",projectId:t[1]}:{type:"other"}}(o.pathname),l=e.filter(e=>{if(!e.enabled||!n.has(e.id))return!1;switch(e.userConfig.scope??e.float.scope.default){case"global":return!0;case"dashboard":return"dashboard"===i.type;case"project":return"project"===i.type;case"project:specific":return"project"===i.type&&(e.userConfig.projectIds??[]).includes(i.projectId??"");default:return!1}}),c="/login"===o.pathname,u="/mobile"===o.pathname;return ee.jsxs(ee.Fragment,{children:[!c&&!u&&!gR&&ee.jsx(cR,{onTogglePlugin:a,activeIds:n}),ee.jsx(lR,{plugins:l,onPluginsChange:t,onClose:s})]})}function yR(){const e=OE(e=>e.token);return W.useEffect(()=>{if(!e)return;let t=!1;return zC().then(({language:e})=>{if(!t&&e&&bf.includes(e)&&wh.language!==e){try{localStorage.setItem(xf,e)}catch{}wh.changeLanguage(e)}}).catch(()=>{}),()=>{t=!0}},[e]),null}function bR({children:e}){const t=ip();return gR&&"/"===t.pathname?ee.jsx(xp,{to:"/mobile",replace:!0}):ee.jsx(ee.Fragment,{children:e})}function xR(){return ee.jsx(zT,{children:ee.jsxs(lT,{children:[ee.jsx(sT,{richColors:!0,position:"bottom-right"}),ee.jsx(HT,{}),ee.jsx(qT,{}),ee.jsx(sR,{children:ee.jsxs(Pp,{children:[ee.jsx(yR,{}),ee.jsx(vR,{}),ee.jsx(bR,{children:ee.jsx(W.Suspense,{fallback:ee.jsx(fR,{}),children:ee.jsxs(Sp,{children:[ee.jsx(wp,{path:"/login",element:ee.jsx(xj,{})}),ee.jsx(wp,{path:"/",element:ee.jsx(mR,{children:ee.jsx(aR,{})})}),ee.jsx(wp,{path:"/projects/:id",element:ee.jsx(mR,{children:ee.jsx(uR,{})})}),ee.jsx(wp,{path:"/settings",element:ee.jsx(mR,{children:ee.jsx(dR,{})})}),ee.jsx(wp,{path:"/skillhub",element:ee.jsx(mR,{children:ee.jsx(pR,{})})}),ee.jsx(wp,{path:"/mobile",element:ee.jsx(mR,{children:ee.jsx(hR,{})})}),ee.jsx(wp,{path:"*",element:ee.jsx(xp,{to:"/",replace:!0})})]})})})]})})]})})}te.createRoot(document.getElementById("root")).render(ee.jsx(H.StrictMode,{children:ee.jsx(xR,{})}));export{aE as $,Iw as A,yE as B,Pj as C,Nj as D,_j as E,Rj as F,HC as G,qC as H,bE as I,QC as J,oP as K,JC as L,Wj as M,ZC as N,Ej as O,Kj as P,ME as Q,H as R,_E as S,aP as T,oE as U,PP as V,hP as W,iP as X,GP as Y,qP as Z,pd as _,$T as a,rj as a$,pP as a0,CP as a1,HN as a2,jP as a3,XP as a4,FN as a5,zP as a6,MP as a7,Zj as a8,uC as a9,xC as aA,lP as aB,tP as aC,cE as aD,Yh as aE,cp as aF,ET as aG,AE as aH,Cj as aI,dP as aJ,GT as aK,VT as aL,Vj as aM,Mj as aN,gj as aO,fj as aP,eC as aQ,JE as aR,kT as aS,OT as aT,mP as aU,cj as aV,tR as aW,nj as aX,ej as aY,nR as aZ,LE as a_,sC as aa,nC as ab,Dj as ac,DT as ad,cC as ae,aC as af,L_ as ag,D_ as ah,A_ as ai,F_ as aj,z_ as ak,EE as al,I_ as am,rC as an,iC as ao,oC as ap,lC as aq,mC as ar,wC as as,pC as at,gC as au,hC as av,vC as aw,fC as ax,yC as ay,bC as az,MC as b,tj as b0,Qj as b1,up as b2,JT as b3,rP as b4,xP as b5,yP as b6,ld as b7,dj as b8,pj as b9,CT as bA,mT as bB,Tj as bC,PC as bD,pb as bE,fb as bF,db as bG,r as bH,o as bI,uj as bJ,sP as bK,a as bL,yj as bM,hj as ba,mj as bb,vj as bc,SC as bd,CC as be,EC as bf,bf as bg,xf as bh,$C as bi,Lp as bj,BT as bk,VC as bl,UC as bm,oj as bn,aj as bo,sj as bp,lj as bq,kC as br,dC as bs,OE as bt,ST as bu,_T as bv,XT as bw,Jj as bx,Uj as by,qj as bz,kj as c,XS as d,Bj as e,TC as f,zE as g,TE as h,FE as i,ee as j,_C as k,Xj as l,DC as m,RC as n,Oj as o,tS as p,BC as q,W as r,RE as s,J_ as t,uT as u,GC as v,OC as w,jj as x,Yj as y,WC as z};