lantern-harness 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +6 -9
- package/cli/ensure-dist.mjs +1 -3
- package/dist/500.html +2 -2
- package/dist/_astro/{Base.CFN876O3.css → Base.B9f_iFAZ.css} +1 -1
- package/dist/_astro/{CaseGenerateApp.oU5Exw2b.js → CaseGenerateApp.Br4uKjun.js} +1 -1
- package/dist/_astro/{CasesLibrary.CDcqlb6I.js → CasesLibrary.CpPoVQ4P.js} +1 -1
- package/dist/_astro/{ChatApp.tMPYvFMU.js → ChatApp.CYSPlSNP.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.DwYJQYZT.js → KnowledgeLibrary.DZinlAWn.js} +1 -1
- package/dist/_astro/{NavLibraries.BwtNpUK6.js → NavLibraries.EayBsg5g.js} +1 -1
- package/dist/_astro/{PluginsPage.tLehAvrG.js → PluginsPage.BNzpPg2H.js} +1 -1
- package/dist/_astro/PluginsPage.CY61glLU.js +1 -0
- package/dist/_astro/{PromptsLibrary.BpetRzj6.js → PromptsLibrary.DfrrCjs7.js} +1 -1
- package/dist/_astro/{SettingsDialog.Dc2xMiIZ.js → SettingsDialog.DD-XOFEX.js} +1 -1
- package/dist/_astro/SpaceSwitcher.Yy2w8MDF.js +7 -0
- package/dist/_astro/i18n.BVvhz-vw.js +7 -0
- package/dist/_astro/{open-docs-in-session.Bx75APfu.js → open-docs-in-session.D3JCwMWB.js} +1 -1
- package/dist/_astro/{settings.Cb-d0EJe.js → settings.BoQ0e0m1.js} +2 -2
- package/dist/cases/generate/index.html +3 -3
- package/dist/cases/library/index.html +3 -3
- package/dist/docs/changelog/index.html +14 -4
- package/dist/docs/install/index.html +2 -2
- package/dist/docs/manual/index.html +2 -2
- package/dist/index.html +3 -3
- package/dist/knowledge/index.html +3 -3
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +2 -2
- package/dist/plugins/index.html +3 -3
- package/dist/prompts/index.html +3 -3
- package/dist/requirements/index.html +2 -2
- package/dist/templates/index.html +2 -2
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +2 -2
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +2 -2
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +2 -2
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +2 -2
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +2 -2
- package/package.json +16 -7
- package/dist/_astro/PluginsPage.CgIpm4kx.js +0 -1
- package/dist/_astro/SpaceSwitcher.CC-GMa_K.js +0 -7
- package/dist/_astro/i18n.BWX_-rcS.js +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.DJNDi_Ht.js","_astro/react-dom.CqAxpHMt.js","_astro/ExcelFieldTags.B_XMwNNx.js","_astro/jsx-runtime.BUXbF_vF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./SearchableSelect.DMS2XmXc.js";import{a as f,c as p,i as m,n as h,o as g,r as _,s as v,t as ee,u as y}from"./ExcelFieldTags.B_XMwNNx.js";import{o as te}from"./llm.BZEzE0x2.js";import{b,d as ne,f as x,h as S,m as C,o as w,r as T,t as re,u as ie,y as ae}from"./SelectDropdown.Dc7QaPbH.js";import{r as oe}from"./prompts-meta.F4wwkjUA.js";import{f as se,l as ce,p as le,y as E}from"./settings.
|
|
2
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./SearchableSelect.DMS2XmXc.js";import{a as f,c as p,i as m,n as h,o as g,r as _,s as v,t as ee,u as y}from"./ExcelFieldTags.B_XMwNNx.js";import{o as te}from"./llm.BZEzE0x2.js";import{b,d as ne,f as x,h as S,m as C,o as w,r as T,t as re,u as ie,y as ae}from"./SelectDropdown.Dc7QaPbH.js";import{r as oe}from"./prompts-meta.F4wwkjUA.js";import{f as se,l as ce,p as le,y as E}from"./settings.BoQ0e0m1.js";import{t as D}from"./jsx-runtime.BUXbF_vF.js";var O=e(t(),1),k=D(),ue=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function de(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function fe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function pe(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function me(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`-`).slice(0,48)||`cases`}function he(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function ge(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function _e(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function ve(e){let t=a(e).templateFolder;try{let{entries:e}=await ie(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...y],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await C(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=f(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await S(`templates`,e.path),r=_(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await S(`templates`,e.path),r=m(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function ye(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await S(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await C(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return((await(await E(()=>import(`./lib.DJNDi_Ht.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2,3]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function A(){let[e,t]=(0,O.useState)(null),[f,m]=(0,O.useState)(!1),[_,C]=(0,O.useState)([]),[E,D]=(0,O.useState)(``),[A,j]=(0,O.useState)(`functional`),[M,be]=(0,O.useState)([]),[N,P]=(0,O.useState)(``),[xe,Se]=(0,O.useState)([]),[F,I]=(0,O.useState)(``),[Ce,L]=(0,O.useState)(``),[we,Te]=(0,O.useState)([]),[R,z]=(0,O.useState)([]),[B,V]=(0,O.useState)(`md`),[H,Ee]=(0,O.useState)(``),[U,W]=(0,O.useState)(null),[G,De]=(0,O.useState)(!1),[Oe,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(null),Y=(0,O.useRef)(null),ke=(0,O.useRef)(null),X=(0,O.useMemo)(()=>M.find(e=>e.id===N)??M[0],[M,N]),Z=A,Ae=a(Z).label;(0,O.useEffect)(()=>{n().then(()=>t(ce()));let e=se(()=>t(ce()));return(async()=>{await i();let e=await w(`requirements`),t=await w(`cases`),n=await w(`templates`),a=await w(`prompts`),o=await w(`knowledge`);m(e&&t&&n&&a);async function s(e,t,n){let{entries:r}=await ie(e,t);for(let t of r)t.type===`file`?n.push(t):await s(e,t.path,n)}if(e)try{let e=[];await s(`requirements`,`.`,e),C(e)}catch{}if(o)try{let e=[];await s(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Te(e)}catch{}if(a)try{let e=[];await s(`prompts`,`.`,e);let t=e.filter(e=>!oe(e.path));t.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Se(t);let n=t.find(e=>e.path.includes(`功能测试用例提示词`))?.path??t[0]?.path??``;I(e=>e&&!oe(e)&&t.some(t=>t.path===e)?e:n)}catch{}let u=new URLSearchParams(window.location.search),f=u.get(`session`),p=u.get(`path`),h=r();if(f){let e=h.sessions.find(e=>e.id===f);e&&(W(e),j(e.caseType),V(e.outputFormat),D(e.reqPaths[0]??``),e.templateId&&P(e.templateId),e.promptPath&&I(e.promptPath),e.knowledgePaths?.length&&z([...e.knowledgePaths]),e.linkedCasePath&&J({path:e.linkedCasePath,count:0}))}else if(p){let e=h.sessions.find(e=>e.linkedCasePath===p);if(e)W(e),j(e.caseType),V(e.outputFormat),D(e.reqPaths[0]??``),e.templateId&&P(e.templateId),e.promptPath&&I(e.promptPath),e.knowledgePaths?.length&&z([...e.knowledgePaths]),e.linkedCasePath&&J({path:e.linkedCasePath,count:0});else{let e=p.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=p.split(`/`)[0]??``,r=d().find(e=>e.casesFolder===n)?.id??d()[0]?.id??`functional`,i=c({title:p.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=l(i.id,{linkedCasePath:p}).sessions.find(e=>e.id===i.id)??null;W(a),j(r),V(t),J({path:p,count:0})}}})(),e},[]),(0,O.useEffect)(()=>{if(!f)return;let e=!1;return ve(A).then(t=>{e||(be(t),P(e=>e&&t.some(t=>t.id===e)?e:U?.templateId&&t.some(e=>e.id===U.templateId)?U.templateId:t[0]?.id??``))}),()=>{e=!0}},[f,A,U?.templateId]),(0,O.useEffect)(()=>{F?S(`prompts`,F).then(e=>L(e.content)).catch(()=>L(``)):L(``)},[F]),(0,O.useEffect)(()=>{ke.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[U?.messages,G]);function Q(e){if(!U)return;let t=l(U.id,e);W(t.sessions.find(e=>e.id===U.id)??U)}async function je(){let e=``;if(E)try{let t=await ye(E);e+=`\n### 需求文档:${E}\n${t.slice(0,16e3)}\n`}catch{e+=`\n### 需求文档:${E}\n(无法读取正文)\n`}X?.body?e+=`\n### 用例模板:${X.title}\n${X.body.slice(0,8e3)}\n`:X&&(e+=`\n### 用例模板:${X.title}\n字段:${(X.headers.length?X.headers:y).join(`、`)}\n`);for(let t of R)try{let n=await S(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content.slice(0,6e3)}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Me(e,t,n,r){let i=a(t.caseType),o=n||t.title||i.label,s=me(o),c=i.casesFolder;try{await ne(`cases`,`.`,c)}catch{}let l=t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`,u;u=t.linkedCasePath?t.linkedCasePath:`${c}/${s}${l}`;let d=r.length?r:[...y];return t.outputFormat===`md`?await b(`cases`,u,v(e,o,d)):t.outputFormat===`csv`?await b(`cases`,u,g(e,d)):await ae(`cases`,u,await p(e,d,i.label)),u}async function Ne(){if(!E)return``;let e=fe(E);try{return pe(await ye(E))||e}catch{return e}}async function Pe(t,n){if(!e){le(`model`);return}if(!f){K(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let r=await Ne(),i=n;i?(l(i.id,{caseType:A,outputFormat:B,reqPaths:E?[E]:[],templateId:X?.id,templateTitle:X?.title,promptPath:F||void 0,knowledgePaths:R.length?[...R]:void 0}),i={...i,caseType:A,outputFormat:B,reqPaths:E?[E]:[],templateId:X?.id,templateTitle:X?.title,promptPath:F||void 0,knowledgePaths:R.length?[...R]:void 0}):(i=c({title:r||t.slice(0,24)||`用例生成`,caseType:A,outputFormat:B,reqPaths:E?[E]:[],templateId:X?.id,templateTitle:X?.title,promptPath:F||void 0,knowledgePaths:R.length?[...R]:void 0}),W(i));let o=await je(),s=a(A).label,u=X?.headers?.length?X.headers:[...y],d=B===`md`?`最终结果将保存为 Markdown 表格文件`:B===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,p=Ce.trim();if(!p){K(`请先选择提示词`);return}let m=`${p}
|
|
3
3
|
|
|
4
4
|
【运行时约束】
|
|
5
5
|
- 用例类型:${s}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{t as c}from"./jsx-runtime.BUXbF_vF.js";import{t as l}from"./ConfirmDialog.BYz4HREM.js";import{i as u,n as d,r as f,t as p}from"./DocsFileBrowser.DkE26UTR.js";import{a as m,o as h,r as g}from"./plugins.CrpY8UI9.js";import{t as _,u as v}from"./open-docs-in-session.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{t as c}from"./jsx-runtime.BUXbF_vF.js";import{t as l}from"./ConfirmDialog.BYz4HREM.js";import{i as u,n as d,r as f,t as p}from"./DocsFileBrowser.DkE26UTR.js";import{a as m,o as h,r as g}from"./plugins.CrpY8UI9.js";import{t as _,u as v}from"./open-docs-in-session.D3JCwMWB.js";var y=e(t(),1),b=c(),x=10;function S(e){let t=e.split(`/`).pop()??e;return t.startsWith(`~$`)||t.startsWith(`.~`)}async function C(e=`.`){let{entries:t}=await s(`cases`,e),n=[];for(let e of t)e.type===`file`?!S(e.path)&&!S(e.name)&&n.push(e):n.push(...await C(e.path));return n}function w(){let e=f(`cases`),[t,s]=(0,y.useState)(!1),[c,S]=(0,y.useState)(!0),[w,T]=(0,y.useState)(e?!0:null),[E,D]=(0,y.useState)(()=>e??[]),[O,k]=(0,y.useState)({}),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),I=d(E,x),L=(0,y.useCallback)(async()=>{j(null);let e=await C(`.`);D(e),u(`cases`,e),k(t=>{let n={};for(let r of e)t[r.path]&&(n[r.path]=!0);return n})},[]);(0,y.useEffect)(()=>{let e=m(e=>S(!!e.cases));return n().then(()=>{S(g(`cases`)),s(!0)}),e},[]),(0,y.useEffect)(()=>{t&&c&&(async()=>{if(!await a(`cases`))T(!1);else try{await v().catch(()=>null),await L(),T(!0)}catch(e){j(e instanceof Error?e.message:String(e)),T(!0)}})()},[t,c,L]);let R=(0,y.useMemo)(()=>Object.keys(O).filter(e=>O[e]),[O]);async function z(){let e=P;if(e){F(null),N(!0),j(null);try{if(e.kind===`one`)await r(`cases`,e.entry.path);else{for(let t of e.paths)await r(`cases`,t);k({})}await L()}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let B=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${o(`cases`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个用例文件?此操作不可恢复。`:``;function V(){g(`caseGen`)?window.location.href=`/?plugin=caseGen`:j(h(`caseGen`))}async function H(e){N(!0),j(null);try{await _(`cases`,e)}catch(e){j(e instanceof Error?e.message:String(e)),N(!1)}}async function U(e){let t=typeof e==`string`?e:e.path;j(null);try{await i(`cases`,t)}catch(e){j(e instanceof Error?e.message:String(e))}}return t?c?w===null?(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):w?(0,b.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,b.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[I.query.trim()?(0,b.jsxs)(b.Fragment,{children:[`匹配 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:I.filtered.length}),` 个`,(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,E.length]})]}):(0,b.jsxs)(b.Fragment,{children:[`共 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:E.length}),` 个文件`]}),R.length>0?(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,R.length]}):null]}),(0,b.jsx)(`button`,{type:`button`,disabled:M||R.length===0,onClick:()=>F({kind:`batch`,paths:R}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:V,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成用例`})]}),A?(0,b.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,b.jsx)(p,{files:E,filtered:I.filtered,pageFiles:I.pageFiles,query:I.query,onQuery:I.setQuery,sortBy:I.sortBy,onSortBy:I.setSortBy,page:I.page,totalPages:I.totalPages,pageSize:I.pageSize,onPage:I.setPage,onPageSize:I.setPageSize,busy:M,emptyText:`暂无用例文件,点击「生成用例」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:O,onToggleRow:e=>k(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>k(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void U(e),renderActions:e=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>void H(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>F({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,b.jsx)(l,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除用例文件`,message:B,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void z()})]}):(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例管理需要本地文档服务,当前未就绪。`}):(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:h(`cases`)}):(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.DJNDi_Ht.js","_astro/react-dom.CqAxpHMt.js","_astro/ExcelFieldTags.B_XMwNNx.js","_astro/jsx-runtime.BUXbF_vF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{F as r,I as i,L as a,P as o,R as s,i as c,p as l,r as u,t as d,u as f,z as p}from"./app-config.CpjKWnzM.js";import{c as m,d as h,f as g,l as _,n as ee,t as v,u as y}from"./SearchableSelect.DMS2XmXc.js";import{a as b,c as x,d as S,f as C,i as w,n as T,o as E,r as D,s as te,t as ne,u as O}from"./ExcelFieldTags.B_XMwNNx.js";import{a as re,i as k,r as ie,s as ae,t as oe}from"./llm.BZEzE0x2.js";import{b as A,f as se,h as ce,m as j,n as le,o as M,r as N,t as ue,u as P,y as de}from"./SelectDropdown.Dc7QaPbH.js";import{i as fe,n as pe,r as me,t as he}from"./prompts-meta.F4wwkjUA.js";import{d as ge,f as F,l as _e,m as I,o as ve,p as ye,r as be,s as xe,y as Se}from"./settings.
|
|
2
|
+
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{F as r,I as i,L as a,P as o,R as s,i as c,p as l,r as u,t as d,u as f,z as p}from"./app-config.CpjKWnzM.js";import{c as m,d as h,f as g,l as _,n as ee,t as v,u as y}from"./SearchableSelect.DMS2XmXc.js";import{a as b,c as x,d as S,f as C,i as w,n as T,o as E,r as D,s as te,t as ne,u as O}from"./ExcelFieldTags.B_XMwNNx.js";import{a as re,i as k,r as ie,s as ae,t as oe}from"./llm.BZEzE0x2.js";import{b as A,f as se,h as ce,m as j,n as le,o as M,r as N,t as ue,u as P,y as de}from"./SelectDropdown.Dc7QaPbH.js";import{i as fe,n as pe,r as me,t as he}from"./prompts-meta.F4wwkjUA.js";import{d as ge,f as F,l as _e,m as I,o as ve,p as ye,r as be,s as xe,y as Se}from"./settings.BoQ0e0m1.js";import{t as Ce}from"./jsx-runtime.BUXbF_vF.js";import{t as we}from"./ConfirmDialog.BYz4HREM.js";import{i as Te,n as Ee,r as De,t as Oe}from"./menu.CqkL87bV.js";import{a as ke,i as Ae,o as je,r as Me,t as Ne}from"./plugins.CrpY8UI9.js";import{C as Pe,D as Fe,E as L,O as Ie,S as Le,T as Re,_ as ze,a as Be,b as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,l as Je,m as Ye,n as Xe,o as Ze,p as Qe,r as $e,s as et,u as tt,v as nt,w as rt,x as it,y as at}from"./open-docs-in-session.D3JCwMWB.js";import{n as ot}from"./i18n.BVvhz-vw.js";import{$ as st,A as ct,B as lt,C as ut,D as dt,E as ft,F as pt,G as mt,H as ht,I as gt,J as _t,K as vt,L as yt,M as bt,N as xt,O as St,P as Ct,Q as wt,R as Tt,T as Et,U as Dt,V as Ot,W as kt,X as At,Y as jt,Z as Mt,_ as Nt,a as Pt,at as Ft,b as It,c as Lt,d as Rt,et as zt,f as Bt,g as Vt,h as Ht,i as Ut,it as Wt,j as Gt,k as Kt,l as qt,m as Jt,n as Yt,nt as Xt,o as Zt,p as Qt,q as $t,r as en,rt as tn,s as nn,t as rn,tt as an,u as on,v as sn,w as R,x as cn,y as ln,z as un}from"./PluginsPage.BNzpPg2H.js";import{t as dn}from"./NamePromptDialog.DGBlDH_k.js";var z=e(t(),1),fn=e(n(),1),pn=`/__tb_sessions/runs`;async function mn(e){try{return(await fetch(pn,{signal:e??AbortSignal.timeout(1500)})).ok}catch{return!1}}async function hn(e){let t=await fetch(pn,{signal:e??AbortSignal.timeout(3e3)});if(!t.ok)return[];let n=await t.json();return Array.isArray(n.runs)?n.runs:[]}async function gn(e){let t=await fetch(pn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error||`HTTP ${t.status}`}}async function _n(e){await fetch(`${pn}/${encodeURIComponent(e)}/stop`,{method:`POST`}).catch(()=>{})}async function vn(e){try{let t=await fetch(`${pn}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(3e3)});return t.status===404?{ok:!1}:t.ok?await t.json():null}catch{return null}}function yn(e){return e===`completed`||e===`stopped`||e===`error`}function bn(e,t,n,r){let i=new AbortController,a=`${pn}/${encodeURIComponent(e)}/events?after=${Math.max(0,t)}`;return(async()=>{try{let e=await fetch(a,{headers:{Accept:`text/event-stream`},signal:i.signal});if(!e.ok||!e.body){r?.(Error(`SSE ${e.status}`));return}let t=e.body.getReader(),o=new TextDecoder,s=``;for(;;){let{done:e,value:a}=await t.read();if(e){i.signal.aborted||r?.(Error(`SSE disconnected`));break}s+=o.decode(a,{stream:!0});let c=s.split(`
|
|
3
3
|
`);s=c.pop()??``;for(let e of c){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(r)try{n(JSON.parse(r))}catch{}}}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;r?.(e instanceof Error?e:Error(String(e)))}})(),()=>i.abort()}function xn(e,t,n){let r=!1,i=Math.max(0,t),a=0,o=null,s,c=n.maxAttempts??10,l=()=>{r=!0,s!=null&&clearTimeout(s),s=void 0,o?.(),o=null},u=()=>{r||n.signal?.aborted||(o?.(),o=bn(e,i,e=>{typeof e.seq==`number`&&Number.isFinite(e.seq)&&(i=Math.max(i,e.seq)),n.onEvent(e),e.type===`status`&&yn(e.status)&&(n.onTerminal?.(e),l())},t=>{r||n.signal?.aborted||(async()=>{a+=1;try{let r=await vn(e);if(r?.ok&&typeof r.seq==`number`&&(i=Math.max(i,r.seq)),r?.ok&&yn(r.status)){let e={type:`status`,status:r.status,seq:r.seq,assistant:r.assistant};n.onEvent(e),n.onTerminal?.(e),l();return}if(r&&r.ok===!1){n.onGaveUp?.(Error(t.message||`run not found`)),l();return}}catch{}if(a>=c){n.onGaveUp?.(t),l();return}let r=Math.min(4e3,250*a);s=setTimeout(u,r)})()}))},d=()=>l();return n.signal?.addEventListener(`abort`,d),u(),()=>{n.signal?.removeEventListener(`abort`,d),l()}}function Sn(e){for(let t of e)if(t.role===`user`&&typeof t.content==`string`){let e=t.content.trim();if(e)return e}return``}function Cn(e,t){let n=(e||``).trim()||`新对话`;return n===`新对话`||n===Pe(t)}function wn(e){let t=String(e??``).trim().replace(/^["「『]+|["」』]+$/g,``).replace(/\s+/g,` `).replace(/^标题[::]\s*/i,``);return t=t.replace(/[。.!!]+$/g,``).trim(),t?t.length>28?`${t.slice(0,28)}…`:t:``}async function Tn(e,t,n){let r=t.trim().slice(0,800);if(!r)return null;let i=[{role:`system`,content:`你为对话生成侧栏短标题。只输出标题本身:中文优先,不超过 16 个字,无引号、无标点收尾、无解释。`},{role:`user`,content:`用户首条消息:\n${r}\n\n请给出标题:`}];try{return wn(await ie(e,i,n))||null}catch{return null}}function En(e){let t=Array.isArray(e.messages)?e.messages:[],n=0,r=0,i=0,a=0,o=0;for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;t.role===`user`?n+=1:t.role===`assistant`&&(r+=1);let s=t.usage;if(s&&typeof s==`object`){let e=s;typeof e.promptTokens==`number`&&(i+=e.promptTokens),typeof e.completionTokens==`number`&&(a+=e.completionTokens),typeof e.totalTokens==`number`?o+=e.totalTokens:(typeof e.promptTokens==`number`||typeof e.completionTokens==`number`)&&(o+=(Number(e.promptTokens)||0)+(Number(e.completionTokens)||0))}}let s=e.goal,c=!!(s&&s.status!==`cleared`&&s.text?.trim());return{sessionId:e.id,title:e.title||`新对话`,messageCount:t.length,userCount:n,assistantCount:r,promptTokens:i,completionTokens:a,totalTokens:o,createdAt:e.createdAt,updatedAt:e.updatedAt,hasGoal:c,todoCount:Array.isArray(e.todos)?e.todos.length:0}}function Dn(e){let t=new Date(e.createdAt).toLocaleString(),n=new Date(e.updatedAt).toLocaleString();return[`会话:${e.title}`,`消息 ${e.messageCount}(用户 ${e.userCount} / 助手 ${e.assistantCount})`,`用量≈ 输入 ${e.promptTokens} · 输出 ${e.completionTokens} · 合计 ${e.totalTokens}`,`待办 ${e.todoCount} · 目标 ${e.hasGoal?`有`:`无`}`,`创建 ${t}`,`更新 ${n}`].join(`
|
|
4
4
|
`)}var On=new Map,kn=new Map,An=40;function jn(e,t,n=``){return`${e}:${t}:${n}`}function Mn(e){for(;e.size>An;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function Nn(e,t,n,r,i=``){let a=e===`outline`?On:kn,o=jn(t,n,i),s=a.get(t);if(s&&s.stamp===o)return s.value;let c=r();return a.set(t,{stamp:o,value:c}),Mn(a),c}var Pn=`/__tb_sessions/log`;function Fn(e){let t=String(e.userContent??``).trim(),n=String(e.assistantContent??``).trim(),r=String(e.reasoning??``).trim(),i=[];if(t&&i.push({role:`user`,content:t}),n||r){let e={role:`assistant`,content:n};r&&(e.reasoning_content=r),i.push(e)}return i}async function In(e){try{let t=await fetch(Pn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,path:n.path}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function Ln(e){return String(e??``).trim()}function Rn(e,t=80){let n=Ln(e).replace(/\s+/g,` `);return n?n.length>t?`${n.slice(0,t)}…`:n:``}function zn(e,t=40){let n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];if(a.role===`user`){let e=Ln(a.content),t=Rn(e);if(!t)continue;r&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),r={text:e,preview:t,time:typeof a.time==`number`?a.time:void 0,messageIndex:i}}else if(a.role===`assistant`&&r){let e=Ln(a.content),t=Ln(a.reasoning)||void 0;n.push({index:n.length+1,userPreview:r.preview,assistantPreview:Rn(e)||(t?`(含思考)`:``),userText:r.text,assistantText:e,reasoning:t,reasoningDuration:typeof a.reasoningDuration==`number`?a.reasoningDuration:void 0,userTime:r.time,assistantTime:typeof a.time==`number`?a.time:void 0,endMessageIndex:i}),r=null}if(n.length>=t)break}return r&&n.length<t&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),n}function Bn(e,t){let n=String(t??``).trim();return!n||n===`inherit`||n===e.model?e:{...e,model:n}}var Vn=`/__tb_fs`,Hn=`你可以使用 office_to_pdf:优先用本机 LibreOffice 转为 PDF;若未安装,则对 docx/xlsx/pptx 降级抽取正文为同目录 .extracted.md(需写权限)。`,Un={type:`function`,function:{name:`office_to_pdf`,description:`Convert Office docs to PDF via LibreOffice when available; otherwise extract text to .extracted.md for docx/xlsx/pptx.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`Input file path relative to workspace (or absolute when allowed)`},outDir:{type:`string`,description:`Optional output directory (default: same as input)`}},required:[`path`]}}};async function Wn(e,t,n){if(e!==`office_to_pdf`)return JSON.stringify({error:`unknown tool: ${e}`});let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({ok:!1,error:`invalid JSON arguments`})}let i=String(r.path??``).trim();if(!i)return JSON.stringify({ok:!1,error:`path is required`});try{let e=await(await fetch(`${Vn}/office-to-pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,outDir:typeof r.outDir==`string`?r.outDir:void 0,access:n}),signal:AbortSignal.timeout(13e4)})).json().catch(()=>({}));return JSON.stringify(e,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}var Gn=`/__tb_fs`,Kn=`你可以使用 load_workspace_dependencies:查询本机 node / npm / pnpm / python 等可执行文件绝对路径(需本地 fs 服务)。`,qn={type:`function`,function:{name:`load_workspace_dependencies`,description:`Resolve absolute paths of common runtimes/package managers on this machine (node, npm, pnpm, python, …).`,parameters:{type:`object`,properties:{}}}};async function Jn(e){if(e!==`load_workspace_dependencies`)return JSON.stringify({error:`unknown tool: ${e}`});try{let e=await fetch(`${Gn}/workspace-dependencies`,{signal:AbortSignal.timeout(8e3)}),t=await e.json().catch(()=>({}));if(!e.ok){let n=typeof t==`object`&&t&&`error`in t?String(t.error):`HTTP ${e.status}`;return JSON.stringify({ok:!1,error:n})}return JSON.stringify(t,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}function Yn(e){return Array.isArray(e)}function B(e){return Yn(e)?e.some(e=>e.type===`image_url`):!1}function Xn(e){let t=e.filter(e=>e.type===`text`).map(e=>e.text),n=e.filter(e=>e.type===`image_url`).length,r=n>0?`[image-offload] 已卸载 ${n} 张图片(超预算,仅保留最近附图)。`:``;return[{type:`text`,text:[...t,r].filter(Boolean).join(`
|
|
5
5
|
`)||r||`(图片已卸载)`}]}function Zn(e,t={}){let n=Math.max(0,Math.floor(t.keepRecentImageMessages??1)),r=[];for(let t=0;t<e.length;t++){let n=e[t];n.role===`user`&&B(n.content)&&r.push(t)}if(r.length<=n)return e;let i=new Set(r.slice(-n)),a=!1,o=e.map((e,t)=>e.role!==`user`||!B(e.content)||i.has(t)||!Yn(e.content)?e:(a=!0,{...e,content:Xn(e.content)}));return a?o:e}function Qn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var $n=Qn();function er(e){$n=e}var tr={exec:()=>null};function V(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(nr.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var nr={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},rr=/^(?:[ \t]*(?:\n|$))+/,ir=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ar=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,or=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,cr=/(?:[*+-]|\d{1,9}[.)])/,lr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ur=V(lr).replace(/bull/g,cr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),dr=V(lr).replace(/bull/g,cr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),fr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pr=/^[^\n]+/,H=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mr=V(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,H).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hr=V(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,cr).getRegex(),gr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,_r=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vr=V(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,_r).replace(`tag`,gr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yr=V(fr).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex(),br={blockquote:V(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,yr).getRegex(),code:ir,def:mr,fences:ar,heading:sr,hr:or,html:vr,lheading:ur,list:hr,newline:rr,paragraph:yr,table:tr,text:pr},xr=V(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex(),Sr={...br,lheading:dr,table:xr,paragraph:V(fr).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,xr).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex()},Cr={...br,html:V(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,_r).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:tr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:V(fr).replace(`hr`,or).replace(`heading`,` *#{1,6} *[^
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{t as c}from"./jsx-runtime.BUXbF_vF.js";import{t as l}from"./ConfirmDialog.BYz4HREM.js";import{i as u,n as d,r as f,t as p}from"./DocsFileBrowser.DkE26UTR.js";import{a as m,o as h,r as g}from"./plugins.CrpY8UI9.js";import{t as _,u as v}from"./open-docs-in-session.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{t as c}from"./jsx-runtime.BUXbF_vF.js";import{t as l}from"./ConfirmDialog.BYz4HREM.js";import{i as u,n as d,r as f,t as p}from"./DocsFileBrowser.DkE26UTR.js";import{a as m,o as h,r as g}from"./plugins.CrpY8UI9.js";import{t as _,u as v}from"./open-docs-in-session.D3JCwMWB.js";var y=e(t(),1),b=c(),x=10;async function S(e=`.`){let{entries:t}=await s(`knowledge`,e),n=[];for(let e of t)e.type===`file`?e.name.endsWith(`.md`)&&n.push(e):n.push(...await S(e.path));return n}function C({staticCount:e=0,base:t}){let s=f(`knowledge`),[c,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(s?!0:null),[O,k]=(0,y.useState)(()=>s??[]),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)({}),[I,L]=(0,y.useState)(null),R=d(O,x),z=(0,y.useCallback)(async()=>{j(null);try{let e=await S(`.`);k(e),u(`knowledge`,e)}catch(e){j(e instanceof Error?e.message:String(e))}},[]);(0,y.useEffect)(()=>{let e=m(e=>T(!!e.knowledgeLib));return n().then(()=>{T(g(`knowledgeLib`)),C(!0)}),e},[]),(0,y.useEffect)(()=>{c&&w&&(async()=>{await a(`knowledge`)?(await v().catch(()=>null),await z(),D(!0)):D(!1)})()},[c,w,z]);let B=(0,y.useMemo)(()=>Object.keys(P).filter(e=>P[e]),[P]);function V(){g(`knowledgeGen`)?window.location.href=`${t}?plugin=knowledgeGen`:j(h(`knowledgeGen`))}async function H(e){N(!0),j(null);try{await i(`knowledge`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function U(e){N(!0),j(null);try{await _(`knowledge`,e)}catch(e){j(e instanceof Error?e.message:String(e)),N(!1)}}async function W(){let e=I;if(e){L(null),N(!0),j(null);try{if(e.kind===`one`)await r(`knowledge`,e.entry.path);else{for(let t of e.paths)await r(`knowledge`,t);F({})}await z()}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let G=I?.kind===`one`?`删除「${I.entry.name}」?将从 ${o(`knowledge`)} 中移除。`:I?.kind===`batch`?`确认删除已选中的 ${I.paths.length} 个知识库文件?此操作不可恢复。`:``;return c?w?E===null?(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):E?(0,b.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,b.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,b.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[R.query.trim()?(0,b.jsxs)(b.Fragment,{children:[`匹配 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:R.filtered.length}),` 个`,(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,O.length]})]}):(0,b.jsxs)(b.Fragment,{children:[`共 `,(0,b.jsx)(`span`,{className:`font-medium text-stone-800`,children:O.length}),` 个知识库文件`]}),B.length>0?(0,b.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,B.length]}):null]}),(0,b.jsx)(`button`,{type:`button`,disabled:M||B.length===0,onClick:()=>L({kind:`batch`,paths:B}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:V,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成知识库`})]}),A?(0,b.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,b.jsx)(p,{files:O,filtered:R.filtered,pageFiles:R.pageFiles,query:R.query,onQuery:R.setQuery,sortBy:R.sortBy,onSortBy:R.setSortBy,page:R.page,totalPages:R.totalPages,pageSize:R.pageSize,onPage:R.setPage,onPageSize:R.setPageSize,busy:M,emptyText:`暂无知识库文件,点击「生成知识库」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:P,onToggleRow:e=>F(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>F(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void H(e),renderBadge:e=>{let t=e.path.includes(`/`)?e.path.split(`/`)[0]:``;return t?(0,b.jsx)(`span`,{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-800 border border-amber-100`,children:t}):null},renderActions:e=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>void U(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,b.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>L({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,b.jsx)(l,{open:I!=null,title:I?.kind===`batch`?`批量删除`:`删除知识库文件`,message:G,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>L(null),onConfirm:()=>void W()})]}):(0,b.jsxs)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:[`知识库管理需要本地文档服务,当前未就绪`,e>0?`(构建期约有 ${e} 份文档可浏览)`:``,`。`]}):(0,b.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:h(`knowledgeLib`)}):(0,b.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,b.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,b.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{A as r,C as i,D as a,E as o,M as s,N as c,O as l,S as u,T as d,_ as f,a as p,b as m,g as h,h as g,i as _,j as v,k as y,m as b,p as x,r as S,t as C,u as w,v as ee,w as T,x as te,y as ne}from"./app-config.CpjKWnzM.js";import{t as re}from"./jsx-runtime.BUXbF_vF.js";import{a as E,i as D,n as O,r as k,t as ie}from"./ConfirmDialog.BYz4HREM.js";import{a as ae,i as oe,r as A}from"./plugins.CrpY8UI9.js";import{n as j}from"./i18n.BWX_-rcS.js";var M=e(t(),1),N=e(n(),1),P=`/__tb_nav/groups`;function se(){return S().navGroups}function F(){return d(S().navIcons)}function ce(e,t){let n={...F(),[e]:t};return w({navIcons:n}),C(),n}function le(){return S().navOrder}function ue(e,t){let n=T(e),r=o(t,n);return w({navGroups:n,navOrder:r}),C(),{groups:n,order:r}}function I(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function de(e){if(!p())return null;try{let t=await fetch(P,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return T(n.groups,!1)}catch{return null}}async function fe(){if(!p())return;let e=S(),t=null;try{let e=await fetch(P,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=T(t.groups,!1),r=o(e.navOrder,n);(!I(n,e.navGroups)||!I(r,e.navOrder))&&(w({navGroups:n,navOrder:r}),C());return}if(!e.navGroups.length)return;let n=await de(e.navGroups);n&&!I(n,e.navGroups)&&(w({navGroups:n,navOrder:o(e.navOrder,n)}),C())}var L=re(),R=`/`;function z(e){return`${R.endsWith(`/`)?R:`${R}/`}${e.replace(/^\//,``)}`}function B(e,t){return e.includes(`/${t}`)}function V(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function H(e){return x(`tw.nav.groupOpen.${e}`)}function U(){return x(`tw.nav.docsOpen`)}function W(e,t){try{let t=localStorage.getItem(H(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(U());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function pe(e,t){try{localStorage.setItem(H(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(U(),t?`1`:`0`)}catch{}}function G(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?j(`nav.docs`):e.name}function me(e){return e.type===`group`?G(e.group):j(m(e.id).i18n)}function K(e){return e.type===`item`?u(e.id):te(e.group.id)}function he(){let[e,t]=(0,M.useState)(()=>window.location.pathname);return(0,M.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function q({children:e}){return(0,L.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function J({id:e,icon:t}){return(0,L.jsx)(q,{children:Y[t??b[e]]})}var Y={check:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,L.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 20h9`}),(0,L.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,L.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,L.jsx)(`path`,{d:`M8 13h8`}),(0,L.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,L.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M8 6h13`}),(0,L.jsx)(`path`,{d:`M8 12h13`}),(0,L.jsx)(`path`,{d:`M8 18h13`}),(0,L.jsx)(`path`,{d:`M3 6h.01`}),(0,L.jsx)(`path`,{d:`M3 12h.01`}),(0,L.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`}),star:(0,L.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,L.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,L.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,L.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 3h6`}),(0,L.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,L.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,L.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,L.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,L.jsx)(`path`,{d:`M9 6l2 2`}),(0,L.jsx)(`path`,{d:`M15 6l-2 2`}),(0,L.jsx)(`path`,{d:`M7 11H4`}),(0,L.jsx)(`path`,{d:`M20 11h-3`}),(0,L.jsx)(`path`,{d:`M7 17H4`}),(0,L.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,L.jsx)(`path`,{d:`M8 3v4`}),(0,L.jsx)(`path`,{d:`M16 3v4`}),(0,L.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 20V10`}),(0,L.jsx)(`path`,{d:`M10 20V4`}),(0,L.jsx)(`path`,{d:`M16 20v-7`}),(0,L.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M3 12h18`}),(0,L.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,L.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,L.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,L.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,L.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,L.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M5 21V4`}),(0,L.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,L.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function X(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})}),(0,L.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`})})]})}function ge(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function _e(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function Z(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function ve(){return(0,L.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function ye(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function be(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,L.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function xe(){return(0,L.jsxs)(q,{children:[(0,L.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Q(){return(0,L.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function Se(e,t,n){let[r,i]=(0,M.useState)(null),a=(0,M.useRef)(null),o=(0,M.useRef)(e);o.current=e;let c=(0,M.useRef)(t);c.current=t;let l=(0,M.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=s(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,c.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}function $(e,t){let n=m(e).plugin;return!n||t[n]!==!1}function Ce({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=m(e),o=B(n,a.match);return(0,L.jsxs)(`div`,{className:[V(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,L.jsxs)(`a`,{href:z(a.href),className:`tw-nav-item-main`,children:[(0,L.jsx)(J,{id:e,icon:t}),(0,L.jsx)(`span`,{className:`tw-nav-label`,children:j(a.i18n)})]}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,L.jsx)(Z,{})})]})}function we(e,t,n){return e.items.some(e=>{let t=m(e).plugin;return(!t||A(t))&&B(n,m(e).match)})?!0:i(t,e.id).some(e=>we(e,t,n))}function Te(e,t){return e.items.some(e=>{let t=m(e).plugin;return!t||A(t)})?!0:i(t,e.id).some(e=>Te(e,t))}function Ee({group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c}){let l=e.items.filter(e=>{let t=m(e).plugin;return!t||A(t)}),u=i(t,e.id),d=we(e,t,r),[f,p]=(0,M.useState)(()=>W(e.id,!0)),[h,g]=(0,M.useState)(!1),_=(0,M.useRef)(null),v=(0,M.useRef)(null),y=(0,M.useRef)(null);if((0,M.useEffect)(()=>b,[]),!Te(e,t))return null;function b(){y.current&&_.current&&_.current.removeEventListener(`transitionend`,y.current),y.current=null,v.current!==null&&(window.clearTimeout(v.current),v.current=null)}function x(){b(),pe(e.id,!0),g(!1),p(!0)}function S(t){if(t.preventDefault(),!f||h){x();return}g(!0),pe(e.id,!1);let n=_.current,r=!1,i=()=>{r||(r=!0,b(),p(!1),g(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};b(),y.current=a,n?.addEventListener(`transitionend`,a),v.current=window.setTimeout(i,360)}return(0,L.jsxs)(`details`,{className:`tw-nav-details ${h?`is-closing`:``}`,open:f||h,"data-nav-group":e.id,children:[(0,L.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,d?`is-branch-active`:``,o===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:S,children:[(0,L.jsx)(X,{}),(0,L.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:G(e)}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e,t.currentTarget)},children:(0,L.jsx)(ge,{})}),(0,L.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,L.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:_,children:(0,L.jsxs)(`div`,{className:`tw-nav-subtree`,children:[l.map(e=>(0,L.jsx)(Ce,{id:e,icon:n[e],pathname:r,actionOpen:a===e,onMenu:t=>c(e,t)},e)),u.map(e=>(0,L.jsx)(Ee,{group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c},e.id))]})})]})}function De({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(``),m=(0,M.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),_=g.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),v=Se(u,d);(0,M.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function y(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){let e=c.trim();if(!e){p(j(`nav.groupNameRequired`));return}if(!u.length){p(j(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>_.find(t=>t.id===e)).filter(e=>!!e),..._.filter(e=>!u.includes(e.id))];return(0,L.jsxs)(D,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?j(`nav.editGroupTitle`):t?.parentId?j(`nav.addSubgroup`):j(`nav.createGroup`)}),(0,L.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[j(`nav.groupName`),(0,L.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:j(`nav.groupItems`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.groupItemsHint`)}),(0,L.jsxs)(`div`,{ref:v.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,L.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,v.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||v.onPointerDown(e.id,t)}:void 0,children:[t?(0,L.jsx)(Q,{}):(0,L.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,L.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>y(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,L.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,L.jsx)(J,{id:e.id,icon:i[e.id]})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(e.i18n)})]},e.id)}),x.length?null:(0,L.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:j(`nav.noAddableItems`)})]})]}),f?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,L.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:j(`nav.deleteGroup`)}):null,(0,L.jsx)(`div`,{className:`flex-1`}),(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:j(`nav.groupCancel`)}),(0,L.jsx)(`button`,{type:`button`,onClick:b,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.groupSave`)})]})]})})]})}function Oe({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=Se(e,n,r);return(0,L.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,L.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,L.jsx)(Q,{}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function ke({open:e,focusGroupId:t,nodes:n,groups:r,onClose:i,onCommit:a}){let[o,s]=(0,M.useState)(()=>n.map(K)),[c,l]=(0,M.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),u=(0,M.useRef)(o);u.current=o;let d=(0,M.useRef)(c);d.current=c;let f=(0,M.useRef)(r);f.current=r;let p=(0,M.useRef)(n);p.current=n;let h=()=>{let e=f.current.map(e=>({...e,items:d.current[e.id]??e.items}));a(u.current,e)};(0,M.useEffect)(()=>{if(!e)return;let t=p.current.map(K);u.current=t,s(t);let n=Object.fromEntries(f.current.map(e=>[e.id,[...e.items]]));d.current=n,l(n)},[e]);let g=e=>{u.current=e,s(e)},_=(e,t)=>{let n={...d.current,[e]:t};d.current=n,l(n)},v=new Map(n.map(e=>[K(e),me(e)])),y=t?r.find(e=>e.id===t):void 0;return(0,L.jsxs)(D,{open:e,onClose:i,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:j(`nav.sortMenuTitle`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.sortHint`)}),(0,L.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:y?(0,L.jsx)(Oe,{ids:c[y.id]??y.items,labelOf:e=>j(m(e).i18n),onChange:e=>_(y.id,e),onEnd:h,indent:!0}):(0,L.jsx)(Oe,{ids:o,labelOf:e=>v.get(e)??e,onChange:g,onEnd:h})}),(0,L.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,L.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.done`)})})]})})]})}function Ae(e){let t=[];for(let n of e.filter(e=>!e.parentId)){t.push({group:n,indent:!1});for(let r of i(e,n.id))t.push({group:r,indent:!0})}return t}function je(){return(0,L.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Me=120;function Ne(){let[e,t]=(0,M.useState)(null),n=(0,M.useRef)(null),r=(0,M.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,M.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,M.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Me)},[r]),o=(0,M.useCallback)(()=>{r(),t(null)},[r]);return(0,M.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Pe(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function Fe({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,M.useRef)(null),[c,l]=(0,M.useState)({top:e.top,left:e.right+8});return(0,M.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,N.createPortal)((0,L.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Pe(a,o),children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(`div`,{className:`tw-nav-icon-grid`,children:h.map(e=>(0,L.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,L.jsx)(J,{id:n,icon:e})},e))})]}),document.body)}function Ie({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,M.useRef)(null),[s,c]=(0,M.useState)({top:e.top,left:e.right+6});return(0,M.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,M.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,N.createPortal)((0,L.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Pe(r,i),children:a}),document.body)}function Le(){let e=he(),[t,n]=(0,M.useState)(()=>se()),[i,o]=(0,M.useState)(()=>F()),[s,u]=(0,M.useState)(()=>le()),[d,p]=(0,M.useState)(()=>oe()),[h,g]=(0,M.useState)(null),[b,x]=(0,M.useState)(!1),[S,C]=(0,M.useState)(null),[w,T]=(0,M.useState)(!1),[te,re]=(0,M.useState)(null),E=Ne(),D=Ne(),O=E.value,k=D.value,A=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);function N(e){re(e),T(!0)}function P(e){g(e),x(!0)}function I(){x(!1),C(null)}(0,M.useEffect)(()=>{let e=!0,t=ae(e=>{p({...e})});return _().then(async()=>{e&&(await fe(),e&&(n(se()),u(le()),o(F()),p(oe())))}),()=>{e=!1,t()}},[]);let R=ee(t,s);function z(e,t){let r=ue(e,t);n(r.groups),u(r.order),de(r.groups).then(e=>{if(!e||JSON.stringify(e)===JSON.stringify(r.groups))return;let t=ue(e,r.order);n(t.groups),u(t.order)})}function B(){V(),D.close(),E.close()}function V(){A.current!==null&&(window.clearTimeout(A.current),A.current=null)}function H(){V(),A.current=window.setTimeout(()=>{A.current=null,D.close()},220)}function U(e,t){V(),D.open({itemId:e,rect:t.getBoundingClientRect()})}function W(e,t){O?.kind===`itemMenu`&&O.itemId===e?B():(D.closeNow(),E.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function pe(e,t){O?.kind===`groupMenu`&&O.group.id===e.id?B():(D.closeNow(),E.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function me(e,n){z(f(t,e,n),s),B()}function K(e){let{groups:n,owner:i}=r(t,e);z(n,i?a(s,e,i,n):s),B()}let q=O?.kind===`assign`||O?.kind===`itemMenu`?O.itemId:void 0,J=O?.kind===`groupMenu`?O.group.id:void 0,Y=O?.kind===`itemMenu`?O:null,X=O?.kind===`groupMenu`?O:null,Z=O?.kind===`assign`?O:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),R.map(n=>n.type===`item`?$(n.id,d)?(0,L.jsx)(Ce,{id:n.id,icon:i[n.id],pathname:e,actionOpen:q===n.id,onMenu:e=>W(n.id,e)},n.id):null:(0,L.jsx)(Ee,{group:n.group,groups:t,icons:i,pathname:e,openItem:q,openGroupId:J,onMenu:pe,onItemMenu:W},n.group.id)),Y?(0,L.jsxs)(Ie,{rect:Y.rect,closing:E.closing,onClose:B,onHoverEnter:V,onHoverLeave:H,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(m(Y.itemId).i18n)}),(0,L.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(V(),D.close())},children:[Q?(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>K(Y.itemId),children:[(0,L.jsx)(ye,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.leaveGroup`)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>E.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.assignGroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;B(),P({name:``,items:[e]})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addToGroup`)})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;B(),N(e)},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(xe,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.sortMenu`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>U(Y.itemId,e.currentTarget),onClick:e=>U(Y.itemId,e.currentTarget),children:[(0,L.jsx)(be,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(je,{})]})]})]}):null,k&&Y&&k.itemId===Y.itemId?(0,L.jsx)(Fe,{anchor:k.rect,itemId:k.itemId,current:i[k.itemId],closing:D.closing,onHoverEnter:V,onHoverLeave:H,onPick:e=>{o(ce(k.itemId,e)),B()}}):null,X?(0,L.jsxs)(Ie,{rect:X.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:G(X.group)}),(0,L.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=X.group.id;B(),P({name:``,items:[],parentId:e})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addSubgroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;B(),P({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(ge,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,L.jsxs)(Ie,{rect:Z.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.assignGroup`)}),(0,L.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?Ae(t).map(({group:e,indent:t})=>{let n=e.items.includes(Z.itemId);return(0,L.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||me(e.id,Z.itemId)},children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:G(e)}),n?(0,L.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:j(`nav.currentGroup`)}):null]},e.id)}):(0,L.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:j(`nav.noGroups`)})})]}):null,(0,L.jsx)(De,{open:b&&!S,draft:h,groups:t,plugins:d,icons:i,onClose:I,onSave:e=>{let n=c(t,e);z(n.groups,y(s,n.groups,n.id)),I()},onDelete:h?.id?()=>C(h.id):void 0}),(0,L.jsx)(ke,{open:w,focusGroupId:te,nodes:R,groups:t,onClose:()=>T(!1),onCommit:(e,t)=>z(t,e)}),(0,L.jsx)(ie,{open:!!S,title:j(`nav.deleteGroup`),message:t.find(e=>e.id===S)?.parentId?j(`nav.deleteSubgroupMsg`):j(`nav.deleteGroupMsg`),confirmLabel:j(`nav.deleteGroup`),cancelLabel:j(`nav.groupCancel`),danger:`outline`,onClose:()=>C(null),onConfirm:()=>{if(S){let e=t.find(e=>e.id===S),n=ne(t,S),r=v(t,S);z(r,e?l(s,e,r,n):s)}I()}})]})}export{Le as default};
|
|
1
|
+
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{A as r,C as i,D as a,E as o,M as s,N as c,O as l,S as u,T as d,_ as f,a as p,b as m,g as h,h as g,i as _,j as v,k as y,m as b,p as x,r as S,t as C,u as w,v as ee,w as T,x as te,y as ne}from"./app-config.CpjKWnzM.js";import{t as re}from"./jsx-runtime.BUXbF_vF.js";import{a as E,i as D,n as O,r as k,t as ie}from"./ConfirmDialog.BYz4HREM.js";import{a as ae,i as oe,r as A}from"./plugins.CrpY8UI9.js";import{n as j}from"./i18n.BVvhz-vw.js";var M=e(t(),1),N=e(n(),1),P=`/__tb_nav/groups`;function se(){return S().navGroups}function F(){return d(S().navIcons)}function ce(e,t){let n={...F(),[e]:t};return w({navIcons:n}),C(),n}function le(){return S().navOrder}function ue(e,t){let n=T(e),r=o(t,n);return w({navGroups:n,navOrder:r}),C(),{groups:n,order:r}}function I(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function de(e){if(!p())return null;try{let t=await fetch(P,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e}),signal:AbortSignal.timeout(4e3)});if(!t.ok)return null;let n=await t.json();return T(n.groups,!1)}catch{return null}}async function fe(){if(!p())return;let e=S(),t=null;try{let e=await fetch(P,{signal:AbortSignal.timeout(4e3)});e.ok&&(t=await e.json())}catch{return}if(!t)return;if(t.scanned){let n=T(t.groups,!1),r=o(e.navOrder,n);(!I(n,e.navGroups)||!I(r,e.navOrder))&&(w({navGroups:n,navOrder:r}),C());return}if(!e.navGroups.length)return;let n=await de(e.navGroups);n&&!I(n,e.navGroups)&&(w({navGroups:n,navOrder:o(e.navOrder,n)}),C())}var L=re(),R=`/`;function z(e){return`${R.endsWith(`/`)?R:`${R}/`}${e.replace(/^\//,``)}`}function B(e,t){return e.includes(`/${t}`)}function V(e){return[`tw-nav-item`,e?`is-active font-medium`:``].filter(Boolean).join(` `)}function H(e){return x(`tw.nav.groupOpen.${e}`)}function U(){return x(`tw.nav.docsOpen`)}function W(e,t){try{let t=localStorage.getItem(H(e));if(t===`1`)return!0;if(t===`0`)return!1;if(e===`docs`){let e=localStorage.getItem(U());if(e===`1`)return!0;if(e===`0`)return!1}}catch{}return t}function pe(e,t){try{localStorage.setItem(H(e),t?`1`:`0`),e===`docs`&&localStorage.setItem(U(),t?`1`:`0`)}catch{}}function G(e){return e.id===`docs`&&(e.name===`文档库`||e.name===`Documents`)?j(`nav.docs`):e.name}function me(e){return e.type===`group`?G(e.group):j(m(e.id).i18n)}function K(e){return e.type===`item`?u(e.id):te(e.group.id)}function he(){let[e,t]=(0,M.useState)(()=>window.location.pathname);return(0,M.useEffect)(()=>{let e=()=>t(window.location.pathname);return document.addEventListener(`astro:page-load`,e),document.addEventListener(`astro:after-swap`,e),window.addEventListener(`popstate`,e),()=>{document.removeEventListener(`astro:page-load`,e),document.removeEventListener(`astro:after-swap`,e),window.removeEventListener(`popstate`,e)}},[]),e}function q({children:e}){return(0,L.jsx)(`svg`,{className:`tw-nav-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:e})}function J({id:e,icon:t}){return(0,L.jsx)(q,{children:Y[t??b[e]]})}var Y={check:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 11l3 3L22 4`}),(0,L.jsx)(`path`,{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`})]}),pencil:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 20h9`}),(0,L.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),book:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 19.5A2.5 2.5 0 0 1 6.5 17H20`}),(0,L.jsx)(`path`,{d:`M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z`})]}),fileText:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M14 3v5h5`}),(0,L.jsx)(`path`,{d:`M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z`}),(0,L.jsx)(`path`,{d:`M8 13h8`}),(0,L.jsx)(`path`,{d:`M8 17h6`})]}),layers:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M12 3 3 8l9 5 9-5-9-5z`}),(0,L.jsx)(`path`,{d:`m3 13 9 5 9-5`})]}),list:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M8 6h13`}),(0,L.jsx)(`path`,{d:`M8 12h13`}),(0,L.jsx)(`path`,{d:`M8 18h13`}),(0,L.jsx)(`path`,{d:`M3 6h.01`}),(0,L.jsx)(`path`,{d:`M3 12h.01`}),(0,L.jsx)(`path`,{d:`M3 18h.01`})]}),folder:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`}),star:(0,L.jsx)(`path`,{d:`m12 3 2.1 5.9L20 11l-5 4.3 1.7 6.2-5.7-3.9-5.7 3.9L7 15.3 2 11l5.9-2.1L12 3z`}),database:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ellipse`,{cx:`12`,cy:`6`,rx:`8`,ry:`3`}),(0,L.jsx)(`path`,{d:`M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6`}),(0,L.jsx)(`path`,{d:`M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),target:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`})]}),code:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m8 8-4 4 4 4`}),(0,L.jsx)(`path`,{d:`m16 8 4 4-4 4`})]}),flask:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 3h6`}),(0,L.jsx)(`path`,{d:`M10 3v6l-5 8a2 2 0 0 0 1.7 3h10.6a2 2 0 0 0 1.7-3l-5-8V3`}),(0,L.jsx)(`path`,{d:`M7.5 14h9`})]}),home:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M3 10.5 12 3l9 7.5`}),(0,L.jsx)(`path`,{d:`M5 9.5V20h14V9.5`})]}),clipboard:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M9 4h6v3H9z`}),(0,L.jsx)(`path`,{d:`M8 4H6a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2`})]}),bug:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`14`,r:`5`}),(0,L.jsx)(`path`,{d:`M9 6l2 2`}),(0,L.jsx)(`path`,{d:`M15 6l-2 2`}),(0,L.jsx)(`path`,{d:`M7 11H4`}),(0,L.jsx)(`path`,{d:`M20 11h-3`}),(0,L.jsx)(`path`,{d:`M7 17H4`}),(0,L.jsx)(`path`,{d:`M20 17h-3`})]}),calendar:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`16`,rx:`2`}),(0,L.jsx)(`path`,{d:`M8 3v4`}),(0,L.jsx)(`path`,{d:`M16 3v4`}),(0,L.jsx)(`path`,{d:`M3 10h18`})]}),chart:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M4 20V10`}),(0,L.jsx)(`path`,{d:`M10 20V4`}),(0,L.jsx)(`path`,{d:`M16 20v-7`}),(0,L.jsx)(`path`,{d:`M2 20h20`})]}),globe:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M3 12h18`}),(0,L.jsx)(`path`,{d:`M12 3c2.5 2.5 4 5.7 4 9s-1.5 6.5-4 9c-2.5-2.5-4-5.7-4-9s1.5-6.5 4-9z`})]}),link:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M10 13a4 4 0 0 0 5.7 0l2.3-2.3a4 4 0 0 0-5.7-5.7L11 6.3`}),(0,L.jsx)(`path`,{d:`M14 11a4 4 0 0 0-5.7 0L6 13.3a4 4 0 0 0 5.7 5.7L13 17.7`})]}),users:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,L.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,L.jsx)(`path`,{d:`M16 5.5a3.5 3.5 0 0 1 0 7`}),(0,L.jsx)(`path`,{d:`M18 20a6 6 0 0 0-2-4.5`})]}),terminal:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`m5 8 4 4-4 4`}),(0,L.jsx)(`path`,{d:`M13 16h6`})]}),tag:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0l-7.2-7.2a2 2 0 0 1-.6-1.4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 1.4.6l6.2 6.2a2 2 0 0 1 0 2.6z`}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.2`})]}),flag:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`path`,{d:`M5 21V4`}),(0,L.jsx)(`path`,{d:`M5 5h11l-2 4 2 4H5z`})]}),zap:(0,L.jsx)(`path`,{d:`M13 2 4 14h6l-1 8 9-12h-6l1-8z`})};function X(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--closed`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})}),(0,L.jsx)(`svg`,{className:`tw-nav-ico tw-nav-ico--open`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`})})]})}function ge(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`path`,{d:`M21 4H14`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M10 4H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 12H12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M21 20H16`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M12 20H3`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M14 2v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 10v4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 18v4`,strokeLinecap:`round`})]})}function _e(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,L.jsx)(`path`,{d:`M12 8v8`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M8 12h8`,strokeLinecap:`round`})]})}function Z(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.7`}),(0,L.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.7`})]})}function ve(){return(0,L.jsx)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,L.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function ye(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`path`,{d:`M9 6H5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M16 8l4 4-4 4`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M20 12H9`,strokeLinecap:`round`})]})}function be(){return(0,L.jsxs)(`svg`,{className:`tw-nav-group-pop-ico`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,L.jsx)(`circle`,{cx:`8.5`,cy:`8.5`,r:`4.5`}),(0,L.jsx)(`rect`,{x:`12`,y:`12`,width:`9`,height:`9`,rx:`2`})]})}function xe(){return(0,L.jsxs)(q,{children:[(0,L.jsx)(`path`,{d:`M8 6v12`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M5 9l3-3 3 3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M16 18V6`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M13 15l3 3 3-3`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Q(){return(0,L.jsxs)(`svg`,{className:`tw-nav-drag-grip`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:[(0,L.jsx)(`circle`,{cx:`7`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`5`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`10`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`7`,cy:`15`,r:`1.25`,fill:`currentColor`}),(0,L.jsx)(`circle`,{cx:`13`,cy:`15`,r:`1.25`,fill:`currentColor`})]})}function Se(e,t,n){let[r,i]=(0,M.useState)(null),a=(0,M.useRef)(null),o=(0,M.useRef)(e);o.current=e;let c=(0,M.useRef)(t);c.current=t;let l=(0,M.useRef)(n);l.current=n;function u(e,t){if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let n=a.current;if(!n)return;i(e);let r=e=>{let t=[...n.querySelectorAll(`[data-sort-key]`)];for(let n of t){let t=n.getBoundingClientRect();if(e>=t.top&&e<=t.bottom)return n.dataset.sortKey}return null},u=t=>{let n=r(t.clientY);if(!n||n===e)return;let i=s(o.current,e,n);i.join(`|`)!==o.current.join(`|`)&&(o.current=i,c.current(i))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d),i(null),l.current?.()};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)}return{listRef:a,dragId:r,onPointerDown:u}}function $(e,t){let n=m(e).plugin;return!n||t[n]!==!1}function Ce({id:e,icon:t,pathname:n,actionOpen:r,onMenu:i}){let a=m(e),o=B(n,a.match);return(0,L.jsxs)(`div`,{className:[V(o),r?`is-action-open`:``].filter(Boolean).join(` `),"data-plugin-nav":a.plugin,children:[(0,L.jsxs)(`a`,{href:z(a.href),className:`tw-nav-item-main`,children:[(0,L.jsx)(J,{id:e,icon:t}),(0,L.jsx)(`span`,{className:`tw-nav-label`,children:j(a.i18n)})]}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.more`),onClick:e=>{e.preventDefault(),e.stopPropagation(),i(e.currentTarget)},children:(0,L.jsx)(Z,{})})]})}function we(e,t,n){return e.items.some(e=>{let t=m(e).plugin;return(!t||A(t))&&B(n,m(e).match)})?!0:i(t,e.id).some(e=>we(e,t,n))}function Te(e,t){return e.items.some(e=>{let t=m(e).plugin;return!t||A(t)})?!0:i(t,e.id).some(e=>Te(e,t))}function Ee({group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c}){let l=e.items.filter(e=>{let t=m(e).plugin;return!t||A(t)}),u=i(t,e.id),d=we(e,t,r),[f,p]=(0,M.useState)(()=>W(e.id,!0)),[h,g]=(0,M.useState)(!1),_=(0,M.useRef)(null),v=(0,M.useRef)(null),y=(0,M.useRef)(null);if((0,M.useEffect)(()=>b,[]),!Te(e,t))return null;function b(){y.current&&_.current&&_.current.removeEventListener(`transitionend`,y.current),y.current=null,v.current!==null&&(window.clearTimeout(v.current),v.current=null)}function x(){b(),pe(e.id,!0),g(!1),p(!0)}function S(t){if(t.preventDefault(),!f||h){x();return}g(!0),pe(e.id,!1);let n=_.current,r=!1,i=()=>{r||(r=!0,b(),p(!1),g(!1))},a=e=>{e.target===n&&e.propertyName===`grid-template-rows`&&i()};b(),y.current=a,n?.addEventListener(`transitionend`,a),v.current=window.setTimeout(i,360)}return(0,L.jsxs)(`details`,{className:`tw-nav-details ${h?`is-closing`:``}`,open:f||h,"data-nav-group":e.id,children:[(0,L.jsxs)(`summary`,{className:[`tw-nav-item tw-nav-summary`,d?`is-branch-active`:``,o===e.id?`is-action-open`:``].filter(Boolean).join(` `),onClick:S,children:[(0,L.jsx)(X,{}),(0,L.jsx)(`span`,{className:`tw-nav-label min-w-0 flex-1 truncate`,children:G(e)}),(0,L.jsx)(`button`,{type:`button`,className:`tw-nav-hover-btn`,"aria-label":j(`nav.groupActions`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(e,t.currentTarget)},children:(0,L.jsx)(ge,{})}),(0,L.jsx)(`svg`,{className:`tw-nav-chevron opacity-70`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M7 5l6 5-6 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,L.jsx)(`div`,{className:`tw-nav-subtree-anim`,ref:_,children:(0,L.jsxs)(`div`,{className:`tw-nav-subtree`,children:[l.map(e=>(0,L.jsx)(Ce,{id:e,icon:n[e],pathname:r,actionOpen:a===e,onMenu:t=>c(e,t)},e)),u.map(e=>(0,L.jsx)(Ee,{group:e,groups:t,icons:n,pathname:r,openItem:a,openGroupId:o,onMenu:s,onItemMenu:c},e.id))]})})]})}function De({open:e,draft:t,groups:n,plugins:r,icons:i,onClose:a,onSave:o,onDelete:s}){let[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(``),m=(0,M.useRef)(null),h=new Set(n.filter(e=>e.id!==t?.id).flatMap(e=>e.items)),_=g.filter(e=>$(e.id,r)&&(!h.has(e.id)||u.includes(e.id))),v=Se(u,d);(0,M.useEffect)(()=>{if(!e||!t)return;l(t.name),d(t.items.filter(e=>$(e,r))),p(``);let n=window.setTimeout(()=>{m.current?.focus(),m.current?.select()},50);return()=>window.clearTimeout(n)},[e,t,r]);function y(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){let e=c.trim();if(!e){p(j(`nav.groupNameRequired`));return}if(!u.length){p(j(`nav.groupItemsRequired`));return}let n=(t?.items??[]).filter(e=>!$(e,r));o({id:t?.id,name:e,items:[...n,...u],parentId:t?.parentId})}let x=[...u.map(e=>_.find(t=>t.id===e)).filter(e=>!!e),..._.filter(e=>!u.includes(e.id))];return(0,L.jsxs)(D,{open:e,onClose:a,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t?.id?j(`nav.editGroupTitle`):t?.parentId?j(`nav.addSubgroup`):j(`nav.createGroup`)}),(0,L.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[j(`nav.groupName`),(0,L.jsx)(`input`,{ref:m,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},className:`mt-1.5 w-full h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6]`})]}),(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:j(`nav.groupItems`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.groupItemsHint`)}),(0,L.jsxs)(`div`,{ref:v.listRef,className:`mt-2 max-h-52 overflow-auto rounded-lg border border-stone-200 p-1`,children:[x.map(e=>{let t=u.includes(e.id);return(0,L.jsxs)(`label`,{"data-sort-key":t?e.id:void 0,className:[`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,t?`tw-nav-drag-row`:``,v.dragId===e.id?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t?t=>{t.target.closest(`input`)||v.onPointerDown(e.id,t)}:void 0,children:[t?(0,L.jsx)(Q,{}):(0,L.jsx)(`span`,{className:`tw-nav-drag-grip`}),(0,L.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>y(e.id),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,L.jsx)(`span`,{className:`tw-nav-editor-ico`,children:(0,L.jsx)(J,{id:e.id,icon:i[e.id]})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(e.i18n)})]},e.id)}),x.length?null:(0,L.jsx)(`div`,{className:`px-3 py-4 text-center text-[12px] text-stone-400`,children:j(`nav.noAddableItems`)})]})]}),f?(0,L.jsx)(`p`,{className:`mt-2 text-[12px] text-red-600`,children:f}):null,(0,L.jsxs)(`div`,{className:`mt-5 flex items-center gap-2`,children:[t?.id&&s?(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`h-8 px-3 text-sm rounded-lg border border-red-200 text-red-600 hover:bg-red-50`,children:j(`nav.deleteGroup`)}):null,(0,L.jsx)(`div`,{className:`flex-1`}),(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100`,children:j(`nav.groupCancel`)}),(0,L.jsx)(`button`,{type:`button`,onClick:b,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.groupSave`)})]})]})})]})}function Oe({ids:e,labelOf:t,onChange:n,onEnd:r,indent:i}){let a=Se(e,n,r);return(0,L.jsx)(`div`,{ref:a.listRef,className:`flex flex-col`,children:e.map(e=>(0,L.jsxs)(`div`,{"data-sort-key":e,className:[`tw-nav-drag-row px-3 py-2 text-sm text-stone-700 hover:bg-stone-50`,i?`tw-nav-drag-row--nested`:``,a.dragId===e?`is-dragging`:``].filter(Boolean).join(` `),onPointerDown:t=>a.onPointerDown(e,t),children:[(0,L.jsx)(Q,{}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t(e)})]},e))})}function ke({open:e,focusGroupId:t,nodes:n,groups:r,onClose:i,onCommit:a}){let[o,s]=(0,M.useState)(()=>n.map(K)),[c,l]=(0,M.useState)(()=>Object.fromEntries(r.map(e=>[e.id,[...e.items]]))),u=(0,M.useRef)(o);u.current=o;let d=(0,M.useRef)(c);d.current=c;let f=(0,M.useRef)(r);f.current=r;let p=(0,M.useRef)(n);p.current=n;let h=()=>{let e=f.current.map(e=>({...e,items:d.current[e.id]??e.items}));a(u.current,e)};(0,M.useEffect)(()=>{if(!e)return;let t=p.current.map(K);u.current=t,s(t);let n=Object.fromEntries(f.current.map(e=>[e.id,[...e.items]]));d.current=n,l(n)},[e]);let g=e=>{u.current=e,s(e)},_=(e,t)=>{let n={...d.current,[e]:t};d.current=n,l(n)},v=new Map(n.map(e=>[K(e),me(e)])),y=t?r.find(e=>e.id===t):void 0;return(0,L.jsxs)(D,{open:e,onClose:i,transition:!0,className:`relative z-110`,children:[(0,L.jsx)(O,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":!0}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,L.jsxs)(E,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,L.jsx)(k,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:j(`nav.sortMenuTitle`)}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:j(`nav.sortHint`)}),(0,L.jsx)(`div`,{className:`mt-4 max-h-80 overflow-auto rounded-lg border border-stone-200 p-1`,children:y?(0,L.jsx)(Oe,{ids:c[y.id]??y.items,labelOf:e=>j(m(e).i18n),onChange:e=>_(y.id,e),onEnd:h,indent:!0}):(0,L.jsx)(Oe,{ids:o,labelOf:e=>v.get(e)??e,onChange:g,onEnd:h})}),(0,L.jsx)(`div`,{className:`mt-5 flex justify-end`,children:(0,L.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0]`,children:j(`nav.done`)})})]})})]})}function Ae(e){let t=[];for(let n of e.filter(e=>!e.parentId)){t.push({group:n,indent:!1});for(let r of i(e,n.id))t.push({group:r,indent:!0})}return t}function je(){return(0,L.jsx)(`svg`,{className:`tw-nav-group-pop-arrow`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":!0,children:(0,L.jsx)(`path`,{d:`M7 5l5 5-5 5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Me=120;function Ne(){let[e,t]=(0,M.useState)(null),n=(0,M.useRef)(null),r=(0,M.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),i=(0,M.useCallback)(e=>{r(),t({value:e,closing:!1})},[r]),a=(0,M.useCallback)(()=>{r(),t(e=>e&&!e.closing?{...e,closing:!0}:e),n.current=window.setTimeout(()=>{n.current=null,t(null)},Me)},[r]),o=(0,M.useCallback)(()=>{r(),t(null)},[r]);return(0,M.useEffect)(()=>r,[r]),{value:e?.value??null,closing:!!e?.closing,open:i,close:a,closeNow:o}}function Pe(e,t){return{onMouseOver:()=>e?.(),onMouseOut:e=>{let n=e.relatedTarget;n&&e.currentTarget.contains(n)||t?.()}}}function Fe({anchor:e,current:t,itemId:n,closing:r,onPick:i,onHoverEnter:a,onHoverLeave:o}){let s=(0,M.useRef)(null),[c,l]=(0,M.useState)({top:e.top,left:e.right+8});return(0,M.useEffect)(()=>{let t=s.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+8,a=e.top-6;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),a<8&&(a=8),l({top:a,left:i})},[e]),(0,N.createPortal)((0,L.jsxs)(`div`,{ref:s,className:[`tw-nav-group-pop`,`tw-nav-icon-pop`,r?`is-closing`:``].filter(Boolean).join(` `),style:{top:c.top,left:c.left},...Pe(a,o),children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(`div`,{className:`tw-nav-icon-grid`,children:h.map(e=>(0,L.jsx)(`button`,{type:`button`,className:[`tw-nav-icon-cell`,t===e?`is-current`:``].filter(Boolean).join(` `),onClick:()=>i(e),children:(0,L.jsx)(J,{id:n,icon:e})},e))})]}),document.body)}function Ie({rect:e,closing:t=!1,onClose:n,onHoverEnter:r,onHoverLeave:i,children:a}){let o=(0,M.useRef)(null),[s,c]=(0,M.useState)({top:e.top,left:e.right+6});return(0,M.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.offsetWidth,r=t.offsetHeight,i=e.right+6,a=e.top;i+n>window.innerWidth-8&&(i=Math.max(8,e.left-n-6)),a+r>window.innerHeight-8&&(a=Math.max(8,window.innerHeight-r-8)),c({top:a,left:i})},[e]),(0,M.useEffect)(()=>{let e=e=>{let t=e.target;o.current?.contains(t)||t?.closest?.(`.tw-nav-icon-pop`)||t?.closest?.(`.tw-nav-hover-btn`)||n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,n)}},[n]),(0,N.createPortal)((0,L.jsx)(`div`,{ref:o,className:[`tw-nav-group-pop`,t?`is-closing`:``].filter(Boolean).join(` `),style:{top:s.top,left:s.left},...Pe(r,i),children:a}),document.body)}function Le(){let e=he(),[t,n]=(0,M.useState)(()=>se()),[i,o]=(0,M.useState)(()=>F()),[s,u]=(0,M.useState)(()=>le()),[d,p]=(0,M.useState)(()=>oe()),[h,g]=(0,M.useState)(null),[b,x]=(0,M.useState)(!1),[S,C]=(0,M.useState)(null),[w,T]=(0,M.useState)(!1),[te,re]=(0,M.useState)(null),E=Ne(),D=Ne(),O=E.value,k=D.value,A=(0,M.useRef)(null);(0,M.useEffect)(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);function N(e){re(e),T(!0)}function P(e){g(e),x(!0)}function I(){x(!1),C(null)}(0,M.useEffect)(()=>{let e=!0,t=ae(e=>{p({...e})});return _().then(async()=>{e&&(await fe(),e&&(n(se()),u(le()),o(F()),p(oe())))}),()=>{e=!1,t()}},[]);let R=ee(t,s);function z(e,t){let r=ue(e,t);n(r.groups),u(r.order),de(r.groups).then(e=>{if(!e||JSON.stringify(e)===JSON.stringify(r.groups))return;let t=ue(e,r.order);n(t.groups),u(t.order)})}function B(){V(),D.close(),E.close()}function V(){A.current!==null&&(window.clearTimeout(A.current),A.current=null)}function H(){V(),A.current=window.setTimeout(()=>{A.current=null,D.close()},220)}function U(e,t){V(),D.open({itemId:e,rect:t.getBoundingClientRect()})}function W(e,t){O?.kind===`itemMenu`&&O.itemId===e?B():(D.closeNow(),E.open({kind:`itemMenu`,itemId:e,rect:t.getBoundingClientRect()}))}function pe(e,t){O?.kind===`groupMenu`&&O.group.id===e.id?B():(D.closeNow(),E.open({kind:`groupMenu`,group:e,rect:t.getBoundingClientRect()}))}function me(e,n){z(f(t,e,n),s),B()}function K(e){let{groups:n,owner:i}=r(t,e);z(n,i?a(s,e,i,n):s),B()}let q=O?.kind===`assign`||O?.kind===`itemMenu`?O.itemId:void 0,J=O?.kind===`groupMenu`?O.group.id:void 0,Y=O?.kind===`itemMenu`?O:null,X=O?.kind===`groupMenu`?O:null,Z=O?.kind===`assign`?O:null,Q=Y?t.find(e=>e.items.includes(Y.itemId))??null:null;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`tw-nav-ready`,"aria-hidden":`true`}),R.map(n=>n.type===`item`?$(n.id,d)?(0,L.jsx)(Ce,{id:n.id,icon:i[n.id],pathname:e,actionOpen:q===n.id,onMenu:e=>W(n.id,e)},n.id):null:(0,L.jsx)(Ee,{group:n.group,groups:t,icons:i,pathname:e,openItem:q,openGroupId:J,onMenu:pe,onItemMenu:W},n.group.id)),Y?(0,L.jsxs)(Ie,{rect:Y.rect,closing:E.closing,onClose:B,onHoverEnter:V,onHoverLeave:H,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(m(Y.itemId).i18n)}),(0,L.jsxs)(`div`,{className:`tw-nav-group-pop-list`,onMouseOver:e=>{let t=e.target.closest(`.tw-nav-group-pop-item`);t&&t.getAttribute(`data-submenu`)!==`icons`&&(V(),D.close())},children:[Q?(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-leave`,onClick:()=>K(Y.itemId),children:[(0,L.jsx)(ye,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.leaveGroup`)})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>E.open({kind:`assign`,itemId:Y.itemId,rect:Y.rect}),children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.assignGroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Y.itemId;B(),P({name:``,items:[e]})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addToGroup`)})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=Q?.id??null;B(),N(e)},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(xe,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.sortMenu`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,"data-submenu":`icons`,onMouseEnter:e=>U(Y.itemId,e.currentTarget),onClick:e=>U(Y.itemId,e.currentTarget),children:[(0,L.jsx)(be,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.chooseIcon`)}),(0,L.jsx)(je,{})]})]})]}):null,k&&Y&&k.itemId===Y.itemId?(0,L.jsx)(Fe,{anchor:k.rect,itemId:k.itemId,current:i[k.itemId],closing:D.closing,onHoverEnter:V,onHoverLeave:H,onPick:e=>{o(ce(k.itemId,e)),B()}}):null,X?(0,L.jsxs)(Ie,{rect:X.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:G(X.group)}),(0,L.jsxs)(`div`,{className:`tw-nav-group-pop-list`,children:[X.group.parentId?null:(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item is-create`,onClick:()=>{let e=X.group.id;B(),P({name:``,items:[],parentId:e})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(_e,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.addSubgroup`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:`tw-nav-group-pop-item`,onClick:()=>{let e=X.group;B(),P({id:e.id,name:e.name,items:[...e.items],parentId:e.parentId})},children:[(0,L.jsx)(`span`,{className:`tw-nav-group-pop-ico`,children:(0,L.jsx)(ge,{})}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:j(`nav.editGroupTitle`)})]})]})]}):null,Z?(0,L.jsxs)(Ie,{rect:Z.rect,closing:E.closing,onClose:B,children:[(0,L.jsx)(`div`,{className:`tw-nav-group-pop-head`,children:j(`nav.assignGroup`)}),(0,L.jsx)(`div`,{className:`tw-nav-group-pop-list`,children:t.length?Ae(t).map(({group:e,indent:t})=>{let n=e.items.includes(Z.itemId);return(0,L.jsxs)(`button`,{type:`button`,className:[`tw-nav-group-pop-item`,n?`is-current`:``,t?`is-child`:``].filter(Boolean).join(` `),onClick:()=>{n||me(e.id,Z.itemId)},children:[(0,L.jsx)(ve,{}),(0,L.jsx)(`span`,{className:`tw-nav-group-pop-name`,children:G(e)}),n?(0,L.jsx)(`span`,{className:`tw-nav-group-pop-tag`,children:j(`nav.currentGroup`)}):null]},e.id)}):(0,L.jsx)(`div`,{className:`tw-nav-group-pop-empty`,children:j(`nav.noGroups`)})})]}):null,(0,L.jsx)(De,{open:b&&!S,draft:h,groups:t,plugins:d,icons:i,onClose:I,onSave:e=>{let n=c(t,e);z(n.groups,y(s,n.groups,n.id)),I()},onDelete:h?.id?()=>C(h.id):void 0}),(0,L.jsx)(ke,{open:w,focusGroupId:te,nodes:R,groups:t,onClose:()=>T(!1),onCommit:(e,t)=>z(t,e)}),(0,L.jsx)(ie,{open:!!S,title:j(`nav.deleteGroup`),message:t.find(e=>e.id===S)?.parentId?j(`nav.deleteSubgroupMsg`):j(`nav.deleteGroupMsg`),confirmLabel:j(`nav.deleteGroup`),cancelLabel:j(`nav.groupCancel`),danger:`outline`,onClose:()=>C(null),onConfirm:()=>{if(S){let e=t.find(e=>e.id===S),n=ne(t,S),r=v(t,S);z(r,e?l(s,e,r,n):s)}I()}})]})}export{Le as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import"./settings.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import"./settings.BoQ0e0m1.js";import{t as r}from"./jsx-runtime.BUXbF_vF.js";import{a as i,i as a,n as o,s,t as c}from"./plugins.CrpY8UI9.js";import{t as l}from"./OverflowHint.lzmplP5j.js";var u=e(t(),1),d=`/__tb_fs`,f=`你可以使用本地文件工具(侧栏工作区已连接时):
|
|
2
2
|
- 侧栏「工作区」决定当前目录;fs_* 默认相对该工作区
|
|
3
3
|
- working_directory_get / working_directory_set:查看或切换当前工作区(已注册列表内)
|
|
4
4
|
- 「仅可查看」「工作区内修改」:用工作区相对路径
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./PluginsPage.BNzpPg2H.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{i as c}from"./prompts-meta.F4wwkjUA.js";import{t as l}from"./jsx-runtime.BUXbF_vF.js";import{t as u}from"./ConfirmDialog.BYz4HREM.js";import{i as d,n as f,r as p,t as m}from"./DocsFileBrowser.DkE26UTR.js";import{a as h,o as g,r as _}from"./plugins.CrpY8UI9.js";import{t as v,u as y}from"./open-docs-in-session.
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.CpjKWnzM.js";import{a as r,f as i,o as a,r as o,u as s}from"./SelectDropdown.Dc7QaPbH.js";import{i as c}from"./prompts-meta.F4wwkjUA.js";import{t as l}from"./jsx-runtime.BUXbF_vF.js";import{t as u}from"./ConfirmDialog.BYz4HREM.js";import{i as d,n as f,r as p,t as m}from"./DocsFileBrowser.DkE26UTR.js";import{a as h,o as g,r as _}from"./plugins.CrpY8UI9.js";import{t as v,u as y}from"./open-docs-in-session.D3JCwMWB.js";var b=e(t(),1),x=l(),S=10;async function C(e=`.`){let{entries:t}=await s(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await C(e.path));return n}function w(){let e=p(`prompts`),[t,s]=(0,b.useState)(!1),[l,w]=(0,b.useState)(!0),[T,E]=(0,b.useState)(e?!0:null),[D,O]=(0,b.useState)(()=>e??[]),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),L=f(D,S),R=(0,b.useCallback)(async()=>{A(null);try{let e=await C(`.`);O(e),d(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=h(e=>w(!!e.prompts));return n().then(()=>{w(_(`prompts`)),s(!0)}),e},[]),(0,b.useEffect)(()=>{t&&l&&(async()=>{await a(`prompts`)?(await y().catch(()=>null),await R(),E(!0)):E(!1)})()},[t,l,R]);let z=(0,b.useMemo)(()=>Object.keys(N).filter(e=>N[e]),[N]);async function B(e){M(!0),A(null);try{await i(`prompts`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}async function V(e){M(!0),A(null);try{await v(`prompts`,e)}catch(e){A(e instanceof Error?e.message:String(e)),M(!1)}}function H(e){c(e.path)?A(`默认提示词不可删除`):I({kind:`one`,entry:e})}async function U(){let e=F;if(e){I(null),M(!0),A(null);try{if(e.kind===`one`)await r(`prompts`,e.entry.path);else{for(let t of e.paths)c(t)||await r(`prompts`,t);P({})}await R()}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}function W(){_(`promptGen`)?window.location.href=`/?plugin=promptGen`:A(g(`promptGen`))}let G=F?.kind===`one`?`删除「${F.entry.name}」?将从 ${o(`prompts`)} 中移除。`:F?.kind===`batch`?`确认删除已选中的 ${F.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?T===null?(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):T?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[L.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:L.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,D.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:D.length}),` 个提示词`]}),z.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,z.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:j||z.length===0,onClick:()=>I({kind:`batch`,paths:z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(`button`,{type:`button`,disabled:j,onClick:W,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成提示词`})]}),k?(0,x.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:k}):null,(0,x.jsx)(m,{files:D,filtered:L.filtered,pageFiles:L.pageFiles,query:L.query,onQuery:L.setQuery,sortBy:L.sortBy,onSortBy:L.setSortBy,page:L.page,totalPages:L.totalPages,pageSize:L.pageSize,onPage:L.setPage,onPageSize:L.setPageSize,busy:j,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!c(e.path),selected:N,onToggleRow:e=>P(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>P(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void B(e),renderActions:e=>{let t=c(e.path);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>void V(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:j||t,"data-hint":t?`默认提示词不可删除`:void 0,onClick:()=>H(e),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:`删除`})]})}}),(0,x.jsx)(u,{open:F!=null,title:F?.kind===`batch`?`批量删除`:`删除提示词`,message:G,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>I(null),onConfirm:()=>void U()})]}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`提示词管理需要本地文档服务,当前未就绪。`}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:g(`prompts`)}):(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.CpjKWnzM.js";import{i as te}from"./llm.BZEzE0x2.js";import{_ as ne,a,c as re,d as ie,g as ae,h as oe,i as se,l as o,n as s,o as ce,r as le,s as c,t as l,u as ue,v as de}from"./settings.Cb-d0EJe.js";import{t as u}from"./jsx-runtime.BUXbF_vF.js";import{i as fe,n as pe,r as me,t as he}from"./listbox.DdDDDJ5Z.js";import{o as ge,s as _e,t as ve}from"./ConfirmDialog.BYz4HREM.js";import{n as d}from"./i18n.BWX_-rcS.js";var f=e(t(),1),ye=`0.1.0`,p=u();function be(e){try{return new URL(e).host}catch{return``}}var xe=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],m=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,h=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Se({className:e=`w-3.5 h-3.5`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,p.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g({className:e=`w-4 h-4`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,p.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Ce({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function we({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,p.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,p.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Te({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,p.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,p.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function _({title:e,description:t,control:n}){return(0,p.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,p.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,p.jsx)(`div`,{className:`shrink-0`,children:n})]})}function v({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,p.jsxs)(me,{value:e,onChange:n,children:[(0,p.jsxs)(fe,{className:h,children:[(0,p.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,p.jsx)(Se,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,p.jsx)(he,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,p.jsxs)(pe,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function y(){let[e,t]=(0,f.useState)(!1),[u,h]=(0,f.useState)(`general`),[y,b]=(0,f.useState)([]),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(``),[Ee,D]=(0,f.useState)(`DeepSeek`),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(``),[M,N]=(0,f.useState)(``),[P,F]=(0,f.useState)([]),[I,L]=(0,f.useState)(`idle`),[De,R]=(0,f.useState)(!1),[Oe,z]=(0,f.useState)(`readonly`),[ke,Ae]=(0,f.useState)(!1),[je,B]=(0,f.useState)(!1),[Me,V]=(0,f.useState)(null),[H,U]=(0,f.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[W,G]=(0,f.useState)(`14`),K=(0,f.useRef)(0),q=C!==null,J=H.language,Y=y.find(e=>e.id===x),X=(Y?.name||``).trim(),Ne=X||(J===`en`?`No model`:`未配置`),Pe=X?Y?.model?.trim()?`${X} · ${Y.model.trim()}`:X:J===`en`?`No model configured`:`未配置模型`;function Fe(e=`general`){h(e),r().then(()=>{Z(),t(!0)})}function Z(){Ae(n()),b(re()),S(a()),B(!!o()),U(c()),le(c()),z(ce()),w(null)}function Ie(e){if(!e){let e=ee();w(e),E(`DeepSeek`),D(`DeepSeek`),k(`https://api.deepseek.com/v1`),j(``),N(``),F([]),L(`idle`),R(!1);return}w(e.id),E(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===a()?i().trim():``)||``;j(t),N(e.model),F(e.availableModels??[]),L(e.availableModels?.length?`ok`:`idle`),D(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),R(!1)}(0,f.useEffect)(()=>{r().then(()=>Z());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:`general`),r().then(()=>{Z(),t(!0)})};window.addEventListener(l,e);let n=ie(e=>U(e)),i=ue(e=>z(e));return()=>{window.removeEventListener(l,e),n(),i()}},[]),(0,f.useEffect)(()=>{if(!e||u!==`model`||!q)return;let t=O.trim(),n=A.trim();if(!t||!n){L(e=>e===`ok`?`ok`:`idle`);return}L(`loading`);let r=++K.current,i=setTimeout(()=>{te(t,n).then(e=>{r===K.current&&(F(e),L(`ok`))}).catch(()=>{r===K.current&&L(`fail`)})},800);return()=>clearTimeout(i)},[e,u,q,O,A]);function Le(e){D(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!T.trim()||s.some(e=>e.label===T))&&E(t.label)),N(``)}function Q(e){U(ae(e))}(0,f.useEffect)(()=>{G(String(H.sessionFontSize))},[H.sessionFontSize]);function Re(){let e=Number(W);if(!W.trim()||!Number.isFinite(e)){G(String(H.sessionFontSize));return}let t=ae({sessionFontSize:Math.round(e)});U(t),G(String(t.sessionFontSize))}let ze=!!(T.trim()&&O.trim()&&A.trim()&&M.trim()),$=P.length>0;function Be(){if(!ze||!C)return;let e=de({id:C,name:T.trim(),baseURL:O.trim(),apiKey:A.trim(),model:M.trim(),availableModels:$?P:void 0},{activate:!0});b(e),S(C),w(null),B(!!o())}function Ve(e){V(e)}function He(){let e=Me;if(!e)return;V(null);let t=se(e);b(t),S(a()),C===e&&w(null),B(!!o())}function Ue(e){ne(e),S(e),B(!!o())}let We=[{value:`readonly`,label:d(`settings.access.readonly`,void 0,J)},{value:`readwrite`,label:d(`settings.access.readwrite`,void 0,J)},{value:`full`,label:d(`settings.access.full`,void 0,J)}],Ge=[{value:`concise`,label:d(`settings.step.concise`,void 0,J)},{value:`standard`,label:d(`settings.step.standard`,void 0,J)},{value:`detailed`,label:d(`settings.step.detailed`,void 0,J)},{value:`full`,label:d(`settings.step.full`,void 0,J)}],Ke=[{value:`queue`,label:d(`settings.busySend.queue`,void 0,J)},{value:`interrupt`,label:d(`settings.busySend.interrupt`,void 0,J)}],qe=[{value:`light`,label:d(`settings.appear.light`,void 0,J),icon:`sun`},{value:`dark`,label:d(`settings.appear.dark`,void 0,J),icon:`moon`},{value:`system`,label:d(`settings.appear.system`,void 0,J),icon:`monitor`}],Je=[{id:`general`,label:d(`settings.general`,void 0,J),icon:(0,p.jsx)(Ce,{})},{id:`model`,label:d(`settings.model`,void 0,J),icon:(0,p.jsx)(we,{})}],Ye=u===`general`?d(`settings.general`,void 0,J):q?y.some(e=>e.id===C)?d(`settings.editProvider`,void 0,J):d(`settings.addProviderTitle`,void 0,J):d(`settings.model`,void 0,J);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(`general`),className:`tw-nav-settings-btn`,"data-hint":je?`设置(已配置模型)`:`设置`,children:[(0,p.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,p.jsx)(`span`,{"data-i18n":`nav.settings`,children:d(`nav.settings`,void 0,J)})]}),(0,p.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${X?``:` is-empty`}`,"data-hint":Pe,onClick:()=>Fe(`model`),children:[(0,p.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`tw-nav-provider-name`,children:Ne})]})]}),(0,p.jsx)(ge,{show:e,children:(0,p.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,p.jsx)(_e,{children:(0,p.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,p.jsx)(_e,{children:(0,p.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,p.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Ye}),(0,p.jsx)(`button`,{type:`button`,"aria-label":d(`settings.close`,void 0,J),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,p.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,p.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Je.map(e=>{let t=u===e.id;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&w(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,p.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:u===`general`?(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,p.jsx)(_,{title:d(`settings.access`,void 0,J),description:d(`settings.accessDesc`,void 0,J),control:(0,p.jsx)(v,{value:Oe,options:We,onChange:e=>{z(e),oe(e)}})}),(0,p.jsx)(_,{title:d(`settings.language`,void 0,J),control:(0,p.jsx)(v,{value:H.language,options:xe,onChange:e=>Q({language:e})})}),(0,p.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:d(`settings.appearance`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:qe.map(e=>{let t=H.appearance===e.value;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(Te,{kind:e.icon}),(0,p.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,p.jsx)(_,{title:d(`settings.fontSize`,void 0,J),description:d(`settings.fontSizeDesc`,void 0,J),control:(0,p.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,p.jsx)(`input`,{type:`number`,min:12,max:22,value:W,onChange:e=>G(e.target.value),onBlur:Re,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,p.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,p.jsx)(_,{title:d(`settings.toolSteps`,void 0,J),description:d(`settings.toolStepsDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.toolStepDetail,options:Ge,onChange:e=>Q({toolStepDetail:e})})}),(0,p.jsx)(_,{title:d(`settings.busySend`,void 0,J),description:d(`settings.busySendDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.busySendBehavior,options:Ke,onChange:e=>Q({busySendBehavior:e})})}),(0,p.jsx)(_,{title:d(`settings.subagentModel`,void 0,J),description:d(`settings.subagentModelDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.subagentModel?.trim()?H.subagentModel:`inherit`,options:[{value:`inherit`,label:d(`settings.subagentModel.inherit`,void 0,J)},...Array.from(new Set([...Y?.availableModels??[],...Y?.model?[Y.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100 flex items-center justify-between text-[11px] text-stone-400`,children:[(0,p.jsx)(`span`,{children:d(`settings.platformVersion`,void 0,J)}),(0,p.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[`v`,ye]})]})]}):q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:d(`settings.back`,void 0,J)})}),(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.displayName`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`DeepSeek`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.preset`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Ee===e.label;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Le(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,p.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?be(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.baseUrl`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.apiKey`,void 0,J)}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(`input`,{type:De?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`sk-...`,className:`${m} pr-14`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:De?J===`en`?`Hide`:`隐藏`:J===`en`?`Show`:`显示`})]}),ke?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:d(`settings.keyHint`,void 0,J)}):null]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:d(`settings.modelField`,void 0,J)}),I===`loading`&&(0,p.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:d(`settings.recognizing`,void 0,J)}),$&&I===`ok`&&(0,p.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:d(`settings.recognized`,{n:P.length},J)}),I===`fail`&&!$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeFail`,void 0,J)}),I===`fail`&&$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeKeep`,void 0,J)})]}),$?(0,p.jsxs)(me,{value:M,onChange:N,children:[(0,p.jsxs)(fe,{className:`${m} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,p.jsx)(`span`,{className:`truncate text-stone-800`,children:M||(J===`en`?`Select a model`:`请选择模型`)}),(0,p.jsx)(Se,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,p.jsx)(he,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:P.map(e=>(0,p.jsxs)(pe,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,p.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:d(`settings.modelPlaceholder`,void 0,J),className:m})]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:d(`settings.cancel`,void 0,J)}),(0,p.jsx)(`button`,{type:`button`,onClick:Be,disabled:!ze,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:d(`settings.save`,void 0,J)})]})]}):(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,p.jsx)(`p`,{className:`text-sm text-stone-500`,children:d(`settings.modelIntro`,void 0,J)}),(0,p.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[y.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===x;return(0,p.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-hint":n?J===`en`?`Active`:`当前使用`:J===`en`?`Set active`:`设为当前`,onClick:()=>Ue(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,p.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,p.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:d(`settings.edit`,void 0,J)}),y.length>1?(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ve(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:d(`settings.delete`,void 0,J)}):null]})]},e.id)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:d(`settings.addProvider`,void 0,J)})]})]})})]})]})})]})}),(0,p.jsx)(ve,{open:Me!=null,title:d(`settings.delete`,void 0,J),message:d(`settings.deleteConfirm`,void 0,J),confirmLabel:d(`settings.delete`,void 0,J),cancelLabel:J===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>V(null),onConfirm:He})]})}export{y as default};
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{a as n,i as r,n as i,s as ee}from"./app-config.CpjKWnzM.js";import{i as te}from"./llm.BZEzE0x2.js";import{_ as ne,a,c as re,d as ie,g as ae,h as oe,i as se,l as o,n as s,o as ce,r as le,s as c,t as l,u as ue,v as de}from"./settings.BoQ0e0m1.js";import{t as u}from"./jsx-runtime.BUXbF_vF.js";import{i as fe,n as pe,r as me,t as he}from"./listbox.DdDDDJ5Z.js";import{o as ge,s as _e,t as ve}from"./ConfirmDialog.BYz4HREM.js";import{n as d}from"./i18n.BVvhz-vw.js";var f=e(t(),1),ye=`0.1.1`,p=u();function be(e){try{return new URL(e).host}catch{return``}}var xe=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],m=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,h=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function Se({className:e=`w-3.5 h-3.5`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,p.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function g({className:e=`w-4 h-4`}){return(0,p.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,p.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Ce({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function we({className:e=`w-4 h-4`}){return(0,p.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,p.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,p.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Te({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,p.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,p.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,p.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,p.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,p.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function _({title:e,description:t,control:n}){return(0,p.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,p.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,p.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,p.jsx)(`div`,{className:`shrink-0`,children:n})]})}function v({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,p.jsxs)(me,{value:e,onChange:n,children:[(0,p.jsxs)(fe,{className:h,children:[(0,p.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,p.jsx)(Se,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,p.jsx)(he,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,p.jsxs)(pe,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,p.jsx)(`span`,{children:e.label}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function y(){let[e,t]=(0,f.useState)(!1),[u,h]=(0,f.useState)(`general`),[y,b]=(0,f.useState)([]),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(``),[Ee,D]=(0,f.useState)(`DeepSeek`),[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(``),[M,N]=(0,f.useState)(``),[P,F]=(0,f.useState)([]),[I,L]=(0,f.useState)(`idle`),[De,R]=(0,f.useState)(!1),[Oe,z]=(0,f.useState)(`readonly`),[ke,Ae]=(0,f.useState)(!1),[je,B]=(0,f.useState)(!1),[Me,V]=(0,f.useState)(null),[H,U]=(0,f.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[W,G]=(0,f.useState)(`14`),K=(0,f.useRef)(0),q=C!==null,J=H.language,Y=y.find(e=>e.id===x),X=(Y?.name||``).trim(),Ne=X||(J===`en`?`No model`:`未配置`),Pe=X?Y?.model?.trim()?`${X} · ${Y.model.trim()}`:X:J===`en`?`No model configured`:`未配置模型`;function Fe(e=`general`){h(e),r().then(()=>{Z(),t(!0)})}function Z(){Ae(n()),b(re()),S(a()),B(!!o()),U(c()),le(c()),z(ce()),w(null)}function Ie(e){if(!e){let e=ee();w(e),E(`DeepSeek`),D(`DeepSeek`),k(`https://api.deepseek.com/v1`),j(``),N(``),F([]),L(`idle`),R(!1);return}w(e.id),E(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===a()?i().trim():``)||``;j(t),N(e.model),F(e.availableModels??[]),L(e.availableModels?.length?`ok`:`idle`),D(s.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),R(!1)}(0,f.useEffect)(()=>{r().then(()=>Z());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:`general`),r().then(()=>{Z(),t(!0)})};window.addEventListener(l,e);let n=ie(e=>U(e)),i=ue(e=>z(e));return()=>{window.removeEventListener(l,e),n(),i()}},[]),(0,f.useEffect)(()=>{if(!e||u!==`model`||!q)return;let t=O.trim(),n=A.trim();if(!t||!n){L(e=>e===`ok`?`ok`:`idle`);return}L(`loading`);let r=++K.current,i=setTimeout(()=>{te(t,n).then(e=>{r===K.current&&(F(e),L(`ok`))}).catch(()=>{r===K.current&&L(`fail`)})},800);return()=>clearTimeout(i)},[e,u,q,O,A]);function Le(e){D(e);let t=s.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!T.trim()||s.some(e=>e.label===T))&&E(t.label)),N(``)}function Q(e){U(ae(e))}(0,f.useEffect)(()=>{G(String(H.sessionFontSize))},[H.sessionFontSize]);function Re(){let e=Number(W);if(!W.trim()||!Number.isFinite(e)){G(String(H.sessionFontSize));return}let t=ae({sessionFontSize:Math.round(e)});U(t),G(String(t.sessionFontSize))}let ze=!!(T.trim()&&O.trim()&&A.trim()&&M.trim()),$=P.length>0;function Be(){if(!ze||!C)return;let e=de({id:C,name:T.trim(),baseURL:O.trim(),apiKey:A.trim(),model:M.trim(),availableModels:$?P:void 0},{activate:!0});b(e),S(C),w(null),B(!!o())}function Ve(e){V(e)}function He(){let e=Me;if(!e)return;V(null);let t=se(e);b(t),S(a()),C===e&&w(null),B(!!o())}function Ue(e){ne(e),S(e),B(!!o())}let We=[{value:`readonly`,label:d(`settings.access.readonly`,void 0,J)},{value:`readwrite`,label:d(`settings.access.readwrite`,void 0,J)},{value:`full`,label:d(`settings.access.full`,void 0,J)}],Ge=[{value:`concise`,label:d(`settings.step.concise`,void 0,J)},{value:`standard`,label:d(`settings.step.standard`,void 0,J)},{value:`detailed`,label:d(`settings.step.detailed`,void 0,J)},{value:`full`,label:d(`settings.step.full`,void 0,J)}],Ke=[{value:`queue`,label:d(`settings.busySend.queue`,void 0,J)},{value:`interrupt`,label:d(`settings.busySend.interrupt`,void 0,J)}],qe=[{value:`light`,label:d(`settings.appear.light`,void 0,J),icon:`sun`},{value:`dark`,label:d(`settings.appear.dark`,void 0,J),icon:`moon`},{value:`system`,label:d(`settings.appear.system`,void 0,J),icon:`monitor`}],Je=[{id:`general`,label:d(`settings.general`,void 0,J),icon:(0,p.jsx)(Ce,{})},{id:`model`,label:d(`settings.model`,void 0,J),icon:(0,p.jsx)(we,{})}],Ye=u===`general`?d(`settings.general`,void 0,J):q?y.some(e=>e.id===C)?d(`settings.editProvider`,void 0,J):d(`settings.addProviderTitle`,void 0,J):d(`settings.model`,void 0,J);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Fe(`general`),className:`tw-nav-settings-btn`,"data-hint":je?`设置(已配置模型)`:`设置`,children:[(0,p.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,p.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,p.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,p.jsx)(`span`,{"data-i18n":`nav.settings`,children:d(`nav.settings`,void 0,J)})]}),(0,p.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${X?``:` is-empty`}`,"data-hint":Pe,onClick:()=>Fe(`model`),children:[(0,p.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`tw-nav-provider-name`,children:Ne})]})]}),(0,p.jsx)(ge,{show:e,children:(0,p.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,p.jsx)(_e,{children:(0,p.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,p.jsx)(_e,{children:(0,p.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,p.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Ye}),(0,p.jsx)(`button`,{type:`button`,"aria-label":d(`settings.close`,void 0,J),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,p.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,p.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,p.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Je.map(e=>{let t=u===e.id;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&w(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,p.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,p.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:u===`general`?(0,p.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,p.jsx)(_,{title:d(`settings.access`,void 0,J),description:d(`settings.accessDesc`,void 0,J),control:(0,p.jsx)(v,{value:Oe,options:We,onChange:e=>{z(e),oe(e)}})}),(0,p.jsx)(_,{title:d(`settings.language`,void 0,J),control:(0,p.jsx)(v,{value:H.language,options:xe,onChange:e=>Q({language:e})})}),(0,p.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:d(`settings.appearance`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:qe.map(e=>{let t=H.appearance===e.value;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(Te,{kind:e.icon}),(0,p.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,p.jsx)(_,{title:d(`settings.fontSize`,void 0,J),description:d(`settings.fontSizeDesc`,void 0,J),control:(0,p.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,p.jsx)(`input`,{type:`number`,min:12,max:22,value:W,onChange:e=>G(e.target.value),onBlur:Re,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,p.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,p.jsx)(_,{title:d(`settings.toolSteps`,void 0,J),description:d(`settings.toolStepsDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.toolStepDetail,options:Ge,onChange:e=>Q({toolStepDetail:e})})}),(0,p.jsx)(_,{title:d(`settings.busySend`,void 0,J),description:d(`settings.busySendDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.busySendBehavior,options:Ke,onChange:e=>Q({busySendBehavior:e})})}),(0,p.jsx)(_,{title:d(`settings.subagentModel`,void 0,J),description:d(`settings.subagentModelDesc`,void 0,J),control:(0,p.jsx)(v,{value:H.subagentModel?.trim()?H.subagentModel:`inherit`,options:[{value:`inherit`,label:d(`settings.subagentModel.inherit`,void 0,J)},...Array.from(new Set([...Y?.availableModels??[],...Y?.model?[Y.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100 flex items-center justify-between text-[11px] text-stone-400`,children:[(0,p.jsx)(`span`,{children:d(`settings.platformVersion`,void 0,J)}),(0,p.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[`v`,ye]})]})]}):q?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:d(`settings.back`,void 0,J)})}),(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.displayName`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`DeepSeek`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.preset`,void 0,J)}),(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map(e=>{let t=Ee===e.label;return(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Le(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,p.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,p.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?be(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.baseUrl`,void 0,J)}),(0,p.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:m})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:d(`settings.apiKey`,void 0,J)}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(`input`,{type:De?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`sk-...`,className:`${m} pr-14`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:De?J===`en`?`Hide`:`隐藏`:J===`en`?`Show`:`显示`})]}),ke?(0,p.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:d(`settings.keyHint`,void 0,J)}):null]}),(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:d(`settings.modelField`,void 0,J)}),I===`loading`&&(0,p.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:d(`settings.recognizing`,void 0,J)}),$&&I===`ok`&&(0,p.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:d(`settings.recognized`,{n:P.length},J)}),I===`fail`&&!$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeFail`,void 0,J)}),I===`fail`&&$&&(0,p.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:d(`settings.recognizeKeep`,void 0,J)})]}),$?(0,p.jsxs)(me,{value:M,onChange:N,children:[(0,p.jsxs)(fe,{className:`${m} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,p.jsx)(`span`,{className:`truncate text-stone-800`,children:M||(J===`en`?`Select a model`:`请选择模型`)}),(0,p.jsx)(Se,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,p.jsx)(he,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:P.map(e=>(0,p.jsxs)(pe,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e}),(0,p.jsx)(g,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,p.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:d(`settings.modelPlaceholder`,void 0,J),className:m})]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>w(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:d(`settings.cancel`,void 0,J)}),(0,p.jsx)(`button`,{type:`button`,onClick:Be,disabled:!ze,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:d(`settings.save`,void 0,J)})]})]}):(0,p.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,p.jsx)(`p`,{className:`text-sm text-stone-500`,children:d(`settings.modelIntro`,void 0,J)}),(0,p.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[y.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===x;return(0,p.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-hint":n?J===`en`?`Active`:`当前使用`:J===`en`?`Set active`:`设为当前`,onClick:()=>Ue(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,p.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,p.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:d(`settings.edit`,void 0,J)}),y.length>1?(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ve(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:d(`settings.delete`,void 0,J)}):null]})]},e.id)}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>Ie(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:d(`settings.addProvider`,void 0,J)})]})]})})]})]})})]})}),(0,p.jsx)(ve,{open:Me!=null,title:d(`settings.delete`,void 0,J),message:d(`settings.deleteConfirm`,void 0,J),confirmLabel:d(`settings.delete`,void 0,J),cancelLabel:J===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>V(null),onConfirm:He})]})}export{y as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{f as n,i as r}from"./app-config.CpjKWnzM.js";import{n as i}from"./llm.BZEzE0x2.js";import{t as a}from"./prompts-meta.F4wwkjUA.js";import{l as o}from"./settings.BoQ0e0m1.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{a as c,i as l,n as u,r as d,t as f}from"./ConfirmDialog.BYz4HREM.js";import{i as p,n as m,r as h,t as g}from"./menu.CqkL87bV.js";import{n as _}from"./i18n.BVvhz-vw.js";var v=e(t(),1),y=`/__tb_spaces`;async function b(e,t){try{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json();return n.ok?r:{ok:!1,error:r?.error||`请求失败(HTTP ${n.status})`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function x(e){try{return(await fetch(y,{signal:e??AbortSignal.timeout(2e3)})).ok}catch{return!1}}async function ee(e){try{let t=e?.stats?`${y}?stats=1`:y,r=await fetch(t);if(!r.ok)return null;let i=await r.json();return i?.activeId&&n(i.activeId),i}catch{return null}}async function S(e){let t=await b(`${y}/switch`,{id:e});return t.ok&&n(e),t}function C(e,t){return b(`${y}/create`,{name:e,managedParent:t?.managedParent,switch:t?.switch===!0,systemPrompt:t?.systemPrompt})}function te(e,t){return b(`${y}/rename`,{id:e,name:t})}function ne(e,t){return b(`${y}/copy`,{id:e,name:t})}function re(e,t){return b(`${y}/delete`,{id:e,purge:t,confirm:t===!0})}function ie(e,t=`full`){return`${y}/export?id=${encodeURIComponent(e)}${t===`content`?`&scope=content`:``}`}function w(e){return b(`${y}/discover`,Array.isArray(e)&&e.length?{adopt:e}:{})}async function ae(e,t){let n=await e.arrayBuffer(),r=new Uint8Array(n),i=``,a=32768;for(let e=0;e<r.length;e+=a)i+=String.fromCharCode(...r.subarray(e,e+a));let o=btoa(i);return b(`${y}/import`,{zipBase64:o,name:t})}function T(e){return e.isPublic?_(`space.publicName`):e.name}function E(e,t){let n=e.includes(`\\`)?`\\`:`/`,r=t.replace(/[/\\]+$/,``),i=`${r}${n}空间池`;if(e===i)return r;let a=`${i}${n}`;return e.startsWith(a)?`${r}${n}${e.slice(a.length)}`:e}function oe(e){if(!e||e<=0)return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return`${r<10&&n>0?r.toFixed(1):Math.round(r)} ${t[n]}`}var se=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
|
|
2
|
+
这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
|
|
3
|
+
要求:
|
|
4
|
+
- 用「你是…」起头设定角色;
|
|
5
|
+
- 紧扣用户描述的领域与工作方式;
|
|
6
|
+
- 写几条简洁的回答原则(问什么答什么、先结论);
|
|
7
|
+
- 只输出提示词正文,不要解释、不要标题。`;function ce(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var D=s();function le(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function O({hint:e,children:t}){return e?(0,D.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function k({open:e,onClose:t,onListChanged:s}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(``),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(null),[L,ue]=(0,v.useState)(``),[R,z]=(0,v.useState)(null),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)([]),[de,K]=(0,v.useState)({}),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null),q=(0,v.useRef)(null),[J,me]=(0,v.useState)(!1),Y=(0,v.useCallback)(async(e=!1)=>{e&&g(`stats`);let t=await ee({stats:e});e&&g(null),t?(m(t),s?.(t)):b(`无法读取数据空间列表(本地服务未运行?)`)},[s]),he=(0,v.useRef)(Y);(0,v.useEffect)(()=>{he.current=Y},[Y]);function X(){q.current?.abort()}(0,v.useEffect)(()=>{e?(b(``),S(``),P(``),he.current(!1)):X()},[e]),(0,v.useLayoutEffect)(()=>{let e=pe.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[j,e]);async function ge(){if(J||h!==null)return;let e=j.trim();if(!e){b(_(`space.promptNeedReq`));return}b(``);let t=new AbortController;q.current=t,me(!0);try{await r();let n=o();if(!n?.apiKey?.trim()||!n.model?.trim()||!n.baseURL?.trim()){b(_(`space.promptNeedModel`));return}let a=k.trim(),s=await i(n,[{role:`system`,content:se},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${e}`}],t.signal);if(t.signal.aborted)return;let c=ce(s);if(!c){b(_(`space.promptGenEmpty`));return}P(c)}catch(e){if(le(e)||t.signal.aborted)return;b(e instanceof Error?e.message:String(e))}finally{q.current===t&&(q.current=null),me(!1)}}async function Z(e){if(h!==null)return!1;let t=k.trim();if(!t)return b(_(`space.needName`)),!1;X();let r=N.trim();g(`create`),b(``);let i=await C(t,{switch:!0,...r?{systemPrompt:r}:{}});if(g(null),!i.ok)return b(i.error||_(`space.create`)+` 失败`),!1;let a=i.space?.id;return a&&n(a),window.location.reload(),!0}async function _e(){if($)return;let e=k.trim(),n=j.trim();!e&&!n?t():await Z({closeAfter:!0})}async function ve(){if(!F)return;let e=L.trim();if(!e)return;g(`rename`),b(``);let t=await te(F.id,e);g(null),t.ok?(I(null),await Y(!1)):b(t.error||`重命名失败`)}async function ye(){if(!B)return;let e=H.trim();if(!e)return;g(`copy`),b(``);let t=await ne(B.id,e);g(null),t.ok?(V(null),S(`已复制为「${t.space?.name}」`),await Y(!1)):b(t.error||`复制失败`)}async function be(e,t){g(`delete`),b(``);let r=await re(e.id,t);g(null),r.ok?(z(null),e.isActive?(n(`public`),window.location.reload()):(S(r.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))):b(r.error||`删除失败`)}async function xe(){g(`discover`),b(``),S(``),G([]);let e=await w();if(g(null),!e.ok){b(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(_(`space.discoverAdded`,{n:t})):i.length||a.push(_(`space.discoverNone`)),n&&a.push(_(`space.discoverBackfilled`,{n})),r&&a.push(_(`space.discoverSkipped`,{n:r})),S(a.join(`;`)),G(i),K(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function Se(){let e=W.filter(e=>de[e.path]).map(e=>e.path);if(!e.length){G([]),S(_(`space.candidatesIgnored`));return}g(`discover`),b(``);let t=await w(e);if(g(null),!t.ok){b(t.error||`纳入失败`);return}G([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?_(`space.candidatesAdopted`,{n}):_(`space.candidatesIgnored`)];r.length&&i.push(_(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),S(i.join(`;`)),await Y(!1)}async function Ce(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;g(`import`),b(``);let n=await ae(t);g(null),n.ok?(S(`已导入为「${n.space?.name}」`),await Y(!1)):b(n.error||`导入失败`)}let we=p?.spaces??[],Q=p?.baseRoot,$=h!==null,Te=!!j.trim()&&!$&&!J;return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(l,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-3xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col max-h-[86vh]`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.manageTitle`)}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:_(`space.manageDesc`)})]}),(0,D.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel shrink-0 w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`mb-5`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-2`,children:_(`space.newTitle`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Z())},placeholder:_(`space.namePlaceholder`),className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`}),(0,D.jsx)(`button`,{type:`button`,disabled:!k.trim()||$,onClick:()=>void Z(),className:`h-9 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`create`?`…`:_(`space.create`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>fe.current?.click(),className:`h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:h===`import`?`…`:_(`space.import`)}),(0,D.jsx)(`input`,{ref:fe,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void Ce(e)})]}),p?(0,D.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,D.jsx)(`code`,{children:E(p.dataRoot,p.baseRoot)})}):null,(0,D.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:_(`space.promptBriefLabel`)}),(0,D.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,D.jsx)(`textarea`,{ref:pe,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),J){X();return}Te&&ge()}},placeholder:_(`space.promptBriefPlaceholder`),rows:1,disabled:$,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,D.jsx)(`span`,{className:`flex-1`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{J?X():ge()},disabled:!J&&!Te,"aria-label":_(J?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${J?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:J?(0,D.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,D.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,D.jsx)(`path`,{d:`M12 19V5`})]})})]})]}),(0,D.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,D.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:_(`space.promptHint`)}),J?(0,D.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[_(`space.promptGeneratingStatus`),(0,D.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,D.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,D.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:_(`space.promptBodyLabel`)}),(0,D.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:a})]}),(0,D.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:_(`space.promptBodyPlaceholder`),rows:6,disabled:$,className:`w-full min-h-30 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`})]})]}),y?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,D.jsx)(`span`,{className:`flex-1 min-w-0`,children:y}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>b(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,x?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,D.jsx)(`span`,{className:`flex-1 min-w-0`,children:x}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,W.length?(0,D.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:_(`space.candidatesTitle`,{n:W.length})}),(0,D.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:_(`space.candidatesHint`)}),(0,D.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:W.map(e=>(0,D.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:de[e.path]===!0,onChange:t=>K(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,D.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,D.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?E(e.path,Q):e.path})]})]},e.path))}),(0,D.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>K(Object.fromEntries(W.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:_(`space.candidatesSelectAll`)}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>K({}),className:`text-[11px] text-stone-500 hover:underline`,children:_(`space.candidatesClear`)}),(0,D.jsx)(`span`,{className:`flex-1`}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{G([]),K({}),S(_(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:_(`space.candidatesIgnore`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Se(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:_(`space.candidatesAdopt`)})]})]}):null,(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,D.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:_(`space.listTitle`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void xe(),"data-hint":_(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:_(h===`discover`?`space.discovering`:`space.discover`)}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":_(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:_(h===`stats`?`space.sizing`:`space.size`)})]})]}),(0,D.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:we.length===0?(0,D.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-stone-400`,children:_(`space.empty`)}):we.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:T(e)}),e.isPublic?(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:_(`space.builtin`)}):null,e.isActive?(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:_(`space.activeTag`)}):null,e.exists?null:(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:_(`space.missing`)}),e.bytes==null?null:(0,D.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:oe(e.bytes)})]}),(0,D.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?E(e.path,Q):e.path,"data-hint-always":``,children:Q?E(e.path,Q):e.path})]}),(0,D.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>{I(e),ue(e.name)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.rename`)})}),(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{V(e),U(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:_(`space.copy`)}),(0,D.jsx)(`a`,{href:ie(e.id,`content`),"data-hint":_(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:_(`space.exportContent`)}),(0,D.jsx)(`a`,{href:ie(e.id,`full`),"data-hint":_(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:_(`space.exportFull`)}),(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>z({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.removeList`)})}),(0,D.jsx)(O,{hint:e.removable?void 0:_(`space.publicLocked`),children:(0,D.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>z({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:_(`space.deleteDisk`)})})]})]},e.id))})]}),(0,D.jsx)(`div`,{className:`flex justify-end gap-2 px-5 py-3 border-t border-stone-200`,children:(0,D.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void _e(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`create`?`…`:_(`space.done`)})})]})})]}),(0,D.jsxs)(l,{open:F!==null,onClose:()=>I(null),transition:!0,className:`relative z-96`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.rename`)}),(0,D.jsx)(`input`,{autoFocus:!0,value:L,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ve())},className:`mt-4 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`}),(0,D.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:`取消`}),(0,D.jsx)(`button`,{type:`button`,disabled:!L.trim()||$,onClick:()=>void ve(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`rename`?`…`:`确定`})]})]})})]}),(0,D.jsxs)(l,{open:B!==null,onClose:()=>V(null),transition:!0,className:`relative z-96`,children:[(0,D.jsx)(u,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,D.jsxs)(c,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,D.jsx)(d,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:_(`space.confirmCopyTitle`)}),(0,D.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:_(`space.confirmCopyMsg`,{name:B?.name??``})}),(0,D.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[_(`space.copyName`),(0,D.jsx)(`input`,{autoFocus:!0,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ye())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,D.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>V(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:`取消`}),(0,D.jsx)(`button`,{type:`button`,disabled:!H.trim()||$,onClick:()=>void ye(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:h===`copy`?`…`:_(`space.copy`)})]})]})})]}),(0,D.jsx)(f,{open:R?.kind===`remove`,title:_(`space.confirmRemoveTitle`),message:R?.kind===`remove`?_(`space.confirmRemoveMsg`,{name:R.space.name,path:R.space.path}):``,confirmLabel:_(`space.removeList`),onClose:()=>z(null),onConfirm:()=>{R?.kind===`remove`&&be(R.space,!1)}}),(0,D.jsx)(f,{open:R?.kind===`delete`,title:_(`space.confirmDeleteTitle`),message:R?.kind===`delete`?_(`space.confirmDeleteMsg`,{name:R.space.name,path:R.space.path}):``,confirmLabel:_(`space.deleteDisk`),danger:`solid`,onClose:()=>z(null),onConfirm:()=>{R?.kind===`delete`&&be(R.space,!0)}})]})}var A=`tw.spaces.list.v1`;function j(){try{let e=sessionStorage.getItem(A);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function M(e){try{sessionStorage.setItem(A,JSON.stringify(e))}catch{}}function N(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function P(){let e=j(),[t,n]=(0,v.useState)(e!==null),[r,i]=(0,v.useState)(e!==null),[a,o]=(0,v.useState)(e),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return(async()=>{let t=await x();if(!e)return;if(i(!0),!t){n(!1),N(!0);return}N(!1),n(!0);let r=await ee();e&&r&&(o(r),M(r))})(),()=>{e=!1}},[]);async function y(e){if(e===a?.activeId)return;u(!0),f(``);let t=await S(e);t.ok?(a&&M({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),window.location.reload()):(u(!1),f(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,D.jsx)(`div`,{className:`tw-nav-space`,children:(0,D.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,D.jsx)(F,{})}),(0,D.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-cap`,children:_(`space.offlineCap`)}),(0,D.jsx)(`span`,{className:`tw-nav-space-name`,children:_(`space.offline`)})]})]})});let b=a?.spaces.find(e=>e.isActive),C=(a?.spaces??[]).filter(e=>!e.isActive);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`tw-nav-space`,children:(0,D.jsxs)(h,{as:`div`,className:`tw-nav-space-menu`,children:[(0,D.jsxs)(g,{className:`tw-nav-space-btn`,"data-hint":_(`space.label`),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,D.jsx)(F,{})}),(0,D.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,D.jsx)(`span`,{className:`tw-nav-space-cap`,children:_(`space.current`)}),(0,D.jsx)(`span`,{className:`tw-nav-space-name`,children:l?_(`space.switching`):b?T(b):`—`})]}),(0,D.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,D.jsxs)(p,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[d?(0,D.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:d}):null,(0,D.jsx)(`div`,{className:`tw-nav-space-group`,children:_(`space.others`)}),C.length===0?(0,D.jsx)(`p`,{className:`tw-nav-space-hint`,children:_(`space.othersEmpty`)}):C.map(e=>(0,D.jsx)(m,{children:(0,D.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:l,onClick:()=>void y(e.id),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,D.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":T(e),children:T(e)})}),(0,D.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,D.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,D.jsx)(m,{children:(0,D.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,D.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,D.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,D.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]})}),(0,D.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,D.jsx)(`span`,{className:`tw-nav-space-item-name`,children:_(`space.manage`)})}),(0,D.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,D.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,D.jsx)(k,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),M(e)}})]})}function F(){return(0,D.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,D.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,D.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,D.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{P as default};
|