@tom2012/cc-web 1.5.32 → 1.5.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-SQm86PR-.js","assets/jszip.min-Db0voCvi.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bu8tNK3Q.js","assets/jszip.min-CwNvmrBU.js"])))=>i.map(i=>d[i]);
2
2
  function aL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var $c=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function sY(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var eC={exports:{}},Fu={},tC={exports:{}},Se={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -528,7 +528,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
528
528
  `,l+1)):l===0?s&&(e.result+=" "):e.result+=Bt.repeat(`
529
529
  `,l):e.result+=Bt.repeat(`
530
530
  `,s?1+l:l),s=!0,a=!0,l=0,n=e.position;!Jn(u)&&u!==0;)u=e.input.charCodeAt(++e.position);ai(e,n,e.position,!1)}return!0}function O0(e,t){var n,r=e.tag,i=e.anchor,s=[],a,o=!1,l;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),l=e.input.charCodeAt(e.position);l!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ne(e,"tab characters must not be used in indentation")),!(l!==45||(a=e.input.charCodeAt(e.position+1),!Kt(a))));){if(o=!0,e.position++,tt(e,!0,-1)&&e.lineIndent<=t){s.push(null),l=e.input.charCodeAt(e.position);continue}if(n=e.line,ua(e,t,YR,!1,!0),s.push(e.result),tt(e,!0,-1),l=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&l!==0)ne(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return o?(e.tag=r,e.anchor=i,e.kind="sequence",e.result=s,!0):!1}function hV(e,t,n){var r,i,s,a,o,l,c=e.tag,d=e.anchor,u={},p=Object.create(null),f=null,g=null,m=null,v=!1,y=!1,_;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),_=e.input.charCodeAt(e.position);_!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,ne(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),s=e.line,(_===63||_===58)&&Kt(r))_===63?(v&&(Hs(e,u,p,f,g,null,a,o,l),f=g=m=null),y=!0,v=!0,i=!0):v?(v=!1,i=!0):ne(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,_=r;else{if(a=e.line,o=e.lineStart,l=e.position,!ua(e,n,KR,!1,!0))break;if(e.line===s){for(_=e.input.charCodeAt(e.position);zi(_);)_=e.input.charCodeAt(++e.position);if(_===58)_=e.input.charCodeAt(++e.position),Kt(_)||ne(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(Hs(e,u,p,f,g,null,a,o,l),f=g=m=null),y=!0,v=!1,i=!1,f=e.tag,g=e.result;else if(y)ne(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=c,e.anchor=d,!0}else if(y)ne(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=c,e.anchor=d,!0}if((e.line===s||e.lineIndent>t)&&(v&&(a=e.line,o=e.lineStart,l=e.position),ua(e,t,Tu,!0,i)&&(v?g=e.result:m=e.result),v||(Hs(e,u,p,f,g,m,a,o,l),f=g=m=null),tt(e,!0,-1),_=e.input.charCodeAt(e.position)),(e.line===s||e.lineIndent>t)&&_!==0)ne(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&Hs(e,u,p,f,g,null,a,o,l),y&&(e.tag=c,e.anchor=d,e.kind="mapping",e.result=u),y}function pV(e){var t,n=!1,r=!1,i,s,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&ne(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,i="!!",a=e.input.charCodeAt(++e.position)):i="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(s=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):ne(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!Kt(a);)a===33&&(r?ne(e,"tag suffix cannot contain exclamation marks"):(i=e.input.slice(t-1,e.position+1),XR.test(i)||ne(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);s=e.input.slice(t,e.position),tV.test(s)&&ne(e,"tag suffix cannot contain flow indicator characters")}s&&!ZR.test(s)&&ne(e,"tag name cannot contain such characters: "+s);try{s=decodeURIComponent(s)}catch{ne(e,"tag name is malformed: "+s)}return n?e.tag=s:ui.call(e.tagMap,i)?e.tag=e.tagMap[i]+s:i==="!"?e.tag="!"+s:i==="!!"?e.tag="tag:yaml.org,2002:"+s:ne(e,'undeclared tag handle "'+i+'"'),!0}function fV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&ne(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!Kt(n)&&!zs(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ne(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function gV(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!Kt(r)&&!zs(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&ne(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),ui.call(e.anchorMap,n)||ne(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],tt(e,!0,-1),!0}function ua(e,t,n,r,i){var s,a,o,l=1,c=!1,d=!1,u,p,f,g,m,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,s=a=o=Tu===n||YR===n,r&&tt(e,!0,-1)&&(c=!0,e.lineIndent>t?l=1:e.lineIndent===t?l=0:e.lineIndent<t&&(l=-1)),l===1)for(;pV(e)||fV(e);)tt(e,!0,-1)?(c=!0,o=s,e.lineIndent>t?l=1:e.lineIndent===t?l=0:e.lineIndent<t&&(l=-1)):o=!1;if(o&&(o=c||i),(l===1||Tu===n)&&(Cu===n||KR===n?m=t:m=t+1,v=e.position-e.lineStart,l===1?o&&(O0(e,v)||hV(e,v,m))||uV(e,m)?d=!0:(a&&dV(e,m)||lV(e,m)||cV(e,m)?d=!0:gV(e)?(d=!0,(e.tag!==null||e.anchor!==null)&&ne(e,"alias node should not have any properties")):oV(e,m,Cu===n)&&(d=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):l===0&&(d=o&&O0(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&ne(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,p=e.implicitTypes.length;u<p;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(ui.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,f=e.typeMap.multi[e.kind||"fallback"],u=0,p=f.length;u<p;u+=1)if(e.tag.slice(0,f[u].tag.length)===f[u].tag){g=f[u];break}g||ne(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&ne(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):ne(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||d}function mV(e){var t=e.position,n,r,i,s=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(tt(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(s=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!Kt(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),i=[],r.length<1&&ne(e,"directive name must not be less than one character in length");a!==0;){for(;zi(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!Jn(a));break}if(Jn(a))break;for(n=e.position;a!==0&&!Kt(a);)a=e.input.charCodeAt(++e.position);i.push(e.input.slice(n,e.position))}a!==0&&gw(e),ui.call(R0,r)?R0[r](e,r,i):Au(e,'unknown document directive "'+r+'"')}if(tt(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,tt(e,!0,-1)):s&&ne(e,"directives end mark is expected"),ua(e,e.lineIndent-1,Tu,!1,!0),tt(e,!0,-1),e.checkLineBreaks&&eV.test(e.input.slice(t,e.position))&&Au(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Ld(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,tt(e,!0,-1));return}if(e.position<e.length-1)ne(e,"end of the stream or a document separator is expected");else return}function bV(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
531
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new aV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ne(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)mV(n);return n.documents}function yV(e,t){var n=bV(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new hr("expected a single document in the stream, but found more")}}var _V=yV,vV={load:_V},SV=vV.load;function L0(e){var v;const t=e.pages||[],n=e.relations||[];if(t.length===0)return{nodes:[],edges:[]};const r=new Map,i=new Map;for(const y of t)r.set(y.id,[]),i.set(y.id,0);for(const y of n)(v=r.get(y.from))==null||v.push(y.to),i.set(y.to,(i.get(y.to)||0)+1);const s=new Map,a=[];for(const y of t)(i.get(y.id)||0)===0&&(a.push(y.id),s.set(y.id,0));let o=0;for(;a.length>0;){const y=a.shift(),_=s.get(y)||0;for(const S of r.get(y)||[]){const w=_+1;w>(s.get(S)||0)&&(s.set(S,w),w>o&&(o=w));const k=(i.get(S)||1)-1;i.set(S,k),k<=0&&a.push(S)}}for(const y of t)s.has(y.id)||s.set(y.id,o+1);const l=new Map;for(const y of t){const _=s.get(y.id)||0;l.has(_)||l.set(_,[]),l.get(_).push(y.id)}const c=160,d=50,u=60,p=80,f=[],g=new Map(t.map(y=>[y.id,y]));for(const[y,_]of l){const w=-(_.length*c+(_.length-1)*u)/2;_.forEach((k,x)=>{const E=g.get(k);f.push({id:k,title:(E==null?void 0:E.title)||k,x:w+x*(c+u)+c/2,y:y*(d+p),layer:y})})}const m=n.map(y=>({from:y.from,to:y.to,label:y.label}));return{nodes:f,edges:m}}const D0=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#f97316","#6366f1"];function wV({folderPath:e}){const[t,n]=b.useState(null),[r,i]=b.useState(!0),[s,a]=b.useState(null),[o,l]=b.useState(1),[c,d]=b.useState({x:0,y:0}),[u,p]=b.useState(!1),[f,g]=b.useState({x:0,y:0}),m=b.useRef(null),v=b.useRef(null),y=`${e}/.notebook/graph.yaml`,_=b.useCallback(async()=>{i(!0),a(null);try{const I=await HT(y);if(!I.content){a("graph.yaml is empty"),n(null);return}const O=SV(I.content);n(O),l(1),d({x:0,y:0})}catch{a("Cannot read .notebook/graph.yaml"),n(null)}finally{i(!1)}},[y]);b.useEffect(()=>{_()},[_]);const S=b.useCallback(I=>{I.preventDefault();const O=I.deltaY>0?-.1:.1;l(N=>Math.max(.2,Math.min(3,N+O)))},[]),w=b.useCallback(I=>{I.button===0&&(p(!0),g({x:I.clientX-c.x,y:I.clientY-c.y}))},[c]),k=b.useCallback(I=>{u&&d({x:I.clientX-f.x,y:I.clientY-f.y})},[u,f]),x=b.useCallback(()=>{p(!1)},[]),E=b.useCallback(()=>{if(!t||!v.current)return;const{nodes:I}=L0(t);if(I.length===0)return;const O=Math.min(...I.map(H=>H.x))-100,N=Math.max(...I.map(H=>H.x))+100,P=Math.min(...I.map(H=>H.y))-40,F=Math.max(...I.map(H=>H.y))+60,B=N-O,j=F-P,M=v.current.clientWidth,U=v.current.clientHeight,C=Math.min(M/B,U/j,1.5)*.9;l(C),d({x:M/2-(O+N)/2*C,y:U/2-(P+F)/2*C})},[t]),{nodes:T,edges:D}=b.useMemo(()=>t?L0(t):{nodes:[],edges:[]},[t]),R=b.useMemo(()=>new Map(T.map(I=>[I.id,I])),[T]);return b.useEffect(()=>{t&&!r&&setTimeout(E,50)},[t,r,E]),r?h.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:h.jsx(vo,{className:"h-5 w-5 animate-spin"})}):s||!t?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted-foreground text-sm px-4 text-center",children:[h.jsx("p",{children:s||"No graph data"}),h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>void _(),children:[h.jsx(Ki,{className:"h-3 w-3 mr-1"})," Retry"]})]}):h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b shrink-0",children:[h.jsxs("span",{className:"text-xs text-muted-foreground mr-auto",children:[T.length," pages, ",D.length," relations"]}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>l(I=>Math.min(3,I+.2)),children:h.jsx(XT,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>l(I=>Math.max(.2,I-.2)),children:h.jsx(ZT,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:E,children:h.jsx(yF,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>void _(),children:h.jsx(Ki,{className:"h-3 w-3"})})]}),h.jsx("div",{ref:v,className:"flex-1 overflow-hidden cursor-grab active:cursor-grabbing bg-muted/30",onWheel:S,onMouseDown:w,onMouseMove:k,onMouseUp:x,onMouseLeave:x,children:h.jsxs("svg",{ref:m,width:"100%",height:"100%",style:{userSelect:"none"},children:[h.jsx("defs",{children:h.jsx("marker",{id:"arrowhead",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"8",markerHeight:"6",orient:"auto",children:h.jsx("polygon",{points:"0 0, 10 3.5, 0 7",className:"fill-muted-foreground/60"})})}),h.jsxs("g",{transform:`translate(${c.x}, ${c.y}) scale(${o})`,children:[D.map((I,O)=>{const N=R.get(I.from),P=R.get(I.to);if(!N||!P)return null;const F=N.y+20,B=P.y-20,j=(F+B)/2;return h.jsxs("g",{children:[h.jsx("path",{d:`M ${N.x} ${F} C ${N.x} ${j}, ${P.x} ${j}, ${P.x} ${B}`,fill:"none",className:"stroke-muted-foreground/40",strokeWidth:1.5,markerEnd:"url(#arrowhead)"}),I.label&&h.jsx("text",{x:(N.x+P.x)/2,y:j-4,textAnchor:"middle",className:"fill-muted-foreground/60",fontSize:9,children:I.label})]},`edge-${O}`)}),T.map(I=>{const O=D0[I.layer%D0.length],N=140,P=36;return h.jsxs("g",{transform:`translate(${I.x-N/2}, ${I.y-P/2})`,children:[h.jsx("rect",{width:N,height:P,rx:8,fill:O,fillOpacity:.15,stroke:O,strokeWidth:1.5}),h.jsx("text",{x:N/2,y:P/2+1,textAnchor:"middle",dominantBaseline:"middle",className:"fill-foreground",fontSize:11,fontWeight:500,children:I.title.length>14?I.title.slice(0,13)+"…":I.title})]},I.id)})]})]})})]})}async function bw(e){let t=Nm(e);const n=kr();n&&(t+=`${t.includes("?")?"&":"?"}token=${encodeURIComponent(n)}`);const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch file: ${r.status}`);return r.arrayBuffer()}function xV({filePath:e,zoom:t}){const[n,r]=b.useState(""),[i,s]=b.useState(null),[a,o]=b.useState(!0);return b.useEffect(()=>{let l=!1;return o(!0),s(null),(async()=>{try{const c=await pb(()=>import("./index-SQm86PR-.js").then(p=>p.i),__vite__mapDeps([0,1])),d=await bw(e),u=await c.convertToHtml({arrayBuffer:d});l||r(u.value)}catch(c){l||s(c instanceof Error?c.message:"Failed to render docx")}finally{l||o(!1)}})(),()=>{l=!0}},[e]),a?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 Word 文档中..."}):i?h.jsx("p",{className:"text-sm text-destructive p-4",children:i}):h.jsx("div",{className:"p-6 prose dark:prose-invert max-w-none",style:{fontSize:`${12*t/100}px`},dangerouslySetInnerHTML:{__html:n}})}function EV({filePath:e,zoom:t}){var d;const[n,r]=b.useState([]),[i,s]=b.useState(0),[a,o]=b.useState(null),[l,c]=b.useState(!0);return b.useEffect(()=>{let u=!1;return c(!0),o(null),(async()=>{try{const p=await pb(()=>import("./xlsx-D_0l8YDs.js"),[]),f=await bw(e),g=p.read(f,{type:"array"}),m=g.SheetNames.map(v=>({name:v,html:p.utils.sheet_to_html(g.Sheets[v],{editable:!1})}));u||(r(m),s(0))}catch(p){u||o(p instanceof Error?p.message:"Failed to render xlsx")}finally{u||c(!1)}})(),()=>{u=!0}},[e]),l?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 Excel 文件中..."}):a?h.jsx("p",{className:"text-sm text-destructive p-4",children:a}):n.length===0?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"空文件"}):h.jsxs("div",{className:"flex flex-col h-full",children:[n.length>1&&h.jsx("div",{className:"flex gap-0.5 px-3 py-1.5 border-b border-border bg-muted/30 flex-shrink-0 overflow-x-auto",children:n.map((u,p)=>h.jsx("button",{onClick:()=>s(p),className:`px-3 py-1 text-xs rounded-t transition-colors whitespace-nowrap ${p===i?"bg-background text-foreground border border-b-0 border-border":"text-muted-foreground hover:text-foreground"}`,children:u.name},p))}),h.jsx("div",{className:"flex-1 overflow-auto p-2 xlsx-preview",style:{fontSize:`${12*t/100}px`},dangerouslySetInnerHTML:{__html:((d=n[i])==null?void 0:d.html)??""}}),h.jsx("style",{children:`
531
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new aV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,ne(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)mV(n);return n.documents}function yV(e,t){var n=bV(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new hr("expected a single document in the stream, but found more")}}var _V=yV,vV={load:_V},SV=vV.load;function L0(e){var v;const t=e.pages||[],n=e.relations||[];if(t.length===0)return{nodes:[],edges:[]};const r=new Map,i=new Map;for(const y of t)r.set(y.id,[]),i.set(y.id,0);for(const y of n)(v=r.get(y.from))==null||v.push(y.to),i.set(y.to,(i.get(y.to)||0)+1);const s=new Map,a=[];for(const y of t)(i.get(y.id)||0)===0&&(a.push(y.id),s.set(y.id,0));let o=0;for(;a.length>0;){const y=a.shift(),_=s.get(y)||0;for(const S of r.get(y)||[]){const w=_+1;w>(s.get(S)||0)&&(s.set(S,w),w>o&&(o=w));const k=(i.get(S)||1)-1;i.set(S,k),k<=0&&a.push(S)}}for(const y of t)s.has(y.id)||s.set(y.id,o+1);const l=new Map;for(const y of t){const _=s.get(y.id)||0;l.has(_)||l.set(_,[]),l.get(_).push(y.id)}const c=160,d=50,u=60,p=80,f=[],g=new Map(t.map(y=>[y.id,y]));for(const[y,_]of l){const w=-(_.length*c+(_.length-1)*u)/2;_.forEach((k,x)=>{const E=g.get(k);f.push({id:k,title:(E==null?void 0:E.title)||k,x:w+x*(c+u)+c/2,y:y*(d+p),layer:y})})}const m=n.map(y=>({from:y.from,to:y.to,label:y.label}));return{nodes:f,edges:m}}const D0=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#f97316","#6366f1"];function wV({folderPath:e}){const[t,n]=b.useState(null),[r,i]=b.useState(!0),[s,a]=b.useState(null),[o,l]=b.useState(1),[c,d]=b.useState({x:0,y:0}),[u,p]=b.useState(!1),[f,g]=b.useState({x:0,y:0}),m=b.useRef(null),v=b.useRef(null),y=`${e}/.notebook/graph.yaml`,_=b.useCallback(async()=>{i(!0),a(null);try{const I=await HT(y);if(!I.content){a("graph.yaml is empty"),n(null);return}const O=SV(I.content);n(O),l(1),d({x:0,y:0})}catch{a("Cannot read .notebook/graph.yaml"),n(null)}finally{i(!1)}},[y]);b.useEffect(()=>{_()},[_]);const S=b.useCallback(I=>{I.preventDefault();const O=I.deltaY>0?-.1:.1;l(N=>Math.max(.2,Math.min(3,N+O)))},[]),w=b.useCallback(I=>{I.button===0&&(p(!0),g({x:I.clientX-c.x,y:I.clientY-c.y}))},[c]),k=b.useCallback(I=>{u&&d({x:I.clientX-f.x,y:I.clientY-f.y})},[u,f]),x=b.useCallback(()=>{p(!1)},[]),E=b.useCallback(()=>{if(!t||!v.current)return;const{nodes:I}=L0(t);if(I.length===0)return;const O=Math.min(...I.map(H=>H.x))-100,N=Math.max(...I.map(H=>H.x))+100,P=Math.min(...I.map(H=>H.y))-40,F=Math.max(...I.map(H=>H.y))+60,B=N-O,j=F-P,M=v.current.clientWidth,U=v.current.clientHeight,C=Math.min(M/B,U/j,1.5)*.9;l(C),d({x:M/2-(O+N)/2*C,y:U/2-(P+F)/2*C})},[t]),{nodes:T,edges:D}=b.useMemo(()=>t?L0(t):{nodes:[],edges:[]},[t]),R=b.useMemo(()=>new Map(T.map(I=>[I.id,I])),[T]);return b.useEffect(()=>{t&&!r&&setTimeout(E,50)},[t,r,E]),r?h.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:h.jsx(vo,{className:"h-5 w-5 animate-spin"})}):s||!t?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted-foreground text-sm px-4 text-center",children:[h.jsx("p",{children:s||"No graph data"}),h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>void _(),children:[h.jsx(Ki,{className:"h-3 w-3 mr-1"})," Retry"]})]}):h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b shrink-0",children:[h.jsxs("span",{className:"text-xs text-muted-foreground mr-auto",children:[T.length," pages, ",D.length," relations"]}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>l(I=>Math.min(3,I+.2)),children:h.jsx(XT,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>l(I=>Math.max(.2,I-.2)),children:h.jsx(ZT,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:E,children:h.jsx(yF,{className:"h-3 w-3"})}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>void _(),children:h.jsx(Ki,{className:"h-3 w-3"})})]}),h.jsx("div",{ref:v,className:"flex-1 overflow-hidden cursor-grab active:cursor-grabbing bg-muted/30",onWheel:S,onMouseDown:w,onMouseMove:k,onMouseUp:x,onMouseLeave:x,children:h.jsxs("svg",{ref:m,width:"100%",height:"100%",style:{userSelect:"none"},children:[h.jsx("defs",{children:h.jsx("marker",{id:"arrowhead",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"8",markerHeight:"6",orient:"auto",children:h.jsx("polygon",{points:"0 0, 10 3.5, 0 7",className:"fill-muted-foreground/60"})})}),h.jsxs("g",{transform:`translate(${c.x}, ${c.y}) scale(${o})`,children:[D.map((I,O)=>{const N=R.get(I.from),P=R.get(I.to);if(!N||!P)return null;const F=N.y+20,B=P.y-20,j=(F+B)/2;return h.jsxs("g",{children:[h.jsx("path",{d:`M ${N.x} ${F} C ${N.x} ${j}, ${P.x} ${j}, ${P.x} ${B}`,fill:"none",className:"stroke-muted-foreground/40",strokeWidth:1.5,markerEnd:"url(#arrowhead)"}),I.label&&h.jsx("text",{x:(N.x+P.x)/2,y:j-4,textAnchor:"middle",className:"fill-muted-foreground/60",fontSize:9,children:I.label})]},`edge-${O}`)}),T.map(I=>{const O=D0[I.layer%D0.length],N=140,P=36;return h.jsxs("g",{transform:`translate(${I.x-N/2}, ${I.y-P/2})`,children:[h.jsx("rect",{width:N,height:P,rx:8,fill:O,fillOpacity:.15,stroke:O,strokeWidth:1.5}),h.jsx("text",{x:N/2,y:P/2+1,textAnchor:"middle",dominantBaseline:"middle",className:"fill-foreground",fontSize:11,fontWeight:500,children:I.title.length>14?I.title.slice(0,13)+"…":I.title})]},I.id)})]})]})})]})}async function bw(e){let t=Nm(e);const n=kr();n&&(t+=`${t.includes("?")?"&":"?"}token=${encodeURIComponent(n)}`);const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch file: ${r.status}`);return r.arrayBuffer()}function xV({filePath:e,zoom:t}){const[n,r]=b.useState(""),[i,s]=b.useState(null),[a,o]=b.useState(!0);return b.useEffect(()=>{let l=!1;return o(!0),s(null),(async()=>{try{const c=await pb(()=>import("./index-Bu8tNK3Q.js").then(p=>p.i),__vite__mapDeps([0,1])),d=await bw(e),u=await c.convertToHtml({arrayBuffer:d});l||r(u.value)}catch(c){l||s(c instanceof Error?c.message:"Failed to render docx")}finally{l||o(!1)}})(),()=>{l=!0}},[e]),a?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 Word 文档中..."}):i?h.jsx("p",{className:"text-sm text-destructive p-4",children:i}):h.jsx("div",{className:"p-6 prose dark:prose-invert max-w-none",style:{fontSize:`${12*t/100}px`},dangerouslySetInnerHTML:{__html:n}})}function EV({filePath:e,zoom:t}){var d;const[n,r]=b.useState([]),[i,s]=b.useState(0),[a,o]=b.useState(null),[l,c]=b.useState(!0);return b.useEffect(()=>{let u=!1;return c(!0),o(null),(async()=>{try{const p=await pb(()=>import("./xlsx-D_0l8YDs.js"),[]),f=await bw(e),g=p.read(f,{type:"array"}),m=g.SheetNames.map(v=>({name:v,html:p.utils.sheet_to_html(g.Sheets[v],{editable:!1})}));u||(r(m),s(0))}catch(p){u||o(p instanceof Error?p.message:"Failed to render xlsx")}finally{u||c(!1)}})(),()=>{u=!0}},[e]),l?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 Excel 文件中..."}):a?h.jsx("p",{className:"text-sm text-destructive p-4",children:a}):n.length===0?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"空文件"}):h.jsxs("div",{className:"flex flex-col h-full",children:[n.length>1&&h.jsx("div",{className:"flex gap-0.5 px-3 py-1.5 border-b border-border bg-muted/30 flex-shrink-0 overflow-x-auto",children:n.map((u,p)=>h.jsx("button",{onClick:()=>s(p),className:`px-3 py-1 text-xs rounded-t transition-colors whitespace-nowrap ${p===i?"bg-background text-foreground border border-b-0 border-border":"text-muted-foreground hover:text-foreground"}`,children:u.name},p))}),h.jsx("div",{className:"flex-1 overflow-auto p-2 xlsx-preview",style:{fontSize:`${12*t/100}px`},dangerouslySetInnerHTML:{__html:((d=n[i])==null?void 0:d.html)??""}}),h.jsx("style",{children:`
532
532
  .xlsx-preview table { border-collapse: collapse; width: auto; min-width: 100%; }
533
533
  .xlsx-preview td, .xlsx-preview th {
534
534
  border: 1px solid hsl(var(--border));
@@ -539,8 +539,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
539
539
  }
540
540
  .xlsx-preview th { background: hsl(var(--muted)); font-weight: 600; }
541
541
  .xlsx-preview tr:hover td { background: hsl(var(--accent) / 0.3); }
542
- `})]})}async function kV(e){const{default:t}=await pb(async()=>{const{default:s}=await import("./jszip.min-Db0voCvi.js").then(a=>a.j);return{default:s}},[]),n=await t.loadAsync(e),r=[],i=Object.keys(n.files).filter(s=>/^ppt\/slides\/slide\d+\.xml$/i.test(s)).sort((s,a)=>{var c,d;const o=parseInt(((c=s.match(/slide(\d+)/))==null?void 0:c[1])??"0"),l=parseInt(((d=a.match(/slide(\d+)/))==null?void 0:d[1])??"0");return o-l});for(let s=0;s<i.length;s++){const a=await n.file(i[s]).async("text"),o=[],l=/<a:t[^>]*>([\s\S]*?)<\/a:t>/g;let c;for(;(c=l.exec(a))!==null;){const d=c[1].replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').trim();d&&o.push(d)}r.push({index:s+1,texts:o})}return r}function CV({filePath:e,zoom:t}){const[n,r]=b.useState([]),[i,s]=b.useState(null),[a,o]=b.useState(!0);return b.useEffect(()=>{let l=!1;return o(!0),s(null),(async()=>{try{const c=await bw(e),d=await kV(c);l||r(d)}catch(c){l||s(c instanceof Error?c.message:"Failed to render pptx")}finally{l||o(!1)}})(),()=>{l=!0}},[e]),a?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 PPT 文件中..."}):i?h.jsx("p",{className:"text-sm text-destructive p-4",children:i}):n.length===0?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"空文件"}):h.jsx("div",{className:"p-4 space-y-4",style:{fontSize:`${12*t/100}px`},children:n.map(l=>h.jsxs("div",{className:"border border-border rounded-lg p-5 bg-muted/20",children:[h.jsxs("div",{className:"text-xs text-muted-foreground mb-2 font-medium",children:["Slide ",l.index]}),l.texts.length>0?h.jsx("div",{className:"space-y-1.5",children:l.texts.map((c,d)=>h.jsx("p",{className:"text-foreground leading-relaxed",style:{fontSize:"inherit"},children:c},d))}):h.jsx("p",{className:"text-muted-foreground text-sm italic",children:"(无文本内容)"})]},l.index))})}const TV=new Set(["docx","xlsx","xls","pptx"]);function AV({filePath:e,ext:t,zoom:n}){return t==="docx"?h.jsx(xV,{filePath:e,zoom:n}):t==="xlsx"||t==="xls"?h.jsx(EV,{filePath:e,zoom:n}):t==="pptx"?h.jsx(CV,{filePath:e,zoom:n}):null}const nI={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function NV(e){const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"dockerfile";if(n==="makefile")return"makefile";const r=t.lastIndexOf(".");return r>=0?t.slice(r+1).toLowerCase():""}const RV=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function IV(e){return e==="md"||e==="html"||e==="htm"||e in nI}function M0(e){return e==="md"?"Markdown":e==="html"||e==="htm"?"HTML":"高亮"}const Ts=[50,75,100,125,150,200,250,300],nl=100,vg="cc_file_zoom";function OV(e){try{const n=JSON.parse(localStorage.getItem(vg)||"{}")[e];return Ts.includes(n)?n:nl}catch{return nl}}function LV(e,t){try{const n=JSON.parse(localStorage.getItem(vg)||"{}");t===nl?delete n[e]:n[e]=t,localStorage.setItem(vg,JSON.stringify(n))}catch{}}function DV({filePath:e,onClose:t}){const n=e.endsWith("/.notebook/graph.yaml"),r=n?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[i,s]=b.useState(null),[a,o]=b.useState(null),[l,c]=b.useState(()=>n?"graph":"rendered"),[d,u]=b.useState(!1),[p,f]=b.useState(nl),[g,m]=b.useState(""),[v,y]=b.useState(!1),[_,S]=b.useState(!1),w=b.useRef(null),{resolved:k}=jm(),x=e.split("/").pop()??e,E=b.useMemo(()=>NV(e),[e]),T=RV.has(E),D=TV.has(E),R=IV(E),I=nI[E]||E,O=b.useMemo(()=>{if(!T)return"";const $=Nm(e),W=kr();return W?`${$}&token=${encodeURIComponent(W)}`:$},[e,T]);b.useEffect(()=>{if(s(null),o(null),f(OV(e)),S(!1),T||D){s({path:e,binary:!1,tooLarge:!1,size:0,content:null}),c("rendered");return}c(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),HT(e).then($=>{s($),m($.content??"")}).catch($=>o($ instanceof Error?$.message:"Failed to load file"))},[e,T,D]);const N=$=>{if($.target===$.currentTarget){if(_&&!confirm("有未保存的修改,确定关闭?"))return;t()}};b.useEffect(()=>{const $=W=>{if(W.key==="Escape"){if(_&&!confirm("有未保存的修改,确定关闭?"))return;t()}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,_]);const P=b.useCallback(async()=>{y(!0);try{await GP(e,g),s($=>$&&{...$,content:g,size:new Blob([g]).size}),S(!1)}catch($){alert($ instanceof Error?$.message:"保存失败")}finally{y(!1)}},[e,g]);b.useEffect(()=>{const $=W=>{(W.metaKey||W.ctrlKey)&&W.key==="s"&&l==="edit"&&(W.preventDefault(),P())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[l,P]);const F=()=>{m((i==null?void 0:i.content)??""),S(!1),c("edit"),setTimeout(()=>{var $;return($=w.current)==null?void 0:$.focus()},0)},B=()=>{_&&!confirm("有未保存的修改,确定退出编辑?")||(c(n?"graph":R?"rendered":"plain"),S(!1))},j=$=>{f($),LV(e,$)},M=()=>{const $=Ts.find(W=>W>p);$&&j($)},U=()=>{const $=[...Ts].reverse().find(W=>W<p);$&&j($)},C=()=>j(nl),H=(i==null?void 0:i.content)??"",Z=k==="dark"?O8:L8,L=12*(p/100),se=i&&!i.binary&&!i.tooLarge,_e=b.useMemo(()=>{var ce,ue;if(E!=="md")return null;const $=l==="edit"?g:H;if(!$)return 0;const W=((ce=$.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))==null?void 0:ce.length)??0,re=((ue=$.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))==null?void 0:ue.length)??0;return W+re},[E,H,g,l]);return h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:N,children:h.jsxs("div",{className:X("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200",d?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg"),children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[h.jsx(Ec,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),h.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[x,_&&h.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),_e!==null&&h.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs",children:[_e.toLocaleString()," 字"]})]}),se&&!T&&!D&&h.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[R&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{onClick:()=>l==="edit"?B():c("plain"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="plain"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[h.jsx(dF,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),h.jsxs("button",{onClick:()=>l==="edit"?B():c("rendered"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="rendered"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:M0(E),children:[h.jsx(qT,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:M0(E)})]})]}),n&&h.jsxs("button",{onClick:()=>l==="edit"?B():c("graph"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="graph"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[h.jsx(xF,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),h.jsxs("button",{onClick:()=>l==="edit"?B():F(),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="edit"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[h.jsx(ad,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),l==="edit"&&h.jsxs("button",{onClick:()=>void P(),disabled:v||!_,className:X("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",_?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[h.jsx(KT,{className:"h-3 w-3"}),v?"保存中...":"保存"]}),(se||T)&&l!=="edit"&&l!=="graph"&&h.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[h.jsx("button",{onClick:U,disabled:p<=Ts[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:h.jsx(ZT,{className:"h-3 w-3"})}),h.jsxs("button",{onClick:C,className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[p,"%"]}),h.jsx("button",{onClick:M,disabled:p>=Ts[Ts.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:h.jsx(XT,{className:"h-3 w-3"})})]}),h.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>u($=>!$),title:d?"退出全屏":"全屏",children:d?h.jsx(Om,{className:"h-3.5 w-3.5"}):h.jsx(Im,{className:"h-3.5 w-3.5"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{_&&!confirm("有未保存的修改,确定关闭?")||t()},children:h.jsx(os,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:X("flex-1 min-h-0",l==="graph"?"overflow-hidden":"overflow-auto"),children:[l==="graph"&&h.jsx(wV,{folderPath:r}),l!=="graph"&&!i&&!a&&h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),l!=="graph"&&a&&h.jsx("p",{className:"text-sm text-red-400 p-4",children:a}),l!=="graph"&&T&&i&&h.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:h.jsx("img",{src:O,alt:x,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${p/100})`,transformOrigin:"center center"},draggable:!1})}),l!=="graph"&&D&&i&&h.jsx(AV,{filePath:e,ext:E,zoom:p}),l!=="graph"&&!T&&!D&&i&&i.binary&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[h.jsx(Ec,{className:"h-8 w-8"}),h.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.size/1024).toFixed(1)," KB"]})]}),l!=="graph"&&!D&&i&&i.tooLarge&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[h.jsx(Ec,{className:"h-8 w-8"}),h.jsx("p",{className:"text-sm",children:"File too large to preview"}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.size/1024/1024).toFixed(2)," MB (limit 1 MB)"]})]}),l!=="graph"&&se&&H!==null&&h.jsxs(h.Fragment,{children:[l==="edit"&&h.jsx("textarea",{ref:w,value:g,onChange:$=>{m($.target.value),S(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${L}px`,minHeight:"100%"},spellCheck:!1}),l!=="edit"&&h.jsxs("div",{className:"p-4",style:{fontSize:`${L}px`},children:[l==="plain"&&h.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:H}),l==="rendered"&&E==="md"&&h.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:h.jsx(lR,{remarkPlugins:[OR],components:{code({className:$,children:W,...re}){const ce=/language-(\w+)/.exec($||"");return!ce&&!$?h.jsx("code",{className:$,...re,children:W}):h.jsx(yg,{style:Z,language:(ce==null?void 0:ce[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(W).replace(/\n$/,"")})}},children:H})}),l==="rendered"&&(E==="html"||E==="htm")&&h.jsx("iframe",{srcDoc:H,className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:x,style:{minHeight:"60vh",transform:`scale(${p/100})`,transformOrigin:"top left",width:`${1e4/p}%`,height:`${1e4/p}%`}}),l==="rendered"&&E!=="md"&&E!=="html"&&E!=="htm"&&I&&h.jsx(yg,{style:Z,language:I,showLineNumbers:!0,lineNumberStyle:{color:k==="dark"?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:H}),l==="rendered"&&!R&&h.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:H})]})]})]})]})})}const MV=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function PV(e){const t=e.lastIndexOf(".");return t>=0&&MV.has(e.slice(t+1).toLowerCase())}function FV({projectPath:e}){const[t,n]=b.useState(new Map),[r,i]=b.useState(new Set([e])),[s,a]=b.useState(new Set),[o,l]=b.useState(null),[c,d]=b.useState(null),[u,p]=b.useState(!1),[f,g]=b.useState(!1),m=b.useRef(null),v=b.useRef(null);b.useEffect(()=>{if(!c)return;const I=()=>d(null);return window.addEventListener("click",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("click",I),window.removeEventListener("scroll",I,!0)}},[c]);const y=(I,O)=>{let N=Nm(I);const P=kr();P&&(N+=`${N.includes("?")?"&":"?"}token=${encodeURIComponent(P)}`);const F=document.createElement("a");F.href=N,F.download=O,F.click()},_=async I=>{if(I.length!==0){p(!0);try{await zP(e,I),w(e)}catch(O){console.error("[FileTree] Upload failed:",O)}finally{p(!1)}}},S=I=>{I.preventDefault(),g(!1);const O=Array.from(I.dataTransfer.files);O.length>0&&_(O)},w=b.useCallback(async I=>{a(O=>{if(O.has(I))return O;const N=new Set(O);return N.add(I),N});try{const O=await zT(I);n(N=>new Map(N).set(I,O.entries))}catch(O){console.error("[FileTree] Failed to load:",I,O),n(N=>new Map(N).set(I,[]))}finally{a(O=>{const N=new Set(O);return N.delete(I),N})}},[]);b.useEffect(()=>{n(new Map),i(new Set([e])),a(new Set),w(e)},[e,w]);const k=b.useCallback(I=>{i(O=>{const N=new Set(O);return N.has(I)?N.delete(I):(N.add(I),t.has(I)||w(I)),N})},[t,w]),x=b.useCallback(()=>{n(new Map),i(new Set([e])),a(new Set),w(e)},[e,w]),E=(I,O)=>I.map(N=>{const P=r.has(N.path),F=s.has(N.path),B=t.get(N.path),j=N.name.startsWith(".");return h.jsxs("div",{children:[h.jsxs("div",{className:X("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted",j&&"opacity-50"),style:{paddingLeft:`${O*14+6}px`,paddingRight:"6px"},onClick:()=>N.type==="dir"?k(N.path):l(N.path),onContextMenu:M=>{N.type==="file"&&(M.preventDefault(),d({x:M.clientX,y:M.clientY,filePath:N.path,fileName:N.name}))},children:[h.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:N.type==="dir"&&(F?h.jsx(Ki,{className:"h-2.5 w-2.5 animate-spin"}):P?h.jsx(pl,{className:"h-2.5 w-2.5"}):h.jsx(sd,{className:"h-2.5 w-2.5"}))}),N.type==="dir"?P?h.jsx(Vo,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):h.jsx(pf,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):PV(N.name)?h.jsx(mF,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):h.jsx(Ec,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:X("text-xs truncate leading-none",N.type==="dir"?"text-foreground":"text-muted-foreground"),title:N.path,children:N.name})]}),N.type==="dir"&&P&&h.jsxs("div",{children:[!B&&!F&&h.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(O+1)*14+6+16}px`},children:"—"}),(B==null?void 0:B.length)===0&&h.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(O+1)*14+6+16}px`},children:"empty"}),B&&B.length>0&&E(B,O+1)]})]},N.path)}),T=t.get(e),D=s.has(e),R=e.split("/").filter(Boolean).pop()??e;return h.jsxs(h.Fragment,{children:[o&&h.jsx(DV,{filePath:o,onClose:()=>l(null)}),c&&h.jsx("div",{ref:m,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:c.x,top:c.y},onClick:I=>I.stopPropagation(),children:h.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{y(c.filePath,c.fileName),d(null)},children:[h.jsx(pu,{className:"h-3.5 w-3.5"}),"下载"]})}),h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),h.jsxs("div",{className:"flex items-center gap-0.5",children:[h.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:I=>{const O=Array.from(I.target.files??[]);O.length>0&&_(O),I.target.value=""}}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var I;return(I=v.current)==null?void 0:I.click()},disabled:u,title:"上传文件",children:h.jsx(gf,{className:X("h-3 w-3",u&&"animate-pulse")})}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:x,title:"Refresh file tree",children:h.jsx(Ki,{className:X("h-3 w-3",D&&"animate-spin")})})]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[h.jsx(Vo,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:R})]}),h.jsxs("div",{className:X("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",f&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:I=>{I.preventDefault(),g(!0)},onDragEnter:I=>{I.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:S,children:[u&&h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),f&&!u&&h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),D&&!T?h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):!T||T.length===0?h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"}):E(T,0)]})]})]})}function BV({open:e,onOpenChange:t,initialLabel:n,initialCommand:r,title:i,onSave:s}){const[a,o]=b.useState(n),[l,c]=b.useState(r);b.useEffect(()=>{e&&(o(n),c(r))},[e,n,r]);const d=()=>{const u=l.trim();u&&(s(a.trim()||u,u),t(!1))};return h.jsx(_a,{open:e,onOpenChange:t,children:h.jsxs(cs,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col",children:[h.jsxs(us,{children:[h.jsx(hs,{children:i}),h.jsx(ps,{children:"Write the command that will be sent to Claude when this shortcut is triggered."})]}),h.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"shortcut-label",children:"Label"}),h.jsx(wn,{id:"shortcut-label",placeholder:"Give it a name (optional)",value:a,onChange:u=>o(u.target.value),className:"text-base",autoFocus:!0})]}),h.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[h.jsx(je,{htmlFor:"shortcut-command",children:"Command"}),h.jsx("textarea",{id:"shortcut-command",placeholder:"Enter the command to send to Claude...",value:l,onChange:u=>c(u.target.value),className:X("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),d())}})]})]}),h.jsxs(ds,{className:"flex items-center justify-between sm:justify-between",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(te,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),h.jsx(te,{onClick:d,disabled:!l.trim(),children:"Save"})]})]})]})})}function jV({open:e,onOpenChange:t,label:n,command:r}){const[i,s]=b.useState(""),[a,o]=b.useState(()=>localStorage.getItem("ccweb_skillhub_author")||""),[l,c]=b.useState(""),[d,u]=b.useState(!1),[p,f]=b.useState(!1);b.useEffect(()=>{if(e){s(""),c(""),f(!1);const m=localStorage.getItem("ccweb_skillhub_author");m&&o(m)}},[e]);const g=async()=>{if(!d){u(!0);try{localStorage.setItem("ccweb_skillhub_author",a),await BP({label:n,command:r,description:i.trim(),author:a.trim()||"anonymous",tags:l.split(",").map(m=>m.trim()).filter(Boolean)}),f(!0)}catch(m){alert(m instanceof Error?m.message:"Failed to submit")}finally{u(!1)}}};return h.jsx(_a,{open:e,onOpenChange:t,children:h.jsxs(cs,{className:"sm:max-w-md",children:[h.jsxs(us,{children:[h.jsx(hs,{children:"分享到 SkillHub"}),h.jsxs(ps,{children:["将「",n,"」分享给社区,审核通过后将出现在 SkillHub 中。"]})]}),p?h.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"提交成功!等待审核后将出现在 SkillHub 中。"}):h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-desc",children:"描述"}),h.jsx("textarea",{id:"share-desc",placeholder:"简要描述这个命令的用途...",value:i,onChange:m=>s(m.target.value),className:X("w-full rounded-md border border-input bg-background px-3 py-2","text-sm min-h-[80px] resize-none","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2")})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-author",children:"作者"}),h.jsx(wn,{id:"share-author",placeholder:"你的名字",value:a,onChange:m=>o(m.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-tags",children:"标签(逗号分隔)"}),h.jsx(wn,{id:"share-tags",placeholder:"代码审查, 中文, 测试",value:l,onChange:m=>c(m.target.value)})]})]}),h.jsx(ds,{children:p?h.jsx(te,{onClick:()=>t(!1),children:"关闭"}):h.jsxs(h.Fragment,{children:[h.jsx(te,{variant:"outline",onClick:()=>t(!1),children:"取消"}),h.jsx(te,{onClick:g,disabled:d,children:d?"提交中...":"提交"})]})})]})})}function UV({projectId:e,onSend:t}){const[n,r]=b.useState([]),[i,s]=b.useState([]),[a,o]=b.useState(!1),[l,c]=b.useState(null),[d,u]=b.useState(!1),[p,f]=b.useState(""),[g,m]=b.useState("");b.useEffect(()=>{LP(e).then(r).catch(()=>r([]))},[e]),b.useEffect(()=>{$T().then(s).catch(()=>s([]))},[]);const v=b.useCallback(E=>{const T=[],D=new Set;let R=E;const I=[];for(;R&&!D.has(R.id);)D.add(R.id),I.unshift(R),R=R.parentId?i.find(O=>O.id===R.parentId):void 0;for(const O of I)T.push(O.command);return T},[i]),y=b.useCallback(E=>{v(E).forEach((D,R)=>{setTimeout(()=>t(D+"\r"),R*500)})},[v,t]),_=()=>{c(null),o(!0)},S=(E,T)=>{T.stopPropagation(),c(E),o(!0)},w=async(E,T)=>{try{if(l){const D=await MP(e,l.id,{label:E,command:T});r(R=>R.map(I=>I.id===D.id?D:I))}else{const D=await DP(e,{label:E,command:T});r(R=>[...R,D])}}catch(D){console.error("Failed to save shortcut:",D)}c(null)},k=(E,T,D)=>{D.stopPropagation(),f(E),m(T),u(!0)},x=async(E,T)=>{T.stopPropagation();try{await PP(e,E),r(D=>D.filter(R=>R.id!==E))}catch(D){console.error("Failed to delete shortcut:",D)}};return h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Shortcuts"}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:_,title:"New shortcut",children:h.jsx(oa,{className:"h-3.5 w-3.5"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[i.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1 pb-0.5",children:[h.jsx(fu,{className:"h-3 w-3 text-muted-foreground"}),h.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"全局"})]}),i.map(E=>{var D;const T=E.parentId?(D=i.find(R=>R.id===E.parentId))==null?void 0:D.label:void 0;return h.jsxs("div",{className:X("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>y(E),title:T?`继承自「${T}」`:"Click to send",children:[h.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-6 leading-snug",children:E.label}),T&&h.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[h.jsx(_o,{className:"h-2.5 w-2.5 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",T]})]}),!T&&E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug",children:E.command}),h.jsx("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:R=>k(E.label,E.command,R),title:"分享到 SkillHub",children:h.jsx(lE,{className:"h-3 w-3"})})})]},E.id)}),n.length>0&&h.jsx("div",{className:"flex items-center gap-1.5 px-1 pt-2 pb-0.5",children:h.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"项目"})})]}),n.length===0&&i.length===0&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[h.jsx(fu,{className:"h-5 w-5"}),h.jsxs("p",{className:"text-xs text-center leading-relaxed",children:["No shortcuts yet.",h.jsx("br",{}),"Click ",h.jsx("strong",{className:"text-muted-foreground",children:"+"})," to add one."]})]}),n.map(E=>h.jsxs("div",{className:X("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>t(E.command+"\r"),title:"Click to send",children:[h.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-10 leading-snug",children:E.label}),E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug pr-10",children:E.command}),h.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:T=>k(E.label,E.command,T),title:"分享到 SkillHub",children:h.jsx(lE,{className:"h-3 w-3"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-blue-400 transition-colors",onClick:T=>S(E,T),title:"Edit shortcut",children:h.jsx(ad,{className:"h-3 w-3"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-red-400 transition-colors",onClick:T=>x(E.id,T),title:"Delete shortcut",children:h.jsx(os,{className:"h-3 w-3"})})]})]},E.id))]}),h.jsx(BV,{open:a,onOpenChange:o,initialLabel:(l==null?void 0:l.label)??"",initialCommand:(l==null?void 0:l.command)??"",title:l?"Edit Shortcut":"New Shortcut",onSave:w}),h.jsx(jV,{open:d,onOpenChange:u,label:p,command:g})]})}function rI(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function iI(e){return`这是我们上一次的聊天记录,请你回忆:
542
+ `})]})}async function kV(e){const{default:t}=await pb(async()=>{const{default:s}=await import("./jszip.min-CwNvmrBU.js").then(a=>a.j);return{default:s}},[]),n=await t.loadAsync(e),r=[],i=Object.keys(n.files).filter(s=>/^ppt\/slides\/slide\d+\.xml$/i.test(s)).sort((s,a)=>{var c,d;const o=parseInt(((c=s.match(/slide(\d+)/))==null?void 0:c[1])??"0"),l=parseInt(((d=a.match(/slide(\d+)/))==null?void 0:d[1])??"0");return o-l});for(let s=0;s<i.length;s++){const a=await n.file(i[s]).async("text"),o=[],l=/<a:t[^>]*>([\s\S]*?)<\/a:t>/g;let c;for(;(c=l.exec(a))!==null;){const d=c[1].replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').trim();d&&o.push(d)}r.push({index:s+1,texts:o})}return r}function CV({filePath:e,zoom:t}){const[n,r]=b.useState([]),[i,s]=b.useState(null),[a,o]=b.useState(!0);return b.useEffect(()=>{let l=!1;return o(!0),s(null),(async()=>{try{const c=await bw(e),d=await kV(c);l||r(d)}catch(c){l||s(c instanceof Error?c.message:"Failed to render pptx")}finally{l||o(!1)}})(),()=>{l=!0}},[e]),a?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"加载 PPT 文件中..."}):i?h.jsx("p",{className:"text-sm text-destructive p-4",children:i}):n.length===0?h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"空文件"}):h.jsx("div",{className:"p-4 space-y-4",style:{fontSize:`${12*t/100}px`},children:n.map(l=>h.jsxs("div",{className:"border border-border rounded-lg p-5 bg-muted/20",children:[h.jsxs("div",{className:"text-xs text-muted-foreground mb-2 font-medium",children:["Slide ",l.index]}),l.texts.length>0?h.jsx("div",{className:"space-y-1.5",children:l.texts.map((c,d)=>h.jsx("p",{className:"text-foreground leading-relaxed",style:{fontSize:"inherit"},children:c},d))}):h.jsx("p",{className:"text-muted-foreground text-sm italic",children:"(无文本内容)"})]},l.index))})}const TV=new Set(["docx","xlsx","xls","pptx"]);function AV({filePath:e,ext:t,zoom:n}){return t==="docx"?h.jsx(xV,{filePath:e,zoom:n}):t==="xlsx"||t==="xls"?h.jsx(EV,{filePath:e,zoom:n}):t==="pptx"?h.jsx(CV,{filePath:e,zoom:n}):null}const nI={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function NV(e){const t=e.split("/").pop()??"",n=t.toLowerCase();if(n==="dockerfile")return"dockerfile";if(n==="makefile")return"makefile";const r=t.lastIndexOf(".");return r>=0?t.slice(r+1).toLowerCase():""}const RV=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function IV(e){return e==="md"||e==="html"||e==="htm"||e in nI}function M0(e){return e==="md"?"Markdown":e==="html"||e==="htm"?"HTML":"高亮"}const Ts=[50,75,100,125,150,200,250,300],nl=100,vg="cc_file_zoom";function OV(e){try{const n=JSON.parse(localStorage.getItem(vg)||"{}")[e];return Ts.includes(n)?n:nl}catch{return nl}}function LV(e,t){try{const n=JSON.parse(localStorage.getItem(vg)||"{}");t===nl?delete n[e]:n[e]=t,localStorage.setItem(vg,JSON.stringify(n))}catch{}}function DV({filePath:e,onClose:t}){const n=e.endsWith("/.notebook/graph.yaml"),r=n?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[i,s]=b.useState(null),[a,o]=b.useState(null),[l,c]=b.useState(()=>n?"graph":"rendered"),[d,u]=b.useState(!1),[p,f]=b.useState(nl),[g,m]=b.useState(""),[v,y]=b.useState(!1),[_,S]=b.useState(!1),w=b.useRef(null),{resolved:k}=jm(),x=e.split("/").pop()??e,E=b.useMemo(()=>NV(e),[e]),T=RV.has(E),D=TV.has(E),R=IV(E),I=nI[E]||E,O=b.useMemo(()=>{if(!T)return"";const $=Nm(e),W=kr();return W?`${$}&token=${encodeURIComponent(W)}`:$},[e,T]);b.useEffect(()=>{if(s(null),o(null),f(OV(e)),S(!1),T||D){s({path:e,binary:!1,tooLarge:!1,size:0,content:null}),c("rendered");return}c(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),HT(e).then($=>{s($),m($.content??"")}).catch($=>o($ instanceof Error?$.message:"Failed to load file"))},[e,T,D]);const N=$=>{if($.target===$.currentTarget){if(_&&!confirm("有未保存的修改,确定关闭?"))return;t()}};b.useEffect(()=>{const $=W=>{if(W.key==="Escape"){if(_&&!confirm("有未保存的修改,确定关闭?"))return;t()}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[t,_]);const P=b.useCallback(async()=>{y(!0);try{await GP(e,g),s($=>$&&{...$,content:g,size:new Blob([g]).size}),S(!1)}catch($){alert($ instanceof Error?$.message:"保存失败")}finally{y(!1)}},[e,g]);b.useEffect(()=>{const $=W=>{(W.metaKey||W.ctrlKey)&&W.key==="s"&&l==="edit"&&(W.preventDefault(),P())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[l,P]);const F=()=>{m((i==null?void 0:i.content)??""),S(!1),c("edit"),setTimeout(()=>{var $;return($=w.current)==null?void 0:$.focus()},0)},B=()=>{_&&!confirm("有未保存的修改,确定退出编辑?")||(c(n?"graph":R?"rendered":"plain"),S(!1))},j=$=>{f($),LV(e,$)},M=()=>{const $=Ts.find(W=>W>p);$&&j($)},U=()=>{const $=[...Ts].reverse().find(W=>W<p);$&&j($)},C=()=>j(nl),H=(i==null?void 0:i.content)??"",Z=k==="dark"?O8:L8,L=12*(p/100),se=i&&!i.binary&&!i.tooLarge,_e=b.useMemo(()=>{var ce,ue;if(E!=="md")return null;const $=l==="edit"?g:H;if(!$)return 0;const W=((ce=$.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))==null?void 0:ce.length)??0,re=((ue=$.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))==null?void 0:ue.length)??0;return W+re},[E,H,g,l]);return h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:N,children:h.jsxs("div",{className:X("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200",d?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg"),children:[h.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[h.jsx(Ec,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),h.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[x,_&&h.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),_e!==null&&h.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs",children:[_e.toLocaleString()," 字"]})]}),se&&!T&&!D&&h.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[R&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{onClick:()=>l==="edit"?B():c("plain"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="plain"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[h.jsx(dF,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),h.jsxs("button",{onClick:()=>l==="edit"?B():c("rendered"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="rendered"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:M0(E),children:[h.jsx(qT,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:M0(E)})]})]}),n&&h.jsxs("button",{onClick:()=>l==="edit"?B():c("graph"),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="graph"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[h.jsx(xF,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),h.jsxs("button",{onClick:()=>l==="edit"?B():F(),className:X("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs",l==="edit"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[h.jsx(ad,{className:"h-3 w-3"}),h.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),l==="edit"&&h.jsxs("button",{onClick:()=>void P(),disabled:v||!_,className:X("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",_?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[h.jsx(KT,{className:"h-3 w-3"}),v?"保存中...":"保存"]}),(se||T)&&l!=="edit"&&l!=="graph"&&h.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[h.jsx("button",{onClick:U,disabled:p<=Ts[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:h.jsx(ZT,{className:"h-3 w-3"})}),h.jsxs("button",{onClick:C,className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[p,"%"]}),h.jsx("button",{onClick:M,disabled:p>=Ts[Ts.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:h.jsx(XT,{className:"h-3 w-3"})})]}),h.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>u($=>!$),title:d?"退出全屏":"全屏",children:d?h.jsx(Om,{className:"h-3.5 w-3.5"}):h.jsx(Im,{className:"h-3.5 w-3.5"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{_&&!confirm("有未保存的修改,确定关闭?")||t()},children:h.jsx(os,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:X("flex-1 min-h-0",l==="graph"?"overflow-hidden":"overflow-auto"),children:[l==="graph"&&h.jsx(wV,{folderPath:r}),l!=="graph"&&!i&&!a&&h.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),l!=="graph"&&a&&h.jsx("p",{className:"text-sm text-red-400 p-4",children:a}),l!=="graph"&&T&&i&&h.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:h.jsx("img",{src:O,alt:x,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${p/100})`,transformOrigin:"center center"},draggable:!1})}),l!=="graph"&&D&&i&&h.jsx(AV,{filePath:e,ext:E,zoom:p}),l!=="graph"&&!T&&!D&&i&&i.binary&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[h.jsx(Ec,{className:"h-8 w-8"}),h.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.size/1024).toFixed(1)," KB"]})]}),l!=="graph"&&!D&&i&&i.tooLarge&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[h.jsx(Ec,{className:"h-8 w-8"}),h.jsx("p",{className:"text-sm",children:"File too large to preview"}),h.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.size/1024/1024).toFixed(2)," MB (limit 1 MB)"]})]}),l!=="graph"&&se&&H!==null&&h.jsxs(h.Fragment,{children:[l==="edit"&&h.jsx("textarea",{ref:w,value:g,onChange:$=>{m($.target.value),S(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${L}px`,minHeight:"100%"},spellCheck:!1}),l!=="edit"&&h.jsxs("div",{className:"p-4",style:{fontSize:`${L}px`},children:[l==="plain"&&h.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:H}),l==="rendered"&&E==="md"&&h.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:h.jsx(lR,{remarkPlugins:[OR],components:{code({className:$,children:W,...re}){const ce=/language-(\w+)/.exec($||"");return!ce&&!$?h.jsx("code",{className:$,...re,children:W}):h.jsx(yg,{style:Z,language:(ce==null?void 0:ce[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(W).replace(/\n$/,"")})}},children:H})}),l==="rendered"&&(E==="html"||E==="htm")&&h.jsx("iframe",{srcDoc:H,className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:x,style:{minHeight:"60vh",transform:`scale(${p/100})`,transformOrigin:"top left",width:`${1e4/p}%`,height:`${1e4/p}%`}}),l==="rendered"&&E!=="md"&&E!=="html"&&E!=="htm"&&I&&h.jsx(yg,{style:Z,language:I,showLineNumbers:!0,lineNumberStyle:{color:k==="dark"?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:H}),l==="rendered"&&!R&&h.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:H})]})]})]})]})})}const MV=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function PV(e){const t=e.lastIndexOf(".");return t>=0&&MV.has(e.slice(t+1).toLowerCase())}function FV({projectPath:e}){const[t,n]=b.useState(new Map),[r,i]=b.useState(new Set([e])),[s,a]=b.useState(new Set),[o,l]=b.useState(null),[c,d]=b.useState(null),[u,p]=b.useState(!1),[f,g]=b.useState(!1),m=b.useRef(null),v=b.useRef(null);b.useEffect(()=>{if(!c)return;const I=()=>d(null);return window.addEventListener("click",I),window.addEventListener("scroll",I,!0),()=>{window.removeEventListener("click",I),window.removeEventListener("scroll",I,!0)}},[c]);const y=(I,O)=>{let N=Nm(I);const P=kr();P&&(N+=`${N.includes("?")?"&":"?"}token=${encodeURIComponent(P)}`);const F=document.createElement("a");F.href=N,F.download=O,F.click()},_=async I=>{if(I.length!==0){p(!0);try{await zP(e,I),w(e)}catch(O){console.error("[FileTree] Upload failed:",O)}finally{p(!1)}}},S=I=>{I.preventDefault(),g(!1);const O=Array.from(I.dataTransfer.files);O.length>0&&_(O)},w=b.useCallback(async I=>{a(O=>{if(O.has(I))return O;const N=new Set(O);return N.add(I),N});try{const O=await zT(I);n(N=>new Map(N).set(I,O.entries))}catch(O){console.error("[FileTree] Failed to load:",I,O),n(N=>new Map(N).set(I,[]))}finally{a(O=>{const N=new Set(O);return N.delete(I),N})}},[]);b.useEffect(()=>{n(new Map),i(new Set([e])),a(new Set),w(e)},[e,w]);const k=b.useCallback(I=>{i(O=>{const N=new Set(O);return N.has(I)?N.delete(I):(N.add(I),t.has(I)||w(I)),N})},[t,w]),x=b.useCallback(()=>{n(new Map),i(new Set([e])),a(new Set),w(e)},[e,w]),E=(I,O)=>I.map(N=>{const P=r.has(N.path),F=s.has(N.path),B=t.get(N.path),j=N.name.startsWith(".");return h.jsxs("div",{children:[h.jsxs("div",{className:X("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted",j&&"opacity-50"),style:{paddingLeft:`${O*14+6}px`,paddingRight:"6px"},onClick:()=>N.type==="dir"?k(N.path):l(N.path),onContextMenu:M=>{N.type==="file"&&(M.preventDefault(),d({x:M.clientX,y:M.clientY,filePath:N.path,fileName:N.name}))},children:[h.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:N.type==="dir"&&(F?h.jsx(Ki,{className:"h-2.5 w-2.5 animate-spin"}):P?h.jsx(pl,{className:"h-2.5 w-2.5"}):h.jsx(sd,{className:"h-2.5 w-2.5"}))}),N.type==="dir"?P?h.jsx(Vo,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):h.jsx(pf,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):PV(N.name)?h.jsx(mF,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):h.jsx(Ec,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),h.jsx("span",{className:X("text-xs truncate leading-none",N.type==="dir"?"text-foreground":"text-muted-foreground"),title:N.path,children:N.name})]}),N.type==="dir"&&P&&h.jsxs("div",{children:[!B&&!F&&h.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(O+1)*14+6+16}px`},children:"—"}),(B==null?void 0:B.length)===0&&h.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(O+1)*14+6+16}px`},children:"empty"}),B&&B.length>0&&E(B,O+1)]})]},N.path)}),T=t.get(e),D=s.has(e),R=e.split("/").filter(Boolean).pop()??e;return h.jsxs(h.Fragment,{children:[o&&h.jsx(DV,{filePath:o,onClose:()=>l(null)}),c&&h.jsx("div",{ref:m,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:c.x,top:c.y},onClick:I=>I.stopPropagation(),children:h.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{y(c.filePath,c.fileName),d(null)},children:[h.jsx(pu,{className:"h-3.5 w-3.5"}),"下载"]})}),h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),h.jsxs("div",{className:"flex items-center gap-0.5",children:[h.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:I=>{const O=Array.from(I.target.files??[]);O.length>0&&_(O),I.target.value=""}}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var I;return(I=v.current)==null?void 0:I.click()},disabled:u,title:"上传文件",children:h.jsx(gf,{className:X("h-3 w-3",u&&"animate-pulse")})}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:x,title:"Refresh file tree",children:h.jsx(Ki,{className:X("h-3 w-3",D&&"animate-spin")})})]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[h.jsx(Vo,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),h.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:R})]}),h.jsxs("div",{className:X("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",f&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:I=>{I.preventDefault(),g(!0)},onDragEnter:I=>{I.preventDefault(),g(!0)},onDragLeave:()=>g(!1),onDrop:S,children:[u&&h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),f&&!u&&h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),D&&!T?h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):!T||T.length===0?h.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"}):E(T,0)]})]})]})}function BV({open:e,onOpenChange:t,initialLabel:n,initialCommand:r,title:i,onSave:s}){const[a,o]=b.useState(n),[l,c]=b.useState(r);b.useEffect(()=>{e&&(o(n),c(r))},[e,n,r]);const d=()=>{const u=l.trim();u&&(s(a.trim()||u,u),t(!1))};return h.jsx(_a,{open:e,onOpenChange:t,children:h.jsxs(cs,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col",children:[h.jsxs(us,{children:[h.jsx(hs,{children:i}),h.jsx(ps,{children:"Write the command that will be sent to Claude when this shortcut is triggered."})]}),h.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"shortcut-label",children:"Label"}),h.jsx(wn,{id:"shortcut-label",placeholder:"Give it a name (optional)",value:a,onChange:u=>o(u.target.value),className:"text-base",autoFocus:!0})]}),h.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[h.jsx(je,{htmlFor:"shortcut-command",children:"Command"}),h.jsx("textarea",{id:"shortcut-command",placeholder:"Enter the command to send to Claude...",value:l,onChange:u=>c(u.target.value),className:X("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),d())}})]})]}),h.jsxs(ds,{className:"flex items-center justify-between sm:justify-between",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(te,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),h.jsx(te,{onClick:d,disabled:!l.trim(),children:"Save"})]})]})]})})}function jV({open:e,onOpenChange:t,label:n,command:r}){const[i,s]=b.useState(""),[a,o]=b.useState(()=>localStorage.getItem("ccweb_skillhub_author")||""),[l,c]=b.useState(""),[d,u]=b.useState(!1),[p,f]=b.useState(!1);b.useEffect(()=>{if(e){s(""),c(""),f(!1);const m=localStorage.getItem("ccweb_skillhub_author");m&&o(m)}},[e]);const g=async()=>{if(!d){u(!0);try{localStorage.setItem("ccweb_skillhub_author",a),await BP({label:n,command:r,description:i.trim(),author:a.trim()||"anonymous",tags:l.split(",").map(m=>m.trim()).filter(Boolean)}),f(!0)}catch(m){alert(m instanceof Error?m.message:"Failed to submit")}finally{u(!1)}}};return h.jsx(_a,{open:e,onOpenChange:t,children:h.jsxs(cs,{className:"sm:max-w-md",children:[h.jsxs(us,{children:[h.jsx(hs,{children:"分享到 SkillHub"}),h.jsxs(ps,{children:["将「",n,"」分享给社区,审核通过后将出现在 SkillHub 中。"]})]}),p?h.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"提交成功!等待审核后将出现在 SkillHub 中。"}):h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-desc",children:"描述"}),h.jsx("textarea",{id:"share-desc",placeholder:"简要描述这个命令的用途...",value:i,onChange:m=>s(m.target.value),className:X("w-full rounded-md border border-input bg-background px-3 py-2","text-sm min-h-[80px] resize-none","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2")})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-author",children:"作者"}),h.jsx(wn,{id:"share-author",placeholder:"你的名字",value:a,onChange:m=>o(m.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{htmlFor:"share-tags",children:"标签(逗号分隔)"}),h.jsx(wn,{id:"share-tags",placeholder:"代码审查, 中文, 测试",value:l,onChange:m=>c(m.target.value)})]})]}),h.jsx(ds,{children:p?h.jsx(te,{onClick:()=>t(!1),children:"关闭"}):h.jsxs(h.Fragment,{children:[h.jsx(te,{variant:"outline",onClick:()=>t(!1),children:"取消"}),h.jsx(te,{onClick:g,disabled:d,children:d?"提交中...":"提交"})]})})]})})}function UV({projectId:e,onSend:t}){const[n,r]=b.useState([]),[i,s]=b.useState([]),[a,o]=b.useState(!1),[l,c]=b.useState(null),[d,u]=b.useState(!1),[p,f]=b.useState(""),[g,m]=b.useState("");b.useEffect(()=>{LP(e).then(r).catch(()=>r([]))},[e]),b.useEffect(()=>{$T().then(s).catch(()=>s([]))},[]);const v=b.useCallback(E=>{const T=[],D=new Set;let R=E;const I=[];for(;R&&!D.has(R.id);)D.add(R.id),I.unshift(R),R=R.parentId?i.find(O=>O.id===R.parentId):void 0;for(const O of I)T.push(O.command);return T},[i]),y=b.useCallback(E=>{v(E).forEach((D,R)=>{setTimeout(()=>t(D+"\r"),R*500)})},[v,t]),_=()=>{c(null),o(!0)},S=(E,T)=>{T.stopPropagation(),c(E),o(!0)},w=async(E,T)=>{try{if(l){const D=await MP(e,l.id,{label:E,command:T});r(R=>R.map(I=>I.id===D.id?D:I))}else{const D=await DP(e,{label:E,command:T});r(R=>[...R,D])}}catch(D){console.error("Failed to save shortcut:",D)}c(null)},k=(E,T,D)=>{D.stopPropagation(),f(E),m(T),u(!0)},x=async(E,T)=>{T.stopPropagation();try{await PP(e,E),r(D=>D.filter(R=>R.id!==E))}catch(D){console.error("Failed to delete shortcut:",D)}};return h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[h.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Shortcuts"}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:_,title:"New shortcut",children:h.jsx(oa,{className:"h-3.5 w-3.5"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[i.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1 pb-0.5",children:[h.jsx(fu,{className:"h-3 w-3 text-muted-foreground"}),h.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"全局"})]}),i.map(E=>{var D;const T=E.parentId?(D=i.find(R=>R.id===E.parentId))==null?void 0:D.label:void 0;return h.jsxs("div",{className:X("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>y(E),title:T?`继承自「${T}」`:"Click to send",children:[h.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-6 leading-snug",children:E.label}),T&&h.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[h.jsx(_o,{className:"h-2.5 w-2.5 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",T]})]}),!T&&E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug",children:E.command}),h.jsx("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:R=>k(E.label,E.command,R),title:"分享到 SkillHub",children:h.jsx(lE,{className:"h-3 w-3"})})})]},E.id)}),n.length>0&&h.jsx("div",{className:"flex items-center gap-1.5 px-1 pt-2 pb-0.5",children:h.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"项目"})})]}),n.length===0&&i.length===0&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[h.jsx(fu,{className:"h-5 w-5"}),h.jsxs("p",{className:"text-xs text-center leading-relaxed",children:["No shortcuts yet.",h.jsx("br",{}),"Click ",h.jsx("strong",{className:"text-muted-foreground",children:"+"})," to add one."]})]}),n.map(E=>h.jsxs("div",{className:X("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>t(E.command+"\r"),title:"Click to send",children:[h.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-10 leading-snug",children:E.label}),E.label!==E.command&&h.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug pr-10",children:E.command}),h.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:T=>k(E.label,E.command,T),title:"分享到 SkillHub",children:h.jsx(lE,{className:"h-3 w-3"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-blue-400 transition-colors",onClick:T=>S(E,T),title:"Edit shortcut",children:h.jsx(ad,{className:"h-3 w-3"})}),h.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-red-400 transition-colors",onClick:T=>x(E.id,T),title:"Delete shortcut",children:h.jsx(os,{className:"h-3 w-3"})})]})]},E.id))]}),h.jsx(BV,{open:a,onOpenChange:o,initialLabel:(l==null?void 0:l.label)??"",initialCommand:(l==null?void 0:l.command)??"",title:l?"Edit Shortcut":"New Shortcut",onSave:w}),h.jsx(jV,{open:d,onOpenChange:u,label:p,command:g})]})}function rI(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function iI(e){return`这是我们上一次的聊天记录,请你回忆:
543
543
 
544
544
  ${e.messages.map(n=>`[${n.role==="user"?"User":"Assistant"}]: ${n.content}`).join(`
545
545
 
546
- `)}`}function $V({session:e,onClose:t,onRecall:n}){return h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),h.jsxs("div",{className:"relative z-10 w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 h-11 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-sm font-medium text-foreground",children:rI(e.startedAt)}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("button",{className:"flex items-center gap-1.5 text-xs px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white transition-colors",onClick:()=>{n(iI(e)),t()},children:[h.jsx(Rm,{className:"h-3 w-3"}),"回忆"]}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5",onClick:t,children:h.jsx(os,{className:"h-4 w-4"})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-h-0",children:[e.messages.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),e.messages.map((r,i)=>h.jsxs("div",{className:X("flex gap-2.5",r.role==="user"?"flex-row-reverse":"flex-row"),children:[h.jsx("div",{className:X("flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center mt-0.5",r.role==="user"?"bg-blue-600/20":"bg-muted"),children:r.role==="user"?h.jsx(YT,{className:"h-3 w-3 text-blue-400"}):h.jsx(GT,{className:"h-3 w-3 text-muted-foreground"})}),h.jsx("div",{className:X("max-w-[85%] text-xs rounded-lg px-3 py-2 whitespace-pre-wrap break-words",r.role==="user"?"bg-blue-600/20 text-blue-100 dark:text-blue-100 border border-blue-500/20":"bg-muted text-foreground border border-border"),children:r.content})]},i))]})]})]})}function zV({projectId:e,onSend:t}){var d;const[n,r]=b.useState([]),[i,s]=b.useState(null),a=n.filter(u=>u.messageCount>0),o=(d=a.find(u=>!u.isCurrent))==null?void 0:d.id;b.useEffect(()=>{let u=null;const p=()=>{document.hidden||nE(e).then(r).catch(()=>{})};nE(e).then(r).catch(()=>r([]));const f=()=>{u=setInterval(p,5e3)},g=()=>{u&&(clearInterval(u),u=null)},m=()=>{document.hidden?g():f()};return f(),document.addEventListener("visibilitychange",m),()=>{g(),document.removeEventListener("visibilitychange",m)}},[e]);const l=async u=>{try{s(await rE(e,u))}catch{}},c=u=>{t(u+"\r")};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[a.length===0&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[h.jsx(GT,{className:"h-5 w-5"}),h.jsx("p",{className:"text-xs text-center",children:"暂无历史记录"})]}),a.map(u=>{const p=u.isCurrent,f=!u.isCurrent&&u.id===o;return h.jsxs("div",{className:X("group rounded border bg-muted hover:border-muted-foreground/30 transition-colors",p?"border-blue-500/50":"border-border"),children:[h.jsxs("button",{className:"w-full text-left px-3 pt-2 pb-1",onClick:()=>void l(u.id),children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-xs font-medium text-foreground",children:rI(u.startedAt)}),p&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30 leading-none",children:"当前"}),f&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground border border-border leading-none",children:"最近"})]}),h.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:[u.messageCount," 条消息"]})]}),h.jsx("div",{className:"px-3 pb-2 flex justify-end",children:h.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async g=>{g.stopPropagation();try{const m=await rE(e,u.id);c(iI(m))}catch{}},children:[h.jsx(Rm,{className:"h-2.5 w-2.5"}),"回忆"]})})]},u.id)})]}),i&&h.jsx($V,{session:i,onClose:()=>s(null),onRecall:c})]})}const HV={shortcuts:"快捷命令",history:"历史记录"};function GV({projectId:e,onSend:t}){const[n,r]=b.useState("shortcuts");return h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground",children:[h.jsx("div",{className:"flex border-b border-border flex-shrink-0",children:["shortcuts","history"].map(i=>h.jsx("button",{onClick:()=>r(i),className:X("flex-1 text-xs py-2 font-medium transition-colors",n===i?"text-foreground border-b-2 border-blue-500 -mb-px bg-muted/50":"text-muted-foreground hover:text-foreground"),children:HV[i]},i))}),n==="shortcuts"&&h.jsx(UV,{projectId:e,onSend:t}),n==="history"&&h.jsx(zV,{projectId:e,onSend:t})]})}const WV=new Set(["preset:wind","preset:rain","preset:stream"]),VV=new Set(["preset:singing-bowl","preset:water-drops","preset:keyboard"]);function qV(e){return e.playMode!=="auto"?e.playMode:WV.has(e.source)?"loop":VV.has(e.source)?"interval":"loop"}function KV({projectId:e,config:t,isActive:n}){const r=b.useRef(null),i=b.useRef(null),s=b.useRef(null),a=b.useRef(null),o=b.useRef(null),l=b.useRef(null),c=b.useRef(!1),d=b.useCallback(()=>{if(o.current&&(clearTimeout(o.current),o.current=null),l.current&&(clearTimeout(l.current),l.current=null),r.current&&(r.current.pause(),r.current.src=""),a.current){try{a.current.disconnect()}catch{}a.current=null}if(s.current){try{s.current.disconnect()}catch{}s.current=null}if(i.current){try{i.current.close()}catch{}i.current=null}r.current=null,c.current=!1},[]),u=b.useCallback(g=>{if(!r.current||r.current.src!==g){if(a.current){try{a.current.disconnect()}catch{}a.current=null}r.current&&r.current.pause();const m=new Audio(g);m.crossOrigin="anonymous",r.current=m}if(i.current||(i.current=new AudioContext),!s.current){const m=i.current.createGain();m.gain.value=0,m.connect(i.current.destination),s.current=m}if(!a.current){const m=i.current.createMediaElementSource(r.current);m.connect(s.current),a.current=m}return{audio:r.current,ctx:i.current,gain:s.current}},[]),p=b.useCallback(g=>{const m=aE(g.source,e),v=Math.max(0,Math.min(1,g.volume)),y=qV(g),{audio:_,ctx:S,gain:w}=u(m);S.resume().then(()=>{if(o.current&&(clearTimeout(o.current),o.current=null),l.current&&(clearTimeout(l.current),l.current=null),y==="loop")_.loop=!0,_.currentTime=0,_.play().catch(()=>{}),c.current=!0,w.gain.cancelScheduledValues(S.currentTime),w.gain.setValueAtTime(w.gain.value,S.currentTime),w.gain.linearRampToValueAtTime(v,S.currentTime+.5);else{_.loop=!1;const k=()=>{if(!c.current)return;_.currentTime=0,_.play().catch(()=>{}),w.gain.cancelScheduledValues(S.currentTime),w.gain.setValueAtTime(w.gain.value,S.currentTime),w.gain.linearRampToValueAtTime(v,S.currentTime+.5);const x=()=>{if(!c.current)return;const[E,T]=g.intervalRange,D=(E+Math.random()*(T-E))*1e3;l.current=setTimeout(k,D)};_.onended=x};c.current=!0,k()}}).catch(()=>{})},[e,u]),f=b.useCallback(()=>{if(!r.current||!i.current||!s.current){c.current=!1;return}c.current=!1,l.current&&(clearTimeout(l.current),l.current=null),r.current&&(r.current.onended=null);const g=i.current,m=s.current,v=r.current;m.gain.cancelScheduledValues(g.currentTime),m.gain.setValueAtTime(m.gain.value,g.currentTime),m.gain.linearRampToValueAtTime(0,g.currentTime+1),o.current=setTimeout(()=>{o.current=null,v&&v.pause()},1100)},[]);return b.useEffect(()=>{!t||!t.enabled||(n?p(t):f())},[n,t,p,f]),b.useEffect(()=>()=>{d()},[d]),b.useEffect(()=>{if(!t){d();return}if(r.current){const g=aE(t.source,e);if(r.current.src!==g){if(f(),a.current){try{a.current.disconnect()}catch{}a.current=null}r.current.pause(),r.current=null,n&&p(t)}}},[t==null?void 0:t.source,e]),null}function sI(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function aI(e){const[t,n]=b.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,o;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;a=c.inlineSize,o=c.blockSize}else a=e.offsetWidth,o=e.offsetHeight;n({width:a,height:o})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Dd="Switch",[YV]=bi(Dd),[XV,ZV]=YV(Dd),oI=b.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:a,disabled:o,value:l="on",onCheckedChange:c,form:d,...u}=e,[p,f]=b.useState(null),g=Le(t,S=>f(S)),m=b.useRef(!1),v=p?d||!!p.closest("form"):!0,[y,_]=Yi({prop:i,defaultProp:s??!1,onChange:c,caller:Dd});return h.jsxs(XV,{scope:n,checked:y,disabled:o,children:[h.jsx(we.button,{type:"button",role:"switch","aria-checked":y,"aria-required":a,"data-state":dI(y),"data-disabled":o?"":void 0,disabled:o,value:l,...u,ref:g,onClick:ge(e.onClick,S=>{_(w=>!w),v&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),v&&h.jsx(uI,{control:p,bubbles:!m.current,name:r,value:l,checked:y,required:a,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});oI.displayName=Dd;var lI="SwitchThumb",cI=b.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=ZV(lI,n);return h.jsx(we.span,{"data-state":dI(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});cI.displayName=lI;var QV="SwitchBubbleInput",uI=b.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},s)=>{const a=b.useRef(null),o=Le(a,s),l=sI(n),c=aI(t);return b.useEffect(()=>{const d=a.current;if(!d)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"checked").set;if(l!==n&&f){const g=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(g)}},[l,n,r]),h.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:o,style:{...i.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});uI.displayName=QV;function dI(e){return e?"checked":"unchecked"}var hI=oI,JV=cI;const yw=b.forwardRef(({className:e,...t},n)=>h.jsx(hI,{className:X("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),...t,ref:n,children:h.jsx(JV,{className:X("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")})}));yw.displayName=hI.displayName;function P0(e,[t,n]){return Math.min(n,Math.max(t,e))}function F0(e){const t=e7(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(n7);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function e7(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=i7(i),o=r7(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var t7=Symbol("radix.slottable");function n7(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t7}function r7(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function i7(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function pI(e){const t=e+"CollectionProvider",[n,r]=bi(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:v,children:y}=m,_=ft.useRef(null),S=ft.useRef(new Map).current;return h.jsx(i,{scope:v,itemMap:S,collectionRef:_,children:y})};a.displayName=t;const o=e+"CollectionSlot",l=F0(o),c=ft.forwardRef((m,v)=>{const{scope:y,children:_}=m,S=s(o,y),w=Le(v,S.collectionRef);return h.jsx(l,{ref:w,children:_})});c.displayName=o;const d=e+"CollectionItemSlot",u="data-radix-collection-item",p=F0(d),f=ft.forwardRef((m,v)=>{const{scope:y,children:_,...S}=m,w=ft.useRef(null),k=Le(v,w),x=s(d,y);return ft.useEffect(()=>(x.itemMap.set(w,{ref:w,...S}),()=>void x.itemMap.delete(w))),h.jsx(p,{[u]:"",ref:k,children:_})});f.displayName=d;function g(m){const v=s(e+"CollectionConsumer",m);return ft.useCallback(()=>{const _=v.collectionRef.current;if(!_)return[];const S=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((x,E)=>S.indexOf(x.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:c,ItemSlot:f},g,r]}var s7=b.createContext(void 0);function _w(e){const t=b.useContext(s7);return e||t||"ltr"}const a7=["top","right","bottom","left"],di=Math.min,sn=Math.max,Nu=Math.round,uc=Math.floor,er=e=>({x:e,y:e}),o7={left:"right",right:"left",bottom:"top",top:"bottom"};function Sg(e,t,n){return sn(e,di(t,n))}function wr(e,t){return typeof e=="function"?e(t):e}function xr(e){return e.split("-")[0]}function Ra(e){return e.split("-")[1]}function vw(e){return e==="x"?"y":"x"}function Sw(e){return e==="y"?"height":"width"}function Yn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ww(e){return vw(Yn(e))}function l7(e,t,n){n===void 0&&(n=!1);const r=Ra(e),i=ww(e),s=Sw(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Ru(a)),[a,Ru(a)]}function c7(e){const t=Ru(e);return[wg(e),t,wg(t)]}function wg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const B0=["left","right"],j0=["right","left"],u7=["top","bottom"],d7=["bottom","top"];function h7(e,t,n){switch(e){case"top":case"bottom":return n?t?j0:B0:t?B0:j0;case"left":case"right":return t?u7:d7;default:return[]}}function p7(e,t,n,r){const i=Ra(e);let s=h7(xr(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(wg)))),s}function Ru(e){const t=xr(e);return o7[t]+e.slice(t.length)}function f7(e){return{top:0,right:0,bottom:0,left:0,...e}}function fI(e){return typeof e!="number"?f7(e):{top:e,right:e,bottom:e,left:e}}function Iu(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function U0(e,t,n){let{reference:r,floating:i}=e;const s=Yn(t),a=ww(t),o=Sw(a),l=xr(t),c=s==="y",d=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,p=r[o]/2-i[o]/2;let f;switch(l){case"top":f={x:d,y:r.y-i.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Ra(t)){case"start":f[a]-=p*(n&&c?-1:1);break;case"end":f[a]+=p*(n&&c?-1:1);break}return f}async function g7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:f=0}=wr(t,e),g=fI(f),v=o[p?u==="floating"?"reference":"floating":u],y=Iu(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:d,strategy:l})),_=u==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),w=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},k=Iu(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:S,strategy:l}):_);return{top:(y.top-k.top+g.top)/w.y,bottom:(k.bottom-y.bottom+g.bottom)/w.y,left:(y.left-k.left+g.left)/w.x,right:(k.right-y.right+g.right)/w.x}}const m7=50,b7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,o=a.detectOverflow?a:{...a,detectOverflow:g7},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:u}=U0(c,r,l),p=r,f=0;const g={};for(let m=0;m<s.length;m++){const v=s[m];if(!v)continue;const{name:y,fn:_}=v,{x:S,y:w,data:k,reset:x}=await _({x:d,y:u,initialPlacement:r,placement:p,strategy:i,middlewareData:g,rects:c,platform:o,elements:{reference:e,floating:t}});d=S??d,u=w??u,g[y]={...g[y],...k},x&&f<m7&&(f++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:d,y:u}=U0(c,p,l)),m=-1)}return{x:d,y:u,placement:p,strategy:i,middlewareData:g}},y7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:o,middlewareData:l}=t,{element:c,padding:d=0}=wr(e,t)||{};if(c==null)return{};const u=fI(d),p={x:n,y:r},f=ww(i),g=Sw(f),m=await a.getDimensions(c),v=f==="y",y=v?"top":"left",_=v?"bottom":"right",S=v?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[f]-p[f]-s.floating[g],k=p[f]-s.reference[f],x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let E=x?x[S]:0;(!E||!await(a.isElement==null?void 0:a.isElement(x)))&&(E=o.floating[S]||s.floating[g]);const T=w/2-k/2,D=E/2-m[g]/2-1,R=di(u[y],D),I=di(u[_],D),O=R,N=E-m[g]-I,P=E/2-m[g]/2+T,F=Sg(O,P,N),B=!l.arrow&&Ra(i)!=null&&P!==F&&s.reference[g]/2-(P<O?R:I)-m[g]/2<0,j=B?P<O?P-O:P-N:0;return{[f]:p[f]+j,data:{[f]:F,centerOffset:P-F-j,...B&&{alignmentOffset:j}},reset:B}}}),_7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:o,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...v}=wr(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=xr(i),_=Yn(o),S=xr(o)===o,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=p||(S||!m?[Ru(o)]:c7(o)),x=g!=="none";!p&&x&&k.push(...p7(o,m,g,w));const E=[o,...k],T=await l.detectOverflow(t,v),D=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&D.push(T[y]),u){const P=l7(i,a,w);D.push(T[P[0]],T[P[1]])}if(R=[...R,{placement:i,overflows:D}],!D.every(P=>P<=0)){var I,O;const P=(((I=s.flip)==null?void 0:I.index)||0)+1,F=E[P];if(F&&(!(u==="alignment"?_!==Yn(F):!1)||R.every(M=>Yn(M.placement)===_?M.overflows[0]>0:!0)))return{data:{index:P,overflows:R},reset:{placement:F}};let B=(O=R.filter(j=>j.overflows[0]<=0).sort((j,M)=>j.overflows[1]-M.overflows[1])[0])==null?void 0:O.placement;if(!B)switch(f){case"bestFit":{var N;const j=(N=R.filter(M=>{if(x){const U=Yn(M.placement);return U===_||U==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(U=>U>0).reduce((U,C)=>U+C,0)]).sort((M,U)=>M[1]-U[1])[0])==null?void 0:N[0];j&&(B=j);break}case"initialPlacement":B=o;break}if(i!==B)return{reset:{placement:B}}}return{}}}};function $0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function z0(e){return a7.some(t=>e[t]>=0)}const v7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=wr(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),o=$0(a,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:z0(o)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),o=$0(a,n.floating);return{data:{escapedOffsets:o,escaped:z0(o)}}}default:return{}}}}},gI=new Set(["left","top"]);async function S7(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xr(n),o=Ra(n),l=Yn(n)==="y",c=gI.has(a)?-1:1,d=s&&l?-1:1,u=wr(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return o&&typeof g=="number"&&(f=o==="end"?g*-1:g),l?{x:f*d,y:p*c}:{x:p*c,y:f*d}}const w7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:o}=t,l=await S7(t,e);return a===((n=o.offset)==null?void 0:n.placement)&&(r=o.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:a}}}}},x7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:_,y:S}=y;return{x:_,y:S}}},...c}=wr(e,t),d={x:n,y:r},u=await s.detectOverflow(t,c),p=Yn(xr(i)),f=vw(p);let g=d[f],m=d[p];if(a){const y=f==="y"?"top":"left",_=f==="y"?"bottom":"right",S=g+u[y],w=g-u[_];g=Sg(S,g,w)}if(o){const y=p==="y"?"top":"left",_=p==="y"?"bottom":"right",S=m+u[y],w=m-u[_];m=Sg(S,m,w)}const v=l.fn({...t,[f]:g,[p]:m});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[f]:a,[p]:o}}}}}},E7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:o=0,mainAxis:l=!0,crossAxis:c=!0}=wr(e,t),d={x:n,y:r},u=Yn(i),p=vw(u);let f=d[p],g=d[u];const m=wr(o,t),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const S=p==="y"?"height":"width",w=s.reference[p]-s.floating[S]+v.mainAxis,k=s.reference[p]+s.reference[S]-v.mainAxis;f<w?f=w:f>k&&(f=k)}if(c){var y,_;const S=p==="y"?"width":"height",w=gI.has(xr(i)),k=s.reference[u]-s.floating[S]+(w&&((y=a.offset)==null?void 0:y[u])||0)+(w?0:v.crossAxis),x=s.reference[u]+s.reference[S]+(w?0:((_=a.offset)==null?void 0:_[u])||0)-(w?v.crossAxis:0);g<k?g=k:g>x&&(g=x)}return{[p]:f,[u]:g}}}},k7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:o}=t,{apply:l=()=>{},...c}=wr(e,t),d=await a.detectOverflow(t,c),u=xr(i),p=Ra(i),f=Yn(i)==="y",{width:g,height:m}=s.floating;let v,y;u==="top"||u==="bottom"?(v=u,y=p===(await(a.isRTL==null?void 0:a.isRTL(o.floating))?"start":"end")?"left":"right"):(y=u,v=p==="end"?"top":"bottom");const _=m-d.top-d.bottom,S=g-d.left-d.right,w=di(m-d[v],_),k=di(g-d[y],S),x=!t.middlewareData.shift;let E=w,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=_),x&&!p){const R=sn(d.left,0),I=sn(d.right,0),O=sn(d.top,0),N=sn(d.bottom,0);f?T=g-2*(R!==0||I!==0?R+I:sn(d.left,d.right)):E=m-2*(O!==0||N!==0?O+N:sn(d.top,d.bottom))}await l({...t,availableWidth:T,availableHeight:E});const D=await a.getDimensions(o.floating);return g!==D.width||m!==D.height?{reset:{rects:!0}}:{}}}};function Md(){return typeof window<"u"}function Ia(e){return mI(e)?(e.nodeName||"").toLowerCase():"#document"}function cn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ir(e){var t;return(t=(mI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mI(e){return Md()?e instanceof Node||e instanceof cn(e).Node:!1}function Fn(e){return Md()?e instanceof Element||e instanceof cn(e).Element:!1}function Nr(e){return Md()?e instanceof HTMLElement||e instanceof cn(e).HTMLElement:!1}function H0(e){return!Md()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof cn(e).ShadowRoot}function Tl(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Bn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function C7(e){return/^(table|td|th)$/.test(Ia(e))}function Pd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const T7=/transform|translate|scale|rotate|perspective|filter/,A7=/paint|layout|strict|content/,Ci=e=>!!e&&e!=="none";let ap;function xw(e){const t=Fn(e)?Bn(e):e;return Ci(t.transform)||Ci(t.translate)||Ci(t.scale)||Ci(t.rotate)||Ci(t.perspective)||!Ew()&&(Ci(t.backdropFilter)||Ci(t.filter))||T7.test(t.willChange||"")||A7.test(t.contain||"")}function N7(e){let t=hi(e);for(;Nr(t)&&!da(t);){if(xw(t))return t;if(Pd(t))return null;t=hi(t)}return null}function Ew(){return ap==null&&(ap=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ap}function da(e){return/^(html|body|#document)$/.test(Ia(e))}function Bn(e){return cn(e).getComputedStyle(e)}function Fd(e){return Fn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function hi(e){if(Ia(e)==="html")return e;const t=e.assignedSlot||e.parentNode||H0(e)&&e.host||ir(e);return H0(t)?t.host:t}function bI(e){const t=hi(e);return da(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nr(t)&&Tl(t)?t:bI(t)}function rl(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=bI(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=cn(i);if(s){const o=xg(a);return t.concat(a,a.visualViewport||[],Tl(i)?i:[],o&&n?rl(o):[])}else return t.concat(i,rl(i,[],n))}function xg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yI(e){const t=Bn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Nr(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=Nu(n)!==s||Nu(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function kw(e){return Fn(e)?e:e.contextElement}function Js(e){const t=kw(e);if(!Nr(t))return er(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=yI(t);let a=(s?Nu(n.width):n.width)/r,o=(s?Nu(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const R7=er(0);function _I(e){const t=cn(e);return!Ew()||!t.visualViewport?R7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function I7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==cn(e)?!1:t}function es(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=kw(e);let a=er(1);t&&(r?Fn(r)&&(a=Js(r)):a=Js(e));const o=I7(s,n,r)?_I(s):er(0);let l=(i.left+o.x)/a.x,c=(i.top+o.y)/a.y,d=i.width/a.x,u=i.height/a.y;if(s){const p=cn(s),f=r&&Fn(r)?cn(r):r;let g=p,m=xg(g);for(;m&&r&&f!==g;){const v=Js(m),y=m.getBoundingClientRect(),_=Bn(m),S=y.left+(m.clientLeft+parseFloat(_.paddingLeft))*v.x,w=y.top+(m.clientTop+parseFloat(_.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,u*=v.y,l+=S,c+=w,g=cn(m),m=xg(g)}}return Iu({width:d,height:u,x:l,y:c})}function Bd(e,t){const n=Fd(e).scrollLeft;return t?t.left+n:es(ir(e)).left+n}function vI(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bd(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function O7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=ir(r),o=t?Pd(t.floating):!1;if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=er(1);const d=er(0),u=Nr(r);if((u||!u&&!s)&&((Ia(r)!=="body"||Tl(a))&&(l=Fd(r)),u)){const f=es(r);c=Js(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const p=a&&!u&&!s?vI(a,l):er(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function L7(e){return Array.from(e.getClientRects())}function D7(e){const t=ir(e),n=Fd(e),r=e.ownerDocument.body,i=sn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=sn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Bd(e);const o=-n.scrollTop;return Bn(r).direction==="rtl"&&(a+=sn(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}const G0=25;function M7(e,t){const n=cn(e),r=ir(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,o=0,l=0;if(i){s=i.width,a=i.height;const d=Ew();(!d||d&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}const c=Bd(r);if(c<=0){const d=r.ownerDocument,u=d.body,p=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-f);g<=G0&&(s-=g)}else c<=G0&&(s+=c);return{width:s,height:a,x:o,y:l}}function P7(e,t){const n=es(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Nr(e)?Js(e):er(1),a=e.clientWidth*s.x,o=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:a,height:o,x:l,y:c}}function W0(e,t,n){let r;if(t==="viewport")r=M7(e,n);else if(t==="document")r=D7(ir(e));else if(Fn(t))r=P7(t,n);else{const i=_I(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Iu(r)}function SI(e,t){const n=hi(e);return n===t||!Fn(n)||da(n)?!1:Bn(n).position==="fixed"||SI(n,t)}function F7(e,t){const n=t.get(e);if(n)return n;let r=rl(e,[],!1).filter(o=>Fn(o)&&Ia(o)!=="body"),i=null;const s=Bn(e).position==="fixed";let a=s?hi(e):e;for(;Fn(a)&&!da(a);){const o=Bn(a),l=xw(a);!l&&o.position==="fixed"&&(i=null),(s?!l&&!i:!l&&o.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Tl(a)&&!l&&SI(e,a))?r=r.filter(d=>d!==a):i=o,a=hi(a)}return t.set(e,r),r}function B7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Pd(t)?[]:F7(t,this._c):[].concat(n),r],o=W0(t,a[0],i);let l=o.top,c=o.right,d=o.bottom,u=o.left;for(let p=1;p<a.length;p++){const f=W0(t,a[p],i);l=sn(f.top,l),c=di(f.right,c),d=di(f.bottom,d),u=sn(f.left,u)}return{width:c-u,height:d-l,x:u,y:l}}function j7(e){const{width:t,height:n}=yI(e);return{width:t,height:n}}function U7(e,t,n){const r=Nr(t),i=ir(t),s=n==="fixed",a=es(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=er(0);function c(){l.x=Bd(i)}if(r||!r&&!s)if((Ia(t)!=="body"||Tl(i))&&(o=Fd(t)),r){const f=es(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else i&&c();s&&!r&&i&&c();const d=i&&!r&&!s?vI(i,o):er(0),u=a.left+o.scrollLeft-l.x-d.x,p=a.top+o.scrollTop-l.y-d.y;return{x:u,y:p,width:a.width,height:a.height}}function op(e){return Bn(e).position==="static"}function V0(e,t){if(!Nr(e)||Bn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ir(e)===n&&(n=n.ownerDocument.body),n}function wI(e,t){const n=cn(e);if(Pd(e))return n;if(!Nr(e)){let i=hi(e);for(;i&&!da(i);){if(Fn(i)&&!op(i))return i;i=hi(i)}return n}let r=V0(e,t);for(;r&&C7(r)&&op(r);)r=V0(r,t);return r&&da(r)&&op(r)&&!xw(r)?n:r||N7(e)||n}const $7=async function(e){const t=this.getOffsetParent||wI,n=this.getDimensions,r=await n(e.floating);return{reference:U7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function z7(e){return Bn(e).direction==="rtl"}const H7={convertOffsetParentRelativeRectToViewportRelativeRect:O7,getDocumentElement:ir,getClippingRect:B7,getOffsetParent:wI,getElementRects:$7,getClientRects:L7,getDimensions:j7,getScale:Js,isElement:Fn,isRTL:z7};function xI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function G7(e,t){let n=null,r;const i=ir(e);function s(){var o;clearTimeout(r),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:u,width:p,height:f}=c;if(o||t(),!p||!f)return;const g=uc(u),m=uc(i.clientWidth-(d+p)),v=uc(i.clientHeight-(u+f)),y=uc(d),S={rootMargin:-g+"px "+-m+"px "+-v+"px "+-y+"px",threshold:sn(0,di(1,l))||1};let w=!0;function k(x){const E=x[0].intersectionRatio;if(E!==l){if(!w)return a();E?a(!1,E):r=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!xI(c,e.getBoundingClientRect())&&a(),w=!1}try{n=new IntersectionObserver(k,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(k,S)}n.observe(e)}return a(!0),s}function W7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=kw(e),d=i||s?[...c?rl(c):[],...t?rl(t):[]]:[];d.forEach(y=>{i&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const u=c&&o?G7(c,n):null;let p=-1,f=null;a&&(f=new ResizeObserver(y=>{let[_]=y;_&&_.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),t&&f.observe(t));let g,m=l?es(e):null;l&&v();function v(){const y=es(e);m&&!xI(m,y)&&n(),m=y,g=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(_=>{i&&_.removeEventListener("scroll",n),s&&_.removeEventListener("resize",n)}),u==null||u(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(g)}}const V7=w7,q7=x7,K7=_7,Y7=k7,X7=v7,q0=y7,Z7=E7,Q7=(e,t,n)=>{const r=new Map,i={platform:H7,...n},s={...i.platform,_c:r};return b7(e,t,{...i,platform:s})};var J7=typeof document<"u",eq=function(){},Fc=J7?b.useLayoutEffect:eq;function Ou(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ou(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Ou(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function EI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function K0(e,t){const n=EI(e);return Math.round(t*n)/n}function lp(e){const t=b.useRef(e);return Fc(()=>{t.current=e}),t}function tq(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:o=!0,whileElementsMounted:l,open:c}=e,[d,u]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=b.useState(r);Ou(p,r)||f(r);const[g,m]=b.useState(null),[v,y]=b.useState(null),_=b.useCallback(M=>{M!==x.current&&(x.current=M,m(M))},[]),S=b.useCallback(M=>{M!==E.current&&(E.current=M,y(M))},[]),w=s||g,k=a||v,x=b.useRef(null),E=b.useRef(null),T=b.useRef(d),D=l!=null,R=lp(l),I=lp(i),O=lp(c),N=b.useCallback(()=>{if(!x.current||!E.current)return;const M={placement:t,strategy:n,middleware:p};I.current&&(M.platform=I.current),Q7(x.current,E.current,M).then(U=>{const C={...U,isPositioned:O.current!==!1};P.current&&!Ou(T.current,C)&&(T.current=C,ma.flushSync(()=>{u(C)}))})},[p,t,n,I,O]);Fc(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,u(M=>({...M,isPositioned:!1})))},[c]);const P=b.useRef(!1);Fc(()=>(P.current=!0,()=>{P.current=!1}),[]),Fc(()=>{if(w&&(x.current=w),k&&(E.current=k),w&&k){if(R.current)return R.current(w,k,N);N()}},[w,k,N,R,D]);const F=b.useMemo(()=>({reference:x,floating:E,setReference:_,setFloating:S}),[_,S]),B=b.useMemo(()=>({reference:w,floating:k}),[w,k]),j=b.useMemo(()=>{const M={position:n,left:0,top:0};if(!B.floating)return M;const U=K0(B.floating,d.x),C=K0(B.floating,d.y);return o?{...M,transform:"translate("+U+"px, "+C+"px)",...EI(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:C}},[n,o,B.floating,d.x,d.y]);return b.useMemo(()=>({...d,update:N,refs:F,elements:B,floatingStyles:j}),[d,N,F,B,j])}const nq=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?q0({element:r.current,padding:i}).fn(n):{}:r?q0({element:r,padding:i}).fn(n):{}}}},rq=(e,t)=>{const n=V7(e);return{name:n.name,fn:n.fn,options:[e,t]}},iq=(e,t)=>{const n=q7(e);return{name:n.name,fn:n.fn,options:[e,t]}},sq=(e,t)=>({fn:Z7(e).fn,options:[e,t]}),aq=(e,t)=>{const n=K7(e);return{name:n.name,fn:n.fn,options:[e,t]}},oq=(e,t)=>{const n=Y7(e);return{name:n.name,fn:n.fn,options:[e,t]}},lq=(e,t)=>{const n=X7(e);return{name:n.name,fn:n.fn,options:[e,t]}},cq=(e,t)=>{const n=nq(e);return{name:n.name,fn:n.fn,options:[e,t]}};var uq="Arrow",kI=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(we.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});kI.displayName=uq;var dq=kI,Cw="Popper",[CI,jd]=bi(Cw),[hq,TI]=CI(Cw),AI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return h.jsx(hq,{scope:t,anchor:r,onAnchorChange:i,children:n})};AI.displayName=Cw;var NI="PopperAnchor",RI=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=TI(NI,n),a=b.useRef(null),o=Le(t,a),l=b.useRef(null);return b.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||a.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(we.div,{...i,ref:o})});RI.displayName=NI;var Tw="PopperContent",[pq,fq]=CI(Tw),II=b.forwardRef((e,t)=>{var W,re,ce,ue,he,me;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:o=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:u="partial",hideWhenDetached:p=!1,updatePositionStrategy:f="optimized",onPlaced:g,...m}=e,v=TI(Tw,n),[y,_]=b.useState(null),S=Le(t,le=>_(le)),[w,k]=b.useState(null),x=aI(w),E=(x==null?void 0:x.width)??0,T=(x==null?void 0:x.height)??0,D=r+(s!=="center"?"-"+s:""),R=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},I=Array.isArray(c)?c:[c],O=I.length>0,N={padding:R,boundary:I.filter(mq),altBoundary:O},{refs:P,floatingStyles:F,placement:B,isPositioned:j,middlewareData:M}=tq({strategy:"fixed",placement:D,whileElementsMounted:(...le)=>W7(...le,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[rq({mainAxis:i+T,alignmentAxis:a}),l&&iq({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?sq():void 0,...N}),l&&aq({...N}),oq({...N,apply:({elements:le,rects:xt,availableWidth:Rr,availableHeight:Ir})=>{const{width:Or,height:Wd}=xt.reference,wi=le.floating.style;wi.setProperty("--radix-popper-available-width",`${Rr}px`),wi.setProperty("--radix-popper-available-height",`${Ir}px`),wi.setProperty("--radix-popper-anchor-width",`${Or}px`),wi.setProperty("--radix-popper-anchor-height",`${Wd}px`)}}),w&&cq({element:w,padding:o}),bq({arrowWidth:E,arrowHeight:T}),p&&lq({strategy:"referenceHidden",...N})]}),[U,C]=DI(B),H=ci(g);It(()=>{j&&(H==null||H())},[j,H]);const Z=(W=M.arrow)==null?void 0:W.x,L=(re=M.arrow)==null?void 0:re.y,se=((ce=M.arrow)==null?void 0:ce.centerOffset)!==0,[_e,$]=b.useState();return It(()=>{y&&$(window.getComputedStyle(y).zIndex)},[y]),h.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:j?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(ue=M.transformOrigin)==null?void 0:ue.x,(he=M.transformOrigin)==null?void 0:he.y].join(" "),...((me=M.hide)==null?void 0:me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(pq,{scope:n,placedSide:U,onArrowChange:k,arrowX:Z,arrowY:L,shouldHideArrow:se,children:h.jsx(we.div,{"data-side":U,"data-align":C,...m,ref:S,style:{...m.style,animation:j?void 0:"none"}})})})});II.displayName=Tw;var OI="PopperArrow",gq={top:"bottom",right:"left",bottom:"top",left:"right"},LI=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=fq(OI,r),a=gq[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(dq,{...i,ref:n,style:{...i.style,display:"block"}})})});LI.displayName=OI;function mq(e){return e!==null}var bq=e=>({name:"transformOrigin",options:e,fn(t){var v,y,_;const{placement:n,rects:r,middlewareData:i}=t,a=((v=i.arrow)==null?void 0:v.centerOffset)!==0,o=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[c,d]=DI(n),u={start:"0%",center:"50%",end:"100%"}[d],p=(((y=i.arrow)==null?void 0:y.x)??0)+o/2,f=(((_=i.arrow)==null?void 0:_.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=a?u:`${p}px`,m=`${-l}px`):c==="top"?(g=a?u:`${p}px`,m=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=a?u:`${f}px`):c==="left"&&(g=`${r.floating.width+l}px`,m=a?u:`${f}px`),{data:{x:g,y:m}}}});function DI(e){const[t,n="center"]=e.split("-");return[t,n]}var MI=AI,Aw=RI,PI=II,FI=LI;function yq(e){const t=_q(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(Sq);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function _q(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=xq(i),o=wq(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vq=Symbol("radix.slottable");function Sq(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vq}function wq(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function xq(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var BI=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"}),Eq="VisuallyHidden",kq=b.forwardRef((e,t)=>h.jsx(we.span,{...e,ref:t,style:{...BI,...e.style}}));kq.displayName=Eq;var Cq=[" ","Enter","ArrowUp","ArrowDown"],Tq=[" ","Enter"],ts="Select",[Ud,$d,Aq]=pI(ts),[Oa]=bi(ts,[Aq,jd]),zd=jd(),[Nq,_i]=Oa(ts),[Rq,Iq]=Oa(ts),jI=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:a,defaultValue:o,onValueChange:l,dir:c,name:d,autoComplete:u,disabled:p,required:f,form:g}=e,m=zd(t),[v,y]=b.useState(null),[_,S]=b.useState(null),[w,k]=b.useState(!1),x=_w(c),[E,T]=Yi({prop:r,defaultProp:i??!1,onChange:s,caller:ts}),[D,R]=Yi({prop:a,defaultProp:o,onChange:l,caller:ts}),I=b.useRef(null),O=v?g||!!v.closest("form"):!0,[N,P]=b.useState(new Set),F=Array.from(N).map(B=>B.props.value).join(";");return h.jsx(MI,{...m,children:h.jsxs(Nq,{required:f,scope:t,trigger:v,onTriggerChange:y,valueNode:_,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:br(),value:D,onValueChange:R,open:E,onOpenChange:T,dir:x,triggerPointerDownPosRef:I,disabled:p,children:[h.jsx(Ud.Provider,{scope:t,children:h.jsx(Rq,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(B=>{P(j=>new Set(j).add(B))},[]),onNativeOptionRemove:b.useCallback(B=>{P(j=>{const M=new Set(j);return M.delete(B),M})},[]),children:n})}),O?h.jsxs(uO,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:u,value:D,onChange:B=>R(B.target.value),disabled:p,form:g,children:[D===void 0?h.jsx("option",{value:""}):null,Array.from(N)]},F):null]})})};jI.displayName=ts;var UI="SelectTrigger",$I=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=zd(n),a=_i(UI,n),o=a.disabled||r,l=Le(t,a.onTriggerChange),c=$d(n),d=b.useRef("touch"),[u,p,f]=hO(m=>{const v=c().filter(S=>!S.disabled),y=v.find(S=>S.value===a.value),_=pO(v,m,y);_!==void 0&&a.onValueChange(_.value)}),g=m=>{o||(a.onOpenChange(!0),f()),m&&(a.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return h.jsx(Aw,{asChild:!0,...s,children:h.jsx(we.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:o,"data-disabled":o?"":void 0,"data-placeholder":dO(a.value)?"":void 0,...i,ref:l,onClick:ge(i.onClick,m=>{m.currentTarget.focus(),d.current!=="mouse"&&g(m)}),onPointerDown:ge(i.onPointerDown,m=>{d.current=m.pointerType;const v=m.target;v.hasPointerCapture(m.pointerId)&&v.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(g(m),m.preventDefault())}),onKeyDown:ge(i.onKeyDown,m=>{const v=u.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&p(m.key),!(v&&m.key===" ")&&Cq.includes(m.key)&&(g(),m.preventDefault())})})})});$I.displayName=UI;var zI="SelectValue",HI=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:a="",...o}=e,l=_i(zI,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,u=Le(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),h.jsx(we.span,{...o,ref:u,style:{pointerEvents:"none"},children:dO(l.value)?h.jsx(h.Fragment,{children:a}):s})});HI.displayName=zI;var Oq="SelectIcon",GI=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return h.jsx(we.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});GI.displayName=Oq;var Lq="SelectPortal",WI=e=>h.jsx(cd,{asChild:!0,...e});WI.displayName=Lq;var ns="SelectContent",VI=b.forwardRef((e,t)=>{const n=_i(ns,e.__scopeSelect),[r,i]=b.useState();if(It(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?ma.createPortal(h.jsx(qI,{scope:e.__scopeSelect,children:h.jsx(Ud.Slot,{scope:e.__scopeSelect,children:h.jsx("div",{children:e.children})})}),s):null}return h.jsx(KI,{...e,ref:t})});VI.displayName=ns;var Nn=10,[qI,vi]=Oa(ns),Dq="SelectContentImpl",Mq=yq("SelectContent.RemoveScroll"),KI=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:a,side:o,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:g,hideWhenDetached:m,avoidCollisions:v,...y}=e,_=_i(ns,n),[S,w]=b.useState(null),[k,x]=b.useState(null),E=Le(t,W=>w(W)),[T,D]=b.useState(null),[R,I]=b.useState(null),O=$d(n),[N,P]=b.useState(!1),F=b.useRef(!1);b.useEffect(()=>{if(S)return Mm(S)},[S]),Dm();const B=b.useCallback(W=>{const[re,...ce]=O().map(me=>me.ref.current),[ue]=ce.slice(-1),he=document.activeElement;for(const me of W)if(me===he||(me==null||me.scrollIntoView({block:"nearest"}),me===re&&k&&(k.scrollTop=0),me===ue&&k&&(k.scrollTop=k.scrollHeight),me==null||me.focus(),document.activeElement!==he))return},[O,k]),j=b.useCallback(()=>B([T,S]),[B,T,S]);b.useEffect(()=>{N&&j()},[N,j]);const{onOpenChange:M,triggerPointerDownPosRef:U}=_;b.useEffect(()=>{if(S){let W={x:0,y:0};const re=ue=>{var he,me;W={x:Math.abs(Math.round(ue.pageX)-(((he=U.current)==null?void 0:he.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((me=U.current)==null?void 0:me.y)??0))}},ce=ue=>{W.x<=10&&W.y<=10?ue.preventDefault():S.contains(ue.target)||M(!1),document.removeEventListener("pointermove",re),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",ce,{capture:!0})}}},[S,M,U]),b.useEffect(()=>{const W=()=>M(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[M]);const[C,H]=hO(W=>{const re=O().filter(he=>!he.disabled),ce=re.find(he=>he.ref.current===document.activeElement),ue=pO(re,W,ce);ue&&setTimeout(()=>ue.ref.current.focus())}),Z=b.useCallback((W,re,ce)=>{const ue=!F.current&&!ce;(_.value!==void 0&&_.value===re||ue)&&(D(W),ue&&(F.current=!0))},[_.value]),L=b.useCallback(()=>S==null?void 0:S.focus(),[S]),se=b.useCallback((W,re,ce)=>{const ue=!F.current&&!ce;(_.value!==void 0&&_.value===re||ue)&&I(W)},[_.value]),_e=r==="popper"?Eg:YI,$=_e===Eg?{side:o,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:g,hideWhenDetached:m,avoidCollisions:v}:{};return h.jsx(qI,{scope:n,content:S,viewport:k,onViewportChange:x,itemRefCallback:Z,selectedItem:T,onItemLeave:L,itemTextRefCallback:se,focusSelectedItem:j,selectedItemText:R,position:r,isPositioned:N,searchRef:C,children:h.jsx(dd,{as:Mq,allowPinchZoom:!0,children:h.jsx(ld,{asChild:!0,trapped:_.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ge(i,W=>{var re;(re=_.trigger)==null||re.focus({preventScroll:!0}),W.preventDefault()}),children:h.jsx(od,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:h.jsx(_e,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:W=>W.preventDefault(),...y,...$,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ge(y.onKeyDown,W=>{const re=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!re&&W.key.length===1&&H(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=O().filter(he=>!he.disabled).map(he=>he.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const he=W.target,me=ue.indexOf(he);ue=ue.slice(me+1)}setTimeout(()=>B(ue)),W.preventDefault()}})})})})})})});KI.displayName=Dq;var Pq="SelectItemAlignedPosition",YI=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=_i(ns,n),a=vi(ns,n),[o,l]=b.useState(null),[c,d]=b.useState(null),u=Le(t,E=>d(E)),p=$d(n),f=b.useRef(!1),g=b.useRef(!0),{viewport:m,selectedItem:v,selectedItemText:y,focusSelectedItem:_}=a,S=b.useCallback(()=>{if(s.trigger&&s.valueNode&&o&&c&&m&&v&&y){const E=s.trigger.getBoundingClientRect(),T=c.getBoundingClientRect(),D=s.valueNode.getBoundingClientRect(),R=y.getBoundingClientRect();if(s.dir!=="rtl"){const he=R.left-T.left,me=D.left-he,le=E.left-me,xt=E.width+le,Rr=Math.max(xt,T.width),Ir=window.innerWidth-Nn,Or=P0(me,[Nn,Math.max(Nn,Ir-Rr)]);o.style.minWidth=xt+"px",o.style.left=Or+"px"}else{const he=T.right-R.right,me=window.innerWidth-D.right-he,le=window.innerWidth-E.right-me,xt=E.width+le,Rr=Math.max(xt,T.width),Ir=window.innerWidth-Nn,Or=P0(me,[Nn,Math.max(Nn,Ir-Rr)]);o.style.minWidth=xt+"px",o.style.right=Or+"px"}const I=p(),O=window.innerHeight-Nn*2,N=m.scrollHeight,P=window.getComputedStyle(c),F=parseInt(P.borderTopWidth,10),B=parseInt(P.paddingTop,10),j=parseInt(P.borderBottomWidth,10),M=parseInt(P.paddingBottom,10),U=F+B+N+M+j,C=Math.min(v.offsetHeight*5,U),H=window.getComputedStyle(m),Z=parseInt(H.paddingTop,10),L=parseInt(H.paddingBottom,10),se=E.top+E.height/2-Nn,_e=O-se,$=v.offsetHeight/2,W=v.offsetTop+$,re=F+B+W,ce=U-re;if(re<=se){const he=I.length>0&&v===I[I.length-1].ref.current;o.style.bottom="0px";const me=c.clientHeight-m.offsetTop-m.offsetHeight,le=Math.max(_e,$+(he?L:0)+me+j),xt=re+le;o.style.height=xt+"px"}else{const he=I.length>0&&v===I[0].ref.current;o.style.top="0px";const le=Math.max(se,F+m.offsetTop+(he?Z:0)+$)+ce;o.style.height=le+"px",m.scrollTop=re-se+m.offsetTop}o.style.margin=`${Nn}px 0`,o.style.minHeight=C+"px",o.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[p,s.trigger,s.valueNode,o,c,m,v,y,s.dir,r]);It(()=>S(),[S]);const[w,k]=b.useState();It(()=>{c&&k(window.getComputedStyle(c).zIndex)},[c]);const x=b.useCallback(E=>{E&&g.current===!0&&(S(),_==null||_(),g.current=!1)},[S,_]);return h.jsx(Bq,{scope:n,contentWrapper:o,shouldExpandOnScrollRef:f,onScrollButtonChange:x,children:h.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:h.jsx(we.div,{...i,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});YI.displayName=Pq;var Fq="SelectPopperPosition",Eg=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Nn,...s}=e,a=zd(n);return h.jsx(PI,{...a,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.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)"}})});Eg.displayName=Fq;var[Bq,Nw]=Oa(ns,{}),kg="SelectViewport",XI=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=vi(kg,n),a=Nw(kg,n),o=Le(t,s.onViewportChange),l=b.useRef(0);return h.jsxs(h.Fragment,{children:[h.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:r}),h.jsx(Ud.Slot,{scope:n,children:h.jsx(we.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:o,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:ge(i.onScroll,c=>{const d=c.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:p}=a;if(p!=null&&p.current&&u){const f=Math.abs(l.current-d.scrollTop);if(f>0){const g=window.innerHeight-Nn*2,m=parseFloat(u.style.minHeight),v=parseFloat(u.style.height),y=Math.max(m,v);if(y<g){const _=y+f,S=Math.min(g,_),w=_-S;u.style.height=S+"px",u.style.bottom==="0px"&&(d.scrollTop=w>0?w:0,u.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});XI.displayName=kg;var ZI="SelectGroup",[jq,Uq]=Oa(ZI),QI=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=br();return h.jsx(jq,{scope:n,id:i,children:h.jsx(we.div,{role:"group","aria-labelledby":i,...r,ref:t})})});QI.displayName=ZI;var JI="SelectLabel",eO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Uq(JI,n);return h.jsx(we.div,{id:i.id,...r,ref:t})});eO.displayName=JI;var Lu="SelectItem",[$q,tO]=Oa(Lu),nO=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...a}=e,o=_i(Lu,n),l=vi(Lu,n),c=o.value===r,[d,u]=b.useState(s??""),[p,f]=b.useState(!1),g=Le(t,_=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,_,r,i)}),m=br(),v=b.useRef("touch"),y=()=>{i||(o.onValueChange(r),o.onOpenChange(!1))};if(r==="")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 h.jsx($q,{scope:n,value:r,disabled:i,textId:m,isSelected:c,onItemTextChange:b.useCallback(_=>{u(S=>S||((_==null?void 0:_.textContent)??"").trim())},[]),children:h.jsx(Ud.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:h.jsx(we.div,{role:"option","aria-labelledby":m,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...a,ref:g,onFocus:ge(a.onFocus,()=>f(!0)),onBlur:ge(a.onBlur,()=>f(!1)),onClick:ge(a.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:ge(a.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:ge(a.onPointerDown,_=>{v.current=_.pointerType}),onPointerMove:ge(a.onPointerMove,_=>{var S;v.current=_.pointerType,i?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(a.onPointerLeave,_=>{var S;_.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ge(a.onKeyDown,_=>{var w;((w=l.searchRef)==null?void 0:w.current)!==""&&_.key===" "||(Tq.includes(_.key)&&y(),_.key===" "&&_.preventDefault())})})})})});nO.displayName=Lu;var lo="SelectItemText",rO=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,a=_i(lo,n),o=vi(lo,n),l=tO(lo,n),c=Iq(lo,n),[d,u]=b.useState(null),p=Le(t,y=>u(y),l.onItemTextChange,y=>{var _;return(_=o.itemTextRefCallback)==null?void 0:_.call(o,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,g=b.useMemo(()=>h.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:m,onNativeOptionRemove:v}=c;return It(()=>(m(g),()=>v(g)),[m,v,g]),h.jsxs(h.Fragment,{children:[h.jsx(we.span,{id:l.textId,...s,ref:p}),l.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ma.createPortal(s.children,a.valueNode):null]})});rO.displayName=lo;var iO="SelectItemIndicator",sO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return tO(iO,n).isSelected?h.jsx(we.span,{"aria-hidden":!0,...r,ref:t}):null});sO.displayName=iO;var Cg="SelectScrollUpButton",aO=b.forwardRef((e,t)=>{const n=vi(Cg,e.__scopeSelect),r=Nw(Cg,e.__scopeSelect),[i,s]=b.useState(!1),a=Le(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let o=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return o(),l.addEventListener("scroll",o),()=>l.removeEventListener("scroll",o)}},[n.viewport,n.isPositioned]),i?h.jsx(lO,{...e,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:l}=n;o&&l&&(o.scrollTop=o.scrollTop-l.offsetHeight)}}):null});aO.displayName=Cg;var Tg="SelectScrollDownButton",oO=b.forwardRef((e,t)=>{const n=vi(Tg,e.__scopeSelect),r=Nw(Tg,e.__scopeSelect),[i,s]=b.useState(!1),a=Le(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let o=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return o(),l.addEventListener("scroll",o),()=>l.removeEventListener("scroll",o)}},[n.viewport,n.isPositioned]),i?h.jsx(lO,{...e,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:l}=n;o&&l&&(o.scrollTop=o.scrollTop+l.offsetHeight)}}):null});oO.displayName=Tg;var lO=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=vi("SelectScrollButton",n),a=b.useRef(null),o=$d(n),l=b.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return b.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=o().find(u=>u.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[o]),h.jsx(we.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ge(i.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:ge(i.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:ge(i.onPointerLeave,()=>{l()})})}),zq="SelectSeparator",cO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return h.jsx(we.div,{"aria-hidden":!0,...r,ref:t})});cO.displayName=zq;var Ag="SelectArrow",Hq=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=zd(n),s=_i(Ag,n),a=vi(Ag,n);return s.open&&a.position==="popper"?h.jsx(FI,{...i,...r,ref:t}):null});Hq.displayName=Ag;var Gq="SelectBubbleInput",uO=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=Le(r,i),a=sI(t);return b.useEffect(()=>{const o=i.current;if(!o)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(a!==t&&d){const u=new Event("change",{bubbles:!0});d.call(o,t),o.dispatchEvent(u)}},[a,t]),h.jsx(we.select,{...n,style:{...BI,...n.style},ref:s,defaultValue:t})});uO.displayName=Gq;function dO(e){return e===""||e===void 0}function hO(e){const t=ci(e),n=b.useRef(""),r=b.useRef(0),i=b.useCallback(a=>{const o=n.current+a;t(o),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(o)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function pO(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=Wq(e,Math.max(s,0));i.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function Wq(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vq=jI,fO=$I,qq=HI,Kq=GI,Yq=WI,gO=VI,Xq=XI,Zq=QI,mO=eO,bO=nO,Qq=rO,Jq=sO,yO=aO,_O=oO,vO=cO;const Du=Vq,cp=Zq,Mu=qq,il=b.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(fO,{ref:r,className:X("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),...n,children:[t,h.jsx(Kq,{asChild:!0,children:h.jsx(pl,{className:"h-4 w-4 opacity-50"})})]}));il.displayName=fO.displayName;const SO=b.forwardRef(({className:e,...t},n)=>h.jsx(yO,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(VT,{className:"h-4 w-4"})}));SO.displayName=yO.displayName;const wO=b.forwardRef(({className:e,...t},n)=>h.jsx(_O,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(pl,{className:"h-4 w-4"})}));wO.displayName=_O.displayName;const sl=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>h.jsx(Yq,{children:h.jsxs(gO,{ref:i,className:X("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",n==="popper"&&"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:n,...r,children:[h.jsx(SO,{}),h.jsx(Xq,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(wO,{})]})}));sl.displayName=gO.displayName;const Bc=b.forwardRef(({className:e,...t},n)=>h.jsx(mO,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Bc.displayName=mO.displayName;const mn=b.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(bO,{ref:r,className:X("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),...n,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(Jq,{children:h.jsx(WT,{className:"h-4 w-4"})})}),h.jsx(Qq,{children:t})]}));mn.displayName=bO.displayName;const eK=b.forwardRef(({className:e,...t},n)=>h.jsx(vO,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));eK.displayName=vO.displayName;function tK(e){const t=nK(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(iK);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function nK(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=aK(i),o=sK(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rK=Symbol("radix.slottable");function iK(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rK}function sK(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function aK(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Hd="Popover",[xO]=bi(Hd,[jd]),Al=jd(),[oK,Si]=xO(Hd),EO=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,o=Al(t),l=b.useRef(null),[c,d]=b.useState(!1),[u,p]=Yi({prop:r,defaultProp:i??!1,onChange:s,caller:Hd});return h.jsx(MI,{...o,children:h.jsx(oK,{scope:t,contentId:br(),triggerRef:l,open:u,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>d(!0),[]),onCustomAnchorRemove:b.useCallback(()=>d(!1),[]),modal:a,children:n})})};EO.displayName=Hd;var kO="PopoverAnchor",lK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(kO,n),s=Al(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=i;return b.useEffect(()=>(a(),()=>o()),[a,o]),h.jsx(Aw,{...s,...r,ref:t})});lK.displayName=kO;var CO="PopoverTrigger",TO=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(CO,n),s=Al(n),a=Le(t,i.triggerRef),o=h.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":OO(i.open),...r,ref:a,onClick:ge(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?o:h.jsx(Aw,{asChild:!0,...s,children:o})});TO.displayName=CO;var Rw="PopoverPortal",[cK,uK]=xO(Rw,{forceMount:void 0}),AO=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Si(Rw,t);return h.jsx(cK,{scope:t,forceMount:n,children:h.jsx(ls,{present:n||s.open,children:h.jsx(cd,{asChild:!0,container:i,children:r})})})};AO.displayName=Rw;var ha="PopoverContent",NO=b.forwardRef((e,t)=>{const n=uK(ha,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Si(ha,e.__scopePopover);return h.jsx(ls,{present:r||s.open,children:s.modal?h.jsx(hK,{...i,ref:t}):h.jsx(pK,{...i,ref:t})})});NO.displayName=ha;var dK=tK("PopoverContent.RemoveScroll"),hK=b.forwardRef((e,t)=>{const n=Si(ha,e.__scopePopover),r=b.useRef(null),i=Le(t,r),s=b.useRef(!1);return b.useEffect(()=>{const a=r.current;if(a)return Mm(a)},[]),h.jsx(dd,{as:dK,allowPinchZoom:!0,children:h.jsx(RO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),s.current||(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0,c=o.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ge(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),pK=b.forwardRef((e,t)=>{const n=Si(ha,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return h.jsx(RO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,o;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(o=n.triggerRef.current)==null||o.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),RO=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...u}=e,p=Si(ha,n),f=Al(n);return Dm(),h.jsx(ld,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(od,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:d,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:h.jsx(PI,{"data-state":OO(p.open),role:"dialog",id:p.contentId,...f,...u,ref:t,style:{...u.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),IO="PopoverClose",fK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(IO,n);return h.jsx(we.button,{type:"button",...r,ref:t,onClick:ge(e.onClick,()=>i.onOpenChange(!1))})});fK.displayName=IO;var gK="PopoverArrow",mK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Al(n);return h.jsx(FI,{...i,...r,ref:t})});mK.displayName=gK;function OO(e){return e?"open":"closed"}var bK=EO,yK=TO,_K=AO,LO=NO;const vK=bK,SK=yK,DO=b.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},i)=>h.jsx(_K,{children:h.jsx(LO,{ref:i,align:t,sideOffset:n,className:X("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})}));DO.displayName=LO.displayName;function wK({projectId:e,config:t,onChange:n}){var k;const[r,i]=b.useState([]),[s,a]=b.useState([]),[o,l]=b.useState(null),[c,d]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{JP().then(i).catch(console.error),vh(e).then(a).catch(console.error)},[e]);const p=x=>{n({...t,...x})},f=async x=>{if(x.startsWith("preset:")){const E=x.replace("preset:",""),T=r.find(D=>D.id===E);if(T&&!T.downloaded){l(E);try{await eF(E),i(R=>R.map(I=>I.id===E?{...I,downloaded:!0}:I));const D=await vh(e);a(D)}catch(D){console.error("Failed to download preset:",D),l(null);return}l(null)}}p({source:x})},g=async x=>{const E=u.current;E&&(E.dataset.scope=x,E.click())},m=async x=>{var D;const E=(D=x.target.files)==null?void 0:D[0];if(!E)return;const T=x.target.dataset.scope||"global";d(!0);try{const{name:R}=await tF(E,T,e),I=await vh(e);a(I),p({source:`${T==="project"?"project":"global"}:${R}`})}catch(R){console.error("Upload failed:",R)}finally{d(!1),x.target.value=""}},v=s.filter(x=>x.source.startsWith("preset:")),y=s.filter(x=>x.source.startsWith("global:")),_=s.filter(x=>x.source.startsWith("project:")),S=r.filter(x=>!x.downloaded&&!v.some(E=>E.source===`preset:${x.id}`)),w=t.playMode==="interval"||t.playMode==="auto"&&((k=r.find(x=>`preset:${x.id}`===t.source))==null?void 0:k.type)==="strike";return h.jsxs(vK,{children:[h.jsx(SK,{asChild:!0,children:h.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8",children:h.jsx(wF,{className:`h-4 w-4 ${t.enabled?"text-primary":""}`})})}),h.jsx(DO,{className:"w-[300px]",children:h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx(je,{className:"text-sm font-medium",children:"背景音效"}),h.jsx(yw,{checked:t.enabled,onCheckedChange:x=>p({enabled:x})})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"音源"}),h.jsxs(Du,{value:t.source,onValueChange:f,children:[h.jsx(il,{className:"h-8 text-xs",children:h.jsx(Mu,{placeholder:"选择音源"})}),h.jsxs(sl,{children:[(v.length>0||S.length>0)&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"预设音效"}),v.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source)),S.map(x=>h.jsx(mn,{value:`preset:${x.id}`,className:"text-xs",children:h.jsxs("span",{className:"flex items-center gap-1.5",children:[x.name,o===x.id?h.jsx(vo,{className:"h-3 w-3 animate-spin"}):h.jsx(pu,{className:"h-3 w-3 text-muted-foreground"})]})},`preset:${x.id}`))]}),y.length>0&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"全局自定义"}),y.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source))]}),_.length>0&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"项目自定义"}),_.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source))]})]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"播放模式"}),h.jsxs(Du,{value:t.playMode,onValueChange:x=>p({playMode:x}),children:[h.jsx(il,{className:"h-8 text-xs",children:h.jsx(Mu,{})}),h.jsxs(sl,{children:[h.jsx(mn,{value:"auto",className:"text-xs",children:"自动"}),h.jsx(mn,{value:"loop",className:"text-xs",children:"循环"}),h.jsx(mn,{value:"interval",className:"text-xs",children:"随机间隔"})]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs(je,{className:"text-xs text-muted-foreground",children:["音量: ",Math.round(t.volume*100),"%"]}),h.jsx("input",{type:"range",min:0,max:100,value:Math.round(t.volume*100),onChange:x=>p({volume:Number(x.target.value)/100}),className:"w-full h-1.5 accent-primary cursor-pointer"})]}),w&&h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"间隔范围(秒)"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",min:1,value:t.intervalRange[0],onChange:x=>p({intervalRange:[Number(x.target.value),t.intervalRange[1]]}),className:"w-20 h-8 rounded-md border bg-background px-2 text-xs"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"~"}),h.jsx("input",{type:"number",min:1,value:t.intervalRange[1],onChange:x=>p({intervalRange:[t.intervalRange[0],Number(x.target.value)]}),className:"w-20 h-8 rounded-md border bg-background px-2 text-xs"})]})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(te,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",disabled:c,onClick:()=>g("global"),children:[c?h.jsx(vo,{className:"h-3 w-3 mr-1 animate-spin"}):h.jsx(gf,{className:"h-3 w-3 mr-1"}),"上传全局"]}),h.jsxs(te,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",disabled:c,onClick:()=>g("project"),children:[c?h.jsx(vo,{className:"h-3 w-3 mr-1 animate-spin"}):h.jsx(gf,{className:"h-3 w-3 mr-1"}),"上传项目"]})]}),h.jsx("input",{ref:u,type:"file",accept:"audio/*",className:"hidden",onChange:m})]})})]})}const xK=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,EK=5,kK=3e3;function CK(e,t){const n=b.useRef(null),r=b.useRef(0),i=b.useRef(!0),s=b.useRef(t);s.current=t;const a=b.useRef(!1),o=b.useCallback(f=>{var g;((g=n.current)==null?void 0:g.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(f))},[]),l=b.useCallback((f,g)=>{var m;((m=n.current)==null?void 0:m.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:f,rows:g})),a.current=!1):a.current=!0},[]),c=b.useCallback(f=>{o({type:"terminal_input",data:f})},[o]),d=b.useCallback((f,g)=>{o({type:"terminal_resize",cols:f,rows:g})},[o]),u=b.useCallback(()=>{o({type:"chat_subscribe"})},[o]),p=b.useCallback(()=>{if(!i.current)return;const f=kr();if(!f){window.location.href="/login";return}const g=new WebSocket(`${xK}/ws/projects/${e}`);n.current=g,g.onopen=()=>{r.current=0,g.send(JSON.stringify({type:"auth",token:f}))},g.onmessage=m=>{var y,_,S,w,k,x,E,T;let v;try{v=JSON.parse(m.data)}catch{return}switch(v.type){case"connected":a.current=!1,(_=(y=s.current).onConnected)==null||_.call(y);break;case"terminal_data":(w=(S=s.current).onTerminalData)==null||w.call(S,v.data);break;case"status":(x=(k=s.current).onStatus)==null||x.call(k,v.status);break;case"chat_message":{const D=v;(T=(E=s.current).onChatMessage)==null||T.call(E,D);break}case"error":console.error("[WS] Server error:",v.message);break}},g.onclose=()=>{n.current=null,i.current&&r.current<EK&&(r.current++,setTimeout(p,kK))},g.onerror=m=>{console.error("[WS] WebSocket error:",m)}},[e]);return b.useEffect(()=>(i.current=!0,p(),()=>{var f;i.current=!1,(f=n.current)==null||f.close(),n.current=null}),[p]),{subscribeTerminal:l,sendTerminalInput:c,sendTerminalResize:d,subscribeChatMessages:u}}function up({icon:e,label:t,content:n}){const[r,i]=b.useState(!1);return h.jsxs("div",{className:"border border-border rounded mt-1.5",children:[h.jsxs("button",{className:"flex items-center gap-1.5 w-full px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(s=>!s),children:[h.jsx(sd,{className:X("h-3 w-3 transition-transform",r&&"rotate-90")}),h.jsx(e,{className:"h-3 w-3"}),h.jsx("span",{className:"truncate",children:t})]}),r&&h.jsx("pre",{className:"px-3 pb-2 text-xs text-muted-foreground whitespace-pre-wrap break-words max-h-40 overflow-auto",children:n})]})}function TK({blocks:e}){return h.jsx(h.Fragment,{children:e.map((t,n)=>t.type==="text"?h.jsx("div",{className:"prose dark:prose-invert prose-sm max-w-none",children:h.jsx(lR,{remarkPlugins:[OR],children:t.content})},n):t.type==="thinking"?h.jsx(up,{icon:Rm,label:"Thinking...",content:t.content},n):t.type==="tool_use"?h.jsx(up,{icon:PF,label:t.content.split("(")[0],content:t.content},n):t.type==="tool_result"?h.jsx(up,{icon:hF,label:"Result",content:t.content},n):null)})}function AK({messages:e,onSend:t,readOnly:n}){const[r,i]=b.useState(""),s=b.useRef(null),a=b.useRef(null);b.useEffect(()=>{var d;(d=s.current)==null||d.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const d=r.trim();d&&(t(d+"\r"),i(""),a.current&&(a.current.style.height="auto"))},l=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),o())},c=d=>{d.style.height="auto",d.style.height=Math.min(d.scrollHeight,120)+"px"};return h.jsxs("div",{className:"flex flex-col h-full bg-background",children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 min-h-0",children:[e.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"等待对话..."}),e.map((d,u)=>h.jsx("div",{className:X("flex",d.role==="user"?"justify-end":"justify-start"),children:h.jsxs("div",{className:X("max-w-[85%] rounded-lg px-3 py-2 text-sm",d.role==="user"?"bg-primary text-primary-foreground":"bg-muted"),children:[h.jsx(TK,{blocks:d.blocks}),h.jsx("div",{className:"text-[10px] opacity-50 mt-1",children:new Date(d.timestamp).toLocaleTimeString()})]})},u)),h.jsx("div",{ref:s})]}),!n&&h.jsxs("div",{className:"border-t border-border p-3 flex gap-2 items-end flex-shrink-0",children:[h.jsx("textarea",{ref:a,value:r,onChange:d=>{i(d.target.value),c(d.target)},onKeyDown:l,placeholder:"输入消息...",rows:1,className:"flex-1 resize-none bg-muted rounded-md px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring",style:{maxHeight:"120px"}}),h.jsx("button",{onClick:o,disabled:!r.trim(),className:"p-2 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex-shrink-0",children:h.jsx(AF,{className:"h-4 w-4"})})]})]})}function NK({status:e}){const t={running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"};return h.jsxs("span",{className:X("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",t[e]),children:[h.jsx("span",{className:X("w-1.5 h-1.5 rounded-full",{"bg-green-500":e==="running","bg-muted-foreground":e==="stopped","bg-yellow-400 animate-pulse":e==="restarting"})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function RK(){const{id:e}=lM(),t=ss(),[n,r]=b.useState(null),[i,s]=b.useState(!0),[a,o]=b.useState(!1),[l,c]=b.useState(!1),[d,u]=b.useState({enabled:!1,source:"preset:rain",playMode:"auto",volume:.5,intervalRange:[3,8]}),[p,f]=b.useState(!1),g=b.useRef(null),[m,v]=b.useState("terminal"),[y,_]=b.useState([]),S=async()=>{if(e){c(!0);try{await KP(e)}catch($){alert($ instanceof Error?$.message:"备份失败")}finally{c(!1)}}},[w,k]=b.useState(()=>{try{return localStorage.getItem("cc_panel_filetree")!=="false"}catch{return!0}}),[x,E]=b.useState(()=>{try{return localStorage.getItem("cc_panel_shortcuts")!=="false"}catch{return!0}}),T=()=>k($=>(localStorage.setItem("cc_panel_filetree",String(!$)),!$)),D=()=>E($=>(localStorage.setItem("cc_panel_shortcuts",String(!$)),!$)),[R,I]=b.useState(!1);b.useEffect(()=>{const $=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const O=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},N=b.useRef(null),P=b.useRef(null),F=b.useRef(null),B=b.useRef(null),j=b.useCallback($=>{var W;(W=N.current)==null||W.write($),f(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>f(!1),3e3)},[]),M=b.useCallback(()=>{var W;const $=P.current;$&&F.current&&F.current($.cols,$.rows),(W=B.current)==null||W.call(B)},[]),{subscribeTerminal:U,sendTerminalInput:C,sendTerminalResize:H,subscribeChatMessages:Z}=CK(e??"",{onTerminalData:j,onStatus:$=>r(W=>W&&{...W,status:$}),onConnected:M,onChatMessage:$=>{_(W=>[...W,$])}});b.useEffect(()=>{F.current=U},[U]),b.useEffect(()=>{B.current=Z},[Z]);const L=b.useCallback(($,W)=>{P.current={cols:$,rows:W},M()},[M]);b.useEffect(()=>{if(!e)return;(async()=>{try{const re=(await UT()).find(ce=>ce.id===e)??null;r(re),re!=null&&re.sound&&u(re.sound)}catch(W){console.error("Failed to load project:",W)}finally{s(!1)}})()},[e]);const se=async()=>{if(n){o(!0);try{r(await kP(n.id))}catch($){console.error($)}finally{o(!1)}}},_e=async()=>{if(n){o(!0);try{r(await CP(n.id))}catch($){console.error($)}finally{o(!1)}}};return i?h.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})}):!n||!e?h.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 bg-background",children:[h.jsx("p",{className:"text-muted-foreground",children:"Project not found."}),h.jsxs(te,{variant:"outline",onClick:()=>t("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]})]}):h.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[h.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:h.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[h.jsx(te,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>t("/"),children:h.jsx(Wo,{className:"h-4 w-4"})}),h.jsx("button",{className:X("p-1 rounded transition-colors",w?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:T,title:"Toggle file tree",children:h.jsx(EF,{className:"h-4 w-4"})}),h.jsx("button",{className:X("p-1 rounded transition-colors",x?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:D,title:"Toggle right panel",children:h.jsx(kF,{className:"h-4 w-4"})}),h.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[h.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:n.name}),h.jsx(NK,{status:n.status}),h.jsx(dr,{variant:"outline",className:"text-xs",children:n.permissionMode==="unlimited"?"Unlimited":"Limited"}),h.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:n.folderPath})]}),h.jsx(RA,{className:"mr-2"}),h.jsx(OA,{}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:O,title:R?"退出全屏":"全屏",children:R?h.jsx(Om,{className:"h-3.5 w-3.5"}):h.jsx(Im,{className:"h-3.5 w-3.5"})}),e&&h.jsx(wK,{projectId:e,config:d,onChange:$=>{u($),nF(e,$)}}),h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void S(),disabled:l,title:"备份到云盘",children:[l?h.jsx(vo,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):h.jsx(MF,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),n.status==="running"||n.status==="restarting"?h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void se(),disabled:a,children:[h.jsx(OF,{className:"h-3.5 w-3.5 mr-1.5"}),"Stop"]}):h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void _e(),disabled:a,children:[h.jsx(CF,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})}),h.jsxs("div",{className:"flex-1 overflow-hidden flex min-h-0",children:[w&&h.jsx("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-hidden",children:h.jsx(FV,{projectPath:n.folderPath})}),h.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex flex-col",children:[h.jsxs("div",{className:"flex items-center border-b border-border bg-muted/30 px-2 h-8 flex-shrink-0",children:[h.jsxs("button",{onClick:()=>v("terminal"),className:X("flex items-center gap-1.5 px-3 py-1 text-xs rounded-t transition-colors",m==="terminal"?"bg-background text-foreground border border-b-0 border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:[h.jsx(ff,{className:"h-3 w-3"}),"终端"]}),h.jsxs("button",{onClick:()=>v("chat"),className:X("flex items-center gap-1.5 px-3 py-1 text-xs rounded-t transition-colors",m==="chat"?"bg-background text-foreground border border-b-0 border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:[h.jsx(_F,{className:"h-3 w-3"}),"对话"]})]}),h.jsx("div",{className:X("flex-1 min-h-0",m!=="terminal"&&"hidden"),children:h.jsx(xN,{ref:N,onInput:C,onResize:($,W)=>{P.current={cols:$,rows:W},H($,W)},onReady:L})}),m==="chat"&&h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(AK,{messages:y,onSend:C,readOnly:(n==null?void 0:n._sharedPermission)==="view"})})]}),x&&h.jsx("div",{className:"w-52 flex-shrink-0 border-l border-border overflow-hidden",children:h.jsx(GV,{projectId:e,onSend:C})})]}),e&&h.jsx(KV,{projectId:e,config:d,isActive:p})]})}var dp="rovingFocusGroup.onEntryFocus",IK={bubbles:!1,cancelable:!0},Nl="RovingFocusGroup",[Ng,MO,OK]=pI(Nl),[LK,PO]=bi(Nl,[OK]),[DK,MK]=LK(Nl),FO=b.forwardRef((e,t)=>h.jsx(Ng.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Ng.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(PK,{...e,ref:t})})}));FO.displayName=Nl;var PK=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...u}=e,p=b.useRef(null),f=Le(t,p),g=_w(s),[m,v]=Yi({prop:a,defaultProp:o??null,onChange:l,caller:Nl}),[y,_]=b.useState(!1),S=ci(c),w=MO(n),k=b.useRef(!1),[x,E]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(dp,S),()=>T.removeEventListener(dp,S)},[S]),h.jsx(DK,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:m,onItemFocus:b.useCallback(T=>v(T),[v]),onItemShiftTab:b.useCallback(()=>_(!0),[]),onFocusableItemAdd:b.useCallback(()=>E(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>E(T=>T-1),[]),children:h.jsx(we.div,{tabIndex:y||x===0?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{k.current=!0}),onFocus:ge(e.onFocus,T=>{const D=!k.current;if(T.target===T.currentTarget&&D&&!y){const R=new CustomEvent(dp,IK);if(T.currentTarget.dispatchEvent(R),!R.defaultPrevented){const I=w().filter(B=>B.focusable),O=I.find(B=>B.active),N=I.find(B=>B.id===m),F=[O,N,...I].filter(Boolean).map(B=>B.ref.current);UO(F,d)}}k.current=!1}),onBlur:ge(e.onBlur,()=>_(!1))})})}),BO="RovingFocusGroupItem",jO=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...o}=e,l=br(),c=s||l,d=MK(BO,n),u=d.currentTabStopId===c,p=MO(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=d;return b.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),h.jsx(Ng.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(we.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...o,ref:t,onMouseDown:ge(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:ge(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ge(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=jK(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=p().filter(w=>w.focusable).map(w=>w.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const w=S.indexOf(v.currentTarget);S=d.loop?UK(S,w+1):S.slice(w+1)}setTimeout(()=>UO(S))}}),children:typeof a=="function"?a({isCurrentTabStop:u,hasTabStop:m!=null}):a})})});jO.displayName=BO;var FK={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function BK(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jK(e,t,n){const r=BK(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return FK[r]}function UO(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function UK(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $K=FO,zK=jO,Gd="Tabs",[HK]=bi(Gd,[PO]),$O=PO(),[GK,Iw]=HK(Gd),zO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:a="horizontal",dir:o,activationMode:l="automatic",...c}=e,d=_w(o),[u,p]=Yi({prop:r,onChange:i,defaultProp:s??"",caller:Gd});return h.jsx(GK,{scope:n,baseId:br(),value:u,onValueChange:p,orientation:a,dir:d,activationMode:l,children:h.jsx(we.div,{dir:d,"data-orientation":a,...c,ref:t})})});zO.displayName=Gd;var HO="TabsList",GO=b.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=Iw(HO,n),a=$O(n);return h.jsx($K,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:r,children:h.jsx(we.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});GO.displayName=HO;var WO="TabsTrigger",VO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,a=Iw(WO,n),o=$O(n),l=YO(a.baseId,r),c=XO(a.baseId,r),d=r===a.value;return h.jsx(zK,{asChild:!0,...o,focusable:!i,active:d,children:h.jsx(we.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...s,ref:t,onMouseDown:ge(e.onMouseDown,u=>{!i&&u.button===0&&u.ctrlKey===!1?a.onValueChange(r):u.preventDefault()}),onKeyDown:ge(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&a.onValueChange(r)}),onFocus:ge(e.onFocus,()=>{const u=a.activationMode!=="manual";!d&&!i&&u&&a.onValueChange(r)})})})});VO.displayName=WO;var qO="TabsContent",KO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...a}=e,o=Iw(qO,n),l=YO(o.baseId,r),c=XO(o.baseId,r),d=r===o.value,u=b.useRef(d);return b.useEffect(()=>{const p=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(p)},[]),h.jsx(ls,{present:i||d,children:({present:p})=>h.jsx(we.div,{"data-state":d?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:c,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:p&&s})})});KO.displayName=qO;function YO(e,t){return`${e}-trigger-${t}`}function XO(e,t){return`${e}-content-${t}`}var WK=zO,ZO=GO,QO=VO,JO=KO;const VK=WK,eL=b.forwardRef(({className:e,...t},n)=>h.jsx(ZO,{ref:n,className:X("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));eL.displayName=ZO.displayName;const jc=b.forwardRef(({className:e,...t},n)=>h.jsx(QO,{ref:n,className:X("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));jc.displayName=QO.displayName;const Uc=b.forwardRef(({className:e,...t},n)=>h.jsx(JO,{ref:n,className:X("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Uc.displayName=JO.displayName;const Y0={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function qK({open:e,onOpenChange:t,onAdded:n}){const[r,i]=b.useState([]),[s,a]=b.useState(!1),[o,l]=b.useState(null),[c,d]=b.useState(""),[u,p]=b.useState(""),[f,g]=b.useState(""),[m,v]=b.useState(""),[y,_]=b.useState(!1),[S,w]=b.useState(null);b.useEffect(()=>{e&&WP().then(D=>i(D.available)).catch(()=>i([]))},[e]);const k=()=>{a(!1),l(null),d(""),p(""),g(""),v(""),_(!1),w(null)},x=async D=>{l(D),w(null);try{const{id:R}=await iE({type:D,label:Y0[D]||D}),{url:I}=await df(R);window.open(I,"_blank"),k(),t(!1),n()}catch(R){w(R instanceof Error?R.message:"添加失败"),l(null)}},E=async()=>{if(!c||!u||!f||!m){w("请填写所有字段");return}_(!0),w(null);try{const{id:D}=await iE({type:c,label:u,clientId:f,clientSecret:m}),{url:R}=await df(D);window.open(R,"_blank"),k(),t(!1),n()}catch(D){w(D instanceof Error?D.message:"添加失败")}finally{_(!1)}},T=r.length>0;return h.jsx(_a,{open:e,onOpenChange:D=>{t(D),D||k()},children:h.jsxs(cs,{className:"sm:max-w-md",children:[h.jsxs(us,{children:[h.jsxs(hs,{className:"flex items-center gap-2",children:[h.jsx(hf,{className:"h-5 w-5"}),"添加云盘账号"]}),h.jsx(ps,{children:s?"手动填写 OAuth 凭据连接云盘":"选择云盘类型,点击后跳转登录授权"})]}),s?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"space-y-4 py-2",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"云盘类型"}),h.jsxs(Du,{value:c,onValueChange:d,children:[h.jsx(il,{children:h.jsx(Mu,{placeholder:"选择云盘类型"})}),h.jsxs(sl,{children:[h.jsx(mn,{value:"google-drive",children:"Google Drive"}),h.jsx(mn,{value:"onedrive",children:"OneDrive"}),h.jsx(mn,{value:"dropbox",children:"Dropbox"})]})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"显示名称"}),h.jsx(wn,{placeholder:"例如:我的 Google Drive",value:u,onChange:D=>p(D.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"Client ID"}),h.jsx(wn,{placeholder:"OAuth Client ID",value:f,onChange:D=>g(D.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"Client Secret"}),h.jsx(wn,{type:"password",placeholder:"OAuth Client Secret",value:m,onChange:D=>v(D.target.value)})]}),S&&h.jsx("p",{className:"text-sm text-destructive",children:S})]}),h.jsxs(ds,{children:[h.jsx(te,{variant:"outline",onClick:()=>{a(!1),w(null)},children:"返回"}),h.jsx(te,{onClick:E,disabled:y,children:y?"添加中...":"添加并授权"})]})]}):h.jsxs("div",{className:"space-y-3 py-2",children:[T?h.jsx(h.Fragment,{children:r.map(D=>h.jsx(te,{variant:"outline",className:"w-full justify-start gap-3 h-12 text-base",onClick:()=>void x(D),disabled:o!==null,children:o===D?"连接中...":`连接 ${Y0[D]||D}`},D))}):h.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"暂无内置 OAuth 凭据,请使用手动模式添加"}),S&&h.jsx("p",{className:"text-sm text-destructive",children:S}),h.jsx("div",{className:"pt-2 border-t border-border",children:h.jsxs("button",{onClick:()=>{a(!0),w(null)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx(NF,{className:"h-3.5 w-3.5"}),"手动填写 OAuth 凭据"]})})]})]})})}const KK={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function YK({type:e}){switch(e){case"google-drive":return h.jsx(oE,{className:"h-5 w-5 text-blue-500"});case"onedrive":return h.jsx(hf,{className:"h-5 w-5 text-sky-500"});case"dropbox":return h.jsx(oE,{className:"h-5 w-5 text-indigo-500"});default:return h.jsx(hf,{className:"h-5 w-5"})}}function XK({provider:e,onDelete:t,onReauth:n}){var a;const[r,i]=b.useState(!1),s=()=>{r?(t(e.id),i(!1)):(i(!0),setTimeout(()=>i(!1),3e3))};return h.jsxs(td,{children:[h.jsx(nd,{className:"pb-3",children:h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(YK,{type:e.type}),h.jsxs("div",{children:[h.jsx(rd,{className:"text-base",children:e.label}),h.jsx("p",{className:"text-sm text-muted-foreground",children:KK[e.type]||e.type})]})]}),h.jsx(dr,{variant:e.authorized?"default":"destructive",className:e.authorized?"bg-green-600 hover:bg-green-700":"",children:e.authorized?"已授权":"未授权"})]})}),h.jsxs(id,{children:[e.authorized&&((a=e.tokens)==null?void 0:a.expiry)&&h.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["授权到期:",new Date(e.tokens.expiry).toLocaleDateString("zh-CN")]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(te,{variant:"outline",size:"sm",onClick:()=>n(e.id),children:[h.jsx(Ki,{className:"h-3.5 w-3.5 mr-1"}),"重新授权"]}),h.jsxs(te,{variant:r?"destructive":"outline",size:"sm",onClick:s,children:[h.jsx(Lm,{className:"h-3.5 w-3.5 mr-1"}),r?"确认删除?":"删除"]})]})]})]})}const ZK={success:{label:"成功",icon:cF,className:"bg-green-600 hover:bg-green-700"},failed:{label:"失败",icon:FF,className:"bg-red-600 hover:bg-red-700"},partial:{label:"部分完成",icon:aF,className:"bg-yellow-600 hover:bg-yellow-700"}};function QK(e,t){const n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;const r=Math.floor(n/1e3);if(r<60)return`${r}秒`;const i=Math.floor(r/60),s=r%60;return`${i}分${s}秒`}function JK(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function eY({history:e}){const t=e.slice(0,20);return t.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[h.jsx(uF,{className:"h-10 w-10 mb-3 opacity-50"}),h.jsx("p",{className:"text-sm",children:"暂无备份记录"})]}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-sm",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"border-b",children:[h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"时间"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"项目"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"云盘"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"状态"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"文件数"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"耗时"})]})}),h.jsx("tbody",{children:t.map(n=>{const r=ZK[n.status],i=r.icon;return h.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/50",children:[h.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:JK(n.startTime)}),h.jsx("td",{className:"py-2.5 px-2",children:n.projectName}),h.jsx("td",{className:"py-2.5 px-2",children:n.providerLabel}),h.jsxs("td",{className:"py-2.5 px-2",children:[h.jsxs(dr,{className:r.className,children:[h.jsx(i,{className:"h-3 w-3 mr-1"}),r.label]}),n.error&&h.jsx("p",{className:"text-xs text-destructive mt-1",children:n.error})]}),h.jsxs("td",{className:"py-2.5 px-2 whitespace-nowrap",children:[n.filesUploaded,"/",n.filesTotal]}),h.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:QK(n.startTime,n.endTime)})]},n.id)})})]})})}const X0=["node_modules",".git","dist","build","*.log",".DS_Store","*.tmp",".venv","__pycache__",".env"],tY=[{value:"30",label:"30分钟"},{value:"60",label:"1小时"},{value:"360",label:"6小时"},{value:"720",label:"12小时"},{value:"1440",label:"24小时"}];function nY(){const e=ss(),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,a]=b.useState(!1),[o,l]=b.useState({enabled:!1,intervalMinutes:60}),[c,d]=b.useState(!0),[u,p]=b.useState([]),[f,g]=b.useState(!0),[m,v]=b.useState(""),[y,_]=b.useState(!1),[S,w]=b.useState(!1),[k,x]=b.useState([]),[E,T]=b.useState(!0),D=async()=>{try{const C=await VP();n(C)}catch{}finally{i(!1)}},R=async()=>{try{const C=await YP();l(C)}catch{}finally{d(!1)}},I=async()=>{try{const C=await XP();p(C.length>0?C:X0)}catch{p(X0)}finally{g(!1)}},O=async()=>{try{const C=await QP();x(C)}catch{}finally{T(!1)}};b.useEffect(()=>{D(),R(),I(),O()},[]);const N=async C=>{try{await qP(C),n(H=>H.filter(Z=>Z.id!==C))}catch{}},P=async C=>{try{const{url:H}=await df(C);window.open(H,"_blank")}catch{}},F=async C=>{const H={...o,enabled:C};l(H);try{await sE({enabled:C})}catch{l(o)}},B=async C=>{const H=parseInt(C,10),Z={...o,intervalMinutes:H};l(Z);try{await sE({intervalMinutes:H})}catch{l(o)}},j=()=>{const C=m.trim();!C||u.includes(C)||(p(H=>[...H,C]),v(""),_(!0))},M=C=>{p(H=>H.filter(Z=>Z!==C)),_(!0)},U=async()=>{w(!0);try{await ZP(u),_(!1)}catch{}finally{w(!1)}};return h.jsx("div",{className:"min-h-screen bg-background",children:h.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-1"}),"返回"]}),h.jsx("h1",{className:"text-2xl font-bold",children:"设置"})]}),h.jsxs(VK,{defaultValue:"providers",children:[h.jsxs(eL,{className:"mb-4",children:[h.jsx(jc,{value:"providers",children:"云盘账号"}),h.jsx(jc,{value:"strategy",children:"备份策略"}),h.jsx(jc,{value:"history",children:"备份记录"})]}),h.jsxs(Uc,{value:"providers",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex justify-end",children:h.jsxs(te,{onClick:()=>a(!0),children:[h.jsx(oa,{className:"h-4 w-4 mr-1"}),"添加云盘"]})}),r?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):t.length===0?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"暂无云盘账号,点击上方按钮添加"}):h.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:t.map(C=>h.jsx(XK,{provider:C,onDelete:N,onReauth:P},C.id))})]}),h.jsx(qK,{open:s,onOpenChange:a,onAdded:()=>void D()})]}),h.jsx(Uc,{value:"strategy",children:h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("h3",{className:"text-lg font-medium",children:"排除规则"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"匹配这些模式的文件和目录将不会被备份"}),f?h.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(C=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-sm",children:[C,h.jsx("button",{onClick:()=>M(C),className:"ml-0.5 rounded-sm hover:bg-muted-foreground/20 p-0.5",children:h.jsx(os,{className:"h-3 w-3"})})]},C))}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(wn,{placeholder:"输入排除模式,例如 *.log",value:m,onChange:C=>v(C.target.value),onKeyDown:C=>{C.key==="Enter"&&j()},className:"max-w-xs"}),h.jsx(te,{variant:"outline",size:"sm",onClick:j,children:"添加"})]}),y&&h.jsxs(te,{onClick:U,disabled:S,children:[h.jsx(KT,{className:"h-4 w-4 mr-1"}),S?"保存中...":"保存"]})]})]}),h.jsxs("div",{className:"space-y-4",children:[h.jsx("h3",{className:"text-lg font-medium",children:"定时备份"}),c?h.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(yw,{checked:o.enabled,onCheckedChange:F}),h.jsx(je,{children:o.enabled?"已开启":"已关闭"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"备份间隔"}),h.jsxs(Du,{value:String(o.intervalMinutes),onValueChange:B,children:[h.jsx(il,{className:"w-48",children:h.jsx(Mu,{})}),h.jsx(sl,{children:tY.map(C=>h.jsx(mn,{value:C.value,children:C.label},C.value))})]})]})]})]})]})}),h.jsx(Uc,{value:"history",children:h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex justify-end",children:h.jsxs(te,{variant:"outline",size:"sm",onClick:()=>{T(!0),O()},children:[h.jsx(Ki,{className:"h-4 w-4 mr-1"}),"刷新"]})}),E?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):h.jsx(eY,{history:k})]})})]})]})})}function rY(){const e=ss(),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,a]=b.useState(null),[o,l]=b.useState(""),[c,d]=b.useState(null),[u,p]=b.useState(null),[f,g]=b.useState(null),[m,v]=b.useState(new Set);b.useEffect(()=>{FP().then(n).catch(k=>a(k instanceof Error?k.message:"Failed to load SkillHub")).finally(()=>i(!1))},[]);const y=b.useMemo(()=>{const k=new Set;return t.forEach(x=>{var E;return(E=x.tags)==null?void 0:E.forEach(T=>k.add(T))}),Array.from(k).sort()},[t]),_=b.useMemo(()=>t.some(k=>!k.tags||k.tags.length===0),[t]),S=b.useMemo(()=>{let k=t;if(c==="__untagged__"?k=k.filter(x=>!x.tags||x.tags.length===0):c&&(k=k.filter(x=>{var E;return(E=x.tags)==null?void 0:E.includes(c)})),o.trim()){const x=o.toLowerCase();k=k.filter(E=>{var T;return E.label.toLowerCase().includes(x)||E.description.toLowerCase().includes(x)||E.command.toLowerCase().includes(x)||E.author.toLowerCase().includes(x)||((T=E.tags)==null?void 0:T.some(D=>D.toLowerCase().includes(x)))})}return k},[t,o,c]),w=async(k,x)=>{if(x.stopPropagation(),!(f||m.has(k.id))){g(k.id);try{await jP(k.id),v(E=>new Set(E).add(k.id)),n(E=>E.map(T=>T.id===k.id?{...T,downloads:(T.downloads||0)+1}:T))}catch(E){alert(E instanceof Error?E.message:"Download failed")}finally{g(null)}}};return h.jsxs("div",{className:"min-h-screen bg-background",children:[h.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:h.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-1"}),"返回"]}),h.jsx("h1",{className:"font-semibold text-lg",children:"SkillHub"}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"relative w-64",children:[h.jsx(TF,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),h.jsx(wn,{placeholder:"搜索命令...",value:o,onChange:k=>l(k.target.value),className:"pl-8 h-9"})]})]})}),h.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:[y.length>0&&h.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(null),children:"全部"}),y.map(k=>h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c===k?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(c===k?null:k),children:k},k)),_&&h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c==="__untagged__"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(c==="__untagged__"?null:"__untagged__"),children:"无标签"})]}),r&&h.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),s&&h.jsx("div",{className:"text-center text-destructive py-20",children:s}),!r&&!s&&t.length===0&&h.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[h.jsx("p",{className:"text-lg mb-2",children:"SkillHub 还没有命令"}),h.jsx("p",{className:"text-sm",children:"在快捷命令面板中点击分享按钮来提交第一个命令吧!"})]}),!r&&!s&&t.length>0&&S.length===0&&h.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的命令"}),h.jsx("div",{className:"space-y-3",children:S.map(k=>{var R;const x=u===k.id,E=m.has(k.id),T=f===k.id,D=k.parentId?t.find(I=>I.id===k.parentId):void 0;return h.jsxs("div",{className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>p(x?null:k.id),children:[h.jsxs("div",{className:"flex items-start justify-between gap-4",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-sm truncate",children:k.label}),(R=k.tags)==null?void 0:R.map(I=>h.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:[h.jsx(DF,{className:"h-2.5 w-2.5"}),I]},I))]}),D&&h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(_o,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground",children:["继承: ",D.label]})]}),k.description&&h.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:k.description}),h.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(YT,{className:"h-3 w-3"}),k.author]}),h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(pu,{className:"h-3 w-3"}),k.downloads||0]}),h.jsx("span",{children:k.createdAt})]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsxs(te,{size:"sm",variant:E?"outline":"default",disabled:T||E,onClick:I=>w(k,I),title:D?`将同时下载继承的「${D.label}」`:void 0,children:[h.jsx(pu,{className:"h-3.5 w-3.5 mr-1"}),E?"已下载":T?"下载中...":"下载"]}),x?h.jsx(VT,{className:"h-4 w-4 text-muted-foreground"}):h.jsx(pl,{className:"h-4 w-4 text-muted-foreground"})]})]}),x&&h.jsx("div",{className:"mt-3 pt-3 border-t",children:h.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:k.command})})]},k.id)})})]})]})}function dc({children:e}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1);return b.useEffect(()=>{if(kr()){i(!0),n(!0);return}uf()?jT().then(a=>{cf(a),i(!0)}).catch(()=>{i(!1)}).finally(()=>n(!0)):n(!0)},[]),t?r?h.jsx(h.Fragment,{children:e}):h.jsx(ET,{to:"/login",replace:!0}):null}function iY(){return h.jsx(L3,{children:h.jsx(TM,{children:h.jsxs(EM,{children:[h.jsx(Ni,{path:"/login",element:h.jsx(rF,{})}),h.jsx(Ni,{path:"/",element:h.jsx(dc,{children:h.jsx(D3,{})})}),h.jsx(Ni,{path:"/projects/:id",element:h.jsx(dc,{children:h.jsx(RK,{})})}),h.jsx(Ni,{path:"/settings",element:h.jsx(dc,{children:h.jsx(nY,{})})}),h.jsx(Ni,{path:"/skillhub",element:h.jsx(dc,{children:h.jsx(rY,{})})}),h.jsx(Ni,{path:"*",element:h.jsx(ET,{to:"/",replace:!0})})]})})})}hp.createRoot(document.getElementById("root")).render(h.jsx(ft.StrictMode,{children:h.jsx(iY,{})}));export{Pu as a,$c as c,sY as g};
546
+ `)}`}function $V({session:e,onClose:t,onRecall:n}){return h.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[h.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),h.jsxs("div",{className:"relative z-10 w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 h-11 border-b border-border flex-shrink-0",children:[h.jsx("span",{className:"text-sm font-medium text-foreground",children:rI(e.startedAt)}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("button",{className:"flex items-center gap-1.5 text-xs px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white transition-colors",onClick:()=>{n(iI(e)),t()},children:[h.jsx(Rm,{className:"h-3 w-3"}),"回忆"]}),h.jsx("button",{className:"text-muted-foreground hover:text-foreground transition-colors p-0.5",onClick:t,children:h.jsx(os,{className:"h-4 w-4"})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-h-0",children:[e.messages.length===0&&h.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),e.messages.map((r,i)=>h.jsxs("div",{className:X("flex gap-2.5",r.role==="user"?"flex-row-reverse":"flex-row"),children:[h.jsx("div",{className:X("flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center mt-0.5",r.role==="user"?"bg-blue-600/20":"bg-muted"),children:r.role==="user"?h.jsx(YT,{className:"h-3 w-3 text-blue-400"}):h.jsx(GT,{className:"h-3 w-3 text-muted-foreground"})}),h.jsx("div",{className:X("max-w-[85%] text-xs rounded-lg px-3 py-2 whitespace-pre-wrap break-words",r.role==="user"?"bg-blue-600/20 text-blue-100 dark:text-blue-100 border border-blue-500/20":"bg-muted text-foreground border border-border"),children:r.content})]},i))]})]})]})}function zV({projectId:e,onSend:t}){var d;const[n,r]=b.useState([]),[i,s]=b.useState(null),a=n.filter(u=>u.messageCount>0),o=(d=a.find(u=>!u.isCurrent))==null?void 0:d.id;b.useEffect(()=>{let u=null;const p=()=>{document.hidden||nE(e).then(r).catch(()=>{})};nE(e).then(r).catch(()=>r([]));const f=()=>{u=setInterval(p,5e3)},g=()=>{u&&(clearInterval(u),u=null)},m=()=>{document.hidden?g():f()};return f(),document.addEventListener("visibilitychange",m),()=>{g(),document.removeEventListener("visibilitychange",m)}},[e]);const l=async u=>{try{s(await rE(e,u))}catch{}},c=u=>{t(u+"\r")};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[a.length===0&&h.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[h.jsx(GT,{className:"h-5 w-5"}),h.jsx("p",{className:"text-xs text-center",children:"暂无历史记录"})]}),a.map(u=>{const p=u.isCurrent,f=!u.isCurrent&&u.id===o;return h.jsxs("div",{className:X("group rounded border bg-muted hover:border-muted-foreground/30 transition-colors",p?"border-blue-500/50":"border-border"),children:[h.jsxs("button",{className:"w-full text-left px-3 pt-2 pb-1",onClick:()=>void l(u.id),children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-xs font-medium text-foreground",children:rI(u.startedAt)}),p&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30 leading-none",children:"当前"}),f&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground border border-border leading-none",children:"最近"})]}),h.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:[u.messageCount," 条消息"]})]}),h.jsx("div",{className:"px-3 pb-2 flex justify-end",children:h.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async g=>{g.stopPropagation();try{const m=await rE(e,u.id);c(iI(m))}catch{}},children:[h.jsx(Rm,{className:"h-2.5 w-2.5"}),"回忆"]})})]},u.id)})]}),i&&h.jsx($V,{session:i,onClose:()=>s(null),onRecall:c})]})}const HV={shortcuts:"快捷命令",history:"历史记录"};function GV({projectId:e,onSend:t}){const[n,r]=b.useState("shortcuts");return h.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground",children:[h.jsx("div",{className:"flex border-b border-border flex-shrink-0",children:["shortcuts","history"].map(i=>h.jsx("button",{onClick:()=>r(i),className:X("flex-1 text-xs py-2 font-medium transition-colors",n===i?"text-foreground border-b-2 border-blue-500 -mb-px bg-muted/50":"text-muted-foreground hover:text-foreground"),children:HV[i]},i))}),n==="shortcuts"&&h.jsx(UV,{projectId:e,onSend:t}),n==="history"&&h.jsx(zV,{projectId:e,onSend:t})]})}const WV=new Set(["preset:wind","preset:rain","preset:stream"]),VV=new Set(["preset:singing-bowl","preset:water-drops","preset:keyboard"]);function qV(e){return e.playMode!=="auto"?e.playMode:WV.has(e.source)?"loop":VV.has(e.source)?"interval":"loop"}function KV({projectId:e,config:t,isActive:n}){const r=b.useRef(null),i=b.useRef(null),s=b.useRef(null),a=b.useRef(null),o=b.useRef(null),l=b.useRef(null),c=b.useRef(!1),d=b.useCallback(()=>{if(o.current&&(clearTimeout(o.current),o.current=null),l.current&&(clearTimeout(l.current),l.current=null),r.current&&(r.current.pause(),r.current.src=""),a.current){try{a.current.disconnect()}catch{}a.current=null}if(s.current){try{s.current.disconnect()}catch{}s.current=null}if(i.current){try{i.current.close()}catch{}i.current=null}r.current=null,c.current=!1},[]),u=b.useCallback(g=>{if(!r.current||r.current.src!==g){if(a.current){try{a.current.disconnect()}catch{}a.current=null}r.current&&r.current.pause();const m=new Audio(g);m.crossOrigin="anonymous",r.current=m}if(i.current||(i.current=new AudioContext),!s.current){const m=i.current.createGain();m.gain.value=0,m.connect(i.current.destination),s.current=m}if(!a.current){const m=i.current.createMediaElementSource(r.current);m.connect(s.current),a.current=m}return{audio:r.current,ctx:i.current,gain:s.current}},[]),p=b.useCallback(g=>{const m=aE(g.source,e),v=Math.max(0,Math.min(1,g.volume)),y=qV(g),{audio:_,ctx:S,gain:w}=u(m);S.resume().then(()=>{if(o.current&&(clearTimeout(o.current),o.current=null),l.current&&(clearTimeout(l.current),l.current=null),y==="loop")_.loop=!0,_.currentTime=0,_.play().catch(()=>{}),c.current=!0,w.gain.cancelScheduledValues(S.currentTime),w.gain.setValueAtTime(w.gain.value,S.currentTime),w.gain.linearRampToValueAtTime(v,S.currentTime+.5);else{_.loop=!1;const k=()=>{if(!c.current)return;_.currentTime=0,_.play().catch(()=>{}),w.gain.cancelScheduledValues(S.currentTime),w.gain.setValueAtTime(w.gain.value,S.currentTime),w.gain.linearRampToValueAtTime(v,S.currentTime+.5);const x=()=>{if(!c.current)return;const[E,T]=g.intervalRange,D=(E+Math.random()*(T-E))*1e3;l.current=setTimeout(k,D)};_.onended=x};c.current=!0,k()}}).catch(()=>{})},[e,u]),f=b.useCallback(()=>{if(!r.current||!i.current||!s.current){c.current=!1;return}c.current=!1,l.current&&(clearTimeout(l.current),l.current=null),r.current&&(r.current.onended=null);const g=i.current,m=s.current,v=r.current;m.gain.cancelScheduledValues(g.currentTime),m.gain.setValueAtTime(m.gain.value,g.currentTime),m.gain.linearRampToValueAtTime(0,g.currentTime+1),o.current=setTimeout(()=>{o.current=null,v&&v.pause()},1100)},[]);return b.useEffect(()=>{!t||!t.enabled||(n?p(t):f())},[n,t,p,f]),b.useEffect(()=>()=>{d()},[d]),b.useEffect(()=>{if(!t){d();return}if(r.current){const g=aE(t.source,e);if(r.current.src!==g){if(f(),a.current){try{a.current.disconnect()}catch{}a.current=null}r.current.pause(),r.current=null,n&&p(t)}}},[t==null?void 0:t.source,e]),null}function sI(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function aI(e){const[t,n]=b.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,o;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;a=c.inlineSize,o=c.blockSize}else a=e.offsetWidth,o=e.offsetHeight;n({width:a,height:o})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Dd="Switch",[YV]=bi(Dd),[XV,ZV]=YV(Dd),oI=b.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:a,disabled:o,value:l="on",onCheckedChange:c,form:d,...u}=e,[p,f]=b.useState(null),g=Le(t,S=>f(S)),m=b.useRef(!1),v=p?d||!!p.closest("form"):!0,[y,_]=Yi({prop:i,defaultProp:s??!1,onChange:c,caller:Dd});return h.jsxs(XV,{scope:n,checked:y,disabled:o,children:[h.jsx(we.button,{type:"button",role:"switch","aria-checked":y,"aria-required":a,"data-state":dI(y),"data-disabled":o?"":void 0,disabled:o,value:l,...u,ref:g,onClick:ge(e.onClick,S=>{_(w=>!w),v&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),v&&h.jsx(uI,{control:p,bubbles:!m.current,name:r,value:l,checked:y,required:a,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});oI.displayName=Dd;var lI="SwitchThumb",cI=b.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=ZV(lI,n);return h.jsx(we.span,{"data-state":dI(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});cI.displayName=lI;var QV="SwitchBubbleInput",uI=b.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},s)=>{const a=b.useRef(null),o=Le(a,s),l=sI(n),c=aI(t);return b.useEffect(()=>{const d=a.current;if(!d)return;const u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"checked").set;if(l!==n&&f){const g=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(g)}},[l,n,r]),h.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:o,style:{...i.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});uI.displayName=QV;function dI(e){return e?"checked":"unchecked"}var hI=oI,JV=cI;const yw=b.forwardRef(({className:e,...t},n)=>h.jsx(hI,{className:X("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),...t,ref:n,children:h.jsx(JV,{className:X("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")})}));yw.displayName=hI.displayName;function P0(e,[t,n]){return Math.min(n,Math.max(t,e))}function F0(e){const t=e7(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(n7);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function e7(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=i7(i),o=r7(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var t7=Symbol("radix.slottable");function n7(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t7}function r7(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function i7(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function pI(e){const t=e+"CollectionProvider",[n,r]=bi(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=m=>{const{scope:v,children:y}=m,_=ft.useRef(null),S=ft.useRef(new Map).current;return h.jsx(i,{scope:v,itemMap:S,collectionRef:_,children:y})};a.displayName=t;const o=e+"CollectionSlot",l=F0(o),c=ft.forwardRef((m,v)=>{const{scope:y,children:_}=m,S=s(o,y),w=Le(v,S.collectionRef);return h.jsx(l,{ref:w,children:_})});c.displayName=o;const d=e+"CollectionItemSlot",u="data-radix-collection-item",p=F0(d),f=ft.forwardRef((m,v)=>{const{scope:y,children:_,...S}=m,w=ft.useRef(null),k=Le(v,w),x=s(d,y);return ft.useEffect(()=>(x.itemMap.set(w,{ref:w,...S}),()=>void x.itemMap.delete(w))),h.jsx(p,{[u]:"",ref:k,children:_})});f.displayName=d;function g(m){const v=s(e+"CollectionConsumer",m);return ft.useCallback(()=>{const _=v.collectionRef.current;if(!_)return[];const S=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((x,E)=>S.indexOf(x.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:c,ItemSlot:f},g,r]}var s7=b.createContext(void 0);function _w(e){const t=b.useContext(s7);return e||t||"ltr"}const a7=["top","right","bottom","left"],di=Math.min,sn=Math.max,Nu=Math.round,uc=Math.floor,er=e=>({x:e,y:e}),o7={left:"right",right:"left",bottom:"top",top:"bottom"};function Sg(e,t,n){return sn(e,di(t,n))}function wr(e,t){return typeof e=="function"?e(t):e}function xr(e){return e.split("-")[0]}function Ra(e){return e.split("-")[1]}function vw(e){return e==="x"?"y":"x"}function Sw(e){return e==="y"?"height":"width"}function Yn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ww(e){return vw(Yn(e))}function l7(e,t,n){n===void 0&&(n=!1);const r=Ra(e),i=ww(e),s=Sw(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Ru(a)),[a,Ru(a)]}function c7(e){const t=Ru(e);return[wg(e),t,wg(t)]}function wg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const B0=["left","right"],j0=["right","left"],u7=["top","bottom"],d7=["bottom","top"];function h7(e,t,n){switch(e){case"top":case"bottom":return n?t?j0:B0:t?B0:j0;case"left":case"right":return t?u7:d7;default:return[]}}function p7(e,t,n,r){const i=Ra(e);let s=h7(xr(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(wg)))),s}function Ru(e){const t=xr(e);return o7[t]+e.slice(t.length)}function f7(e){return{top:0,right:0,bottom:0,left:0,...e}}function fI(e){return typeof e!="number"?f7(e):{top:e,right:e,bottom:e,left:e}}function Iu(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function U0(e,t,n){let{reference:r,floating:i}=e;const s=Yn(t),a=ww(t),o=Sw(a),l=xr(t),c=s==="y",d=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,p=r[o]/2-i[o]/2;let f;switch(l){case"top":f={x:d,y:r.y-i.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Ra(t)){case"start":f[a]-=p*(n&&c?-1:1);break;case"end":f[a]+=p*(n&&c?-1:1);break}return f}async function g7(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:f=0}=wr(t,e),g=fI(f),v=o[p?u==="floating"?"reference":"floating":u],y=Iu(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:d,strategy:l})),_=u==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),w=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},k=Iu(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:_,offsetParent:S,strategy:l}):_);return{top:(y.top-k.top+g.top)/w.y,bottom:(k.bottom-y.bottom+g.bottom)/w.y,left:(y.left-k.left+g.left)/w.x,right:(k.right-y.right+g.right)/w.x}}const m7=50,b7=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,o=a.detectOverflow?a:{...a,detectOverflow:g7},l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:d,y:u}=U0(c,r,l),p=r,f=0;const g={};for(let m=0;m<s.length;m++){const v=s[m];if(!v)continue;const{name:y,fn:_}=v,{x:S,y:w,data:k,reset:x}=await _({x:d,y:u,initialPlacement:r,placement:p,strategy:i,middlewareData:g,rects:c,platform:o,elements:{reference:e,floating:t}});d=S??d,u=w??u,g[y]={...g[y],...k},x&&f<m7&&(f++,typeof x=="object"&&(x.placement&&(p=x.placement),x.rects&&(c=x.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:d,y:u}=U0(c,p,l)),m=-1)}return{x:d,y:u,placement:p,strategy:i,middlewareData:g}},y7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:o,middlewareData:l}=t,{element:c,padding:d=0}=wr(e,t)||{};if(c==null)return{};const u=fI(d),p={x:n,y:r},f=ww(i),g=Sw(f),m=await a.getDimensions(c),v=f==="y",y=v?"top":"left",_=v?"bottom":"right",S=v?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[f]-p[f]-s.floating[g],k=p[f]-s.reference[f],x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let E=x?x[S]:0;(!E||!await(a.isElement==null?void 0:a.isElement(x)))&&(E=o.floating[S]||s.floating[g]);const T=w/2-k/2,D=E/2-m[g]/2-1,R=di(u[y],D),I=di(u[_],D),O=R,N=E-m[g]-I,P=E/2-m[g]/2+T,F=Sg(O,P,N),B=!l.arrow&&Ra(i)!=null&&P!==F&&s.reference[g]/2-(P<O?R:I)-m[g]/2<0,j=B?P<O?P-O:P-N:0;return{[f]:p[f]+j,data:{[f]:F,centerOffset:P-F-j,...B&&{alignmentOffset:j}},reset:B}}}),_7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:o,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...v}=wr(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=xr(i),_=Yn(o),S=xr(o)===o,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=p||(S||!m?[Ru(o)]:c7(o)),x=g!=="none";!p&&x&&k.push(...p7(o,m,g,w));const E=[o,...k],T=await l.detectOverflow(t,v),D=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&D.push(T[y]),u){const P=l7(i,a,w);D.push(T[P[0]],T[P[1]])}if(R=[...R,{placement:i,overflows:D}],!D.every(P=>P<=0)){var I,O;const P=(((I=s.flip)==null?void 0:I.index)||0)+1,F=E[P];if(F&&(!(u==="alignment"?_!==Yn(F):!1)||R.every(M=>Yn(M.placement)===_?M.overflows[0]>0:!0)))return{data:{index:P,overflows:R},reset:{placement:F}};let B=(O=R.filter(j=>j.overflows[0]<=0).sort((j,M)=>j.overflows[1]-M.overflows[1])[0])==null?void 0:O.placement;if(!B)switch(f){case"bestFit":{var N;const j=(N=R.filter(M=>{if(x){const U=Yn(M.placement);return U===_||U==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(U=>U>0).reduce((U,C)=>U+C,0)]).sort((M,U)=>M[1]-U[1])[0])==null?void 0:N[0];j&&(B=j);break}case"initialPlacement":B=o;break}if(i!==B)return{reset:{placement:B}}}return{}}}};function $0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function z0(e){return a7.some(t=>e[t]>=0)}const v7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=wr(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),o=$0(a,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:z0(o)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),o=$0(a,n.floating);return{data:{escapedOffsets:o,escaped:z0(o)}}}default:return{}}}}},gI=new Set(["left","top"]);async function S7(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xr(n),o=Ra(n),l=Yn(n)==="y",c=gI.has(a)?-1:1,d=s&&l?-1:1,u=wr(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return o&&typeof g=="number"&&(f=o==="end"?g*-1:g),l?{x:f*d,y:p*c}:{x:p*c,y:f*d}}const w7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:o}=t,l=await S7(t,e);return a===((n=o.offset)==null?void 0:n.placement)&&(r=o.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:a}}}}},x7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:_,y:S}=y;return{x:_,y:S}}},...c}=wr(e,t),d={x:n,y:r},u=await s.detectOverflow(t,c),p=Yn(xr(i)),f=vw(p);let g=d[f],m=d[p];if(a){const y=f==="y"?"top":"left",_=f==="y"?"bottom":"right",S=g+u[y],w=g-u[_];g=Sg(S,g,w)}if(o){const y=p==="y"?"top":"left",_=p==="y"?"bottom":"right",S=m+u[y],w=m-u[_];m=Sg(S,m,w)}const v=l.fn({...t,[f]:g,[p]:m});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[f]:a,[p]:o}}}}}},E7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:o=0,mainAxis:l=!0,crossAxis:c=!0}=wr(e,t),d={x:n,y:r},u=Yn(i),p=vw(u);let f=d[p],g=d[u];const m=wr(o,t),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const S=p==="y"?"height":"width",w=s.reference[p]-s.floating[S]+v.mainAxis,k=s.reference[p]+s.reference[S]-v.mainAxis;f<w?f=w:f>k&&(f=k)}if(c){var y,_;const S=p==="y"?"width":"height",w=gI.has(xr(i)),k=s.reference[u]-s.floating[S]+(w&&((y=a.offset)==null?void 0:y[u])||0)+(w?0:v.crossAxis),x=s.reference[u]+s.reference[S]+(w?0:((_=a.offset)==null?void 0:_[u])||0)-(w?v.crossAxis:0);g<k?g=k:g>x&&(g=x)}return{[p]:f,[u]:g}}}},k7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:o}=t,{apply:l=()=>{},...c}=wr(e,t),d=await a.detectOverflow(t,c),u=xr(i),p=Ra(i),f=Yn(i)==="y",{width:g,height:m}=s.floating;let v,y;u==="top"||u==="bottom"?(v=u,y=p===(await(a.isRTL==null?void 0:a.isRTL(o.floating))?"start":"end")?"left":"right"):(y=u,v=p==="end"?"top":"bottom");const _=m-d.top-d.bottom,S=g-d.left-d.right,w=di(m-d[v],_),k=di(g-d[y],S),x=!t.middlewareData.shift;let E=w,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=_),x&&!p){const R=sn(d.left,0),I=sn(d.right,0),O=sn(d.top,0),N=sn(d.bottom,0);f?T=g-2*(R!==0||I!==0?R+I:sn(d.left,d.right)):E=m-2*(O!==0||N!==0?O+N:sn(d.top,d.bottom))}await l({...t,availableWidth:T,availableHeight:E});const D=await a.getDimensions(o.floating);return g!==D.width||m!==D.height?{reset:{rects:!0}}:{}}}};function Md(){return typeof window<"u"}function Ia(e){return mI(e)?(e.nodeName||"").toLowerCase():"#document"}function cn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ir(e){var t;return(t=(mI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mI(e){return Md()?e instanceof Node||e instanceof cn(e).Node:!1}function Fn(e){return Md()?e instanceof Element||e instanceof cn(e).Element:!1}function Nr(e){return Md()?e instanceof HTMLElement||e instanceof cn(e).HTMLElement:!1}function H0(e){return!Md()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof cn(e).ShadowRoot}function Tl(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Bn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function C7(e){return/^(table|td|th)$/.test(Ia(e))}function Pd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const T7=/transform|translate|scale|rotate|perspective|filter/,A7=/paint|layout|strict|content/,Ci=e=>!!e&&e!=="none";let ap;function xw(e){const t=Fn(e)?Bn(e):e;return Ci(t.transform)||Ci(t.translate)||Ci(t.scale)||Ci(t.rotate)||Ci(t.perspective)||!Ew()&&(Ci(t.backdropFilter)||Ci(t.filter))||T7.test(t.willChange||"")||A7.test(t.contain||"")}function N7(e){let t=hi(e);for(;Nr(t)&&!da(t);){if(xw(t))return t;if(Pd(t))return null;t=hi(t)}return null}function Ew(){return ap==null&&(ap=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ap}function da(e){return/^(html|body|#document)$/.test(Ia(e))}function Bn(e){return cn(e).getComputedStyle(e)}function Fd(e){return Fn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function hi(e){if(Ia(e)==="html")return e;const t=e.assignedSlot||e.parentNode||H0(e)&&e.host||ir(e);return H0(t)?t.host:t}function bI(e){const t=hi(e);return da(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nr(t)&&Tl(t)?t:bI(t)}function rl(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=bI(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=cn(i);if(s){const o=xg(a);return t.concat(a,a.visualViewport||[],Tl(i)?i:[],o&&n?rl(o):[])}else return t.concat(i,rl(i,[],n))}function xg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yI(e){const t=Bn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Nr(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=Nu(n)!==s||Nu(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function kw(e){return Fn(e)?e:e.contextElement}function Js(e){const t=kw(e);if(!Nr(t))return er(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=yI(t);let a=(s?Nu(n.width):n.width)/r,o=(s?Nu(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const R7=er(0);function _I(e){const t=cn(e);return!Ew()||!t.visualViewport?R7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function I7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==cn(e)?!1:t}function es(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=kw(e);let a=er(1);t&&(r?Fn(r)&&(a=Js(r)):a=Js(e));const o=I7(s,n,r)?_I(s):er(0);let l=(i.left+o.x)/a.x,c=(i.top+o.y)/a.y,d=i.width/a.x,u=i.height/a.y;if(s){const p=cn(s),f=r&&Fn(r)?cn(r):r;let g=p,m=xg(g);for(;m&&r&&f!==g;){const v=Js(m),y=m.getBoundingClientRect(),_=Bn(m),S=y.left+(m.clientLeft+parseFloat(_.paddingLeft))*v.x,w=y.top+(m.clientTop+parseFloat(_.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,u*=v.y,l+=S,c+=w,g=cn(m),m=xg(g)}}return Iu({width:d,height:u,x:l,y:c})}function Bd(e,t){const n=Fd(e).scrollLeft;return t?t.left+n:es(ir(e)).left+n}function vI(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bd(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function O7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=ir(r),o=t?Pd(t.floating):!1;if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=er(1);const d=er(0),u=Nr(r);if((u||!u&&!s)&&((Ia(r)!=="body"||Tl(a))&&(l=Fd(r)),u)){const f=es(r);c=Js(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const p=a&&!u&&!s?vI(a,l):er(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function L7(e){return Array.from(e.getClientRects())}function D7(e){const t=ir(e),n=Fd(e),r=e.ownerDocument.body,i=sn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=sn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Bd(e);const o=-n.scrollTop;return Bn(r).direction==="rtl"&&(a+=sn(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}const G0=25;function M7(e,t){const n=cn(e),r=ir(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,o=0,l=0;if(i){s=i.width,a=i.height;const d=Ew();(!d||d&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}const c=Bd(r);if(c<=0){const d=r.ownerDocument,u=d.body,p=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-f);g<=G0&&(s-=g)}else c<=G0&&(s+=c);return{width:s,height:a,x:o,y:l}}function P7(e,t){const n=es(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Nr(e)?Js(e):er(1),a=e.clientWidth*s.x,o=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:a,height:o,x:l,y:c}}function W0(e,t,n){let r;if(t==="viewport")r=M7(e,n);else if(t==="document")r=D7(ir(e));else if(Fn(t))r=P7(t,n);else{const i=_I(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Iu(r)}function SI(e,t){const n=hi(e);return n===t||!Fn(n)||da(n)?!1:Bn(n).position==="fixed"||SI(n,t)}function F7(e,t){const n=t.get(e);if(n)return n;let r=rl(e,[],!1).filter(o=>Fn(o)&&Ia(o)!=="body"),i=null;const s=Bn(e).position==="fixed";let a=s?hi(e):e;for(;Fn(a)&&!da(a);){const o=Bn(a),l=xw(a);!l&&o.position==="fixed"&&(i=null),(s?!l&&!i:!l&&o.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Tl(a)&&!l&&SI(e,a))?r=r.filter(d=>d!==a):i=o,a=hi(a)}return t.set(e,r),r}function B7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Pd(t)?[]:F7(t,this._c):[].concat(n),r],o=W0(t,a[0],i);let l=o.top,c=o.right,d=o.bottom,u=o.left;for(let p=1;p<a.length;p++){const f=W0(t,a[p],i);l=sn(f.top,l),c=di(f.right,c),d=di(f.bottom,d),u=sn(f.left,u)}return{width:c-u,height:d-l,x:u,y:l}}function j7(e){const{width:t,height:n}=yI(e);return{width:t,height:n}}function U7(e,t,n){const r=Nr(t),i=ir(t),s=n==="fixed",a=es(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=er(0);function c(){l.x=Bd(i)}if(r||!r&&!s)if((Ia(t)!=="body"||Tl(i))&&(o=Fd(t)),r){const f=es(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else i&&c();s&&!r&&i&&c();const d=i&&!r&&!s?vI(i,o):er(0),u=a.left+o.scrollLeft-l.x-d.x,p=a.top+o.scrollTop-l.y-d.y;return{x:u,y:p,width:a.width,height:a.height}}function op(e){return Bn(e).position==="static"}function V0(e,t){if(!Nr(e)||Bn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ir(e)===n&&(n=n.ownerDocument.body),n}function wI(e,t){const n=cn(e);if(Pd(e))return n;if(!Nr(e)){let i=hi(e);for(;i&&!da(i);){if(Fn(i)&&!op(i))return i;i=hi(i)}return n}let r=V0(e,t);for(;r&&C7(r)&&op(r);)r=V0(r,t);return r&&da(r)&&op(r)&&!xw(r)?n:r||N7(e)||n}const $7=async function(e){const t=this.getOffsetParent||wI,n=this.getDimensions,r=await n(e.floating);return{reference:U7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function z7(e){return Bn(e).direction==="rtl"}const H7={convertOffsetParentRelativeRectToViewportRelativeRect:O7,getDocumentElement:ir,getClippingRect:B7,getOffsetParent:wI,getElementRects:$7,getClientRects:L7,getDimensions:j7,getScale:Js,isElement:Fn,isRTL:z7};function xI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function G7(e,t){let n=null,r;const i=ir(e);function s(){var o;clearTimeout(r),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:u,width:p,height:f}=c;if(o||t(),!p||!f)return;const g=uc(u),m=uc(i.clientWidth-(d+p)),v=uc(i.clientHeight-(u+f)),y=uc(d),S={rootMargin:-g+"px "+-m+"px "+-v+"px "+-y+"px",threshold:sn(0,di(1,l))||1};let w=!0;function k(x){const E=x[0].intersectionRatio;if(E!==l){if(!w)return a();E?a(!1,E):r=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!xI(c,e.getBoundingClientRect())&&a(),w=!1}try{n=new IntersectionObserver(k,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(k,S)}n.observe(e)}return a(!0),s}function W7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=kw(e),d=i||s?[...c?rl(c):[],...t?rl(t):[]]:[];d.forEach(y=>{i&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const u=c&&o?G7(c,n):null;let p=-1,f=null;a&&(f=new ResizeObserver(y=>{let[_]=y;_&&_.target===c&&f&&t&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),t&&f.observe(t));let g,m=l?es(e):null;l&&v();function v(){const y=es(e);m&&!xI(m,y)&&n(),m=y,g=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(_=>{i&&_.removeEventListener("scroll",n),s&&_.removeEventListener("resize",n)}),u==null||u(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(g)}}const V7=w7,q7=x7,K7=_7,Y7=k7,X7=v7,q0=y7,Z7=E7,Q7=(e,t,n)=>{const r=new Map,i={platform:H7,...n},s={...i.platform,_c:r};return b7(e,t,{...i,platform:s})};var J7=typeof document<"u",eq=function(){},Fc=J7?b.useLayoutEffect:eq;function Ou(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ou(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Ou(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function EI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function K0(e,t){const n=EI(e);return Math.round(t*n)/n}function lp(e){const t=b.useRef(e);return Fc(()=>{t.current=e}),t}function tq(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:o=!0,whileElementsMounted:l,open:c}=e,[d,u]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=b.useState(r);Ou(p,r)||f(r);const[g,m]=b.useState(null),[v,y]=b.useState(null),_=b.useCallback(M=>{M!==x.current&&(x.current=M,m(M))},[]),S=b.useCallback(M=>{M!==E.current&&(E.current=M,y(M))},[]),w=s||g,k=a||v,x=b.useRef(null),E=b.useRef(null),T=b.useRef(d),D=l!=null,R=lp(l),I=lp(i),O=lp(c),N=b.useCallback(()=>{if(!x.current||!E.current)return;const M={placement:t,strategy:n,middleware:p};I.current&&(M.platform=I.current),Q7(x.current,E.current,M).then(U=>{const C={...U,isPositioned:O.current!==!1};P.current&&!Ou(T.current,C)&&(T.current=C,ma.flushSync(()=>{u(C)}))})},[p,t,n,I,O]);Fc(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,u(M=>({...M,isPositioned:!1})))},[c]);const P=b.useRef(!1);Fc(()=>(P.current=!0,()=>{P.current=!1}),[]),Fc(()=>{if(w&&(x.current=w),k&&(E.current=k),w&&k){if(R.current)return R.current(w,k,N);N()}},[w,k,N,R,D]);const F=b.useMemo(()=>({reference:x,floating:E,setReference:_,setFloating:S}),[_,S]),B=b.useMemo(()=>({reference:w,floating:k}),[w,k]),j=b.useMemo(()=>{const M={position:n,left:0,top:0};if(!B.floating)return M;const U=K0(B.floating,d.x),C=K0(B.floating,d.y);return o?{...M,transform:"translate("+U+"px, "+C+"px)",...EI(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:C}},[n,o,B.floating,d.x,d.y]);return b.useMemo(()=>({...d,update:N,refs:F,elements:B,floatingStyles:j}),[d,N,F,B,j])}const nq=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?q0({element:r.current,padding:i}).fn(n):{}:r?q0({element:r,padding:i}).fn(n):{}}}},rq=(e,t)=>{const n=V7(e);return{name:n.name,fn:n.fn,options:[e,t]}},iq=(e,t)=>{const n=q7(e);return{name:n.name,fn:n.fn,options:[e,t]}},sq=(e,t)=>({fn:Z7(e).fn,options:[e,t]}),aq=(e,t)=>{const n=K7(e);return{name:n.name,fn:n.fn,options:[e,t]}},oq=(e,t)=>{const n=Y7(e);return{name:n.name,fn:n.fn,options:[e,t]}},lq=(e,t)=>{const n=X7(e);return{name:n.name,fn:n.fn,options:[e,t]}},cq=(e,t)=>{const n=nq(e);return{name:n.name,fn:n.fn,options:[e,t]}};var uq="Arrow",kI=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(we.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});kI.displayName=uq;var dq=kI,Cw="Popper",[CI,jd]=bi(Cw),[hq,TI]=CI(Cw),AI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return h.jsx(hq,{scope:t,anchor:r,onAnchorChange:i,children:n})};AI.displayName=Cw;var NI="PopperAnchor",RI=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=TI(NI,n),a=b.useRef(null),o=Le(t,a),l=b.useRef(null);return b.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||a.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(we.div,{...i,ref:o})});RI.displayName=NI;var Tw="PopperContent",[pq,fq]=CI(Tw),II=b.forwardRef((e,t)=>{var W,re,ce,ue,he,me;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:o=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:u="partial",hideWhenDetached:p=!1,updatePositionStrategy:f="optimized",onPlaced:g,...m}=e,v=TI(Tw,n),[y,_]=b.useState(null),S=Le(t,le=>_(le)),[w,k]=b.useState(null),x=aI(w),E=(x==null?void 0:x.width)??0,T=(x==null?void 0:x.height)??0,D=r+(s!=="center"?"-"+s:""),R=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},I=Array.isArray(c)?c:[c],O=I.length>0,N={padding:R,boundary:I.filter(mq),altBoundary:O},{refs:P,floatingStyles:F,placement:B,isPositioned:j,middlewareData:M}=tq({strategy:"fixed",placement:D,whileElementsMounted:(...le)=>W7(...le,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[rq({mainAxis:i+T,alignmentAxis:a}),l&&iq({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?sq():void 0,...N}),l&&aq({...N}),oq({...N,apply:({elements:le,rects:xt,availableWidth:Rr,availableHeight:Ir})=>{const{width:Or,height:Wd}=xt.reference,wi=le.floating.style;wi.setProperty("--radix-popper-available-width",`${Rr}px`),wi.setProperty("--radix-popper-available-height",`${Ir}px`),wi.setProperty("--radix-popper-anchor-width",`${Or}px`),wi.setProperty("--radix-popper-anchor-height",`${Wd}px`)}}),w&&cq({element:w,padding:o}),bq({arrowWidth:E,arrowHeight:T}),p&&lq({strategy:"referenceHidden",...N})]}),[U,C]=DI(B),H=ci(g);It(()=>{j&&(H==null||H())},[j,H]);const Z=(W=M.arrow)==null?void 0:W.x,L=(re=M.arrow)==null?void 0:re.y,se=((ce=M.arrow)==null?void 0:ce.centerOffset)!==0,[_e,$]=b.useState();return It(()=>{y&&$(window.getComputedStyle(y).zIndex)},[y]),h.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:j?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(ue=M.transformOrigin)==null?void 0:ue.x,(he=M.transformOrigin)==null?void 0:he.y].join(" "),...((me=M.hide)==null?void 0:me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(pq,{scope:n,placedSide:U,onArrowChange:k,arrowX:Z,arrowY:L,shouldHideArrow:se,children:h.jsx(we.div,{"data-side":U,"data-align":C,...m,ref:S,style:{...m.style,animation:j?void 0:"none"}})})})});II.displayName=Tw;var OI="PopperArrow",gq={top:"bottom",right:"left",bottom:"top",left:"right"},LI=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=fq(OI,r),a=gq[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(dq,{...i,ref:n,style:{...i.style,display:"block"}})})});LI.displayName=OI;function mq(e){return e!==null}var bq=e=>({name:"transformOrigin",options:e,fn(t){var v,y,_;const{placement:n,rects:r,middlewareData:i}=t,a=((v=i.arrow)==null?void 0:v.centerOffset)!==0,o=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[c,d]=DI(n),u={start:"0%",center:"50%",end:"100%"}[d],p=(((y=i.arrow)==null?void 0:y.x)??0)+o/2,f=(((_=i.arrow)==null?void 0:_.y)??0)+l/2;let g="",m="";return c==="bottom"?(g=a?u:`${p}px`,m=`${-l}px`):c==="top"?(g=a?u:`${p}px`,m=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,m=a?u:`${f}px`):c==="left"&&(g=`${r.floating.width+l}px`,m=a?u:`${f}px`),{data:{x:g,y:m}}}});function DI(e){const[t,n="center"]=e.split("-");return[t,n]}var MI=AI,Aw=RI,PI=II,FI=LI;function yq(e){const t=_q(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(Sq);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function _q(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=xq(i),o=wq(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vq=Symbol("radix.slottable");function Sq(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vq}function wq(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function xq(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var BI=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"}),Eq="VisuallyHidden",kq=b.forwardRef((e,t)=>h.jsx(we.span,{...e,ref:t,style:{...BI,...e.style}}));kq.displayName=Eq;var Cq=[" ","Enter","ArrowUp","ArrowDown"],Tq=[" ","Enter"],ts="Select",[Ud,$d,Aq]=pI(ts),[Oa]=bi(ts,[Aq,jd]),zd=jd(),[Nq,_i]=Oa(ts),[Rq,Iq]=Oa(ts),jI=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:a,defaultValue:o,onValueChange:l,dir:c,name:d,autoComplete:u,disabled:p,required:f,form:g}=e,m=zd(t),[v,y]=b.useState(null),[_,S]=b.useState(null),[w,k]=b.useState(!1),x=_w(c),[E,T]=Yi({prop:r,defaultProp:i??!1,onChange:s,caller:ts}),[D,R]=Yi({prop:a,defaultProp:o,onChange:l,caller:ts}),I=b.useRef(null),O=v?g||!!v.closest("form"):!0,[N,P]=b.useState(new Set),F=Array.from(N).map(B=>B.props.value).join(";");return h.jsx(MI,{...m,children:h.jsxs(Nq,{required:f,scope:t,trigger:v,onTriggerChange:y,valueNode:_,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:br(),value:D,onValueChange:R,open:E,onOpenChange:T,dir:x,triggerPointerDownPosRef:I,disabled:p,children:[h.jsx(Ud.Provider,{scope:t,children:h.jsx(Rq,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(B=>{P(j=>new Set(j).add(B))},[]),onNativeOptionRemove:b.useCallback(B=>{P(j=>{const M=new Set(j);return M.delete(B),M})},[]),children:n})}),O?h.jsxs(uO,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:u,value:D,onChange:B=>R(B.target.value),disabled:p,form:g,children:[D===void 0?h.jsx("option",{value:""}):null,Array.from(N)]},F):null]})})};jI.displayName=ts;var UI="SelectTrigger",$I=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=zd(n),a=_i(UI,n),o=a.disabled||r,l=Le(t,a.onTriggerChange),c=$d(n),d=b.useRef("touch"),[u,p,f]=hO(m=>{const v=c().filter(S=>!S.disabled),y=v.find(S=>S.value===a.value),_=pO(v,m,y);_!==void 0&&a.onValueChange(_.value)}),g=m=>{o||(a.onOpenChange(!0),f()),m&&(a.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return h.jsx(Aw,{asChild:!0,...s,children:h.jsx(we.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:o,"data-disabled":o?"":void 0,"data-placeholder":dO(a.value)?"":void 0,...i,ref:l,onClick:ge(i.onClick,m=>{m.currentTarget.focus(),d.current!=="mouse"&&g(m)}),onPointerDown:ge(i.onPointerDown,m=>{d.current=m.pointerType;const v=m.target;v.hasPointerCapture(m.pointerId)&&v.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(g(m),m.preventDefault())}),onKeyDown:ge(i.onKeyDown,m=>{const v=u.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&p(m.key),!(v&&m.key===" ")&&Cq.includes(m.key)&&(g(),m.preventDefault())})})})});$I.displayName=UI;var zI="SelectValue",HI=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:a="",...o}=e,l=_i(zI,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,u=Le(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),h.jsx(we.span,{...o,ref:u,style:{pointerEvents:"none"},children:dO(l.value)?h.jsx(h.Fragment,{children:a}):s})});HI.displayName=zI;var Oq="SelectIcon",GI=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return h.jsx(we.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});GI.displayName=Oq;var Lq="SelectPortal",WI=e=>h.jsx(cd,{asChild:!0,...e});WI.displayName=Lq;var ns="SelectContent",VI=b.forwardRef((e,t)=>{const n=_i(ns,e.__scopeSelect),[r,i]=b.useState();if(It(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?ma.createPortal(h.jsx(qI,{scope:e.__scopeSelect,children:h.jsx(Ud.Slot,{scope:e.__scopeSelect,children:h.jsx("div",{children:e.children})})}),s):null}return h.jsx(KI,{...e,ref:t})});VI.displayName=ns;var Nn=10,[qI,vi]=Oa(ns),Dq="SelectContentImpl",Mq=yq("SelectContent.RemoveScroll"),KI=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:a,side:o,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:g,hideWhenDetached:m,avoidCollisions:v,...y}=e,_=_i(ns,n),[S,w]=b.useState(null),[k,x]=b.useState(null),E=Le(t,W=>w(W)),[T,D]=b.useState(null),[R,I]=b.useState(null),O=$d(n),[N,P]=b.useState(!1),F=b.useRef(!1);b.useEffect(()=>{if(S)return Mm(S)},[S]),Dm();const B=b.useCallback(W=>{const[re,...ce]=O().map(me=>me.ref.current),[ue]=ce.slice(-1),he=document.activeElement;for(const me of W)if(me===he||(me==null||me.scrollIntoView({block:"nearest"}),me===re&&k&&(k.scrollTop=0),me===ue&&k&&(k.scrollTop=k.scrollHeight),me==null||me.focus(),document.activeElement!==he))return},[O,k]),j=b.useCallback(()=>B([T,S]),[B,T,S]);b.useEffect(()=>{N&&j()},[N,j]);const{onOpenChange:M,triggerPointerDownPosRef:U}=_;b.useEffect(()=>{if(S){let W={x:0,y:0};const re=ue=>{var he,me;W={x:Math.abs(Math.round(ue.pageX)-(((he=U.current)==null?void 0:he.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((me=U.current)==null?void 0:me.y)??0))}},ce=ue=>{W.x<=10&&W.y<=10?ue.preventDefault():S.contains(ue.target)||M(!1),document.removeEventListener("pointermove",re),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",ce,{capture:!0})}}},[S,M,U]),b.useEffect(()=>{const W=()=>M(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[M]);const[C,H]=hO(W=>{const re=O().filter(he=>!he.disabled),ce=re.find(he=>he.ref.current===document.activeElement),ue=pO(re,W,ce);ue&&setTimeout(()=>ue.ref.current.focus())}),Z=b.useCallback((W,re,ce)=>{const ue=!F.current&&!ce;(_.value!==void 0&&_.value===re||ue)&&(D(W),ue&&(F.current=!0))},[_.value]),L=b.useCallback(()=>S==null?void 0:S.focus(),[S]),se=b.useCallback((W,re,ce)=>{const ue=!F.current&&!ce;(_.value!==void 0&&_.value===re||ue)&&I(W)},[_.value]),_e=r==="popper"?Eg:YI,$=_e===Eg?{side:o,sideOffset:l,align:c,alignOffset:d,arrowPadding:u,collisionBoundary:p,collisionPadding:f,sticky:g,hideWhenDetached:m,avoidCollisions:v}:{};return h.jsx(qI,{scope:n,content:S,viewport:k,onViewportChange:x,itemRefCallback:Z,selectedItem:T,onItemLeave:L,itemTextRefCallback:se,focusSelectedItem:j,selectedItemText:R,position:r,isPositioned:N,searchRef:C,children:h.jsx(dd,{as:Mq,allowPinchZoom:!0,children:h.jsx(ld,{asChild:!0,trapped:_.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ge(i,W=>{var re;(re=_.trigger)==null||re.focus({preventScroll:!0}),W.preventDefault()}),children:h.jsx(od,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:h.jsx(_e,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:W=>W.preventDefault(),...y,...$,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ge(y.onKeyDown,W=>{const re=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!re&&W.key.length===1&&H(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=O().filter(he=>!he.disabled).map(he=>he.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const he=W.target,me=ue.indexOf(he);ue=ue.slice(me+1)}setTimeout(()=>B(ue)),W.preventDefault()}})})})})})})});KI.displayName=Dq;var Pq="SelectItemAlignedPosition",YI=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=_i(ns,n),a=vi(ns,n),[o,l]=b.useState(null),[c,d]=b.useState(null),u=Le(t,E=>d(E)),p=$d(n),f=b.useRef(!1),g=b.useRef(!0),{viewport:m,selectedItem:v,selectedItemText:y,focusSelectedItem:_}=a,S=b.useCallback(()=>{if(s.trigger&&s.valueNode&&o&&c&&m&&v&&y){const E=s.trigger.getBoundingClientRect(),T=c.getBoundingClientRect(),D=s.valueNode.getBoundingClientRect(),R=y.getBoundingClientRect();if(s.dir!=="rtl"){const he=R.left-T.left,me=D.left-he,le=E.left-me,xt=E.width+le,Rr=Math.max(xt,T.width),Ir=window.innerWidth-Nn,Or=P0(me,[Nn,Math.max(Nn,Ir-Rr)]);o.style.minWidth=xt+"px",o.style.left=Or+"px"}else{const he=T.right-R.right,me=window.innerWidth-D.right-he,le=window.innerWidth-E.right-me,xt=E.width+le,Rr=Math.max(xt,T.width),Ir=window.innerWidth-Nn,Or=P0(me,[Nn,Math.max(Nn,Ir-Rr)]);o.style.minWidth=xt+"px",o.style.right=Or+"px"}const I=p(),O=window.innerHeight-Nn*2,N=m.scrollHeight,P=window.getComputedStyle(c),F=parseInt(P.borderTopWidth,10),B=parseInt(P.paddingTop,10),j=parseInt(P.borderBottomWidth,10),M=parseInt(P.paddingBottom,10),U=F+B+N+M+j,C=Math.min(v.offsetHeight*5,U),H=window.getComputedStyle(m),Z=parseInt(H.paddingTop,10),L=parseInt(H.paddingBottom,10),se=E.top+E.height/2-Nn,_e=O-se,$=v.offsetHeight/2,W=v.offsetTop+$,re=F+B+W,ce=U-re;if(re<=se){const he=I.length>0&&v===I[I.length-1].ref.current;o.style.bottom="0px";const me=c.clientHeight-m.offsetTop-m.offsetHeight,le=Math.max(_e,$+(he?L:0)+me+j),xt=re+le;o.style.height=xt+"px"}else{const he=I.length>0&&v===I[0].ref.current;o.style.top="0px";const le=Math.max(se,F+m.offsetTop+(he?Z:0)+$)+ce;o.style.height=le+"px",m.scrollTop=re-se+m.offsetTop}o.style.margin=`${Nn}px 0`,o.style.minHeight=C+"px",o.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[p,s.trigger,s.valueNode,o,c,m,v,y,s.dir,r]);It(()=>S(),[S]);const[w,k]=b.useState();It(()=>{c&&k(window.getComputedStyle(c).zIndex)},[c]);const x=b.useCallback(E=>{E&&g.current===!0&&(S(),_==null||_(),g.current=!1)},[S,_]);return h.jsx(Bq,{scope:n,contentWrapper:o,shouldExpandOnScrollRef:f,onScrollButtonChange:x,children:h.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:h.jsx(we.div,{...i,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});YI.displayName=Pq;var Fq="SelectPopperPosition",Eg=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Nn,...s}=e,a=zd(n);return h.jsx(PI,{...a,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.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)"}})});Eg.displayName=Fq;var[Bq,Nw]=Oa(ns,{}),kg="SelectViewport",XI=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=vi(kg,n),a=Nw(kg,n),o=Le(t,s.onViewportChange),l=b.useRef(0);return h.jsxs(h.Fragment,{children:[h.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:r}),h.jsx(Ud.Slot,{scope:n,children:h.jsx(we.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:o,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:ge(i.onScroll,c=>{const d=c.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:p}=a;if(p!=null&&p.current&&u){const f=Math.abs(l.current-d.scrollTop);if(f>0){const g=window.innerHeight-Nn*2,m=parseFloat(u.style.minHeight),v=parseFloat(u.style.height),y=Math.max(m,v);if(y<g){const _=y+f,S=Math.min(g,_),w=_-S;u.style.height=S+"px",u.style.bottom==="0px"&&(d.scrollTop=w>0?w:0,u.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});XI.displayName=kg;var ZI="SelectGroup",[jq,Uq]=Oa(ZI),QI=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=br();return h.jsx(jq,{scope:n,id:i,children:h.jsx(we.div,{role:"group","aria-labelledby":i,...r,ref:t})})});QI.displayName=ZI;var JI="SelectLabel",eO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Uq(JI,n);return h.jsx(we.div,{id:i.id,...r,ref:t})});eO.displayName=JI;var Lu="SelectItem",[$q,tO]=Oa(Lu),nO=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...a}=e,o=_i(Lu,n),l=vi(Lu,n),c=o.value===r,[d,u]=b.useState(s??""),[p,f]=b.useState(!1),g=Le(t,_=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,_,r,i)}),m=br(),v=b.useRef("touch"),y=()=>{i||(o.onValueChange(r),o.onOpenChange(!1))};if(r==="")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 h.jsx($q,{scope:n,value:r,disabled:i,textId:m,isSelected:c,onItemTextChange:b.useCallback(_=>{u(S=>S||((_==null?void 0:_.textContent)??"").trim())},[]),children:h.jsx(Ud.ItemSlot,{scope:n,value:r,disabled:i,textValue:d,children:h.jsx(we.div,{role:"option","aria-labelledby":m,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...a,ref:g,onFocus:ge(a.onFocus,()=>f(!0)),onBlur:ge(a.onBlur,()=>f(!1)),onClick:ge(a.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:ge(a.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:ge(a.onPointerDown,_=>{v.current=_.pointerType}),onPointerMove:ge(a.onPointerMove,_=>{var S;v.current=_.pointerType,i?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(a.onPointerLeave,_=>{var S;_.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ge(a.onKeyDown,_=>{var w;((w=l.searchRef)==null?void 0:w.current)!==""&&_.key===" "||(Tq.includes(_.key)&&y(),_.key===" "&&_.preventDefault())})})})})});nO.displayName=Lu;var lo="SelectItemText",rO=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,a=_i(lo,n),o=vi(lo,n),l=tO(lo,n),c=Iq(lo,n),[d,u]=b.useState(null),p=Le(t,y=>u(y),l.onItemTextChange,y=>{var _;return(_=o.itemTextRefCallback)==null?void 0:_.call(o,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,g=b.useMemo(()=>h.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:m,onNativeOptionRemove:v}=c;return It(()=>(m(g),()=>v(g)),[m,v,g]),h.jsxs(h.Fragment,{children:[h.jsx(we.span,{id:l.textId,...s,ref:p}),l.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ma.createPortal(s.children,a.valueNode):null]})});rO.displayName=lo;var iO="SelectItemIndicator",sO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return tO(iO,n).isSelected?h.jsx(we.span,{"aria-hidden":!0,...r,ref:t}):null});sO.displayName=iO;var Cg="SelectScrollUpButton",aO=b.forwardRef((e,t)=>{const n=vi(Cg,e.__scopeSelect),r=Nw(Cg,e.__scopeSelect),[i,s]=b.useState(!1),a=Le(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let o=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return o(),l.addEventListener("scroll",o),()=>l.removeEventListener("scroll",o)}},[n.viewport,n.isPositioned]),i?h.jsx(lO,{...e,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:l}=n;o&&l&&(o.scrollTop=o.scrollTop-l.offsetHeight)}}):null});aO.displayName=Cg;var Tg="SelectScrollDownButton",oO=b.forwardRef((e,t)=>{const n=vi(Tg,e.__scopeSelect),r=Nw(Tg,e.__scopeSelect),[i,s]=b.useState(!1),a=Le(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let o=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return o(),l.addEventListener("scroll",o),()=>l.removeEventListener("scroll",o)}},[n.viewport,n.isPositioned]),i?h.jsx(lO,{...e,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:l}=n;o&&l&&(o.scrollTop=o.scrollTop+l.offsetHeight)}}):null});oO.displayName=Tg;var lO=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=vi("SelectScrollButton",n),a=b.useRef(null),o=$d(n),l=b.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return b.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=o().find(u=>u.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[o]),h.jsx(we.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:ge(i.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:ge(i.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:ge(i.onPointerLeave,()=>{l()})})}),zq="SelectSeparator",cO=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return h.jsx(we.div,{"aria-hidden":!0,...r,ref:t})});cO.displayName=zq;var Ag="SelectArrow",Hq=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=zd(n),s=_i(Ag,n),a=vi(Ag,n);return s.open&&a.position==="popper"?h.jsx(FI,{...i,...r,ref:t}):null});Hq.displayName=Ag;var Gq="SelectBubbleInput",uO=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=Le(r,i),a=sI(t);return b.useEffect(()=>{const o=i.current;if(!o)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(a!==t&&d){const u=new Event("change",{bubbles:!0});d.call(o,t),o.dispatchEvent(u)}},[a,t]),h.jsx(we.select,{...n,style:{...BI,...n.style},ref:s,defaultValue:t})});uO.displayName=Gq;function dO(e){return e===""||e===void 0}function hO(e){const t=ci(e),n=b.useRef(""),r=b.useRef(0),i=b.useCallback(a=>{const o=n.current+a;t(o),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(o)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function pO(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=Wq(e,Math.max(s,0));i.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function Wq(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vq=jI,fO=$I,qq=HI,Kq=GI,Yq=WI,gO=VI,Xq=XI,Zq=QI,mO=eO,bO=nO,Qq=rO,Jq=sO,yO=aO,_O=oO,vO=cO;const Du=Vq,cp=Zq,Mu=qq,il=b.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(fO,{ref:r,className:X("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),...n,children:[t,h.jsx(Kq,{asChild:!0,children:h.jsx(pl,{className:"h-4 w-4 opacity-50"})})]}));il.displayName=fO.displayName;const SO=b.forwardRef(({className:e,...t},n)=>h.jsx(yO,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(VT,{className:"h-4 w-4"})}));SO.displayName=yO.displayName;const wO=b.forwardRef(({className:e,...t},n)=>h.jsx(_O,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:h.jsx(pl,{className:"h-4 w-4"})}));wO.displayName=_O.displayName;const sl=b.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>h.jsx(Yq,{children:h.jsxs(gO,{ref:i,className:X("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",n==="popper"&&"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:n,...r,children:[h.jsx(SO,{}),h.jsx(Xq,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),h.jsx(wO,{})]})}));sl.displayName=gO.displayName;const Bc=b.forwardRef(({className:e,...t},n)=>h.jsx(mO,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Bc.displayName=mO.displayName;const mn=b.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(bO,{ref:r,className:X("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),...n,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(Jq,{children:h.jsx(WT,{className:"h-4 w-4"})})}),h.jsx(Qq,{children:t})]}));mn.displayName=bO.displayName;const eK=b.forwardRef(({className:e,...t},n)=>h.jsx(vO,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));eK.displayName=vO.displayName;function tK(e){const t=nK(e),n=b.forwardRef((r,i)=>{const{children:s,...a}=r,o=b.Children.toArray(s),l=o.find(iK);if(l){const c=l.props.children,d=o.map(u=>u===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:u);return h.jsx(t,{...a,ref:i,children:b.isValidElement(c)?b.cloneElement(c,void 0,d):null})}return h.jsx(t,{...a,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function nK(e){const t=b.forwardRef((n,r)=>{const{children:i,...s}=n;if(b.isValidElement(i)){const a=aK(i),o=sK(s,i.props);return i.type!==b.Fragment&&(o.ref=r?as(r,a):a),b.cloneElement(i,o)}return b.Children.count(i)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rK=Symbol("radix.slottable");function iK(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rK}function sK(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function aK(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Hd="Popover",[xO]=bi(Hd,[jd]),Al=jd(),[oK,Si]=xO(Hd),EO=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,o=Al(t),l=b.useRef(null),[c,d]=b.useState(!1),[u,p]=Yi({prop:r,defaultProp:i??!1,onChange:s,caller:Hd});return h.jsx(MI,{...o,children:h.jsx(oK,{scope:t,contentId:br(),triggerRef:l,open:u,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>d(!0),[]),onCustomAnchorRemove:b.useCallback(()=>d(!1),[]),modal:a,children:n})})};EO.displayName=Hd;var kO="PopoverAnchor",lK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(kO,n),s=Al(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=i;return b.useEffect(()=>(a(),()=>o()),[a,o]),h.jsx(Aw,{...s,...r,ref:t})});lK.displayName=kO;var CO="PopoverTrigger",TO=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(CO,n),s=Al(n),a=Le(t,i.triggerRef),o=h.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":OO(i.open),...r,ref:a,onClick:ge(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?o:h.jsx(Aw,{asChild:!0,...s,children:o})});TO.displayName=CO;var Rw="PopoverPortal",[cK,uK]=xO(Rw,{forceMount:void 0}),AO=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=Si(Rw,t);return h.jsx(cK,{scope:t,forceMount:n,children:h.jsx(ls,{present:n||s.open,children:h.jsx(cd,{asChild:!0,container:i,children:r})})})};AO.displayName=Rw;var ha="PopoverContent",NO=b.forwardRef((e,t)=>{const n=uK(ha,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=Si(ha,e.__scopePopover);return h.jsx(ls,{present:r||s.open,children:s.modal?h.jsx(hK,{...i,ref:t}):h.jsx(pK,{...i,ref:t})})});NO.displayName=ha;var dK=tK("PopoverContent.RemoveScroll"),hK=b.forwardRef((e,t)=>{const n=Si(ha,e.__scopePopover),r=b.useRef(null),i=Le(t,r),s=b.useRef(!1);return b.useEffect(()=>{const a=r.current;if(a)return Mm(a)},[]),h.jsx(dd,{as:dK,allowPinchZoom:!0,children:h.jsx(RO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,a=>{var o;a.preventDefault(),s.current||(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0,c=o.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ge(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),pK=b.forwardRef((e,t)=>{const n=Si(ha,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return h.jsx(RO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,o;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(o=n.triggerRef.current)==null||o.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),RO=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...u}=e,p=Si(ha,n),f=Al(n);return Dm(),h.jsx(ld,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(od,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:d,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:h.jsx(PI,{"data-state":OO(p.open),role:"dialog",id:p.contentId,...f,...u,ref:t,style:{...u.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),IO="PopoverClose",fK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Si(IO,n);return h.jsx(we.button,{type:"button",...r,ref:t,onClick:ge(e.onClick,()=>i.onOpenChange(!1))})});fK.displayName=IO;var gK="PopoverArrow",mK=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Al(n);return h.jsx(FI,{...i,...r,ref:t})});mK.displayName=gK;function OO(e){return e?"open":"closed"}var bK=EO,yK=TO,_K=AO,LO=NO;const vK=bK,SK=yK,DO=b.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},i)=>h.jsx(_K,{children:h.jsx(LO,{ref:i,align:t,sideOffset:n,className:X("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",e),...r})}));DO.displayName=LO.displayName;function wK({projectId:e,config:t,onChange:n}){var k;const[r,i]=b.useState([]),[s,a]=b.useState([]),[o,l]=b.useState(null),[c,d]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{JP().then(i).catch(console.error),vh(e).then(a).catch(console.error)},[e]);const p=x=>{n({...t,...x})},f=async x=>{if(x.startsWith("preset:")){const E=x.replace("preset:",""),T=r.find(D=>D.id===E);if(T&&!T.downloaded){l(E);try{await eF(E),i(R=>R.map(I=>I.id===E?{...I,downloaded:!0}:I));const D=await vh(e);a(D)}catch(D){console.error("Failed to download preset:",D),l(null);return}l(null)}}p({source:x})},g=async x=>{const E=u.current;E&&(E.dataset.scope=x,E.click())},m=async x=>{var D;const E=(D=x.target.files)==null?void 0:D[0];if(!E)return;const T=x.target.dataset.scope||"global";d(!0);try{const{name:R}=await tF(E,T,e),I=await vh(e);a(I),p({source:`${T==="project"?"project":"global"}:${R}`})}catch(R){console.error("Upload failed:",R)}finally{d(!1),x.target.value=""}},v=s.filter(x=>x.source.startsWith("preset:")),y=s.filter(x=>x.source.startsWith("global:")),_=s.filter(x=>x.source.startsWith("project:")),S=r.filter(x=>!x.downloaded&&!v.some(E=>E.source===`preset:${x.id}`)),w=t.playMode==="interval"||t.playMode==="auto"&&((k=r.find(x=>`preset:${x.id}`===t.source))==null?void 0:k.type)==="strike";return h.jsxs(vK,{children:[h.jsx(SK,{asChild:!0,children:h.jsx(te,{variant:"ghost",size:"icon",className:"h-8 w-8",children:h.jsx(wF,{className:`h-4 w-4 ${t.enabled?"text-primary":""}`})})}),h.jsx(DO,{className:"w-[300px]",children:h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx(je,{className:"text-sm font-medium",children:"背景音效"}),h.jsx(yw,{checked:t.enabled,onCheckedChange:x=>p({enabled:x})})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"音源"}),h.jsxs(Du,{value:t.source,onValueChange:f,children:[h.jsx(il,{className:"h-8 text-xs",children:h.jsx(Mu,{placeholder:"选择音源"})}),h.jsxs(sl,{children:[(v.length>0||S.length>0)&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"预设音效"}),v.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source)),S.map(x=>h.jsx(mn,{value:`preset:${x.id}`,className:"text-xs",children:h.jsxs("span",{className:"flex items-center gap-1.5",children:[x.name,o===x.id?h.jsx(vo,{className:"h-3 w-3 animate-spin"}):h.jsx(pu,{className:"h-3 w-3 text-muted-foreground"})]})},`preset:${x.id}`))]}),y.length>0&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"全局自定义"}),y.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source))]}),_.length>0&&h.jsxs(cp,{children:[h.jsx(Bc,{children:"项目自定义"}),_.map(x=>h.jsx(mn,{value:x.source,className:"text-xs",children:x.name},x.source))]})]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"播放模式"}),h.jsxs(Du,{value:t.playMode,onValueChange:x=>p({playMode:x}),children:[h.jsx(il,{className:"h-8 text-xs",children:h.jsx(Mu,{})}),h.jsxs(sl,{children:[h.jsx(mn,{value:"auto",className:"text-xs",children:"自动"}),h.jsx(mn,{value:"loop",className:"text-xs",children:"循环"}),h.jsx(mn,{value:"interval",className:"text-xs",children:"随机间隔"})]})]})]}),h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs(je,{className:"text-xs text-muted-foreground",children:["音量: ",Math.round(t.volume*100),"%"]}),h.jsx("input",{type:"range",min:0,max:100,value:Math.round(t.volume*100),onChange:x=>p({volume:Number(x.target.value)/100}),className:"w-full h-1.5 accent-primary cursor-pointer"})]}),w&&h.jsxs("div",{className:"space-y-1.5",children:[h.jsx(je,{className:"text-xs text-muted-foreground",children:"间隔范围(秒)"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",min:1,value:t.intervalRange[0],onChange:x=>p({intervalRange:[Number(x.target.value),t.intervalRange[1]]}),className:"w-20 h-8 rounded-md border bg-background px-2 text-xs"}),h.jsx("span",{className:"text-xs text-muted-foreground",children:"~"}),h.jsx("input",{type:"number",min:1,value:t.intervalRange[1],onChange:x=>p({intervalRange:[t.intervalRange[0],Number(x.target.value)]}),className:"w-20 h-8 rounded-md border bg-background px-2 text-xs"})]})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(te,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",disabled:c,onClick:()=>g("global"),children:[c?h.jsx(vo,{className:"h-3 w-3 mr-1 animate-spin"}):h.jsx(gf,{className:"h-3 w-3 mr-1"}),"上传全局"]}),h.jsxs(te,{variant:"outline",size:"sm",className:"flex-1 h-7 text-xs",disabled:c,onClick:()=>g("project"),children:[c?h.jsx(vo,{className:"h-3 w-3 mr-1 animate-spin"}):h.jsx(gf,{className:"h-3 w-3 mr-1"}),"上传项目"]})]}),h.jsx("input",{ref:u,type:"file",accept:"audio/*",className:"hidden",onChange:m})]})})]})}const xK=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,EK=5,kK=3e3;function CK(e,t){const n=b.useRef(null),r=b.useRef(0),i=b.useRef(!0),s=b.useRef(t);s.current=t;const a=b.useRef(!1),o=b.useCallback(f=>{var g;((g=n.current)==null?void 0:g.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(f))},[]),l=b.useCallback((f,g)=>{var m;((m=n.current)==null?void 0:m.readyState)===WebSocket.OPEN?(n.current.send(JSON.stringify({type:"terminal_subscribe",cols:f,rows:g})),a.current=!1):a.current=!0},[]),c=b.useCallback(f=>{o({type:"terminal_input",data:f})},[o]),d=b.useCallback((f,g)=>{o({type:"terminal_resize",cols:f,rows:g})},[o]),u=b.useCallback(()=>{o({type:"chat_subscribe"})},[o]),p=b.useCallback(()=>{if(!i.current)return;const f=kr();if(!f){window.location.href="/login";return}const g=new WebSocket(`${xK}/ws/projects/${e}`);n.current=g,g.onopen=()=>{r.current=0,g.send(JSON.stringify({type:"auth",token:f}))},g.onmessage=m=>{var y,_,S,w,k,x,E,T;let v;try{v=JSON.parse(m.data)}catch{return}switch(v.type){case"connected":a.current=!1,(_=(y=s.current).onConnected)==null||_.call(y);break;case"terminal_data":(w=(S=s.current).onTerminalData)==null||w.call(S,v.data);break;case"status":(x=(k=s.current).onStatus)==null||x.call(k,v.status);break;case"chat_message":{const D=v;(T=(E=s.current).onChatMessage)==null||T.call(E,D);break}case"error":console.error("[WS] Server error:",v.message);break}},g.onclose=()=>{n.current=null,i.current&&r.current<EK&&(r.current++,setTimeout(p,kK))},g.onerror=m=>{console.error("[WS] WebSocket error:",m)}},[e]);return b.useEffect(()=>(i.current=!0,p(),()=>{var f;i.current=!1,(f=n.current)==null||f.close(),n.current=null}),[p]),{subscribeTerminal:l,sendTerminalInput:c,sendTerminalResize:d,subscribeChatMessages:u}}function up({icon:e,label:t,content:n}){const[r,i]=b.useState(!1);return h.jsxs("div",{className:"border border-border rounded mt-1.5",children:[h.jsxs("button",{className:"flex items-center gap-1.5 w-full px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(s=>!s),children:[h.jsx(sd,{className:X("h-3 w-3 transition-transform",r&&"rotate-90")}),h.jsx(e,{className:"h-3 w-3"}),h.jsx("span",{className:"truncate",children:t})]}),r&&h.jsx("pre",{className:"px-3 pb-2 text-xs text-muted-foreground whitespace-pre-wrap break-words max-h-40 overflow-auto",children:n})]})}function TK({blocks:e}){return h.jsx(h.Fragment,{children:e.map((t,n)=>t.type==="text"?h.jsx("div",{className:"prose dark:prose-invert prose-sm max-w-none",children:h.jsx(lR,{remarkPlugins:[OR],children:t.content})},n):t.type==="thinking"?h.jsx(up,{icon:Rm,label:"Thinking...",content:t.content},n):t.type==="tool_use"?h.jsx(up,{icon:PF,label:t.content.split("(")[0],content:t.content},n):t.type==="tool_result"?h.jsx(up,{icon:hF,label:"Result",content:t.content},n):null)})}function AK({messages:e,onSend:t,readOnly:n}){const[r,i]=b.useState(""),s=b.useRef(null),a=b.useRef(null);b.useEffect(()=>{var d;(d=s.current)==null||d.scrollIntoView({behavior:"smooth"})},[e.length]);const o=()=>{const d=r.trim();d&&(t(d+"\r"),i(""),a.current&&(a.current.style.height="auto"))},l=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),o())},c=d=>{d.style.height="auto",d.style.height=Math.min(d.scrollHeight,120)+"px"};return h.jsxs("div",{className:"flex flex-col h-full bg-background",children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 min-h-0",children:[e.length===0&&h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"等待对话..."}),e.map((d,u)=>h.jsx("div",{className:X("flex",d.role==="user"?"justify-end":"justify-start"),children:h.jsxs("div",{className:X("max-w-[85%] rounded-lg px-3 py-2 text-sm",d.role==="user"?"bg-blue-600 text-white dark:bg-blue-500":"bg-muted"),children:[h.jsx(TK,{blocks:d.blocks}),h.jsx("div",{className:"text-[10px] opacity-50 mt-1",children:new Date(d.timestamp).toLocaleTimeString()})]})},u)),h.jsx("div",{ref:s})]}),!n&&h.jsxs("div",{className:"border-t border-border p-3 flex gap-2 items-end flex-shrink-0",children:[h.jsx("textarea",{ref:a,value:r,onChange:d=>{i(d.target.value),c(d.target)},onKeyDown:l,placeholder:"输入消息...",rows:1,className:"flex-1 resize-none bg-muted rounded-md px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring",style:{maxHeight:"120px"}}),h.jsx("button",{onClick:o,disabled:!r.trim(),className:"p-2 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex-shrink-0",children:h.jsx(AF,{className:"h-4 w-4"})})]})]})}function NK({status:e}){const t={running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"};return h.jsxs("span",{className:X("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",t[e]),children:[h.jsx("span",{className:X("w-1.5 h-1.5 rounded-full",{"bg-green-500":e==="running","bg-muted-foreground":e==="stopped","bg-yellow-400 animate-pulse":e==="restarting"})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function RK(){const{id:e}=lM(),t=ss(),[n,r]=b.useState(null),[i,s]=b.useState(!0),[a,o]=b.useState(!1),[l,c]=b.useState(!1),[d,u]=b.useState({enabled:!1,source:"preset:rain",playMode:"auto",volume:.5,intervalRange:[3,8]}),[p,f]=b.useState(!1),g=b.useRef(null),[m,v]=b.useState("terminal"),[y,_]=b.useState([]),S=async()=>{if(e){c(!0);try{await KP(e)}catch($){alert($ instanceof Error?$.message:"备份失败")}finally{c(!1)}}},[w,k]=b.useState(()=>{try{return localStorage.getItem("cc_panel_filetree")!=="false"}catch{return!0}}),[x,E]=b.useState(()=>{try{return localStorage.getItem("cc_panel_shortcuts")!=="false"}catch{return!0}}),T=()=>k($=>(localStorage.setItem("cc_panel_filetree",String(!$)),!$)),D=()=>E($=>(localStorage.setItem("cc_panel_shortcuts",String(!$)),!$)),[R,I]=b.useState(!1);b.useEffect(()=>{const $=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$),()=>document.removeEventListener("fullscreenchange",$)},[]);const O=()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},N=b.useRef(null),P=b.useRef(null),F=b.useRef(null),B=b.useRef(null),j=b.useCallback($=>{var W;(W=N.current)==null||W.write($),f(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>f(!1),3e3)},[]),M=b.useCallback(()=>{var W;const $=P.current;$&&F.current&&F.current($.cols,$.rows),(W=B.current)==null||W.call(B)},[]),{subscribeTerminal:U,sendTerminalInput:C,sendTerminalResize:H,subscribeChatMessages:Z}=CK(e??"",{onTerminalData:j,onStatus:$=>r(W=>W&&{...W,status:$}),onConnected:M,onChatMessage:$=>{_(W=>[...W,$])}});b.useEffect(()=>{F.current=U},[U]),b.useEffect(()=>{B.current=Z},[Z]);const L=b.useCallback(($,W)=>{P.current={cols:$,rows:W},M()},[M]);b.useEffect(()=>{if(!e)return;(async()=>{try{const re=(await UT()).find(ce=>ce.id===e)??null;r(re),re!=null&&re.sound&&u(re.sound)}catch(W){console.error("Failed to load project:",W)}finally{s(!1)}})()},[e]);const se=async()=>{if(n){o(!0);try{r(await kP(n.id))}catch($){console.error($)}finally{o(!1)}}},_e=async()=>{if(n){o(!0);try{r(await CP(n.id))}catch($){console.error($)}finally{o(!1)}}};return i?h.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})}):!n||!e?h.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 bg-background",children:[h.jsx("p",{className:"text-muted-foreground",children:"Project not found."}),h.jsxs(te,{variant:"outline",onClick:()=>t("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]})]}):h.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[h.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:h.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[h.jsx(te,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>t("/"),children:h.jsx(Wo,{className:"h-4 w-4"})}),h.jsx("button",{className:X("p-1 rounded transition-colors",w?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:T,title:"Toggle file tree",children:h.jsx(EF,{className:"h-4 w-4"})}),h.jsx("button",{className:X("p-1 rounded transition-colors",x?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:D,title:"Toggle right panel",children:h.jsx(kF,{className:"h-4 w-4"})}),h.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[h.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:n.name}),h.jsx(NK,{status:n.status}),h.jsx(dr,{variant:"outline",className:"text-xs",children:n.permissionMode==="unlimited"?"Unlimited":"Limited"}),h.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:n.folderPath})]}),h.jsx(RA,{className:"mr-2"}),h.jsx(OA,{}),h.jsx(te,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:O,title:R?"退出全屏":"全屏",children:R?h.jsx(Om,{className:"h-3.5 w-3.5"}):h.jsx(Im,{className:"h-3.5 w-3.5"})}),e&&h.jsx(wK,{projectId:e,config:d,onChange:$=>{u($),nF(e,$)}}),h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void S(),disabled:l,title:"备份到云盘",children:[l?h.jsx(vo,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):h.jsx(MF,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),n.status==="running"||n.status==="restarting"?h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void se(),disabled:a,children:[h.jsx(OF,{className:"h-3.5 w-3.5 mr-1.5"}),"Stop"]}):h.jsxs(te,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>void _e(),disabled:a,children:[h.jsx(CF,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})}),h.jsxs("div",{className:"flex-1 overflow-hidden flex min-h-0",children:[w&&h.jsx("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-hidden",children:h.jsx(FV,{projectPath:n.folderPath})}),h.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex flex-col",children:[h.jsxs("div",{className:"flex items-center border-b border-border bg-muted/30 px-2 h-8 flex-shrink-0",children:[h.jsxs("button",{onClick:()=>v("terminal"),className:X("flex items-center gap-1.5 px-3 py-1 text-xs rounded-t transition-colors",m==="terminal"?"bg-background text-foreground border border-b-0 border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:[h.jsx(ff,{className:"h-3 w-3"}),"终端"]}),h.jsxs("button",{onClick:()=>v("chat"),className:X("flex items-center gap-1.5 px-3 py-1 text-xs rounded-t transition-colors",m==="chat"?"bg-background text-foreground border border-b-0 border-border -mb-px":"text-muted-foreground hover:text-foreground"),children:[h.jsx(_F,{className:"h-3 w-3"}),"对话"]})]}),h.jsx("div",{className:X("flex-1 min-h-0",m!=="terminal"&&"hidden"),children:h.jsx(xN,{ref:N,onInput:C,onResize:($,W)=>{P.current={cols:$,rows:W},H($,W)},onReady:L})}),m==="chat"&&h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(AK,{messages:y,onSend:C,readOnly:(n==null?void 0:n._sharedPermission)==="view"})})]}),x&&h.jsx("div",{className:"w-52 flex-shrink-0 border-l border-border overflow-hidden",children:h.jsx(GV,{projectId:e,onSend:C})})]}),e&&h.jsx(KV,{projectId:e,config:d,isActive:p})]})}var dp="rovingFocusGroup.onEntryFocus",IK={bubbles:!1,cancelable:!0},Nl="RovingFocusGroup",[Ng,MO,OK]=pI(Nl),[LK,PO]=bi(Nl,[OK]),[DK,MK]=LK(Nl),FO=b.forwardRef((e,t)=>h.jsx(Ng.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(Ng.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(PK,{...e,ref:t})})}));FO.displayName=Nl;var PK=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...u}=e,p=b.useRef(null),f=Le(t,p),g=_w(s),[m,v]=Yi({prop:a,defaultProp:o??null,onChange:l,caller:Nl}),[y,_]=b.useState(!1),S=ci(c),w=MO(n),k=b.useRef(!1),[x,E]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(dp,S),()=>T.removeEventListener(dp,S)},[S]),h.jsx(DK,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:m,onItemFocus:b.useCallback(T=>v(T),[v]),onItemShiftTab:b.useCallback(()=>_(!0),[]),onFocusableItemAdd:b.useCallback(()=>E(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>E(T=>T-1),[]),children:h.jsx(we.div,{tabIndex:y||x===0?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{k.current=!0}),onFocus:ge(e.onFocus,T=>{const D=!k.current;if(T.target===T.currentTarget&&D&&!y){const R=new CustomEvent(dp,IK);if(T.currentTarget.dispatchEvent(R),!R.defaultPrevented){const I=w().filter(B=>B.focusable),O=I.find(B=>B.active),N=I.find(B=>B.id===m),F=[O,N,...I].filter(Boolean).map(B=>B.ref.current);UO(F,d)}}k.current=!1}),onBlur:ge(e.onBlur,()=>_(!1))})})}),BO="RovingFocusGroupItem",jO=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...o}=e,l=br(),c=s||l,d=MK(BO,n),u=d.currentTabStopId===c,p=MO(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=d;return b.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),h.jsx(Ng.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(we.span,{tabIndex:u?0:-1,"data-orientation":d.orientation,...o,ref:t,onMouseDown:ge(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:ge(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ge(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=jK(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=p().filter(w=>w.focusable).map(w=>w.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const w=S.indexOf(v.currentTarget);S=d.loop?UK(S,w+1):S.slice(w+1)}setTimeout(()=>UO(S))}}),children:typeof a=="function"?a({isCurrentTabStop:u,hasTabStop:m!=null}):a})})});jO.displayName=BO;var FK={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function BK(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jK(e,t,n){const r=BK(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return FK[r]}function UO(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function UK(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $K=FO,zK=jO,Gd="Tabs",[HK]=bi(Gd,[PO]),$O=PO(),[GK,Iw]=HK(Gd),zO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:a="horizontal",dir:o,activationMode:l="automatic",...c}=e,d=_w(o),[u,p]=Yi({prop:r,onChange:i,defaultProp:s??"",caller:Gd});return h.jsx(GK,{scope:n,baseId:br(),value:u,onValueChange:p,orientation:a,dir:d,activationMode:l,children:h.jsx(we.div,{dir:d,"data-orientation":a,...c,ref:t})})});zO.displayName=Gd;var HO="TabsList",GO=b.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=Iw(HO,n),a=$O(n);return h.jsx($K,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:r,children:h.jsx(we.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});GO.displayName=HO;var WO="TabsTrigger",VO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,a=Iw(WO,n),o=$O(n),l=YO(a.baseId,r),c=XO(a.baseId,r),d=r===a.value;return h.jsx(zK,{asChild:!0,...o,focusable:!i,active:d,children:h.jsx(we.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":c,"data-state":d?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...s,ref:t,onMouseDown:ge(e.onMouseDown,u=>{!i&&u.button===0&&u.ctrlKey===!1?a.onValueChange(r):u.preventDefault()}),onKeyDown:ge(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&a.onValueChange(r)}),onFocus:ge(e.onFocus,()=>{const u=a.activationMode!=="manual";!d&&!i&&u&&a.onValueChange(r)})})})});VO.displayName=WO;var qO="TabsContent",KO=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...a}=e,o=Iw(qO,n),l=YO(o.baseId,r),c=XO(o.baseId,r),d=r===o.value,u=b.useRef(d);return b.useEffect(()=>{const p=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(p)},[]),h.jsx(ls,{present:i||d,children:({present:p})=>h.jsx(we.div,{"data-state":d?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:c,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:p&&s})})});KO.displayName=qO;function YO(e,t){return`${e}-trigger-${t}`}function XO(e,t){return`${e}-content-${t}`}var WK=zO,ZO=GO,QO=VO,JO=KO;const VK=WK,eL=b.forwardRef(({className:e,...t},n)=>h.jsx(ZO,{ref:n,className:X("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));eL.displayName=ZO.displayName;const jc=b.forwardRef(({className:e,...t},n)=>h.jsx(QO,{ref:n,className:X("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));jc.displayName=QO.displayName;const Uc=b.forwardRef(({className:e,...t},n)=>h.jsx(JO,{ref:n,className:X("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Uc.displayName=JO.displayName;const Y0={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function qK({open:e,onOpenChange:t,onAdded:n}){const[r,i]=b.useState([]),[s,a]=b.useState(!1),[o,l]=b.useState(null),[c,d]=b.useState(""),[u,p]=b.useState(""),[f,g]=b.useState(""),[m,v]=b.useState(""),[y,_]=b.useState(!1),[S,w]=b.useState(null);b.useEffect(()=>{e&&WP().then(D=>i(D.available)).catch(()=>i([]))},[e]);const k=()=>{a(!1),l(null),d(""),p(""),g(""),v(""),_(!1),w(null)},x=async D=>{l(D),w(null);try{const{id:R}=await iE({type:D,label:Y0[D]||D}),{url:I}=await df(R);window.open(I,"_blank"),k(),t(!1),n()}catch(R){w(R instanceof Error?R.message:"添加失败"),l(null)}},E=async()=>{if(!c||!u||!f||!m){w("请填写所有字段");return}_(!0),w(null);try{const{id:D}=await iE({type:c,label:u,clientId:f,clientSecret:m}),{url:R}=await df(D);window.open(R,"_blank"),k(),t(!1),n()}catch(D){w(D instanceof Error?D.message:"添加失败")}finally{_(!1)}},T=r.length>0;return h.jsx(_a,{open:e,onOpenChange:D=>{t(D),D||k()},children:h.jsxs(cs,{className:"sm:max-w-md",children:[h.jsxs(us,{children:[h.jsxs(hs,{className:"flex items-center gap-2",children:[h.jsx(hf,{className:"h-5 w-5"}),"添加云盘账号"]}),h.jsx(ps,{children:s?"手动填写 OAuth 凭据连接云盘":"选择云盘类型,点击后跳转登录授权"})]}),s?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"space-y-4 py-2",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"云盘类型"}),h.jsxs(Du,{value:c,onValueChange:d,children:[h.jsx(il,{children:h.jsx(Mu,{placeholder:"选择云盘类型"})}),h.jsxs(sl,{children:[h.jsx(mn,{value:"google-drive",children:"Google Drive"}),h.jsx(mn,{value:"onedrive",children:"OneDrive"}),h.jsx(mn,{value:"dropbox",children:"Dropbox"})]})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"显示名称"}),h.jsx(wn,{placeholder:"例如:我的 Google Drive",value:u,onChange:D=>p(D.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"Client ID"}),h.jsx(wn,{placeholder:"OAuth Client ID",value:f,onChange:D=>g(D.target.value)})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"Client Secret"}),h.jsx(wn,{type:"password",placeholder:"OAuth Client Secret",value:m,onChange:D=>v(D.target.value)})]}),S&&h.jsx("p",{className:"text-sm text-destructive",children:S})]}),h.jsxs(ds,{children:[h.jsx(te,{variant:"outline",onClick:()=>{a(!1),w(null)},children:"返回"}),h.jsx(te,{onClick:E,disabled:y,children:y?"添加中...":"添加并授权"})]})]}):h.jsxs("div",{className:"space-y-3 py-2",children:[T?h.jsx(h.Fragment,{children:r.map(D=>h.jsx(te,{variant:"outline",className:"w-full justify-start gap-3 h-12 text-base",onClick:()=>void x(D),disabled:o!==null,children:o===D?"连接中...":`连接 ${Y0[D]||D}`},D))}):h.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"暂无内置 OAuth 凭据,请使用手动模式添加"}),S&&h.jsx("p",{className:"text-sm text-destructive",children:S}),h.jsx("div",{className:"pt-2 border-t border-border",children:h.jsxs("button",{onClick:()=>{a(!0),w(null)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx(NF,{className:"h-3.5 w-3.5"}),"手动填写 OAuth 凭据"]})})]})]})})}const KK={"google-drive":"Google Drive",onedrive:"OneDrive",dropbox:"Dropbox"};function YK({type:e}){switch(e){case"google-drive":return h.jsx(oE,{className:"h-5 w-5 text-blue-500"});case"onedrive":return h.jsx(hf,{className:"h-5 w-5 text-sky-500"});case"dropbox":return h.jsx(oE,{className:"h-5 w-5 text-indigo-500"});default:return h.jsx(hf,{className:"h-5 w-5"})}}function XK({provider:e,onDelete:t,onReauth:n}){var a;const[r,i]=b.useState(!1),s=()=>{r?(t(e.id),i(!1)):(i(!0),setTimeout(()=>i(!1),3e3))};return h.jsxs(td,{children:[h.jsx(nd,{className:"pb-3",children:h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(YK,{type:e.type}),h.jsxs("div",{children:[h.jsx(rd,{className:"text-base",children:e.label}),h.jsx("p",{className:"text-sm text-muted-foreground",children:KK[e.type]||e.type})]})]}),h.jsx(dr,{variant:e.authorized?"default":"destructive",className:e.authorized?"bg-green-600 hover:bg-green-700":"",children:e.authorized?"已授权":"未授权"})]})}),h.jsxs(id,{children:[e.authorized&&((a=e.tokens)==null?void 0:a.expiry)&&h.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["授权到期:",new Date(e.tokens.expiry).toLocaleDateString("zh-CN")]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(te,{variant:"outline",size:"sm",onClick:()=>n(e.id),children:[h.jsx(Ki,{className:"h-3.5 w-3.5 mr-1"}),"重新授权"]}),h.jsxs(te,{variant:r?"destructive":"outline",size:"sm",onClick:s,children:[h.jsx(Lm,{className:"h-3.5 w-3.5 mr-1"}),r?"确认删除?":"删除"]})]})]})]})}const ZK={success:{label:"成功",icon:cF,className:"bg-green-600 hover:bg-green-700"},failed:{label:"失败",icon:FF,className:"bg-red-600 hover:bg-red-700"},partial:{label:"部分完成",icon:aF,className:"bg-yellow-600 hover:bg-yellow-700"}};function QK(e,t){const n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;const r=Math.floor(n/1e3);if(r<60)return`${r}秒`;const i=Math.floor(r/60),s=r%60;return`${i}分${s}秒`}function JK(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function eY({history:e}){const t=e.slice(0,20);return t.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[h.jsx(uF,{className:"h-10 w-10 mb-3 opacity-50"}),h.jsx("p",{className:"text-sm",children:"暂无备份记录"})]}):h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-sm",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"border-b",children:[h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"时间"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"项目"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"云盘"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"状态"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"文件数"}),h.jsx("th",{className:"text-left py-3 px-2 font-medium text-muted-foreground",children:"耗时"})]})}),h.jsx("tbody",{children:t.map(n=>{const r=ZK[n.status],i=r.icon;return h.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/50",children:[h.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:JK(n.startTime)}),h.jsx("td",{className:"py-2.5 px-2",children:n.projectName}),h.jsx("td",{className:"py-2.5 px-2",children:n.providerLabel}),h.jsxs("td",{className:"py-2.5 px-2",children:[h.jsxs(dr,{className:r.className,children:[h.jsx(i,{className:"h-3 w-3 mr-1"}),r.label]}),n.error&&h.jsx("p",{className:"text-xs text-destructive mt-1",children:n.error})]}),h.jsxs("td",{className:"py-2.5 px-2 whitespace-nowrap",children:[n.filesUploaded,"/",n.filesTotal]}),h.jsx("td",{className:"py-2.5 px-2 whitespace-nowrap",children:QK(n.startTime,n.endTime)})]},n.id)})})]})})}const X0=["node_modules",".git","dist","build","*.log",".DS_Store","*.tmp",".venv","__pycache__",".env"],tY=[{value:"30",label:"30分钟"},{value:"60",label:"1小时"},{value:"360",label:"6小时"},{value:"720",label:"12小时"},{value:"1440",label:"24小时"}];function nY(){const e=ss(),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,a]=b.useState(!1),[o,l]=b.useState({enabled:!1,intervalMinutes:60}),[c,d]=b.useState(!0),[u,p]=b.useState([]),[f,g]=b.useState(!0),[m,v]=b.useState(""),[y,_]=b.useState(!1),[S,w]=b.useState(!1),[k,x]=b.useState([]),[E,T]=b.useState(!0),D=async()=>{try{const C=await VP();n(C)}catch{}finally{i(!1)}},R=async()=>{try{const C=await YP();l(C)}catch{}finally{d(!1)}},I=async()=>{try{const C=await XP();p(C.length>0?C:X0)}catch{p(X0)}finally{g(!1)}},O=async()=>{try{const C=await QP();x(C)}catch{}finally{T(!1)}};b.useEffect(()=>{D(),R(),I(),O()},[]);const N=async C=>{try{await qP(C),n(H=>H.filter(Z=>Z.id!==C))}catch{}},P=async C=>{try{const{url:H}=await df(C);window.open(H,"_blank")}catch{}},F=async C=>{const H={...o,enabled:C};l(H);try{await sE({enabled:C})}catch{l(o)}},B=async C=>{const H=parseInt(C,10),Z={...o,intervalMinutes:H};l(Z);try{await sE({intervalMinutes:H})}catch{l(o)}},j=()=>{const C=m.trim();!C||u.includes(C)||(p(H=>[...H,C]),v(""),_(!0))},M=C=>{p(H=>H.filter(Z=>Z!==C)),_(!0)},U=async()=>{w(!0);try{await ZP(u),_(!1)}catch{}finally{w(!1)}};return h.jsx("div",{className:"min-h-screen bg-background",children:h.jsxs("div",{className:"max-w-4xl mx-auto p-6",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-1"}),"返回"]}),h.jsx("h1",{className:"text-2xl font-bold",children:"设置"})]}),h.jsxs(VK,{defaultValue:"providers",children:[h.jsxs(eL,{className:"mb-4",children:[h.jsx(jc,{value:"providers",children:"云盘账号"}),h.jsx(jc,{value:"strategy",children:"备份策略"}),h.jsx(jc,{value:"history",children:"备份记录"})]}),h.jsxs(Uc,{value:"providers",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex justify-end",children:h.jsxs(te,{onClick:()=>a(!0),children:[h.jsx(oa,{className:"h-4 w-4 mr-1"}),"添加云盘"]})}),r?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):t.length===0?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"暂无云盘账号,点击上方按钮添加"}):h.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:t.map(C=>h.jsx(XK,{provider:C,onDelete:N,onReauth:P},C.id))})]}),h.jsx(qK,{open:s,onOpenChange:a,onAdded:()=>void D()})]}),h.jsx(Uc,{value:"strategy",children:h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("h3",{className:"text-lg font-medium",children:"排除规则"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"匹配这些模式的文件和目录将不会被备份"}),f?h.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(C=>h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-sm",children:[C,h.jsx("button",{onClick:()=>M(C),className:"ml-0.5 rounded-sm hover:bg-muted-foreground/20 p-0.5",children:h.jsx(os,{className:"h-3 w-3"})})]},C))}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(wn,{placeholder:"输入排除模式,例如 *.log",value:m,onChange:C=>v(C.target.value),onKeyDown:C=>{C.key==="Enter"&&j()},className:"max-w-xs"}),h.jsx(te,{variant:"outline",size:"sm",onClick:j,children:"添加"})]}),y&&h.jsxs(te,{onClick:U,disabled:S,children:[h.jsx(KT,{className:"h-4 w-4 mr-1"}),S?"保存中...":"保存"]})]})]}),h.jsxs("div",{className:"space-y-4",children:[h.jsx("h3",{className:"text-lg font-medium",children:"定时备份"}),c?h.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."}):h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(yw,{checked:o.enabled,onCheckedChange:F}),h.jsx(je,{children:o.enabled?"已开启":"已关闭"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(je,{children:"备份间隔"}),h.jsxs(Du,{value:String(o.intervalMinutes),onValueChange:B,children:[h.jsx(il,{className:"w-48",children:h.jsx(Mu,{})}),h.jsx(sl,{children:tY.map(C=>h.jsx(mn,{value:C.value,children:C.label},C.value))})]})]})]})]})]})}),h.jsx(Uc,{value:"history",children:h.jsxs("div",{className:"space-y-4",children:[h.jsx("div",{className:"flex justify-end",children:h.jsxs(te,{variant:"outline",size:"sm",onClick:()=>{T(!0),O()},children:[h.jsx(Ki,{className:"h-4 w-4 mr-1"}),"刷新"]})}),E?h.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"加载中..."}):h.jsx(eY,{history:k})]})})]})]})})}function rY(){const e=ss(),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,a]=b.useState(null),[o,l]=b.useState(""),[c,d]=b.useState(null),[u,p]=b.useState(null),[f,g]=b.useState(null),[m,v]=b.useState(new Set);b.useEffect(()=>{FP().then(n).catch(k=>a(k instanceof Error?k.message:"Failed to load SkillHub")).finally(()=>i(!1))},[]);const y=b.useMemo(()=>{const k=new Set;return t.forEach(x=>{var E;return(E=x.tags)==null?void 0:E.forEach(T=>k.add(T))}),Array.from(k).sort()},[t]),_=b.useMemo(()=>t.some(k=>!k.tags||k.tags.length===0),[t]),S=b.useMemo(()=>{let k=t;if(c==="__untagged__"?k=k.filter(x=>!x.tags||x.tags.length===0):c&&(k=k.filter(x=>{var E;return(E=x.tags)==null?void 0:E.includes(c)})),o.trim()){const x=o.toLowerCase();k=k.filter(E=>{var T;return E.label.toLowerCase().includes(x)||E.description.toLowerCase().includes(x)||E.command.toLowerCase().includes(x)||E.author.toLowerCase().includes(x)||((T=E.tags)==null?void 0:T.some(D=>D.toLowerCase().includes(x)))})}return k},[t,o,c]),w=async(k,x)=>{if(x.stopPropagation(),!(f||m.has(k.id))){g(k.id);try{await jP(k.id),v(E=>new Set(E).add(k.id)),n(E=>E.map(T=>T.id===k.id?{...T,downloads:(T.downloads||0)+1}:T))}catch(E){alert(E instanceof Error?E.message:"Download failed")}finally{g(null)}}};return h.jsxs("div",{className:"min-h-screen bg-background",children:[h.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:h.jsxs("div",{className:"max-w-4xl mx-auto px-4 h-14 flex items-center gap-4",children:[h.jsxs(te,{variant:"ghost",size:"sm",onClick:()=>e("/"),children:[h.jsx(Wo,{className:"h-4 w-4 mr-1"}),"返回"]}),h.jsx("h1",{className:"font-semibold text-lg",children:"SkillHub"}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"relative w-64",children:[h.jsx(TF,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),h.jsx(wn,{placeholder:"搜索命令...",value:o,onChange:k=>l(k.target.value),className:"pl-8 h-9"})]})]})}),h.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6",children:[y.length>0&&h.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c===null?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(null),children:"全部"}),y.map(k=>h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c===k?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(c===k?null:k),children:k},k)),_&&h.jsx("button",{className:X("px-3 py-1 rounded-full text-xs font-medium transition-colors",c==="__untagged__"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent"),onClick:()=>d(c==="__untagged__"?null:"__untagged__"),children:"无标签"})]}),r&&h.jsx("div",{className:"text-center text-muted-foreground py-20",children:"加载中..."}),s&&h.jsx("div",{className:"text-center text-destructive py-20",children:s}),!r&&!s&&t.length===0&&h.jsxs("div",{className:"text-center text-muted-foreground py-20",children:[h.jsx("p",{className:"text-lg mb-2",children:"SkillHub 还没有命令"}),h.jsx("p",{className:"text-sm",children:"在快捷命令面板中点击分享按钮来提交第一个命令吧!"})]}),!r&&!s&&t.length>0&&S.length===0&&h.jsx("div",{className:"text-center text-muted-foreground py-20",children:"没有匹配的命令"}),h.jsx("div",{className:"space-y-3",children:S.map(k=>{var R;const x=u===k.id,E=m.has(k.id),T=f===k.id,D=k.parentId?t.find(I=>I.id===k.parentId):void 0;return h.jsxs("div",{className:"rounded-lg border bg-card p-4 cursor-pointer hover:border-muted-foreground/30 transition-colors",onClick:()=>p(x?null:k.id),children:[h.jsxs("div",{className:"flex items-start justify-between gap-4",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-sm truncate",children:k.label}),(R=k.tags)==null?void 0:R.map(I=>h.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:[h.jsx(DF,{className:"h-2.5 w-2.5"}),I]},I))]}),D&&h.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[h.jsx(_o,{className:"h-3 w-3 text-muted-foreground"}),h.jsxs("span",{className:"text-xs text-muted-foreground",children:["继承: ",D.label]})]}),k.description&&h.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:k.description}),h.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(YT,{className:"h-3 w-3"}),k.author]}),h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(pu,{className:"h-3 w-3"}),k.downloads||0]}),h.jsx("span",{children:k.createdAt})]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsxs(te,{size:"sm",variant:E?"outline":"default",disabled:T||E,onClick:I=>w(k,I),title:D?`将同时下载继承的「${D.label}」`:void 0,children:[h.jsx(pu,{className:"h-3.5 w-3.5 mr-1"}),E?"已下载":T?"下载中...":"下载"]}),x?h.jsx(VT,{className:"h-4 w-4 text-muted-foreground"}):h.jsx(pl,{className:"h-4 w-4 text-muted-foreground"})]})]}),x&&h.jsx("div",{className:"mt-3 pt-3 border-t",children:h.jsx("pre",{className:"text-xs font-mono bg-muted rounded p-3 whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:k.command})})]},k.id)})})]})]})}function dc({children:e}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1);return b.useEffect(()=>{if(kr()){i(!0),n(!0);return}uf()?jT().then(a=>{cf(a),i(!0)}).catch(()=>{i(!1)}).finally(()=>n(!0)):n(!0)},[]),t?r?h.jsx(h.Fragment,{children:e}):h.jsx(ET,{to:"/login",replace:!0}):null}function iY(){return h.jsx(L3,{children:h.jsx(TM,{children:h.jsxs(EM,{children:[h.jsx(Ni,{path:"/login",element:h.jsx(rF,{})}),h.jsx(Ni,{path:"/",element:h.jsx(dc,{children:h.jsx(D3,{})})}),h.jsx(Ni,{path:"/projects/:id",element:h.jsx(dc,{children:h.jsx(RK,{})})}),h.jsx(Ni,{path:"/settings",element:h.jsx(dc,{children:h.jsx(nY,{})})}),h.jsx(Ni,{path:"/skillhub",element:h.jsx(dc,{children:h.jsx(rY,{})})}),h.jsx(Ni,{path:"*",element:h.jsx(ET,{to:"/",replace:!0})})]})})})}hp.createRoot(document.getElementById("root")).render(h.jsx(ft.StrictMode,{children:h.jsx(iY,{})}));export{Pu as a,$c as c,sY as g};