@tom2012/cc-web 2026.4.21-a → 2026.4.22-b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/backend/dist/adapters/claude-adapter.d.ts.map +1 -1
- package/backend/dist/adapters/claude-adapter.js +3 -1
- package/backend/dist/adapters/claude-adapter.js.map +1 -1
- package/backend/dist/agent-prompts.d.ts.map +1 -1
- package/backend/dist/agent-prompts.js +4 -2
- package/backend/dist/agent-prompts.js.map +1 -1
- package/backend/dist/approval-manager.d.ts.map +1 -1
- package/backend/dist/approval-manager.js +4 -2
- package/backend/dist/approval-manager.js.map +1 -1
- package/backend/dist/auth.d.ts.map +1 -1
- package/backend/dist/auth.js +15 -2
- package/backend/dist/auth.js.map +1 -1
- package/backend/dist/config.d.ts.map +1 -1
- package/backend/dist/config.js +3 -1
- package/backend/dist/config.js.map +1 -1
- package/backend/dist/hooks-manager.d.ts.map +1 -1
- package/backend/dist/hooks-manager.js +5 -3
- package/backend/dist/hooks-manager.js.map +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +49 -13
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/logger.d.ts +47 -0
- package/backend/dist/logger.d.ts.map +1 -0
- package/backend/dist/logger.js +355 -0
- package/backend/dist/logger.js.map +1 -0
- package/backend/dist/middleware/request-log.d.ts +3 -0
- package/backend/dist/middleware/request-log.d.ts.map +1 -0
- package/backend/dist/middleware/request-log.js +97 -0
- package/backend/dist/middleware/request-log.js.map +1 -0
- package/backend/dist/notify-service.d.ts.map +1 -1
- package/backend/dist/notify-service.js +3 -1
- package/backend/dist/notify-service.js.map +1 -1
- package/backend/dist/plugin-manager.d.ts.map +1 -1
- package/backend/dist/plugin-manager.js +8 -6
- package/backend/dist/plugin-manager.js.map +1 -1
- package/backend/dist/routes/auth.d.ts.map +1 -1
- package/backend/dist/routes/auth.js +3 -1
- package/backend/dist/routes/auth.js.map +1 -1
- package/backend/dist/routes/hooks.d.ts.map +1 -1
- package/backend/dist/routes/hooks.js +19 -0
- package/backend/dist/routes/hooks.js.map +1 -1
- package/backend/dist/routes/projects.d.ts.map +1 -1
- package/backend/dist/routes/projects.js +3 -1
- package/backend/dist/routes/projects.js.map +1 -1
- package/backend/dist/routes/skillhub.d.ts.map +1 -1
- package/backend/dist/routes/skillhub.js +4 -2
- package/backend/dist/routes/skillhub.js.map +1 -1
- package/backend/dist/routes/update.d.ts.map +1 -1
- package/backend/dist/routes/update.js +24 -6
- package/backend/dist/routes/update.js.map +1 -1
- package/backend/dist/session-manager.d.ts.map +1 -1
- package/backend/dist/session-manager.js +66 -16
- package/backend/dist/session-manager.js.map +1 -1
- package/backend/dist/sync-scheduler.d.ts.map +1 -1
- package/backend/dist/sync-scheduler.js +41 -2
- package/backend/dist/sync-scheduler.js.map +1 -1
- package/backend/dist/sync-service.d.ts +3 -1
- package/backend/dist/sync-service.d.ts.map +1 -1
- package/backend/dist/sync-service.js +18 -6
- package/backend/dist/sync-service.js.map +1 -1
- package/backend/dist/terminal-manager.d.ts +4 -1
- package/backend/dist/terminal-manager.d.ts.map +1 -1
- package/backend/dist/terminal-manager.js +31 -8
- package/backend/dist/terminal-manager.js.map +1 -1
- package/backend/dist/usage-terminal.d.ts.map +1 -1
- package/backend/dist/usage-terminal.js +5 -3
- package/backend/dist/usage-terminal.js.map +1 -1
- package/backend/package-lock.json +153 -0
- package/backend/package.json +2 -0
- package/bin/ccweb.js +3 -1
- package/frontend/dist/assets/{AssistantMessageContent-Dm3z0RIO.js → AssistantMessageContent-Cq5TZh-h.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-DC6o5F0m.js → GraphPreview-c6BsDMXu.js} +1 -1
- package/frontend/dist/assets/{MobilePage-BPKPsPbS.js → MobilePage-DNIigJYo.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-C215GkvD.js → OfficePreview-13EiheWO.js} +2 -2
- package/frontend/dist/assets/ProjectPage-C2X-iWbl.js +26 -0
- package/frontend/dist/assets/{SettingsPage-CYfAxyoC.js → SettingsPage-Cc8ol0p-.js} +2 -2
- package/frontend/dist/assets/{SkillHubPage-lb0WJ97m.js → SkillHubPage-Bv8o6-4f.js} +3 -3
- package/frontend/dist/assets/{chevron-down-CbFkp9NB.js → chevron-down-ClSQun3W.js} +1 -1
- package/frontend/dist/assets/{chevron-up-PypucKf2.js → chevron-up-_MjOCzPW.js} +1 -1
- package/frontend/dist/assets/{index-LBFGRSfF.js → index-BakiN5Cj.js} +1 -1
- package/frontend/dist/assets/{index-Hqp72os9.js → index-CgCzkWOS.js} +1 -1
- package/frontend/dist/assets/{index-BBvmgEUM.js → index-CmAWu5B1.js} +4 -4
- package/frontend/dist/assets/index-t3Zp9UzI.css +1 -0
- package/frontend/dist/assets/{jszip.min-C4dvRM2c.js → jszip.min-DfUlQ97F.js} +1 -1
- package/frontend/dist/assets/{search-6DMKwY12.js → search-cUgNWB9T.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/ProjectPage-lrAM-2d9.js +0 -26
- package/frontend/dist/assets/index-CjKxGpPA.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,r as s,U as t,
|
|
1
|
+
import{c as e,r as s,U as t,aY as n,j as a,W as r,V as l,N as o,d as i,K as c,aZ as d,aL as u,Q as h,a_ as m,L as p,Y as x,$ as f,a0 as g,a1 as v,a2 as j,x as b,az as y,a$ as w,t as N,af as k,I as S,B as C,aE as _,X as R,D as P,b0 as E,b1 as I,b2 as T,b3 as M,u as D,b4 as A,T as L,b5 as H,b6 as O,b7 as V,b8 as F,b9 as z,ay as B,ba as $,bb as W,h as K,S as U,bc as q,aA as G,bd as Z,s as Y,be as Q}from"./index-CmAWu5B1.js";import{k as X,u as J,R as ee,d as se,f as te,A as ne,C as ae,j as re,h as le,S as oe,U as ie,i as ce,T as de,a as ue,b as he,c as me}from"./index-CgCzkWOS.js";import{C as pe}from"./chevron-down-ClSQun3W.js";import{C as xe,a as fe}from"./chevron-up-_MjOCzPW.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
@@ -10,4 +10,4 @@ import{c as e,r as s,U as t,aX as n,j as a,W as r,V as l,N as o,d as i,K as c,aY
|
|
|
10
10
|
*
|
|
11
11
|
* This source code is licensed under the ISC license.
|
|
12
12
|
* See the LICENSE file in the root directory of this source tree.
|
|
13
|
-
*/function Se(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ce="Switch",[_e]=o(Ce),[Re,Pe]=_e(Ce),Ee=s.forwardRef((e,o)=>{const{__scopeSwitch:i,name:c,checked:d,defaultChecked:u,required:h,disabled:m,value:p="on",onCheckedChange:x,form:f,...g}=e,[v,j]=s.useState(null),b=t(o,e=>j(e)),y=s.useRef(!1),w=!v||(f||!!v.closest("form")),[N,k]=n({prop:d,defaultProp:u??!1,onChange:x,caller:Ce});return a.jsxs(Re,{scope:i,checked:N,disabled:m,children:[a.jsx(r.button,{type:"button",role:"switch","aria-checked":N,"aria-required":h,"data-state":De(N),"data-disabled":m?"":void 0,disabled:m,value:p,...g,ref:b,onClick:l(e.onClick,e=>{k(e=>!e),w&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())})}),w&&a.jsx(Me,{control:v,bubbles:!y.current,name:c,value:p,checked:N,required:h,disabled:m,form:f,style:{transform:"translateX(-100%)"}})]})});Ee.displayName=Ce;var Ie="SwitchThumb",Te=s.forwardRef((e,s)=>{const{__scopeSwitch:t,...n}=e,l=Pe(Ie,t);return a.jsx(r.span,{"data-state":De(l.checked),"data-disabled":l.disabled?"":void 0,...n,ref:s})});Te.displayName=Ie;var Me=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:l=!0,...o},i)=>{const c=s.useRef(null),d=t(c,i),u=Se(r),h=Q(n);return s.useEffect(()=>{const e=c.current;if(!e)return;const s=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(s,"checked").set;if(u!==r&&t){const s=new Event("click",{bubbles:l});t.call(e,r),e.dispatchEvent(s)}},[u,r,l]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:d,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function De(e){return e?"checked":"unchecked"}Me.displayName="SwitchBubbleInput";var Ae=Ee,He=Te;const Le=s.forwardRef(({className:e,...s},t)=>a.jsx(Ae,{className:i("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:t,children:a.jsx(He,{className:i("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));function Oe(e){const t=Ve(e),n=s.forwardRef((e,n)=>{const{children:r,...l}=e,o=s.Children.toArray(r),i=o.find(ze);if(i){const e=i.props.children,r=o.map(t=>t===i?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return a.jsx(t,{...l,ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,r):null})}return a.jsx(t,{...l,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ve(e){const t=s.forwardRef((e,t)=>{const{children:n,...a}=e;if(s.isValidElement(n)){const e=function(e){var s,t;let n=null==(s=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:s.get,a=n&&"isReactWarning"in n&&n.isReactWarning;if(a)return e.ref;if(n=null==(t=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:t.get,a=n&&"isReactWarning"in n&&n.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,s){const t={...s};for(const n in s){const a=e[n],r=s[n];/^on[A-Z]/.test(n)?a&&r?t[n]=(...e)=>{const s=r(...e);return a(...e),s}:a&&(t[n]=a):"style"===n?t[n]={...a,...r}:"className"===n&&(t[n]=[a,r].filter(Boolean).join(" "))}return{...e,...t}}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?c(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Le.displayName=Ae.displayName;var Fe=Symbol("radix.slottable");function ze(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Fe}var Be=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});s.forwardRef((e,s)=>a.jsx(r.span,{...e,ref:s,style:{...Be,...e.style}})).displayName="VisuallyHidden";var $e=[" ","Enter","ArrowUp","ArrowDown"],We=[" ","Enter"],Ke="Select",[Ue,qe,Ge]=te(Ke),[Ze]=o(Ke,[Ge,se]),Xe=se(),[Ye,Qe]=Ze(Ke),[Je,es]=Ze(Ke),ss=e=>{const{__scopeSelect:t,children:r,open:l,defaultOpen:o,onOpenChange:i,value:c,defaultValue:u,onValueChange:h,dir:m,name:p,autoComplete:x,disabled:f,required:g,form:v}=e,j=Xe(t),[b,y]=s.useState(null),[w,N]=s.useState(null),[k,S]=s.useState(!1),C=J(m),[_,R]=n({prop:l,defaultProp:o??!1,onChange:i,caller:Ke}),[P,E]=n({prop:c,defaultProp:u,onChange:h,caller:Ke}),I=s.useRef(null),T=!b||(v||!!b.closest("form")),[M,D]=s.useState(new Set),A=Array.from(M).map(e=>e.props.value).join(";");return a.jsx(ee,{...j,children:a.jsxs(Ye,{required:g,scope:t,trigger:b,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:d(),value:P,onValueChange:E,open:_,onOpenChange:R,dir:C,triggerPointerDownPosRef:I,disabled:f,children:[a.jsx(Ue.Provider,{scope:t,children:a.jsx(Je,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(s=>new Set(s).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(s=>{const t=new Set(s);return t.delete(e),t})},[]),children:r})}),T?a.jsxs(zs,{"aria-hidden":!0,required:g,tabIndex:-1,name:p,autoComplete:x,value:P,onChange:e=>E(e.target.value),disabled:f,form:v,children:[void 0===P?a.jsx("option",{value:""}):null,Array.from(M)]},A):null]})})};ss.displayName=Ke;var ts="SelectTrigger",ns=s.forwardRef((e,n)=>{const{__scopeSelect:o,disabled:i=!1,...c}=e,d=Xe(o),u=Qe(ts,o),h=u.disabled||i,m=t(n,u.onTriggerChange),p=qe(o),x=s.useRef("touch"),[f,g,v]=$s(e=>{const s=p().filter(e=>!e.disabled),t=s.find(e=>e.value===u.value),n=Ws(s,e,t);void 0!==n&&u.onValueChange(n.value)}),j=e=>{h||(u.onOpenChange(!0),v()),e&&(u.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return a.jsx(ne,{asChild:!0,...d,children:a.jsx(r.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:h,"data-disabled":h?"":void 0,"data-placeholder":Bs(u.value)?"":void 0,...c,ref:m,onClick:l(c.onClick,e=>{e.currentTarget.focus(),"mouse"!==x.current&&j(e)}),onPointerDown:l(c.onPointerDown,e=>{x.current=e.pointerType;const s=e.target;s.hasPointerCapture(e.pointerId)&&s.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(j(e),e.preventDefault())}),onKeyDown:l(c.onKeyDown,e=>{const s=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||g(e.key),s&&" "===e.key||$e.includes(e.key)&&(j(),e.preventDefault())})})})});ns.displayName=ts;var as="SelectValue",rs=s.forwardRef((e,s)=>{const{__scopeSelect:n,className:l,style:o,children:i,placeholder:c="",...d}=e,h=Qe(as,n),{onValueNodeHasChildrenChange:m}=h,p=void 0!==i,x=t(s,h.onValueNodeChange);return u(()=>{m(p)},[m,p]),a.jsx(r.span,{...d,ref:x,style:{pointerEvents:"none"},children:Bs(h.value)?a.jsx(a.Fragment,{children:c}):i})});rs.displayName=as;var ls=s.forwardRef((e,s)=>{const{__scopeSelect:t,children:n,...l}=e;return a.jsx(r.span,{"aria-hidden":!0,...l,ref:s,children:n||"▼"})});ls.displayName="SelectIcon";var os=e=>a.jsx(h,{asChild:!0,...e});os.displayName="SelectPortal";var is="SelectContent",cs=s.forwardRef((e,t)=>{const n=Qe(is,e.__scopeSelect),[r,l]=s.useState();if(u(()=>{l(new DocumentFragment)},[]),!n.open){const s=r;return s?m.createPortal(a.jsx(us,{scope:e.__scopeSelect,children:a.jsx(Ue.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(ps,{...e,ref:t})});cs.displayName=is;var ds=10,[us,hs]=Ze(is),ms=Oe("SelectContent.RemoveScroll"),ps=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:c,onPointerDownOutside:d,side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:b,collisionBoundary:y,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S,...C}=e,_=Qe(is,r),[R,P]=s.useState(null),[E,I]=s.useState(null),T=t(n,e=>P(e)),[M,D]=s.useState(null),[A,H]=s.useState(null),L=qe(r),[O,V]=s.useState(!1),F=s.useRef(!1);s.useEffect(()=>{if(R)return x(R)},[R]),f();const z=s.useCallback(e=>{const[s,...t]=L().map(e=>e.ref.current),[n]=t.slice(-1),a=document.activeElement;for(const r of e){if(r===a)return;if(null==r||r.scrollIntoView({block:"nearest"}),r===s&&E&&(E.scrollTop=0),r===n&&E&&(E.scrollTop=E.scrollHeight),null==r||r.focus(),document.activeElement!==a)return}},[L,E]),B=s.useCallback(()=>z([M,R]),[z,M,R]);s.useEffect(()=>{O&&B()},[O,B]);const{onOpenChange:$,triggerPointerDownPosRef:W}=_;s.useEffect(()=>{if(R){let e={x:0,y:0};const s=s=>{var t,n;e={x:Math.abs(Math.round(s.pageX)-((null==(t=W.current)?void 0:t.x)??0)),y:Math.abs(Math.round(s.pageY)-((null==(n=W.current)?void 0:n.y)??0))}},t=t=>{e.x<=10&&e.y<=10?t.preventDefault():R.contains(t.target)||$(!1),document.removeEventListener("pointermove",s),W.current=null};return null!==W.current&&(document.addEventListener("pointermove",s),document.addEventListener("pointerup",t,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",t,{capture:!0})}}},[R,$,W]),s.useEffect(()=>{const e=()=>$(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[$]);const[K,U]=$s(e=>{const s=L().filter(e=>!e.disabled),t=s.find(e=>e.ref.current===document.activeElement),n=Ws(s,e,t);n&&setTimeout(()=>n.ref.current.focus())}),q=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&(D(e),n&&(F.current=!0))},[_.value]),G=s.useCallback(()=>null==R?void 0:R.focus(),[R]),Z=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&H(e)},[_.value]),X="popper"===o?fs:xs,Y=X===fs?{side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:b,collisionBoundary:y,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S}:{};return a.jsx(us,{scope:r,content:R,viewport:E,onViewportChange:I,itemRefCallback:q,selectedItem:M,onItemLeave:G,itemTextRefCallback:Z,focusSelectedItem:B,selectedItemText:A,position:o,isPositioned:O,searchRef:K,children:a.jsx(g,{as:ms,allowPinchZoom:!0,children:a.jsx(v,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:l(i,e=>{var s;null==(s=_.trigger)||s.focus({preventScroll:!0}),e.preventDefault()}),children:a.jsx(j,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:a.jsx(X,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...C,...Y,onPlaced:()=>V(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:l(C.onKeyDown,e=>{const s=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),s||1!==e.key.length||U(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let s=L().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(s=s.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const t=e.target,n=s.indexOf(t);s=s.slice(n+1)}setTimeout(()=>z(s)),e.preventDefault()}})})})})})})});ps.displayName="SelectContentImpl";var xs=s.forwardRef((e,n)=>{const{__scopeSelect:l,onPlaced:o,...i}=e,c=Qe(is,l),d=hs(is,l),[h,m]=s.useState(null),[p,x]=s.useState(null),f=t(n,e=>x(e)),g=qe(l),v=s.useRef(!1),j=s.useRef(!0),{viewport:b,selectedItem:y,selectedItemText:w,focusSelectedItem:N}=d,k=s.useCallback(()=>{if(c.trigger&&c.valueNode&&h&&p&&b&&y&&w){const e=c.trigger.getBoundingClientRect(),s=p.getBoundingClientRect(),t=c.valueNode.getBoundingClientRect(),n=w.getBoundingClientRect();if("rtl"!==c.dir){const a=n.left-s.left,r=t.left-a,l=e.left-r,o=e.width+l,i=Math.max(o,s.width),c=window.innerWidth-ds,d=re(r,[ds,Math.max(ds,c-i)]);h.style.minWidth=o+"px",h.style.left=d+"px"}else{const a=s.right-n.right,r=window.innerWidth-t.right-a,l=window.innerWidth-e.right-r,o=e.width+l,i=Math.max(o,s.width),c=window.innerWidth-ds,d=re(r,[ds,Math.max(ds,c-i)]);h.style.minWidth=o+"px",h.style.right=d+"px"}const a=g(),r=window.innerHeight-2*ds,l=b.scrollHeight,i=window.getComputedStyle(p),d=parseInt(i.borderTopWidth,10),u=parseInt(i.paddingTop,10),m=parseInt(i.borderBottomWidth,10),x=d+u+l+parseInt(i.paddingBottom,10)+m,f=Math.min(5*y.offsetHeight,x),j=window.getComputedStyle(b),N=parseInt(j.paddingTop,10),k=parseInt(j.paddingBottom,10),S=e.top+e.height/2-ds,C=r-S,_=y.offsetHeight/2,R=d+u+(y.offsetTop+_),P=x-R;if(R<=S){const e=a.length>0&&y===a[a.length-1].ref.current;h.style.bottom="0px";const s=p.clientHeight-b.offsetTop-b.offsetHeight,t=R+Math.max(C,_+(e?k:0)+s+m);h.style.height=t+"px"}else{const e=a.length>0&&y===a[0].ref.current;h.style.top="0px";const s=Math.max(S,d+b.offsetTop+(e?N:0)+_)+P;h.style.height=s+"px",b.scrollTop=R-S+b.offsetTop}h.style.margin=`${ds}px 0`,h.style.minHeight=f+"px",h.style.maxHeight=r+"px",null==o||o(),requestAnimationFrame(()=>v.current=!0)}},[g,c.trigger,c.valueNode,h,p,b,y,w,c.dir,o]);u(()=>k(),[k]);const[S,C]=s.useState();u(()=>{p&&C(window.getComputedStyle(p).zIndex)},[p]);const _=s.useCallback(e=>{e&&!0===j.current&&(k(),null==N||N(),j.current=!1)},[k,N]);return a.jsx(gs,{scope:l,contentWrapper:h,shouldExpandOnScrollRef:v,onScrollButtonChange:_,children:a.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:a.jsx(r.div,{...i,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});xs.displayName="SelectItemAlignedPosition";var fs=s.forwardRef((e,s)=>{const{__scopeSelect:t,align:n="start",collisionPadding:r=ds,...l}=e,o=Xe(t);return a.jsx(ae,{...o,...l,ref:s,align:n,collisionPadding:r,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});fs.displayName="SelectPopperPosition";var[gs,vs]=Ze(is,{}),js="SelectViewport",bs=s.forwardRef((e,n)=>{const{__scopeSelect:o,nonce:i,...c}=e,d=hs(js,o),u=vs(js,o),h=t(n,d.onViewportChange),m=s.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),a.jsx(Ue.Slot,{scope:o,children:a.jsx(r.div,{"data-radix-select-viewport":"",role:"presentation",...c,ref:h,style:{position:"relative",flex:1,overflow:"hidden auto",...c.style},onScroll:l(c.onScroll,e=>{const s=e.currentTarget,{contentWrapper:t,shouldExpandOnScrollRef:n}=u;if((null==n?void 0:n.current)&&t){const e=Math.abs(m.current-s.scrollTop);if(e>0){const n=window.innerHeight-2*ds,a=parseFloat(t.style.minHeight),r=parseFloat(t.style.height),l=Math.max(a,r);if(l<n){const a=l+e,r=Math.min(n,a),o=a-r;t.style.height=r+"px","0px"===t.style.bottom&&(s.scrollTop=o>0?o:0,t.style.justifyContent="flex-end")}}}m.current=s.scrollTop})})})]})});bs.displayName=js;var ys="SelectGroup",[ws,Ns]=Ze(ys);s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,l=d();return a.jsx(ws,{scope:t,id:l,children:a.jsx(r.div,{role:"group","aria-labelledby":l,...n,ref:s})})}).displayName=ys;var ks="SelectLabel",Ss=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,l=Ns(ks,t);return a.jsx(r.div,{id:l.id,...n,ref:s})});Ss.displayName=ks;var Cs="SelectItem",[_s,Rs]=Ze(Cs),Ps=s.forwardRef((e,n)=>{const{__scopeSelect:o,value:i,disabled:c=!1,textValue:u,...h}=e,m=Qe(Cs,o),p=hs(Cs,o),x=m.value===i,[f,g]=s.useState(u??""),[v,j]=s.useState(!1),b=t(n,e=>{var s;return null==(s=p.itemRefCallback)?void 0:s.call(p,e,i,c)}),y=d(),w=s.useRef("touch"),N=()=>{c||(m.onValueChange(i),m.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(_s,{scope:o,value:i,disabled:c,textId:y,isSelected:x,onItemTextChange:s.useCallback(e=>{g(s=>s||((null==e?void 0:e.textContent)??"").trim())},[]),children:a.jsx(Ue.ItemSlot,{scope:o,value:i,disabled:c,textValue:f,children:a.jsx(r.div,{role:"option","aria-labelledby":y,"data-highlighted":v?"":void 0,"aria-selected":x&&v,"data-state":x?"checked":"unchecked","aria-disabled":c||void 0,"data-disabled":c?"":void 0,tabIndex:c?void 0:-1,...h,ref:b,onFocus:l(h.onFocus,()=>j(!0)),onBlur:l(h.onBlur,()=>j(!1)),onClick:l(h.onClick,()=>{"mouse"!==w.current&&N()}),onPointerUp:l(h.onPointerUp,()=>{"mouse"===w.current&&N()}),onPointerDown:l(h.onPointerDown,e=>{w.current=e.pointerType}),onPointerMove:l(h.onPointerMove,e=>{var s;w.current=e.pointerType,c?null==(s=p.onItemLeave)||s.call(p):"mouse"===w.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:l(h.onPointerLeave,e=>{var s;e.currentTarget===document.activeElement&&(null==(s=p.onItemLeave)||s.call(p))}),onKeyDown:l(h.onKeyDown,e=>{var s;""!==(null==(s=p.searchRef)?void 0:s.current)&&" "===e.key||(We.includes(e.key)&&N()," "===e.key&&e.preventDefault())})})})})});Ps.displayName=Cs;var Es="SelectItemText",Is=s.forwardRef((e,n)=>{const{__scopeSelect:l,className:o,style:i,...c}=e,d=Qe(Es,l),h=hs(Es,l),p=Rs(Es,l),x=es(Es,l),[f,g]=s.useState(null),v=t(n,e=>g(e),p.onItemTextChange,e=>{var s;return null==(s=h.itemTextRefCallback)?void 0:s.call(h,e,p.value,p.disabled)}),j=null==f?void 0:f.textContent,b=s.useMemo(()=>a.jsx("option",{value:p.value,disabled:p.disabled,children:j},p.value),[p.disabled,p.value,j]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=x;return u(()=>(y(b),()=>w(b)),[y,w,b]),a.jsxs(a.Fragment,{children:[a.jsx(r.span,{id:p.textId,...c,ref:v}),p.isSelected&&d.valueNode&&!d.valueNodeHasChildren?m.createPortal(c.children,d.valueNode):null]})});Is.displayName=Es;var Ts="SelectItemIndicator",Ms=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return Rs(Ts,t).isSelected?a.jsx(r.span,{"aria-hidden":!0,...n,ref:s}):null});Ms.displayName=Ts;var Ds="SelectScrollUpButton",As=s.forwardRef((e,n)=>{const r=hs(Ds,e.__scopeSelect),l=vs(Ds,e.__scopeSelect),[o,i]=s.useState(!1),c=t(n,l.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollTop>0;i(e)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?a.jsx(Os,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop-s.offsetHeight)}}):null});As.displayName=Ds;var Hs="SelectScrollDownButton",Ls=s.forwardRef((e,n)=>{const r=hs(Hs,e.__scopeSelect),l=vs(Hs,e.__scopeSelect),[o,i]=s.useState(!1),c=t(n,l.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollHeight-s.clientHeight,t=Math.ceil(s.scrollTop)<e;i(t)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?a.jsx(Os,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop+s.offsetHeight)}}):null});Ls.displayName=Hs;var Os=s.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...i}=e,c=hs("SelectScrollButton",n),d=s.useRef(null),h=qe(n),m=s.useCallback(()=>{null!==d.current&&(window.clearInterval(d.current),d.current=null)},[]);return s.useEffect(()=>()=>m(),[m]),u(()=>{var e;const s=h().find(e=>e.ref.current===document.activeElement);null==(e=null==s?void 0:s.ref.current)||e.scrollIntoView({block:"nearest"})},[h]),a.jsx(r.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:l(i.onPointerDown,()=>{null===d.current&&(d.current=window.setInterval(o,50))}),onPointerMove:l(i.onPointerMove,()=>{var e;null==(e=c.onItemLeave)||e.call(c),null===d.current&&(d.current=window.setInterval(o,50))}),onPointerLeave:l(i.onPointerLeave,()=>{m()})})}),Vs=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return a.jsx(r.div,{"aria-hidden":!0,...n,ref:s})});Vs.displayName="SelectSeparator";var Fs="SelectArrow";s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,r=Xe(t),l=Qe(Fs,t),o=hs(Fs,t);return l.open&&"popper"===o.position?a.jsx(le,{...r,...n,ref:s}):null}).displayName=Fs;var zs=s.forwardRef(({__scopeSelect:e,value:n,...l},o)=>{const i=s.useRef(null),c=t(o,i),d=Se(n);return s.useEffect(()=>{const e=i.current;if(!e)return;const s=window.HTMLSelectElement.prototype,t=Object.getOwnPropertyDescriptor(s,"value").set;if(d!==n&&t){const s=new Event("change",{bubbles:!0});t.call(e,n),e.dispatchEvent(s)}},[d,n]),a.jsx(r.select,{...l,style:{...Be,...l.style},ref:c,defaultValue:n})});function Bs(e){return""===e||void 0===e}function $s(e){const t=p(e),n=s.useRef(""),a=s.useRef(0),r=s.useCallback(e=>{const s=n.current+e;t(s),function e(s){n.current=s,window.clearTimeout(a.current),""!==s&&(a.current=window.setTimeout(()=>e(""),1e3))}(s)},[t]),l=s.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,r,l]}function Ws(e,s,t){const n=s.length>1&&Array.from(s).every(e=>e===s[0])?s[0]:s,a=t?e.indexOf(t):-1;let r=(l=e,o=Math.max(a,0),l.map((e,s)=>l[(o+s)%l.length]));var l,o;1===n.length&&(r=r.filter(e=>e!==t));const i=r.find(e=>e.textValue.toLowerCase().startsWith(n.toLowerCase()));return i!==t?i:void 0}zs.displayName="SelectBubbleInput";var Ks=ns,Us=ls,qs=os,Gs=cs,Zs=bs,Xs=Ss,Ys=Ps,Qs=Is,Js=Ms,et=As,st=Ls,tt=Vs;const nt=ss,at=rs,rt=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(Ks,{ref:n,className:i("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...t,children:[s,a.jsx(Us,{asChild:!0,children:a.jsx(pe,{className:"h-4 w-4 opacity-50"})})]}));rt.displayName=Ks.displayName;const lt=s.forwardRef(({className:e,...s},t)=>a.jsx(et,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(xe,{className:"h-4 w-4"})}));lt.displayName=et.displayName;const ot=s.forwardRef(({className:e,...s},t)=>a.jsx(st,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(pe,{className:"h-4 w-4"})}));ot.displayName=st.displayName;const it=s.forwardRef(({className:e,children:s,position:t="popper",...n},r)=>a.jsx(qs,{children:a.jsxs(Gs,{ref:r,className:i("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===t&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:t,...n,children:[a.jsx(lt,{}),a.jsx(Zs,{className:i("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),a.jsx(ot,{})]})}));it.displayName=Gs.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx(Xs,{ref:t,className:i("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s})).displayName=Xs.displayName;const ct=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(Ys,{ref:n,className:i("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Js,{children:a.jsx(b,{className:"h-4 w-4"})})}),a.jsx(Qs,{children:s})]}));ct.displayName=Ys.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx(tt,{ref:t,className:i("-mx-1 my-1 h-px bg-muted",e),...s})).displayName=tt.displayName;function dt(){const[e,t]=s.useState(null),[n,r]=s.useState(!0),[l,o]=s.useState(!1),[i,c]=s.useState(!1),[d,u]=s.useState(!1),[h,m]=s.useState(!1),[p,x]=s.useState(null),[f,g]=s.useState(0),[v,j]=s.useState(""),[b,D]=s.useState("");y({onStart:e=>{x(e.projectId),g(0)},onProgress:e=>{x(e.projectId),g(e.filesTransferred)},onDone:()=>{x(null),g(0)}}),s.useEffect(()=>{let e=!1;return w().then(s=>{e||(t(s),D(s.defaultExcludes.join("\n")))}).catch(e=>N.error(`加载同步配置失败: ${e.message}`)).finally(()=>{e||r(!1)}),()=>{e=!0}},[]);const A=(e,s)=>{t(t=>t?{...t,[e]:s}:t)};return n||!e?a.jsx("div",{className:"text-sm text-muted-foreground",children:"加载中…"}):a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"服务器配置"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-host",children:"主机 (host)"}),a.jsx(S,{id:"sync-host",value:e.host,onChange:e=>A("host",e.target.value),placeholder:"example.com"})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-port",children:"端口"}),a.jsx(S,{id:"sync-port",type:"number",value:e.port,onChange:e=>A("port",Number(e.target.value)||22)})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-user",children:"用户名"}),a.jsx(S,{id:"sync-user",value:e.user,onChange:e=>A("user",e.target.value),placeholder:"tom"})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-remote",children:"远端根路径"}),a.jsx(S,{id:"sync-remote",value:e.remoteRoot,onChange:e=>A("remoteRoot",e.target.value),placeholder:"/data/projects"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["每个项目会同步到 ",a.jsx("code",{children:"远端路径/项目文件夹"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"认证"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{children:"方式"}),a.jsxs(nt,{value:e.authMethod,onValueChange:e=>A("authMethod",e),children:[a.jsx(rt,{children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"key",children:"SSH key"}),a.jsx(ct,{value:"password",children:"密码"})]})]})]}),"key"===e.authMethod?a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-key",children:"私钥路径"}),a.jsx(S,{id:"sync-key",value:e.keyPath??"",onChange:e=>A("keyPath",e.target.value),placeholder:"~/.ssh/id_rsa"})]}):a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-pw",children:"密码"}),a.jsx(S,{id:"sync-pw",type:"password",value:v,onChange:e=>j(e.target.value),placeholder:e.passwordSet?"已设置,留空保持不变":"未设置"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["需要系统安装 ",a.jsx("code",{children:"sshpass"}),"(密码通过 SSHPASS env 传递,不会出现在 argv 里)"]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"同步策略"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{children:"方向"}),a.jsxs(nt,{value:e.direction,onValueChange:e=>A("direction",e),children:[a.jsx(rt,{children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"push",children:"单向:本地 → 远端(--delete)"}),a.jsx(ct,{value:"pull",children:"单向:远端 → 本地"}),a.jsx(ct,{value:"bidirectional",children:"双向(先 push 再 pull)"})]})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(k,{htmlFor:"sync-cron",children:"定时 cron 表达式"}),a.jsx(S,{id:"sync-cron",value:e.schedule.cron,onChange:s=>A("schedule",{...e.schedule,cron:s.target.value}),placeholder:"0 3 * * *"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["5 段:分 时 日 月 周。例:",a.jsx("code",{children:"0 3 * * *"})," 每天 03:00"]})]}),a.jsxs("div",{className:"flex items-center gap-2 pb-1.5",children:[a.jsx(Le,{checked:e.schedule.enabled,onCheckedChange:s=>A("schedule",{...e.schedule,enabled:s})}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"启用"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"默认排除(每行一个 glob)"}),a.jsx("textarea",{value:b,onChange:e=>D(e.target.value),rows:6,className:"w-full font-mono text-xs p-2 rounded border border-input bg-background resize-y",placeholder:"node_modules/\n.git/objects/\n*.log"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["作为 ",a.jsx("code",{children:"rsync --exclude"})," 传入。项目级的额外排除暂通过 API 设置。"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t",children:[a.jsxs(C,{onClick:()=>{(async()=>{if(e){o(!0);try{const s=b.split("\n").map(e=>e.trim()).filter(Boolean),n={host:e.host,port:e.port,user:e.user,authMethod:e.authMethod,keyPath:e.keyPath,remoteRoot:e.remoteRoot,direction:e.direction,defaultExcludes:s,schedule:e.schedule};v&&"__keep__"!==v&&(n.password=v);const a=await E(n);t(a),D(a.defaultExcludes.join("\n")),j(""),N.success("已保存")}catch(s){N.error(`保存失败: ${s.message}`)}finally{o(!1)}}})()},disabled:l,children:[l?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]}),a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{c(!0);try{const e=await I();e.ok?N.success(e.message||"连接成功"):N.error(e.message||"连接失败")}catch(e){N.error(`测试失败: ${e.message}`)}finally{c(!1)}})()},disabled:i,children:[i?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(Ne,{className:"h-3.5 w-3.5 mr-1.5"}),"测试连接"]}),a.jsx("div",{className:"flex-1"}),d&&p&&a.jsx("span",{className:"text-xs text-muted-foreground self-center mr-1 tabular-nums",children:f>0?`同步中: ${p} (${f} 文件)`:`同步中: ${p}`}),a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{u(!0);try{const e=await T(),s=e.results.filter(e=>e.ok).length,t=e.results.filter(e=>e.skipped).length,n=e.results.filter(e=>"cancelled"===e.reason).length,a=e.total-s-t-n;n>0?N.info(`已取消:${s} 成功 / ${t} 跳过 / ${n} 取消 / ${a} 失败`):N.success(`同步完成:${s} 成功 / ${t} 跳过 / ${a} 失败`)}catch(e){N.error(`同步失败: ${e.message}`)}finally{u(!1),m(!1),x(null),g(0)}})()},disabled:d,title:"按当前方向同步所有项目",children:[d?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(ie,{className:"h-3.5 w-3.5 mr-1.5"}),"立即同步全部"]}),d&&a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{if(d&&!h){m(!0);try{await M(),N.info("已请求取消")}catch(e){N.error(`取消失败: ${e.message}`),m(!1)}}})()},disabled:h,title:"取消批量同步:SIGTERM 当前 rsync 并停止后续项目",children:[h?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(R,{className:"h-3.5 w-3.5 mr-1.5"}),"取消"]})]}),a.jsxs("div",{className:"border-t pt-4 text-xs text-muted-foreground",children:["一次性 push/pull 工具:进入项目内部,点击 header 的 ",a.jsx(ie,{className:"inline h-3 w-3"})," / ",a.jsx(P,{className:"inline h-3 w-3"})," 按钮。 或通过 API 调用 ",a.jsx("code",{children:"POST /api/sync/project/:id"})," with body ",a.jsx("code",{children:'{ "direction": "push" }'}),"。"]})]})}function ut(){const e=D(),[t,n]=s.useState(null),[r,l]=s.useState(!0),[o,i]=s.useState(""),[c,d]=s.useState(!1);s.useEffect(()=>{let e=!1;return A().then(s=>{e||n(s)}).catch(()=>{e||n({configured:!1,needsReset:!1})}).finally(()=>{e||l(!1)}),()=>{e=!0}},[]);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-1",children:"CCWeb Hub 直接提交"}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:['配置你的 GitHub PAT 后,在 Quick Prompts / Agent Prompts 卡片右键选择"共享"时可一键直接提交 Issue 到 ',a.jsx("code",{children:"zbc0315/ccweb-hub"}),"。 ccweb 本身不自带 token —— 使用你自己的账号身份提交,归属清晰,互不影响。"]})]}),r?a.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[a.jsx(_,{className:"h-4 w-4 animate-spin"}),"加载中…"]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"rounded-md border px-3 py-2.5 text-xs flex items-center gap-2",children:(null==t?void 0:t.configured)?a.jsxs(a.Fragment,{children:[a.jsx(fe,{className:"h-4 w-4 text-green-500 shrink-0"}),a.jsx("span",{children:"已配置 token,可直接提交"}),a.jsx("div",{className:"flex-1"}),a.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{(async()=>{if(await e({title:"清除 Hub Token",description:"清除后将无法直接提交到 ccweb-hub,需要重新配置 token。确认?",destructive:!0,confirmLabel:"清除"}))try{await L(),n({configured:!1,needsReset:!1}),N.success("已清除")}catch(s){N.error(`清除失败: ${s.message}`)}})()},children:[a.jsx(H,{className:"h-3.5 w-3.5 mr-1"}),"清除"]})]}):(null==t?void 0:t.needsReset)?a.jsxs(a.Fragment,{children:[a.jsx(ve,{className:"h-4 w-4 text-amber-500 shrink-0"}),a.jsx("span",{children:"之前的 token 已失效(服务端密钥可能已轮换),请重新设置"})]}):a.jsxs(a.Fragment,{children:[a.jsx(ve,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{children:"尚未配置 token"})]})}),a.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2.5 text-xs space-y-2",children:[a.jsx("div",{className:"font-medium text-foreground",children:"如何获取 token"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[a.jsxs("li",{children:["打开"," ",a.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline inline-flex items-center gap-0.5",children:["GitHub fine-grained PAT",a.jsx(be,{className:"h-3 w-3"})]})," ","创建页"]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository access"}),':选 "Only select repositories",添加 ',a.jsx("code",{children:"zbc0315/ccweb-hub"})]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository permissions → Issues"}),':设置为 "Read and write"']}),a.jsx("li",{children:"其余权限保持默认(全部无访问)"}),a.jsx("li",{children:"生成后复制 token 粘贴到下方"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(k,{htmlFor:"hub-token",className:"text-xs",children:["GitHub Token ",(null==t?void 0:t.configured)&&a.jsx("span",{className:"text-muted-foreground",children:"(填写会覆盖现有 token)"})]}),a.jsx(S,{id:"hub-token",type:"password",placeholder:"github_pat_...",value:o,onChange:e=>i(e.target.value),autoComplete:"off",spellCheck:!1}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Token 以 AES-256-GCM 加密存储于 ",a.jsx("code",{children:"~/.ccweb/hub-auth/"}),";per-user 独立,不会被其他用户读到。"]})]}),a.jsx("div",{className:"flex gap-2 pt-2 border-t",children:a.jsxs(C,{onClick:()=>{(async()=>{const e=o.trim();if(e){d(!0);try{const s=await O(e);n(s),i(""),N.success("已保存")}catch(s){N.error(`保存失败: ${s.message}`)}finally{d(!1)}}else N.error("请输入 token")})()},disabled:c||!o.trim(),children:[c?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]})})]})]})}function ht(){const{t:e,i18n:s}=ce();return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(we,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs(nt,{value:s.language,onValueChange:async t=>{if(V.includes(t)){try{localStorage.setItem(F,t)}catch{}await s.changeLanguage(t);try{await z(t)}catch{N.error(e("language.switch_failed"))}}},children:[a.jsx(rt,{className:"w-40",children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"zh",children:e("language.zh")}),a.jsx(ct,{value:"en",children:e("language.en")})]})]})]})}function mt(){const{t:e}=ce(),t=B(),[n]=$(),r=n.get("tab")||"sync",[l,o]=s.useState(()=>W()),[i,c]=s.useState(!1),[d,u]=s.useState({webhookEnabled:!1}),[h,m]=s.useState(""),[p,x]=s.useState(!1),[f,g]=s.useState(()=>K(U.usageMonitorTool,"claude"));s.useEffect(()=>{q().then(e=>{u(e),m(e.webhookUrl??"")}).catch(()=>{})},[]);const v=(e,s)=>{const t=parseInt(s,10);isNaN(t)||t<1||(o(s=>({...s,[e]:t})),c(!0))};return a.jsx("div",{className:"min-h-screen bg-background",children:a.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[a.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[a.jsx(G,{className:"h-4 w-4 mr-1"}),e("common.back")]}),a.jsx("h1",{className:"text-2xl font-bold",children:e("settings.title")})]}),a.jsxs(de,{defaultValue:r,children:[a.jsxs(ue,{className:"mb-4",children:[a.jsxs(he,{value:"sync",children:[a.jsx(ke,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_sync")]}),a.jsxs(he,{value:"hub",children:[a.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_hub")]}),a.jsxs(he,{value:"notifications",children:[a.jsx(je,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_notifications")]}),a.jsxs(he,{value:"pomodoro",children:[a.jsx(Z,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_pomodoro")]}),a.jsxs(he,{value:"usage",children:[a.jsx(ge,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_usage")]}),a.jsxs(he,{value:"language",children:[a.jsx(we,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_language")]})]}),a.jsx(me,{value:"sync",children:a.jsx(dt,{})}),a.jsx(me,{value:"hub",children:a.jsx(ut,{})}),a.jsx(me,{value:"notifications",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.browser_notify.title")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.browser_notify.description")})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.webhook.title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.webhook.description")})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:"Webhook URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(S,{placeholder:"https://hooks.slack.com/...",value:h,onChange:e=>m(e.target.value),className:"font-mono text-xs"}),a.jsx(C,{size:"sm",onClick:()=>{(async()=>{x(!0);try{const s=await Y({webhookEnabled:h.trim().length>0,webhookUrl:h.trim()||void 0});u(s),N.success(e("settings.webhook.saved"))}catch{N.error(e("settings.webhook.save_failed"))}finally{x(!1)}})()},disabled:p,children:e(p?"common.saving":"common.save")})]}),d.webhookEnabled&&d.webhookUrl&&a.jsxs("p",{className:"text-xs text-green-500",children:[e("settings.webhook.enabled_prefix")," ",d.webhookUrl]})]})]})]})}),a.jsx(me,{value:"pomodoro",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.pomodoro.section_desc")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-6 max-w-xs",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:e("settings.pomodoro.work_minutes")}),a.jsx(S,{type:"number",min:1,max:120,value:l.workMinutes,onChange:e=>v("workMinutes",e.target.value),className:"w-full"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:e("settings.pomodoro.break_minutes")}),a.jsx(S,{type:"number",min:1,max:60,value:l.breakMinutes,onChange:e=>v("breakMinutes",e.target.value),className:"w-full"})]})]}),i&&a.jsxs(C,{size:"sm",onClick:()=>{X(U.pomodoroConfig,l,!0),c(!1),N.success(e("settings.pomodoro.saved"))},children:[a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),e("common.save")]})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.howto_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsxs("li",{children:[a.jsx(Z,{className:"h-3 w-3 inline-block mx-0.5"})," ",e("settings.pomodoro.howto_item_1")]}),a.jsx("li",{children:e("settings.pomodoro.howto_item_2")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_3")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_4")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_5")})]})]})]})}),a.jsx(me,{value:"usage",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.usage.section_desc")})]}),a.jsx("div",{className:"grid gap-3 max-w-md",children:[{key:"claude",label:"Claude Code",desc:e("settings.usage.tool_claude_desc")},{key:"codex",label:"Codex",desc:e("settings.usage.tool_codex_desc")},{key:"opencode",label:"OpenCode",desc:e("settings.usage.tool_opencode_desc")},{key:"qwen",label:"Qwen Code",desc:e("settings.usage.tool_qwen_desc")},{key:"gemini",label:"Gemini CLI",desc:e("settings.usage.tool_gemini_desc")}].map(s=>a.jsxs("label",{className:"flex items-start gap-3 rounded-lg border p-3 cursor-pointer transition-colors "+(f===s.key?"border-blue-500/50 bg-blue-500/5":"border-border hover:bg-muted/30"),children:[a.jsx("input",{type:"radio",name:"usageTool",value:s.key,checked:f===s.key,onChange:()=>{g(s.key),X(U.usageMonitorTool,s.key),window.dispatchEvent(new Event("ccweb:usage-tool-change")),N.success(e("settings.usage.switched_toast",{tool:s.label}))},className:"mt-0.5"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:s.label}),a.jsx("div",{className:"text-xs text-muted-foreground",children:s.desc})]})]},s.key))})]}),a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.info_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsx("li",{children:e("settings.usage.info_item_1")}),a.jsx("li",{children:e("settings.usage.info_item_2")}),a.jsx("li",{children:e("settings.usage.info_item_3")}),a.jsx("li",{children:e("settings.usage.info_item_4")})]})]})]})}),a.jsx(me,{value:"language",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[a.jsx("div",{children:a.jsx("h3",{className:"text-sm font-medium",children:e("language.label")})}),a.jsx(ht,{})]})})})]})]})})}export{mt as SettingsPage};
|
|
13
|
+
*/function Se(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ce="Switch",[_e]=o(Ce),[Re,Pe]=_e(Ce),Ee=s.forwardRef((e,o)=>{const{__scopeSwitch:i,name:c,checked:d,defaultChecked:u,required:h,disabled:m,value:p="on",onCheckedChange:x,form:f,...g}=e,[v,j]=s.useState(null),b=t(o,e=>j(e)),y=s.useRef(!1),w=!v||(f||!!v.closest("form")),[N,k]=n({prop:d,defaultProp:u??!1,onChange:x,caller:Ce});return a.jsxs(Re,{scope:i,checked:N,disabled:m,children:[a.jsx(r.button,{type:"button",role:"switch","aria-checked":N,"aria-required":h,"data-state":De(N),"data-disabled":m?"":void 0,disabled:m,value:p,...g,ref:b,onClick:l(e.onClick,e=>{k(e=>!e),w&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())})}),w&&a.jsx(Me,{control:v,bubbles:!y.current,name:c,value:p,checked:N,required:h,disabled:m,form:f,style:{transform:"translateX(-100%)"}})]})});Ee.displayName=Ce;var Ie="SwitchThumb",Te=s.forwardRef((e,s)=>{const{__scopeSwitch:t,...n}=e,l=Pe(Ie,t);return a.jsx(r.span,{"data-state":De(l.checked),"data-disabled":l.disabled?"":void 0,...n,ref:s})});Te.displayName=Ie;var Me=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:l=!0,...o},i)=>{const c=s.useRef(null),d=t(c,i),u=Se(r),h=X(n);return s.useEffect(()=>{const e=c.current;if(!e)return;const s=window.HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(s,"checked").set;if(u!==r&&t){const s=new Event("click",{bubbles:l});t.call(e,r),e.dispatchEvent(s)}},[u,r,l]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:d,style:{...o.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function De(e){return e?"checked":"unchecked"}Me.displayName="SwitchBubbleInput";var Ae=Ee,Le=Te;const He=s.forwardRef(({className:e,...s},t)=>a.jsx(Ae,{className:i("peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:t,children:a.jsx(Le,{className:i("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));function Oe(e){const t=Ve(e),n=s.forwardRef((e,n)=>{const{children:r,...l}=e,o=s.Children.toArray(r),i=o.find(ze);if(i){const e=i.props.children,r=o.map(t=>t===i?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return a.jsx(t,{...l,ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,r):null})}return a.jsx(t,{...l,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ve(e){const t=s.forwardRef((e,t)=>{const{children:n,...a}=e;if(s.isValidElement(n)){const e=function(e){var s,t;let n=null==(s=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:s.get,a=n&&"isReactWarning"in n&&n.isReactWarning;if(a)return e.ref;if(n=null==(t=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:t.get,a=n&&"isReactWarning"in n&&n.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,s){const t={...s};for(const n in s){const a=e[n],r=s[n];/^on[A-Z]/.test(n)?a&&r?t[n]=(...e)=>{const s=r(...e);return a(...e),s}:a&&(t[n]=a):"style"===n?t[n]={...a,...r}:"className"===n&&(t[n]=[a,r].filter(Boolean).join(" "))}return{...e,...t}}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?c(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}He.displayName=Ae.displayName;var Fe=Symbol("radix.slottable");function ze(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Fe}var Be=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});s.forwardRef((e,s)=>a.jsx(r.span,{...e,ref:s,style:{...Be,...e.style}})).displayName="VisuallyHidden";var $e=[" ","Enter","ArrowUp","ArrowDown"],We=[" ","Enter"],Ke="Select",[Ue,qe,Ge]=te(Ke),[Ze]=o(Ke,[Ge,se]),Ye=se(),[Qe,Xe]=Ze(Ke),[Je,es]=Ze(Ke),ss=e=>{const{__scopeSelect:t,children:r,open:l,defaultOpen:o,onOpenChange:i,value:c,defaultValue:u,onValueChange:h,dir:m,name:p,autoComplete:x,disabled:f,required:g,form:v}=e,j=Ye(t),[b,y]=s.useState(null),[w,N]=s.useState(null),[k,S]=s.useState(!1),C=J(m),[_,R]=n({prop:l,defaultProp:o??!1,onChange:i,caller:Ke}),[P,E]=n({prop:c,defaultProp:u,onChange:h,caller:Ke}),I=s.useRef(null),T=!b||(v||!!b.closest("form")),[M,D]=s.useState(new Set),A=Array.from(M).map(e=>e.props.value).join(";");return a.jsx(ee,{...j,children:a.jsxs(Qe,{required:g,scope:t,trigger:b,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:d(),value:P,onValueChange:E,open:_,onOpenChange:R,dir:C,triggerPointerDownPosRef:I,disabled:f,children:[a.jsx(Ue.Provider,{scope:t,children:a.jsx(Je,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(s=>new Set(s).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(s=>{const t=new Set(s);return t.delete(e),t})},[]),children:r})}),T?a.jsxs(zs,{"aria-hidden":!0,required:g,tabIndex:-1,name:p,autoComplete:x,value:P,onChange:e=>E(e.target.value),disabled:f,form:v,children:[void 0===P?a.jsx("option",{value:""}):null,Array.from(M)]},A):null]})})};ss.displayName=Ke;var ts="SelectTrigger",ns=s.forwardRef((e,n)=>{const{__scopeSelect:o,disabled:i=!1,...c}=e,d=Ye(o),u=Xe(ts,o),h=u.disabled||i,m=t(n,u.onTriggerChange),p=qe(o),x=s.useRef("touch"),[f,g,v]=$s(e=>{const s=p().filter(e=>!e.disabled),t=s.find(e=>e.value===u.value),n=Ws(s,e,t);void 0!==n&&u.onValueChange(n.value)}),j=e=>{h||(u.onOpenChange(!0),v()),e&&(u.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return a.jsx(ne,{asChild:!0,...d,children:a.jsx(r.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:h,"data-disabled":h?"":void 0,"data-placeholder":Bs(u.value)?"":void 0,...c,ref:m,onClick:l(c.onClick,e=>{e.currentTarget.focus(),"mouse"!==x.current&&j(e)}),onPointerDown:l(c.onPointerDown,e=>{x.current=e.pointerType;const s=e.target;s.hasPointerCapture(e.pointerId)&&s.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(j(e),e.preventDefault())}),onKeyDown:l(c.onKeyDown,e=>{const s=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||g(e.key),s&&" "===e.key||$e.includes(e.key)&&(j(),e.preventDefault())})})})});ns.displayName=ts;var as="SelectValue",rs=s.forwardRef((e,s)=>{const{__scopeSelect:n,className:l,style:o,children:i,placeholder:c="",...d}=e,h=Xe(as,n),{onValueNodeHasChildrenChange:m}=h,p=void 0!==i,x=t(s,h.onValueNodeChange);return u(()=>{m(p)},[m,p]),a.jsx(r.span,{...d,ref:x,style:{pointerEvents:"none"},children:Bs(h.value)?a.jsx(a.Fragment,{children:c}):i})});rs.displayName=as;var ls=s.forwardRef((e,s)=>{const{__scopeSelect:t,children:n,...l}=e;return a.jsx(r.span,{"aria-hidden":!0,...l,ref:s,children:n||"▼"})});ls.displayName="SelectIcon";var os=e=>a.jsx(h,{asChild:!0,...e});os.displayName="SelectPortal";var is="SelectContent",cs=s.forwardRef((e,t)=>{const n=Xe(is,e.__scopeSelect),[r,l]=s.useState();if(u(()=>{l(new DocumentFragment)},[]),!n.open){const s=r;return s?m.createPortal(a.jsx(us,{scope:e.__scopeSelect,children:a.jsx(Ue.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),s):null}return a.jsx(ps,{...e,ref:t})});cs.displayName=is;var ds=10,[us,hs]=Ze(is),ms=Oe("SelectContent.RemoveScroll"),ps=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:c,onPointerDownOutside:d,side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:b,collisionBoundary:y,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S,...C}=e,_=Xe(is,r),[R,P]=s.useState(null),[E,I]=s.useState(null),T=t(n,e=>P(e)),[M,D]=s.useState(null),[A,L]=s.useState(null),H=qe(r),[O,V]=s.useState(!1),F=s.useRef(!1);s.useEffect(()=>{if(R)return x(R)},[R]),f();const z=s.useCallback(e=>{const[s,...t]=H().map(e=>e.ref.current),[n]=t.slice(-1),a=document.activeElement;for(const r of e){if(r===a)return;if(null==r||r.scrollIntoView({block:"nearest"}),r===s&&E&&(E.scrollTop=0),r===n&&E&&(E.scrollTop=E.scrollHeight),null==r||r.focus(),document.activeElement!==a)return}},[H,E]),B=s.useCallback(()=>z([M,R]),[z,M,R]);s.useEffect(()=>{O&&B()},[O,B]);const{onOpenChange:$,triggerPointerDownPosRef:W}=_;s.useEffect(()=>{if(R){let e={x:0,y:0};const s=s=>{var t,n;e={x:Math.abs(Math.round(s.pageX)-((null==(t=W.current)?void 0:t.x)??0)),y:Math.abs(Math.round(s.pageY)-((null==(n=W.current)?void 0:n.y)??0))}},t=t=>{e.x<=10&&e.y<=10?t.preventDefault():R.contains(t.target)||$(!1),document.removeEventListener("pointermove",s),W.current=null};return null!==W.current&&(document.addEventListener("pointermove",s),document.addEventListener("pointerup",t,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",t,{capture:!0})}}},[R,$,W]),s.useEffect(()=>{const e=()=>$(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[$]);const[K,U]=$s(e=>{const s=H().filter(e=>!e.disabled),t=s.find(e=>e.ref.current===document.activeElement),n=Ws(s,e,t);n&&setTimeout(()=>n.ref.current.focus())}),q=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&(D(e),n&&(F.current=!0))},[_.value]),G=s.useCallback(()=>null==R?void 0:R.focus(),[R]),Z=s.useCallback((e,s,t)=>{const n=!F.current&&!t;(void 0!==_.value&&_.value===s||n)&&L(e)},[_.value]),Y="popper"===o?fs:xs,Q=Y===fs?{side:u,sideOffset:h,align:m,alignOffset:p,arrowPadding:b,collisionBoundary:y,collisionPadding:w,sticky:N,hideWhenDetached:k,avoidCollisions:S}:{};return a.jsx(us,{scope:r,content:R,viewport:E,onViewportChange:I,itemRefCallback:q,selectedItem:M,onItemLeave:G,itemTextRefCallback:Z,focusSelectedItem:B,selectedItemText:A,position:o,isPositioned:O,searchRef:K,children:a.jsx(g,{as:ms,allowPinchZoom:!0,children:a.jsx(v,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:l(i,e=>{var s;null==(s=_.trigger)||s.focus({preventScroll:!0}),e.preventDefault()}),children:a.jsx(j,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:a.jsx(Y,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...C,...Q,onPlaced:()=>V(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:l(C.onKeyDown,e=>{const s=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),s||1!==e.key.length||U(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let s=H().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(s=s.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const t=e.target,n=s.indexOf(t);s=s.slice(n+1)}setTimeout(()=>z(s)),e.preventDefault()}})})})})})})});ps.displayName="SelectContentImpl";var xs=s.forwardRef((e,n)=>{const{__scopeSelect:l,onPlaced:o,...i}=e,c=Xe(is,l),d=hs(is,l),[h,m]=s.useState(null),[p,x]=s.useState(null),f=t(n,e=>x(e)),g=qe(l),v=s.useRef(!1),j=s.useRef(!0),{viewport:b,selectedItem:y,selectedItemText:w,focusSelectedItem:N}=d,k=s.useCallback(()=>{if(c.trigger&&c.valueNode&&h&&p&&b&&y&&w){const e=c.trigger.getBoundingClientRect(),s=p.getBoundingClientRect(),t=c.valueNode.getBoundingClientRect(),n=w.getBoundingClientRect();if("rtl"!==c.dir){const a=n.left-s.left,r=t.left-a,l=e.left-r,o=e.width+l,i=Math.max(o,s.width),c=window.innerWidth-ds,d=re(r,[ds,Math.max(ds,c-i)]);h.style.minWidth=o+"px",h.style.left=d+"px"}else{const a=s.right-n.right,r=window.innerWidth-t.right-a,l=window.innerWidth-e.right-r,o=e.width+l,i=Math.max(o,s.width),c=window.innerWidth-ds,d=re(r,[ds,Math.max(ds,c-i)]);h.style.minWidth=o+"px",h.style.right=d+"px"}const a=g(),r=window.innerHeight-2*ds,l=b.scrollHeight,i=window.getComputedStyle(p),d=parseInt(i.borderTopWidth,10),u=parseInt(i.paddingTop,10),m=parseInt(i.borderBottomWidth,10),x=d+u+l+parseInt(i.paddingBottom,10)+m,f=Math.min(5*y.offsetHeight,x),j=window.getComputedStyle(b),N=parseInt(j.paddingTop,10),k=parseInt(j.paddingBottom,10),S=e.top+e.height/2-ds,C=r-S,_=y.offsetHeight/2,R=d+u+(y.offsetTop+_),P=x-R;if(R<=S){const e=a.length>0&&y===a[a.length-1].ref.current;h.style.bottom="0px";const s=p.clientHeight-b.offsetTop-b.offsetHeight,t=R+Math.max(C,_+(e?k:0)+s+m);h.style.height=t+"px"}else{const e=a.length>0&&y===a[0].ref.current;h.style.top="0px";const s=Math.max(S,d+b.offsetTop+(e?N:0)+_)+P;h.style.height=s+"px",b.scrollTop=R-S+b.offsetTop}h.style.margin=`${ds}px 0`,h.style.minHeight=f+"px",h.style.maxHeight=r+"px",null==o||o(),requestAnimationFrame(()=>v.current=!0)}},[g,c.trigger,c.valueNode,h,p,b,y,w,c.dir,o]);u(()=>k(),[k]);const[S,C]=s.useState();u(()=>{p&&C(window.getComputedStyle(p).zIndex)},[p]);const _=s.useCallback(e=>{e&&!0===j.current&&(k(),null==N||N(),j.current=!1)},[k,N]);return a.jsx(gs,{scope:l,contentWrapper:h,shouldExpandOnScrollRef:v,onScrollButtonChange:_,children:a.jsx("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:a.jsx(r.div,{...i,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});xs.displayName="SelectItemAlignedPosition";var fs=s.forwardRef((e,s)=>{const{__scopeSelect:t,align:n="start",collisionPadding:r=ds,...l}=e,o=Ye(t);return a.jsx(ae,{...o,...l,ref:s,align:n,collisionPadding:r,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});fs.displayName="SelectPopperPosition";var[gs,vs]=Ze(is,{}),js="SelectViewport",bs=s.forwardRef((e,n)=>{const{__scopeSelect:o,nonce:i,...c}=e,d=hs(js,o),u=vs(js,o),h=t(n,d.onViewportChange),m=s.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),a.jsx(Ue.Slot,{scope:o,children:a.jsx(r.div,{"data-radix-select-viewport":"",role:"presentation",...c,ref:h,style:{position:"relative",flex:1,overflow:"hidden auto",...c.style},onScroll:l(c.onScroll,e=>{const s=e.currentTarget,{contentWrapper:t,shouldExpandOnScrollRef:n}=u;if((null==n?void 0:n.current)&&t){const e=Math.abs(m.current-s.scrollTop);if(e>0){const n=window.innerHeight-2*ds,a=parseFloat(t.style.minHeight),r=parseFloat(t.style.height),l=Math.max(a,r);if(l<n){const a=l+e,r=Math.min(n,a),o=a-r;t.style.height=r+"px","0px"===t.style.bottom&&(s.scrollTop=o>0?o:0,t.style.justifyContent="flex-end")}}}m.current=s.scrollTop})})})]})});bs.displayName=js;var ys="SelectGroup",[ws,Ns]=Ze(ys);s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,l=d();return a.jsx(ws,{scope:t,id:l,children:a.jsx(r.div,{role:"group","aria-labelledby":l,...n,ref:s})})}).displayName=ys;var ks="SelectLabel",Ss=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,l=Ns(ks,t);return a.jsx(r.div,{id:l.id,...n,ref:s})});Ss.displayName=ks;var Cs="SelectItem",[_s,Rs]=Ze(Cs),Ps=s.forwardRef((e,n)=>{const{__scopeSelect:o,value:i,disabled:c=!1,textValue:u,...h}=e,m=Xe(Cs,o),p=hs(Cs,o),x=m.value===i,[f,g]=s.useState(u??""),[v,j]=s.useState(!1),b=t(n,e=>{var s;return null==(s=p.itemRefCallback)?void 0:s.call(p,e,i,c)}),y=d(),w=s.useRef("touch"),N=()=>{c||(m.onValueChange(i),m.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(_s,{scope:o,value:i,disabled:c,textId:y,isSelected:x,onItemTextChange:s.useCallback(e=>{g(s=>s||((null==e?void 0:e.textContent)??"").trim())},[]),children:a.jsx(Ue.ItemSlot,{scope:o,value:i,disabled:c,textValue:f,children:a.jsx(r.div,{role:"option","aria-labelledby":y,"data-highlighted":v?"":void 0,"aria-selected":x&&v,"data-state":x?"checked":"unchecked","aria-disabled":c||void 0,"data-disabled":c?"":void 0,tabIndex:c?void 0:-1,...h,ref:b,onFocus:l(h.onFocus,()=>j(!0)),onBlur:l(h.onBlur,()=>j(!1)),onClick:l(h.onClick,()=>{"mouse"!==w.current&&N()}),onPointerUp:l(h.onPointerUp,()=>{"mouse"===w.current&&N()}),onPointerDown:l(h.onPointerDown,e=>{w.current=e.pointerType}),onPointerMove:l(h.onPointerMove,e=>{var s;w.current=e.pointerType,c?null==(s=p.onItemLeave)||s.call(p):"mouse"===w.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:l(h.onPointerLeave,e=>{var s;e.currentTarget===document.activeElement&&(null==(s=p.onItemLeave)||s.call(p))}),onKeyDown:l(h.onKeyDown,e=>{var s;""!==(null==(s=p.searchRef)?void 0:s.current)&&" "===e.key||(We.includes(e.key)&&N()," "===e.key&&e.preventDefault())})})})})});Ps.displayName=Cs;var Es="SelectItemText",Is=s.forwardRef((e,n)=>{const{__scopeSelect:l,className:o,style:i,...c}=e,d=Xe(Es,l),h=hs(Es,l),p=Rs(Es,l),x=es(Es,l),[f,g]=s.useState(null),v=t(n,e=>g(e),p.onItemTextChange,e=>{var s;return null==(s=h.itemTextRefCallback)?void 0:s.call(h,e,p.value,p.disabled)}),j=null==f?void 0:f.textContent,b=s.useMemo(()=>a.jsx("option",{value:p.value,disabled:p.disabled,children:j},p.value),[p.disabled,p.value,j]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=x;return u(()=>(y(b),()=>w(b)),[y,w,b]),a.jsxs(a.Fragment,{children:[a.jsx(r.span,{id:p.textId,...c,ref:v}),p.isSelected&&d.valueNode&&!d.valueNodeHasChildren?m.createPortal(c.children,d.valueNode):null]})});Is.displayName=Es;var Ts="SelectItemIndicator",Ms=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return Rs(Ts,t).isSelected?a.jsx(r.span,{"aria-hidden":!0,...n,ref:s}):null});Ms.displayName=Ts;var Ds="SelectScrollUpButton",As=s.forwardRef((e,n)=>{const r=hs(Ds,e.__scopeSelect),l=vs(Ds,e.__scopeSelect),[o,i]=s.useState(!1),c=t(n,l.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollTop>0;i(e)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?a.jsx(Os,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop-s.offsetHeight)}}):null});As.displayName=Ds;var Ls="SelectScrollDownButton",Hs=s.forwardRef((e,n)=>{const r=hs(Ls,e.__scopeSelect),l=vs(Ls,e.__scopeSelect),[o,i]=s.useState(!1),c=t(n,l.onScrollButtonChange);return u(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=s.scrollHeight-s.clientHeight,t=Math.ceil(s.scrollTop)<e;i(t)};const s=r.viewport;return e(),s.addEventListener("scroll",e),()=>s.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?a.jsx(Os,{...e,ref:c,onAutoScroll:()=>{const{viewport:e,selectedItem:s}=r;e&&s&&(e.scrollTop=e.scrollTop+s.offsetHeight)}}):null});Hs.displayName=Ls;var Os=s.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...i}=e,c=hs("SelectScrollButton",n),d=s.useRef(null),h=qe(n),m=s.useCallback(()=>{null!==d.current&&(window.clearInterval(d.current),d.current=null)},[]);return s.useEffect(()=>()=>m(),[m]),u(()=>{var e;const s=h().find(e=>e.ref.current===document.activeElement);null==(e=null==s?void 0:s.ref.current)||e.scrollIntoView({block:"nearest"})},[h]),a.jsx(r.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:l(i.onPointerDown,()=>{null===d.current&&(d.current=window.setInterval(o,50))}),onPointerMove:l(i.onPointerMove,()=>{var e;null==(e=c.onItemLeave)||e.call(c),null===d.current&&(d.current=window.setInterval(o,50))}),onPointerLeave:l(i.onPointerLeave,()=>{m()})})}),Vs=s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e;return a.jsx(r.div,{"aria-hidden":!0,...n,ref:s})});Vs.displayName="SelectSeparator";var Fs="SelectArrow";s.forwardRef((e,s)=>{const{__scopeSelect:t,...n}=e,r=Ye(t),l=Xe(Fs,t),o=hs(Fs,t);return l.open&&"popper"===o.position?a.jsx(le,{...r,...n,ref:s}):null}).displayName=Fs;var zs=s.forwardRef(({__scopeSelect:e,value:n,...l},o)=>{const i=s.useRef(null),c=t(o,i),d=Se(n);return s.useEffect(()=>{const e=i.current;if(!e)return;const s=window.HTMLSelectElement.prototype,t=Object.getOwnPropertyDescriptor(s,"value").set;if(d!==n&&t){const s=new Event("change",{bubbles:!0});t.call(e,n),e.dispatchEvent(s)}},[d,n]),a.jsx(r.select,{...l,style:{...Be,...l.style},ref:c,defaultValue:n})});function Bs(e){return""===e||void 0===e}function $s(e){const t=p(e),n=s.useRef(""),a=s.useRef(0),r=s.useCallback(e=>{const s=n.current+e;t(s),function e(s){n.current=s,window.clearTimeout(a.current),""!==s&&(a.current=window.setTimeout(()=>e(""),1e3))}(s)},[t]),l=s.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,r,l]}function Ws(e,s,t){const n=s.length>1&&Array.from(s).every(e=>e===s[0])?s[0]:s,a=t?e.indexOf(t):-1;let r=(l=e,o=Math.max(a,0),l.map((e,s)=>l[(o+s)%l.length]));var l,o;1===n.length&&(r=r.filter(e=>e!==t));const i=r.find(e=>e.textValue.toLowerCase().startsWith(n.toLowerCase()));return i!==t?i:void 0}zs.displayName="SelectBubbleInput";var Ks=ns,Us=ls,qs=os,Gs=cs,Zs=bs,Ys=Ss,Qs=Ps,Xs=Is,Js=Ms,et=As,st=Hs,tt=Vs;const nt=ss,at=rs,rt=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(Ks,{ref:n,className:i("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...t,children:[s,a.jsx(Us,{asChild:!0,children:a.jsx(pe,{className:"h-4 w-4 opacity-50"})})]}));rt.displayName=Ks.displayName;const lt=s.forwardRef(({className:e,...s},t)=>a.jsx(et,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(xe,{className:"h-4 w-4"})}));lt.displayName=et.displayName;const ot=s.forwardRef(({className:e,...s},t)=>a.jsx(st,{ref:t,className:i("flex cursor-default items-center justify-center py-1",e),...s,children:a.jsx(pe,{className:"h-4 w-4"})}));ot.displayName=st.displayName;const it=s.forwardRef(({className:e,children:s,position:t="popper",...n},r)=>a.jsx(qs,{children:a.jsxs(Gs,{ref:r,className:i("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===t&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:t,...n,children:[a.jsx(lt,{}),a.jsx(Zs,{className:i("p-1","popper"===t&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),a.jsx(ot,{})]})}));it.displayName=Gs.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx(Ys,{ref:t,className:i("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s})).displayName=Ys.displayName;const ct=s.forwardRef(({className:e,children:s,...t},n)=>a.jsxs(Qs,{ref:n,className:i("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Js,{children:a.jsx(b,{className:"h-4 w-4"})})}),a.jsx(Xs,{children:s})]}));ct.displayName=Qs.displayName;s.forwardRef(({className:e,...s},t)=>a.jsx(tt,{ref:t,className:i("-mx-1 my-1 h-px bg-muted",e),...s})).displayName=tt.displayName;function dt(){const[e,t]=s.useState(null),[n,r]=s.useState(!0),[l,o]=s.useState(!1),[i,c]=s.useState(!1),[d,u]=s.useState(!1),[h,m]=s.useState(!1),[p,x]=s.useState(null),[f,g]=s.useState(0),[v,j]=s.useState(""),[b,D]=s.useState("");y({onStart:e=>{x(e.projectId),g(0)},onProgress:e=>{x(e.projectId),g(e.filesTransferred)},onDone:()=>{x(null),g(0)}}),s.useEffect(()=>{let e=!1;return w().then(s=>{e||(t(s),D(s.defaultExcludes.join("\n")))}).catch(e=>N.error(`加载同步配置失败: ${e.message}`)).finally(()=>{e||r(!1)}),()=>{e=!0}},[]);const A=(e,s)=>{t(t=>t?{...t,[e]:s}:t)};return n||!e?a.jsx("div",{className:"text-sm text-muted-foreground",children:"加载中…"}):a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"服务器配置"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-host",children:"主机 (host)"}),a.jsx(S,{id:"sync-host",value:e.host,onChange:e=>A("host",e.target.value),placeholder:"example.com"})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-port",children:"端口"}),a.jsx(S,{id:"sync-port",type:"number",value:e.port,onChange:e=>A("port",Number(e.target.value)||22)})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-user",children:"用户名"}),a.jsx(S,{id:"sync-user",value:e.user,onChange:e=>A("user",e.target.value),placeholder:"tom"})]}),a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-remote",children:"远端根路径"}),a.jsx(S,{id:"sync-remote",value:e.remoteRoot,onChange:e=>A("remoteRoot",e.target.value),placeholder:"/data/projects"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["每个项目会同步到 ",a.jsx("code",{children:"远端路径/项目文件夹"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"认证"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{children:"方式"}),a.jsxs(nt,{value:e.authMethod,onValueChange:e=>A("authMethod",e),children:[a.jsx(rt,{children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"key",children:"SSH key"}),a.jsx(ct,{value:"password",children:"密码"})]})]})]}),"key"===e.authMethod?a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-key",children:"私钥路径"}),a.jsx(S,{id:"sync-key",value:e.keyPath??"",onChange:e=>A("keyPath",e.target.value),placeholder:"~/.ssh/id_rsa"})]}):a.jsxs("div",{children:[a.jsx(k,{htmlFor:"sync-pw",children:"密码"}),a.jsx(S,{id:"sync-pw",type:"password",value:v,onChange:e=>j(e.target.value),placeholder:e.passwordSet?"已设置,留空保持不变":"未设置"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["需要系统安装 ",a.jsx("code",{children:"sshpass"}),"(密码通过 SSHPASS env 传递,不会出现在 argv 里)"]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"同步策略"}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(k,{children:"方向"}),a.jsxs(nt,{value:e.direction,onValueChange:e=>A("direction",e),children:[a.jsx(rt,{children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"push",children:"单向:本地 → 远端(--delete)"}),a.jsx(ct,{value:"pull",children:"单向:远端 → 本地"}),a.jsx(ct,{value:"bidirectional",children:"双向(先 push 再 pull)"})]})]})]}),a.jsxs("div",{className:"flex items-end gap-2",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(k,{htmlFor:"sync-cron",children:"定时 cron 表达式"}),a.jsx(S,{id:"sync-cron",value:e.schedule.cron,onChange:s=>A("schedule",{...e.schedule,cron:s.target.value}),placeholder:"0 3 * * *"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["5 段:分 时 日 月 周。例:",a.jsx("code",{children:"0 3 * * *"})," 每天 03:00"]})]}),a.jsxs("div",{className:"flex items-center gap-2 pb-1.5",children:[a.jsx(He,{checked:e.schedule.enabled,onCheckedChange:s=>A("schedule",{...e.schedule,enabled:s})}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"启用"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-3",children:"默认排除(每行一个 glob)"}),a.jsx("textarea",{value:b,onChange:e=>D(e.target.value),rows:6,className:"w-full font-mono text-xs p-2 rounded border border-input bg-background resize-y",placeholder:"node_modules/\n.git/objects/\n*.log"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["作为 ",a.jsx("code",{children:"rsync --exclude"})," 传入。项目级的额外排除暂通过 API 设置。"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 pt-2 border-t",children:[a.jsxs(C,{onClick:()=>{(async()=>{if(e){o(!0);try{const s=b.split("\n").map(e=>e.trim()).filter(Boolean),n={host:e.host,port:e.port,user:e.user,authMethod:e.authMethod,keyPath:e.keyPath,remoteRoot:e.remoteRoot,direction:e.direction,defaultExcludes:s,schedule:e.schedule};v&&"__keep__"!==v&&(n.password=v);const a=await E(n);t(a),D(a.defaultExcludes.join("\n")),j(""),N.success("已保存")}catch(s){N.error(`保存失败: ${s.message}`)}finally{o(!1)}}})()},disabled:l,children:[l?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]}),a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{c(!0);try{const e=await I();e.ok?N.success(e.message||"连接成功"):N.error(e.message||"连接失败")}catch(e){N.error(`测试失败: ${e.message}`)}finally{c(!1)}})()},disabled:i,children:[i?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(Ne,{className:"h-3.5 w-3.5 mr-1.5"}),"测试连接"]}),a.jsx("div",{className:"flex-1"}),d&&p&&a.jsx("span",{className:"text-xs text-muted-foreground self-center mr-1 tabular-nums",children:f>0?`同步中: ${p} (${f} 文件)`:`同步中: ${p}`}),a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{u(!0);try{const e=await T(),s=e.results.filter(e=>e.ok).length,t=e.results.filter(e=>e.skipped).length,n=e.results.filter(e=>"cancelled"===e.reason).length,a=e.total-s-t-n;n>0?N.info(`已取消:${s} 成功 / ${t} 跳过 / ${n} 取消 / ${a} 失败`):N.success(`同步完成:${s} 成功 / ${t} 跳过 / ${a} 失败`)}catch(e){N.error(`同步失败: ${e.message}`)}finally{u(!1),m(!1),x(null),g(0)}})()},disabled:d,title:"按当前方向同步所有项目",children:[d?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(ie,{className:"h-3.5 w-3.5 mr-1.5"}),"立即同步全部"]}),d&&a.jsxs(C,{variant:"outline",onClick:()=>{(async()=>{if(d&&!h){m(!0);try{await M(),N.info("已请求取消")}catch(e){N.error(`取消失败: ${e.message}`),m(!1)}}})()},disabled:h,title:"取消批量同步:SIGTERM 当前 rsync 并停止后续项目",children:[h?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(R,{className:"h-3.5 w-3.5 mr-1.5"}),"取消"]})]}),a.jsxs("div",{className:"border-t pt-4 text-xs text-muted-foreground",children:["一次性 push/pull 工具:进入项目内部,点击 header 的 ",a.jsx(ie,{className:"inline h-3 w-3"})," / ",a.jsx(P,{className:"inline h-3 w-3"})," 按钮。 或通过 API 调用 ",a.jsx("code",{children:"POST /api/sync/project/:id"})," with body ",a.jsx("code",{children:'{ "direction": "push" }'}),"。"]})]})}function ut(){const e=D(),[t,n]=s.useState(null),[r,l]=s.useState(!0),[o,i]=s.useState(""),[c,d]=s.useState(!1);s.useEffect(()=>{let e=!1;return A().then(s=>{e||n(s)}).catch(()=>{e||n({configured:!1,needsReset:!1})}).finally(()=>{e||l(!1)}),()=>{e=!0}},[]);return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-semibold mb-1",children:"CCWeb Hub 直接提交"}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:['配置你的 GitHub PAT 后,在 Quick Prompts / Agent Prompts 卡片右键选择"共享"时可一键直接提交 Issue 到 ',a.jsx("code",{children:"zbc0315/ccweb-hub"}),"。 ccweb 本身不自带 token —— 使用你自己的账号身份提交,归属清晰,互不影响。"]})]}),r?a.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[a.jsx(_,{className:"h-4 w-4 animate-spin"}),"加载中…"]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"rounded-md border px-3 py-2.5 text-xs flex items-center gap-2",children:(null==t?void 0:t.configured)?a.jsxs(a.Fragment,{children:[a.jsx(fe,{className:"h-4 w-4 text-green-500 shrink-0"}),a.jsx("span",{children:"已配置 token,可直接提交"}),a.jsx("div",{className:"flex-1"}),a.jsxs(C,{size:"sm",variant:"outline",onClick:()=>{(async()=>{if(await e({title:"清除 Hub Token",description:"清除后将无法直接提交到 ccweb-hub,需要重新配置 token。确认?",destructive:!0,confirmLabel:"清除"}))try{await H(),n({configured:!1,needsReset:!1}),N.success("已清除")}catch(s){N.error(`清除失败: ${s.message}`)}})()},children:[a.jsx(L,{className:"h-3.5 w-3.5 mr-1"}),"清除"]})]}):(null==t?void 0:t.needsReset)?a.jsxs(a.Fragment,{children:[a.jsx(ve,{className:"h-4 w-4 text-amber-500 shrink-0"}),a.jsx("span",{children:"之前的 token 已失效(服务端密钥可能已轮换),请重新设置"})]}):a.jsxs(a.Fragment,{children:[a.jsx(ve,{className:"h-4 w-4 text-muted-foreground shrink-0"}),a.jsx("span",{children:"尚未配置 token"})]})}),a.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2.5 text-xs space-y-2",children:[a.jsx("div",{className:"font-medium text-foreground",children:"如何获取 token"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-muted-foreground",children:[a.jsxs("li",{children:["打开"," ",a.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline inline-flex items-center gap-0.5",children:["GitHub fine-grained PAT",a.jsx(be,{className:"h-3 w-3"})]})," ","创建页"]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository access"}),':选 "Only select repositories",添加 ',a.jsx("code",{children:"zbc0315/ccweb-hub"})]}),a.jsxs("li",{children:[a.jsx("strong",{className:"text-foreground",children:"Repository permissions → Issues"}),':设置为 "Read and write"']}),a.jsx("li",{children:"其余权限保持默认(全部无访问)"}),a.jsx("li",{children:"生成后复制 token 粘贴到下方"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(k,{htmlFor:"hub-token",className:"text-xs",children:["GitHub Token ",(null==t?void 0:t.configured)&&a.jsx("span",{className:"text-muted-foreground",children:"(填写会覆盖现有 token)"})]}),a.jsx(S,{id:"hub-token",type:"password",placeholder:"github_pat_...",value:o,onChange:e=>i(e.target.value),autoComplete:"off",spellCheck:!1}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Token 以 AES-256-GCM 加密存储于 ",a.jsx("code",{children:"~/.ccweb/hub-auth/"}),";per-user 独立,不会被其他用户读到。"]})]}),a.jsx("div",{className:"flex gap-2 pt-2 border-t",children:a.jsxs(C,{onClick:()=>{(async()=>{const e=o.trim();if(e){d(!0);try{const s=await O(e);n(s),i(""),N.success("已保存")}catch(s){N.error(`保存失败: ${s.message}`)}finally{d(!1)}}else N.error("请输入 token")})()},disabled:c||!o.trim(),children:[c?a.jsx(_,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"保存"]})})]})]})}function ht(){const{t:e,i18n:s}=ce();return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(we,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs(nt,{value:s.language,onValueChange:async t=>{if(V.includes(t)){try{localStorage.setItem(F,t)}catch{}await s.changeLanguage(t);try{await z(t)}catch{N.error(e("language.switch_failed"))}}},children:[a.jsx(rt,{className:"w-40",children:a.jsx(at,{})}),a.jsxs(it,{children:[a.jsx(ct,{value:"zh",children:e("language.zh")}),a.jsx(ct,{value:"en",children:e("language.en")})]})]})]})}function mt(){const{t:e}=ce(),t=B(),[n]=$(),r=n.get("tab")||"sync",[l,o]=s.useState(()=>W()),[i,c]=s.useState(!1),[d,u]=s.useState({webhookEnabled:!1}),[h,m]=s.useState(""),[p,x]=s.useState(!1),[f,g]=s.useState(()=>K(U.usageMonitorTool,"claude"));s.useEffect(()=>{q().then(e=>{u(e),m(e.webhookUrl??"")}).catch(()=>{})},[]);const v=(e,s)=>{const t=parseInt(s,10);isNaN(t)||t<1||(o(s=>({...s,[e]:t})),c(!0))};return a.jsx("div",{className:"min-h-screen bg-background",children:a.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[a.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>t("/"),children:[a.jsx(G,{className:"h-4 w-4 mr-1"}),e("common.back")]}),a.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:e("settings.title")})]}),a.jsxs(de,{defaultValue:r,children:[a.jsxs(ue,{className:"mb-4",children:[a.jsxs(he,{value:"sync",children:[a.jsx(ke,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_sync")]}),a.jsxs(he,{value:"hub",children:[a.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_hub")]}),a.jsxs(he,{value:"notifications",children:[a.jsx(je,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_notifications")]}),a.jsxs(he,{value:"pomodoro",children:[a.jsx(Z,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_pomodoro")]}),a.jsxs(he,{value:"usage",children:[a.jsx(ge,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_usage")]}),a.jsxs(he,{value:"language",children:[a.jsx(we,{className:"h-3.5 w-3.5 mr-1.5"}),e("settings.tab_language")]})]}),a.jsx(me,{value:"sync",children:a.jsx(dt,{})}),a.jsx(me,{value:"hub",children:a.jsx(ut,{})}),a.jsx(me,{value:"notifications",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.browser_notify.title")}),a.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.browser_notify.description")})]}),a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.webhook.title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.webhook.description")})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:"Webhook URL"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(S,{placeholder:"https://hooks.slack.com/...",value:h,onChange:e=>m(e.target.value),className:"font-mono text-xs"}),a.jsx(C,{size:"sm",onClick:()=>{(async()=>{x(!0);try{const s=await Q({webhookEnabled:h.trim().length>0,webhookUrl:h.trim()||void 0});u(s),N.success(e("settings.webhook.saved"))}catch{N.error(e("settings.webhook.save_failed"))}finally{x(!1)}})()},disabled:p,children:e(p?"common.saving":"common.save")})]}),d.webhookEnabled&&d.webhookUrl&&a.jsxs("p",{className:"text-xs text-green-500",children:[e("settings.webhook.enabled_prefix")," ",d.webhookUrl]})]})]})]})}),a.jsx(me,{value:"pomodoro",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.pomodoro.section_desc")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-6 max-w-xs",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:e("settings.pomodoro.work_minutes")}),a.jsx(S,{type:"number",min:1,max:120,value:l.workMinutes,onChange:e=>v("workMinutes",e.target.value),className:"w-full"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(k,{className:"text-xs",children:e("settings.pomodoro.break_minutes")}),a.jsx(S,{type:"number",min:1,max:60,value:l.breakMinutes,onChange:e=>v("breakMinutes",e.target.value),className:"w-full"})]})]}),i&&a.jsxs(C,{size:"sm",onClick:()=>{Y(U.pomodoroConfig,l,!0),c(!1),N.success(e("settings.pomodoro.saved"))},children:[a.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),e("common.save")]})]}),a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.pomodoro.howto_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsxs("li",{children:[a.jsx(Z,{className:"h-3 w-3 inline-block mx-0.5"})," ",e("settings.pomodoro.howto_item_1")]}),a.jsx("li",{children:e("settings.pomodoro.howto_item_2")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_3")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_4")}),a.jsx("li",{children:e("settings.pomodoro.howto_item_5")})]})]})]})}),a.jsx(me,{value:"usage",children:a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.section_title")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e("settings.usage.section_desc")})]}),a.jsx("div",{className:"grid gap-3 max-w-md",children:[{key:"claude",label:"Claude Code",desc:e("settings.usage.tool_claude_desc")},{key:"codex",label:"Codex",desc:e("settings.usage.tool_codex_desc")},{key:"opencode",label:"OpenCode",desc:e("settings.usage.tool_opencode_desc")},{key:"qwen",label:"Qwen Code",desc:e("settings.usage.tool_qwen_desc")},{key:"gemini",label:"Gemini CLI",desc:e("settings.usage.tool_gemini_desc")}].map(s=>a.jsxs("label",{className:"flex items-start gap-3 rounded-md border p-3 cursor-pointer transition-colors "+(f===s.key?"border-blue-500/50 bg-blue-500/5":"border-border hover:bg-muted/30"),children:[a.jsx("input",{type:"radio",name:"usageTool",value:s.key,checked:f===s.key,onChange:()=>{g(s.key),Y(U.usageMonitorTool,s.key),window.dispatchEvent(new Event("ccweb:usage-tool-change")),N.success(e("settings.usage.switched_toast",{tool:s.label}))},className:"mt-0.5"}),a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:s.label}),a.jsx("div",{className:"text-xs text-muted-foreground",children:s.desc})]})]},s.key))})]}),a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-2",children:[a.jsx("h3",{className:"text-sm font-medium",children:e("settings.usage.info_title")}),a.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 list-disc list-inside",children:[a.jsx("li",{children:e("settings.usage.info_item_1")}),a.jsx("li",{children:e("settings.usage.info_item_2")}),a.jsx("li",{children:e("settings.usage.info_item_3")}),a.jsx("li",{children:e("settings.usage.info_item_4")})]})]})]})}),a.jsx(me,{value:"language",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-3",children:[a.jsx("div",{children:a.jsx("h3",{className:"text-sm font-medium",children:e("language.label")})}),a.jsx(ht,{})]})})})]})]})})}export{mt as SettingsPage};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{c as e,
|
|
1
|
+
import{c as e,ay as s,r as t,bh as a,bi as r,t as l,bj as n,bk as i,bl as c,a5 as d,bm as o,j as m,B as x,aA as u,d as p,I as h,T as g,p as f,D as j,av as b,aw as N,A as y,ah as v,an as k}from"./index-CmAWu5B1.js";import{S as w}from"./search-cUgNWB9T.js";import{C}from"./chevron-down-ClSQun3W.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const S=e("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),P=e("Puzzle",[["path",{d:"M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z",key:"i0oyt7"}]]),
|
|
7
|
+
*/const S=e("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),P=e("Puzzle",[["path",{d:"M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z",key:"i0oyt7"}]]),A=e("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]),E=e("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);
|
|
8
8
|
/**
|
|
9
9
|
* @license lucide-react v0.309.0 - ISC
|
|
10
10
|
*
|
|
11
11
|
* This source code is licensed under the ISC license.
|
|
12
12
|
* See the LICENSE file in the root directory of this source tree.
|
|
13
|
-
*/function q(){const e=s(),[q,M]=t.useState("prompts"),[H,_]=t.useState(""),[F,Q]=t.useState([]),[W,I]=t.useState([]),[O,T]=t.useState(!1),[U,Z]=t.useState(null);t.useEffect(()=>{"plugins"===q&&(T(!0),Promise.all([a().catch(()=>[]),fetch("/api/skillhub/plugins").then(e=>e.ok?e.json():[]).catch(()=>[])]).then(([e,s])=>{Q(e),I(s)}).finally(()=>T(!1)))},[q]);const B=t.useCallback(async e=>{if(!U){Z(e.id);try{await r(e.downloadUrl),l.success(`已安装 ${e.name}`);const s=await a().catch(()=>[]);Q(s)}catch(s){l.error(s instanceof Error?s.message:"安装失败")}finally{Z(null)}}},[U]),D=t.useCallback(async e=>{try{await n(e),Q(s=>s.filter(s=>s.id!==e)),l.success("已卸载")}catch(s){l.error(s instanceof Error?s.message:"卸载失败")}},[]),$=t.useCallback(async(e,s)=>{try{await i(e,s),Q(t=>t.map(t=>t.id===e?{...t,enabled:s}:t))}catch(t){l.error(t instanceof Error?t.message:"操作失败")}},[]),[G,J]=t.useState([]),[K,R]=t.useState(!0),[V,X]=t.useState(null),[Y,ee]=t.useState("all"),[se,te]=t.useState(null),[ae,re]=t.useState(null),[le,ne]=t.useState(new Set),[ie,ce]=t.useState(null);t.useEffect(()=>{Promise.all([c(),d().catch(()=>[]),o().catch(()=>[])]).then(([e,s,t])=>{J(e);const a=new Set;for(const r of e)"quick-prompt"===r.kind?s.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id):t.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id);ne(a)}).catch(e=>X(e instanceof Error?e.message:"Failed to load CCWeb Hub")).finally(()=>R(!1))},[]);const de=t.useMemo(()=>{const e=new Set;return G.forEach(s=>{var t;return null==(t=s.tags)?void 0:t.forEach(s=>e.add(s))}),[...e].sort()},[G]),oe=t.useMemo(()=>{let e=G;"all"!==Y&&(e=e.filter(e=>e.kind===Y)),"__untagged__"===se?e=e.filter(e=>!e.tags||0===e.tags.length):se&&(e=e.filter(e=>{var s;return null==(s=e.tags)?void 0:s.includes(se)}));const s=H.trim().toLowerCase();return s&&(e=e.filter(e=>e.label.toLowerCase().includes(s)||e.body.toLowerCase().includes(s)||(e.description??"").toLowerCase().includes(s)||(e.author??"").toLowerCase().includes(s)||(e.tags??[]).some(e=>e.toLowerCase().includes(s)))),e},[G,Y,se,H]);return m.jsxs("div",{className:"min-h-screen bg-background",children:[m.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[m.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[m.jsx(u,{className:"h-4 w-4 mr-1"}),"返回"]}),m.jsx("h1",{className:"font-semibold text-lg",children:"CCWeb Hub"}),m.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[m.jsx("button",{onClick:()=>M("prompts"),className:p("px-3 py-1 rounded-md text-sm transition-colors","prompts"===q?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:"Prompts"}),m.jsxs("button",{onClick:()=>M("plugins"),className:p("px-3 py-1 rounded-md text-sm transition-colors flex items-center gap-1","plugins"===q?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:[m.jsx(P,{className:"h-3.5 w-3.5"}),"插件"]})]}),m.jsx("div",{className:"flex-1"}),m.jsxs("div",{className:"relative w-64",children:[m.jsx(w,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),m.jsx(h,{placeholder:"prompts"===q?"搜索 prompt...":"搜索插件...",value:H,onChange:e=>_(e.target.value),className:"pl-8 h-9"})]})]})}),m.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:["plugins"===q&&m.jsxs("div",{children:[O&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),!O&&m.jsxs(m.Fragment,{children:[F.length>0&&m.jsxs("div",{className:"mb-8",children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:"已安装"}),m.jsx("div",{className:"space-y-2",children:F.map(e=>m.jsxs("div",{className:"rounded-lg border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsx("span",{className:p("text-xs px-1.5 py-0.5 rounded",e.enabled?"bg-green-500/10 text-green-500":"bg-muted text-muted-foreground"),children:e.enabled?"启用":"禁用"})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>$(e.id,!e.enabled),title:e.enabled?"禁用":"启用",children:m.jsx(S,{className:p("h-4 w-4",e.enabled?"text-green-500":"text-muted-foreground")})}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>D(e.id),title:"卸载",children:m.jsx(g,{className:"h-4 w-4 text-red-400"})})]},e.id))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:F.length>0?"更多插件":"可用插件"}),0===W.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx(P,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),m.jsx("p",{className:"text-sm",children:"Hub 暂无可用插件"})]}),m.jsx("div",{className:"space-y-2",children:W.filter(e=>!F.some(s=>s.id===e.id)).map((e,s)=>{const t=U===e.id;return m.jsxs(f.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s},className:"rounded-lg border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",e.author]})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsxs(x,{size:"sm",disabled:t,onClick:()=>B(e),children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),t?"安装中...":"安装"]})]},e.id)})})]})]})]}),"prompts"===q&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[m.jsx(A,{active:"all"===Y,onClick:()=>ee("all"),children:"全部"}),m.jsxs(A,{active:"quick-prompt"===Y,onClick:()=>ee("quick-prompt"),children:[m.jsx(b,{className:"h-3 w-3"}),"Quick Prompts"]}),m.jsxs(A,{active:"agent-prompt"===Y,onClick:()=>ee("agent-prompt"),children:[m.jsx(N,{className:"h-3 w-3"}),"Agent Prompts"]})]}),de.length>0&&m.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[m.jsx(L,{active:null===se,onClick:()=>te(null),children:"全部标签"}),de.map(e=>m.jsx(L,{active:se===e,onClick:()=>te(se===e?null:e),children:e},e))]}),K&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),V&&m.jsx("div",{className:"text-center text-destructive py-20",children:V}),!K&&!V&&0===G.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx("p",{className:"text-lg mb-2",children:"CCWeb Hub 还没有 prompt"}),m.jsx("p",{className:"text-sm",children:'在 Quick Prompts 或 Agent Prompts 卡片上右键选择"共享"来提交第一个吧!'})]}),!K&&!V&&G.length>0&&0===oe.length&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的 prompt"}),m.jsx("div",{className:"space-y-3",children:oe.map((e,s)=>{var t;const a=ae===e.id,r=le.has(e.id),n=ie===e.id;return m.jsxs(f.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s,ease:"easeOut"},className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>re(a?null:e.id),children:[m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[m.jsxs("span",{className:p("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium","quick-prompt"===e.kind?"bg-blue-500/15 text-blue-400":"bg-green-500/15 text-green-500"),children:["quick-prompt"===e.kind?m.jsx(b,{className:"h-2.5 w-2.5"}):m.jsx(N,{className:"h-2.5 w-2.5"}),"quick-prompt"===e.kind?"Quick":"Agent"]}),m.jsx("h3",{className:"font-medium text-sm truncate",children:e.label}),null==(t=e.tags)?void 0:t.map(e=>m.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[m.jsx(z,{className:"h-2.5 w-2.5"}),e]},e))]}),e.description&&m.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:e.description}),m.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.author&&m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(E,{className:"h-3 w-3"}),e.author]}),m.jsx("code",{className:"text-[10px] opacity-60",children:e.file})]})]}),m.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxs(x,{size:"sm",variant:r?"outline":"default",disabled:n||r,onClick:s=>{(async(e,s)=>{if(s.stopPropagation(),!ie&&!le.has(e.id)){ce(e.id);try{"quick-prompt"===e.kind?(await v({label:e.label,command:e.body}),l.success("已导入到全局快捷 Prompts")):(await k({label:e.label,command:e.body}),l.success("已导入到全局 Agent Prompts")),ne(s=>new Set(s).add(e.id))}catch(t){l.error(t instanceof Error?t.message:"导入失败")}finally{ce(null)}}})(e,s)},title:"quick-prompt"===e.kind?"导入到全局快捷 Prompts":"导入到全局 Agent Prompts",children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),r?"已导入":n?"导入中...":"导入"]}),m.jsx(f.span,{animate:{rotate:a?180:0},transition:{duration:.2},children:m.jsx(C,{className:"h-4 w-4 text-muted-foreground"})})]})]}),m.jsx(y,{children:a&&m.jsx(f.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:m.jsx("div",{className:"mt-3 pt-3 border-t",children:m.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:e.body})})})})]},e.id)})})]})]})]})}function A({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("flex items-center gap-1 px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}function L({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}export{q as SkillHubPage};
|
|
13
|
+
*/function q(){const e=s(),[q,M]=t.useState("prompts"),[H,_]=t.useState(""),[F,Q]=t.useState([]),[W,I]=t.useState([]),[O,T]=t.useState(!1),[U,Z]=t.useState(null);t.useEffect(()=>{"plugins"===q&&(T(!0),Promise.all([a().catch(()=>[]),fetch("/api/skillhub/plugins").then(e=>e.ok?e.json():[]).catch(()=>[])]).then(([e,s])=>{Q(e),I(s)}).finally(()=>T(!1)))},[q]);const B=t.useCallback(async e=>{if(!U){Z(e.id);try{await r(e.downloadUrl),l.success(`已安装 ${e.name}`);const s=await a().catch(()=>[]);Q(s)}catch(s){l.error(s instanceof Error?s.message:"安装失败")}finally{Z(null)}}},[U]),D=t.useCallback(async e=>{try{await n(e),Q(s=>s.filter(s=>s.id!==e)),l.success("已卸载")}catch(s){l.error(s instanceof Error?s.message:"卸载失败")}},[]),$=t.useCallback(async(e,s)=>{try{await i(e,s),Q(t=>t.map(t=>t.id===e?{...t,enabled:s}:t))}catch(t){l.error(t instanceof Error?t.message:"操作失败")}},[]),[G,J]=t.useState([]),[K,R]=t.useState(!0),[V,X]=t.useState(null),[Y,ee]=t.useState("all"),[se,te]=t.useState(null),[ae,re]=t.useState(null),[le,ne]=t.useState(new Set),[ie,ce]=t.useState(null);t.useEffect(()=>{Promise.all([c(),d().catch(()=>[]),o().catch(()=>[])]).then(([e,s,t])=>{J(e);const a=new Set;for(const r of e)"quick-prompt"===r.kind?s.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id):t.some(e=>e.label===r.label&&e.command===r.body)&&a.add(r.id);ne(a)}).catch(e=>X(e instanceof Error?e.message:"Failed to load CCWeb Hub")).finally(()=>R(!1))},[]);const de=t.useMemo(()=>{const e=new Set;return G.forEach(s=>{var t;return null==(t=s.tags)?void 0:t.forEach(s=>e.add(s))}),[...e].sort()},[G]),oe=t.useMemo(()=>{let e=G;"all"!==Y&&(e=e.filter(e=>e.kind===Y)),"__untagged__"===se?e=e.filter(e=>!e.tags||0===e.tags.length):se&&(e=e.filter(e=>{var s;return null==(s=e.tags)?void 0:s.includes(se)}));const s=H.trim().toLowerCase();return s&&(e=e.filter(e=>e.label.toLowerCase().includes(s)||e.body.toLowerCase().includes(s)||(e.description??"").toLowerCase().includes(s)||(e.author??"").toLowerCase().includes(s)||(e.tags??[]).some(e=>e.toLowerCase().includes(s)))),e},[G,Y,se,H]);return m.jsxs("div",{className:"min-h-screen bg-background",children:[m.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[m.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[m.jsx(u,{className:"h-4 w-4 mr-1"}),"返回"]}),m.jsx("h1",{className:"font-semibold text-lg",children:"CCWeb Hub"}),m.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[m.jsx("button",{onClick:()=>M("prompts"),className:p("px-3 py-1 rounded-md text-sm transition-colors","prompts"===q?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:"Prompts"}),m.jsxs("button",{onClick:()=>M("plugins"),className:p("px-3 py-1 rounded-md text-sm transition-colors flex items-center gap-1","plugins"===q?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent"),children:[m.jsx(P,{className:"h-3.5 w-3.5"}),"插件"]})]}),m.jsx("div",{className:"flex-1"}),m.jsxs("div",{className:"relative w-64",children:[m.jsx(w,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),m.jsx(h,{placeholder:"prompts"===q?"搜索 prompt...":"搜索插件...",value:H,onChange:e=>_(e.target.value),className:"pl-8 h-9"})]})]})}),m.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:["plugins"===q&&m.jsxs("div",{children:[O&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),!O&&m.jsxs(m.Fragment,{children:[F.length>0&&m.jsxs("div",{className:"mb-8",children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:"已安装"}),m.jsx("div",{className:"space-y-2",children:F.map(e=>m.jsxs("div",{className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsx("span",{className:p("text-xs px-1.5 py-0.5 rounded",e.enabled?"bg-green-500/10 text-green-500":"bg-muted text-muted-foreground"),children:e.enabled?"启用":"禁用"})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>$(e.id,!e.enabled),title:e.enabled?"禁用":"启用",children:m.jsx(S,{className:p("h-4 w-4",e.enabled?"text-green-500":"text-muted-foreground")})}),m.jsx(x,{size:"sm",variant:"ghost",onClick:()=>D(e.id),title:"卸载",children:m.jsx(g,{className:"h-4 w-4 text-red-400"})})]},e.id))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"text-sm font-medium text-muted-foreground mb-3",children:F.length>0?"更多插件":"可用插件"}),0===W.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx(P,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),m.jsx("p",{className:"text-sm",children:"Hub 暂无可用插件"})]}),m.jsx("div",{className:"space-y-2",children:W.filter(e=>!F.some(s=>s.id===e.id)).map((e,s)=>{const t=U===e.id;return m.jsxs(f.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s},className:"rounded-xl border bg-card p-4 flex items-center gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-medium text-sm",children:e.name}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["v",e.version]}),m.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",e.author]})]}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description}),e.permissions.length>0&&m.jsx("div",{className:"flex gap-1 mt-1 flex-wrap",children:e.permissions.map(e=>m.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:e},e))})]}),m.jsxs(x,{size:"sm",disabled:t,onClick:()=>B(e),children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),t?"安装中...":"安装"]})]},e.id)})})]})]})]}),"prompts"===q&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[m.jsx(z,{active:"all"===Y,onClick:()=>ee("all"),children:"全部"}),m.jsxs(z,{active:"quick-prompt"===Y,onClick:()=>ee("quick-prompt"),children:[m.jsx(b,{className:"h-3 w-3"}),"Quick Prompts"]}),m.jsxs(z,{active:"agent-prompt"===Y,onClick:()=>ee("agent-prompt"),children:[m.jsx(N,{className:"h-3 w-3"}),"Agent Prompts"]})]}),de.length>0&&m.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[m.jsx(L,{active:null===se,onClick:()=>te(null),children:"全部标签"}),de.map(e=>m.jsx(L,{active:se===e,onClick:()=>te(se===e?null:e),children:e},e))]}),K&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),V&&m.jsx("div",{className:"text-center text-destructive py-20",children:V}),!K&&!V&&0===G.length&&m.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[m.jsx("p",{className:"text-lg mb-2",children:"CCWeb Hub 还没有 prompt"}),m.jsx("p",{className:"text-sm",children:'在 Quick Prompts 或 Agent Prompts 卡片上右键选择"共享"来提交第一个吧!'})]}),!K&&!V&&G.length>0&&0===oe.length&&m.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的 prompt"}),m.jsx("div",{className:"space-y-3",children:oe.map((e,s)=>{var t;const a=ae===e.id,r=le.has(e.id),n=ie===e.id;return m.jsxs(f.div,{layout:!0,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25,delay:.03*s,ease:"easeOut"},className:"rounded-xl border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>re(a?null:e.id),children:[m.jsxs("div",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[m.jsxs("span",{className:p("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium","quick-prompt"===e.kind?"bg-blue-500/15 text-blue-400":"bg-green-500/15 text-green-500"),children:["quick-prompt"===e.kind?m.jsx(b,{className:"h-2.5 w-2.5"}):m.jsx(N,{className:"h-2.5 w-2.5"}),"quick-prompt"===e.kind?"Quick":"Agent"]}),m.jsx("h3",{className:"font-medium text-sm truncate",children:e.label}),null==(t=e.tags)?void 0:t.map(e=>m.jsxs("span",{className:"inline-flex items-center gap-0.5 px-2 py-0.5 rounded-full text-xs bg-muted text-muted-foreground",children:[m.jsx(A,{className:"h-2.5 w-2.5"}),e]},e))]}),e.description&&m.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:e.description}),m.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.author&&m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(E,{className:"h-3 w-3"}),e.author]}),m.jsx("code",{className:"text-[10px] opacity-60",children:e.file})]})]}),m.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxs(x,{size:"sm",variant:r?"outline":"default",disabled:n||r,onClick:s=>{(async(e,s)=>{if(s.stopPropagation(),!ie&&!le.has(e.id)){ce(e.id);try{"quick-prompt"===e.kind?(await v({label:e.label,command:e.body}),l.success("已导入到全局快捷 Prompts")):(await k({label:e.label,command:e.body}),l.success("已导入到全局 Agent Prompts")),ne(s=>new Set(s).add(e.id))}catch(t){l.error(t instanceof Error?t.message:"导入失败")}finally{ce(null)}}})(e,s)},title:"quick-prompt"===e.kind?"导入到全局快捷 Prompts":"导入到全局 Agent Prompts",children:[m.jsx(j,{className:"h-3.5 w-3.5 mr-1"}),r?"已导入":n?"导入中...":"导入"]}),m.jsx(f.span,{animate:{rotate:a?180:0},transition:{duration:.2},children:m.jsx(C,{className:"h-4 w-4 text-muted-foreground"})})]})]}),m.jsx(y,{children:a&&m.jsx(f.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"overflow-hidden",children:m.jsx("div",{className:"mt-3 pt-3 border-t",children:m.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:e.body})})})})]},e.id)})})]})]})]})}function z({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("flex items-center gap-1 px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}function L({active:e,onClick:s,children:t}){return m.jsx("button",{onClick:s,className:p("px-3 py-1 rounded-full text-xs font-medium transition-colors",e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),children:t})}export{q as SkillHubPage};
|