@jonathanleelx/meddle 0.4.5-beta.3 → 0.4.5-beta.5
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/package.json +1 -1
- package/web/dist/assets/{checkbox-PKkvo6cn.js → checkbox-ChXVVrCY.js} +1 -1
- package/web/dist/assets/clipboard-Dz6MgwV-.js +1 -0
- package/web/dist/assets/{code-fixer-CXlb1cN3.js → code-fixer-BfjDVuBA.js} +1 -1
- package/web/dist/assets/detail-panel-CIvk7olQ.js +4 -0
- package/web/dist/assets/{global-panel-shell-PTg7xaym.js → global-panel-shell-DQOnNe3D.js} +1 -1
- package/web/dist/assets/{health-panel-pdzWYSTh.js → health-panel-BfxXtLWw.js} +1 -1
- package/web/dist/assets/{index-BB8Kl9wK.js → index-B8P4vdT0.js} +2 -2
- package/web/dist/assets/index-DQtOwhpd.css +2 -0
- package/web/dist/assets/{mobile-proxy-panel-C3uLDCci.js → mobile-proxy-panel-BCimHuOG.js} +1 -1
- package/web/dist/assets/{mock-config-BUPDw5l6.js → mock-config-ClD9lXXU.js} +1 -1
- package/web/dist/assets/{mock-editor-panel-Cd-IcUfX.js → mock-editor-panel-BMRCZ8_O.js} +1 -1
- package/web/dist/assets/{monaco-editor-CUsyh0Fx.js → monaco-editor-Bumwz1AX.js} +1 -1
- package/web/dist/assets/{plugin-code-editor-B1s07F0K.js → plugin-code-editor-Bi1mmhpZ.js} +1 -1
- package/web/dist/assets/{plugin-config-CZvH0XnM.js → plugin-config-CRdXibi4.js} +1 -1
- package/web/dist/assets/{plugin-generator-BzYQZ63A.js → plugin-generator-CqupwkDE.js} +1 -1
- package/web/dist/assets/{plugin-test-dialog-D0PKIfXW.js → plugin-test-dialog-CmosZ5Dn.js} +1 -1
- package/web/dist/assets/{route-preview-Bpay16um.js → route-preview-DdQpN7oC.js} +1 -1
- package/web/dist/assets/{rule-ai-assistant-panel-B3zTS8S3.js → rule-ai-assistant-panel-jNusgNtU.js} +1 -1
- package/web/dist/assets/{rule-config-DpHCgvVh.js → rule-config-zRM53JYS.js} +1 -1
- package/web/dist/assets/{select-DozhHbSJ.js → select-hRbutLaS.js} +1 -1
- package/web/dist/assets/{settings-panel-BiXW0HbO.js → settings-panel-CbZ-_Gge.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/clipboard-DmLDmwss.js +0 -1
- package/web/dist/assets/detail-panel-Ctl9eso1.js +0 -4
- package/web/dist/assets/index-Lpo4FZtf.css +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,f as t,t as n,u as r}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as i}from"./circle-x-C9USji_R.js";import{t as a}from"./code-5_eJ_XpJ.js";import{t as o}from"./copy-BYjq1hdN.js";import{t as s}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{o as ee,r as te}from"./ai-config-store-DQXVJVn_.js";import{$ as ne,A as c,X as l,_ as re,b as u,d as ie,f as ae,g as oe,h as se,m as d,mt as ce,ot as f,p as le,pt as ue,u as p,v as de,y as fe,z as m}from"./index-
|
|
1
|
+
import{a as e,f as t,t as n,u as r}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as i}from"./circle-x-C9USji_R.js";import{t as a}from"./code-5_eJ_XpJ.js";import{t as o}from"./copy-BYjq1hdN.js";import{t as s}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{o as ee,r as te}from"./ai-config-store-DQXVJVn_.js";import{$ as ne,A as c,X as l,_ as re,b as u,d as ie,f as ae,g as oe,h as se,m as d,mt as ce,ot as f,p as le,pt as ue,u as p,v as de,y as fe,z as m}from"./index-B8P4vdT0.js";import{t as pe}from"./textarea-vuxJwU0x.js";var h=t(r(),1),g=e();function _({open:e=!1,onOpenChange:t,embedded:r=!1,onPluginSaved:_}){let[v,y]=(0,h.useState)(``),[b,x]=(0,h.useState)(``),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(``),[E,D]=(0,h.useState)(!1),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(``),[P,F]=(0,h.useState)(null),[I,L]=(0,h.useState)(null),[R,z]=(0,h.useState)(``),[me,B]=(0,h.useState)(!1),[V,H]=(0,h.useState)(0),[U,W]=(0,h.useState)(0),[G,K]=(0,h.useState)(!1),[q,J]=(0,h.useState)(!1),Y=te(),X=ee(Y),he=async()=>{if(!v.trim()||!b.trim()){L(`error`),z(`请填写插件名称和描述`);return}if(!X){L(`error`),z(`AI 配置未完成,请先配置 AI 服务`);return}D(!0),L(null),z(`正在连接 AI 服务...`),j(``),H(0),W(0);let e=Date.now(),t=0;try{let n={name:v,description:b,hooks:S.split(`,`).map(e=>e.trim()).filter(Boolean),permissions:w.split(`,`).map(e=>e.trim()).filter(Boolean)},r=await fetch(`/api/plugins/generate-stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({requirement:n,aiConfig:{provider:Y.provider,apiKey:Y.apiKey,baseUrl:Y.baseUrl,model:Y.model}})});if(!r.ok)throw Error(`请求失败: ${r.status}`);let i=r.body?.getReader(),a=new TextDecoder;if(!i)throw Error(`无法读取响应流`);let o=``;for(;;){let{done:n,value:r}=await i.read();if(n)break;o+=a.decode(r,{stream:!0});let s=o.split(`
|
|
2
2
|
`);o=s.pop()||``;for(let n of s)if(!n.startsWith(`event:`)&&n.startsWith(`data:`)){let r=n.slice(5).trim();try{let n=JSON.parse(r);if(n.status===`generating`)z(`AI 正在生成代码...`),W(10);else if(n.chunk){t++;let r=n.accumulated||n.chunk;j(r),H(r.length),W(Math.min(90,10+t*2));let i=((Date.now()-e)/1e3).toFixed(1);z(`生成中... (${r.length} 字符, ${i}s)`)}else if(n.status===`success`){j(n.plugin.code),N(n.plugin.filename),F(n.plugin.manifest),H(n.plugin.code.length),W(100),L(`success`);let t=((Date.now()-e)/1e3).toFixed(1);z(`插件代码生成成功!(${n.plugin.code.length} 字符, ${t}s)`)}else if(n.error)throw Error(n.error)}catch(e){if(e instanceof Error&&e.message!==`Unexpected end of JSON input`)throw e}}}}catch(e){L(`error`),z(e instanceof Error?e.message:`生成失败`),W(0)}finally{D(!1)}},Z=async()=>{if(!A||!M){L(`error`),z(`没有可保存的插件代码`);return}k(!0),L(null),z(`正在保存插件...`);try{let e=await fetch(`/api/plugins/save`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({filename:M,code:A})});if(!e.ok){let t=await e.json();throw Error(t.error||`保存失败`)}await e.json(),L(`success`),z(`插件已保存!现在可以热加载并测试。`),K(!0),window.dispatchEvent(new CustomEvent(`plugins-custom-updated`)),p.success(`插件保存成功`),_&&_(),window.dispatchEvent(new CustomEvent(`plugins-custom-updated`))}catch(e){let t=e instanceof Error?e.message:`保存失败`;L(`error`),z(t),p.error(t)}finally{k(!1)}};ie({active:(e||r)&&!!A&&!G,enabled:!O&&!E&&!!M,priority:ae.panel,onSave:Z});let ge=async()=>{A&&(await navigator.clipboard.writeText(A),B(!0),setTimeout(()=>B(!1),2e3))},_e=async()=>{J(!0);try{let e=await fetch(`/api/plugins/reload`,{method:`POST`});if(!e.ok){let t=await e.json();throw Error(t.error||`热加载失败`)}let n=await e.json();L(`success`),z(`成功热加载 ${n.count} 个插件!插件已激活,可以使用了。`),_&&_(),setTimeout(()=>{t?.(!1),Q()},3e3)}catch(e){L(`error`),z(e instanceof Error?e.message:`热加载失败`)}finally{J(!1)}},Q=()=>{y(``),x(``),C(``),T(``),j(``),N(``),F(null),L(null),z(``),B(!1),H(0),W(0),K(!1),J(!1)},$=(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(de,{className:`px-6 pt-6 pb-4`,children:[(0,g.jsxs)(fe,{className:`flex items-center gap-2`,children:[(0,g.jsx)(l,{className:`h-5 w-5`}),`AI 插件生成器`]}),(0,g.jsx)(re,{children:`使用 AI 根据插件系统设计和您的需求自动生成自定义插件代码`})]}),(0,g.jsx)(d,{}),(0,g.jsxs)(`div`,{className:`app-panel-content`,children:[!X&&(0,g.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-950/20 border border-yellow-200 dark:border-yellow-900 rounded-md p-3`,children:(0,g.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300`,children:`AI 功能未配置或未启用,请先在设置中配置 AI 服务`})}),(0,g.jsxs)(`div`,{className:`app-section`,children:[(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsxs)(u,{htmlFor:`pluginName`,children:[`插件名称 `,(0,g.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,g.jsx)(c,{id:`pluginName`,value:v,onChange:e=>y(e.target.value),placeholder:`例如:请求日志分析器`,disabled:E||O})]}),(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsxs)(u,{htmlFor:`pluginDescription`,children:[`插件描述 `,(0,g.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,g.jsx)(pe,{id:`pluginDescription`,value:b,onChange:e=>x(e.target.value),placeholder:`详细描述插件的功能,例如:分析HTTP请求日志,统计各个API的调用次数、响应时间等信息,并在控制台输出统计报告`,rows:4,disabled:E||O})]}),(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsx)(u,{htmlFor:`hooks`,children:`需要的 Hooks(可选,用逗号分隔)`}),(0,g.jsx)(c,{id:`hooks`,value:S,onChange:e=>C(e.target.value),placeholder:`例如:onRequestStart, onAfterResponse`,disabled:E||O}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`可选:onRequestStart, onBeforeProxy, onBeforeResponse, onAfterResponse, onError`})]}),(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsx)(u,{htmlFor:`permissions`,children:`需要的权限(可选,用逗号分隔)`}),(0,g.jsx)(c,{id:`permissions`,value:w,onChange:e=>T(e.target.value),placeholder:`例如:proxy:read, storage:write`,disabled:E||O}),(0,g.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`可选:proxy:read, proxy:write, response:shortcircuit, storage:read, storage:write`})]})]}),E&&U>0&&(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:`生成进度`}),(0,g.jsxs)(`span`,{className:`font-medium`,children:[U,`%`]})]}),(0,g.jsx)(`div`,{className:`w-full bg-muted rounded-full h-2 overflow-hidden`,children:(0,g.jsx)(`div`,{className:`bg-primary h-full transition-all duration-300 ease-out`,style:{width:`${U}%`}})})]}),(A||E)&&(0,g.jsxs)(`div`,{className:`app-field-group`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(a,{className:`h-4 w-4`}),E?`正在生成插件代码`:`生成的插件代码`]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[V>0&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[V,` 字符`]}),!E&&A&&(0,g.jsx)(n,{variant:`ghost`,size:`sm`,onClick:ge,className:`h-8`,children:me?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ce,{className:`h-4 w-4 mr-1`}),`已复制`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(o,{className:`h-4 w-4 mr-1`}),`复制`]})})]})]}),(0,g.jsxs)(`div`,{className:`bg-muted rounded-md p-4 max-h-[400px] overflow-auto relative`,children:[E&&(0,g.jsx)(`div`,{className:`absolute top-2 right-2`,children:(0,g.jsx)(f,{className:`h-4 w-4 animate-spin text-muted-foreground`})}),(0,g.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-all`,children:A||`等待 AI 响应...`})]}),P&&(0,g.jsxs)(`div`,{className:`bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-900 rounded-md p-3 space-y-2`,children:[(0,g.jsx)(`p`,{className:`text-sm font-medium text-blue-900 dark:text-blue-100`,children:`插件信息`}),(0,g.jsxs)(`div`,{className:`text-xs space-y-1 text-blue-700 dark:text-blue-300`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`strong`,{children:`ID:`}),` `,P.id]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`strong`,{children:`名称:`}),` `,P.name]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`strong`,{children:`版本:`}),` `,P.version]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`strong`,{children:`Hooks:`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:P.hooks.map(e=>(0,g.jsx)(m,{variant:`secondary`,className:`text-xs`,children:e},e))})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`strong`,{children:`权限:`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:P.permissions.map(e=>(0,g.jsx)(m,{variant:`outline`,className:`text-xs`,children:e},e))})]})]})]})]}),R&&(0,g.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-md border ${I===`success`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:I===`error`?`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`:`bg-blue-50 dark:bg-blue-950/20 border-blue-200 dark:border-blue-900`}`,children:[I===`success`&&(0,g.jsx)(ue,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5`}),I===`error`&&(0,g.jsx)(i,{className:`h-4 w-4 text-red-600 dark:text-red-400 mt-0.5`}),E&&(0,g.jsx)(f,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 mt-0.5 animate-spin`}),(0,g.jsx)(`span`,{className:`text-xs flex-1 ${I===`success`?`text-green-700 dark:text-green-300`:I===`error`?`text-red-700 dark:text-red-300`:`text-blue-700 dark:text-blue-300`}`,children:R})]})]}),(0,g.jsx)(d,{}),(0,g.jsxs)(`div`,{className:`px-6 py-4 flex justify-between gap-2`,children:[(0,g.jsx)(n,{variant:`outline`,size:`sm`,onClick:()=>{t?.(!1),Q()},disabled:E||O||q,children:G?`完成`:`取消`}),(0,g.jsx)(`div`,{className:`flex gap-2`,children:A?G?(0,g.jsx)(n,{size:`sm`,onClick:_e,disabled:q,className:`bg-green-600 hover:bg-green-700`,children:q?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{className:`h-4 w-4 mr-1 animate-spin`}),`加载中...`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l,{className:`h-4 w-4 mr-1`}),`热加载并测试`]})}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(n,{variant:`outline`,size:`sm`,onClick:()=>{j(``),N(``),F(null),L(null),z(``)},disabled:E||O,children:`重新生成`}),(0,g.jsx)(le,{size:`sm`,onClick:Z,disabled:O,children:O?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{"data-icon":`inline-start`,className:`animate-spin`}),`保存中...`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(ne,{"data-icon":`inline-start`}),`保存插件`]})})]}):(0,g.jsx)(n,{size:`sm`,onClick:he,disabled:!X||E||O||!v.trim()||!b.trim(),children:E?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(f,{className:`h-4 w-4 mr-1 animate-spin`}),`生成中...`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(s,{className:`h-4 w-4 mr-1`}),`生成插件`]})})})]})]});return r?(0,g.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:$}):(0,g.jsx)(se,{open:e,onOpenChange:e=>{t?.(e),e||Q()},children:(0,g.jsx)(oe,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:900,storageKey:`plugin-generator`,children:$})})}export{_ as PluginGenerator};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{t as o}from"./circle-alert-Q8cZk9Rv.js";import{t as s}from"./circle-x-C9USji_R.js";import{t as ee}from"./pencil-line-Cqe41E4h.js";import{t as c}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{i as ne,o as re,r as ie}from"./ai-config-store-DQXVJVn_.js";import{A as ae,B as l,H as u,U as d,_ as oe,b as f,ft as se,g as ce,h as le,lt as ue,m as p,ot as m,pt as de,q as h,st as fe,v as pe,y as me,z as g}from"./index-BB8Kl9wK.js";import{t as _}from"./body-diff-view-D7dCWajG.js";import{n as he,t as ge}from"./monaco-editor-CUsyh0Fx.js";import{t as _e}from"./textarea-vuxJwU0x.js";var ve=n(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=t(i(),1),y=e();function b(e){let t=new Map;return!e||typeof e!=`object`||Object.entries(e).forEach(([e,n])=>{t.set(e.toLowerCase(),{displayKey:e,value:n==null?``:String(n)})}),t}function x(e,t){let n=b(e),r=b(t);return Array.from(new Set([...n.keys(),...r.keys()])).sort().map(e=>{let t=n.get(e),i=r.get(e),a=t?.value??``,o=i?.value??``,s=`unchanged`;return!t&&i?s=`added`:t&&!i?s=`removed`:a!==o&&(s=`changed`),{key:e,displayKey:i?.displayKey??t?.displayKey??e,originalValue:a,modifiedValue:o,status:s}})}function S(e,t){let n=`rounded-md border px-2 py-1.5`;return e===`unchanged`?`${n} border-transparent`:e===`changed`?`${n} border-orange-300 bg-orange-500/10`:e===`added`?t===`modified`?`${n} border-green-300 bg-green-500/10`:`${n} border-transparent opacity-50`:e===`removed`?t===`original`?`${n} border-red-300 bg-red-500/10`:`${n} border-transparent opacity-50`:n}function ye({original:e,modified:t,mode:n=`split`}){let r=x(e,t);return n===`inline`?(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border px-2 py-1.5 ${e.status===`unchanged`?`border-transparent`:e.status===`changed`?`border-orange-300 bg-orange-500/10`:e.status===`added`?`border-green-300 bg-green-500/10`:`border-red-300 bg-red-500/10`}`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.displayKey}),(0,y.jsx)(g,{variant:`outline`,className:`h-5 px-1.5 text-[10px] font-normal`,children:e.status===`unchanged`?`未变`:e.status===`changed`?`修改`:e.status===`added`?`新增`:`删除`})]}),e.status===`changed`&&(0,y.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,y.jsxs)(`div`,{className:`text-red-700 dark:text-red-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`-`}),e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),(0,y.jsxs)(`div`,{className:`text-green-700 dark:text-green-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`+`}),e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]})]}),e.status===`added`&&(0,y.jsxs)(`div`,{className:`mt-1 text-green-700 dark:text-green-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`+`}),e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),e.status===`removed`&&(0,y.jsxs)(`div`,{className:`mt-1 text-red-700 dark:text-red-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`-`}),e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),e.status===`unchanged`&&(0,y.jsx)(`div`,{className:`mt-1`,children:e.modifiedValue||e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})})]},e.key))}):(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:`原始`}),(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:S(e.status,`original`),children:[(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.displayKey,`:`]}),` `,e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]},`original-${e.key}`))})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:`修改后`}),(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:S(e.status,`modified`),children:[(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.displayKey,`:`]}),` `,e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]},`modified-${e.key}`))})]})]})}function be(e){switch(e){case`generating`:return`AI 正在流式生成修复代码`;case`saving`:return`正在保存修复后的插件代码`;case`reloading`:return`正在热加载插件`;case`retesting`:return`正在重新执行插件测试`;default:return``}}function C({open:e=!1,onOpenChange:t,embedded:n=!1,pluginId:i,pluginName:b,hooks:x,onPluginFixed:S}){let[C,xe]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),[Se,Ce]=(0,v.useState)(`https://365.wps.cn/home`),[we,Te]=(0,v.useState)(`GET`),[E,D]=(0,v.useState)(`standalone`),[O,k]=(0,v.useState)(null),[A,Ee]=(0,v.useState)(`split`),[j,De]=(0,v.useState)(`inline`),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(``),[R,Oe]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(``),[ke,U]=(0,v.useState)(`normal`),[W,Ae]=(0,v.useState)(``),[G,K]=(0,v.useState)(`idle`),q=ie(),J=ne(q),je=J?{provider:J.provider,apiKey:J.apiKey,baseUrl:J.baseUrl,model:J.model}:{provider:q.provider,apiKey:q.apiKey,baseUrl:q.baseUrl,model:q.model},Y=re(q),X=i.startsWith(`local.`)?`${i.slice(6)}.js`:``,Z=(0,v.useCallback)(async()=>{if(!X||!e){F(``),L(``),B(null);return}Oe(!0),B(null);try{let e=await fetch(`/api/plugins/custom/${encodeURIComponent(X)}/code`);if(!e.ok){let t=await e.json();throw Error(t.error||`读取插件源码失败`)}let t=await e.json();F(t.code||``),!w&&!V&&L(t.code||``)}catch(e){F(``),L(``),B(e instanceof Error?e.message:`读取插件源码失败`)}finally{Oe(!1)}},[X,w,V,e]);(0,v.useEffect)(()=>{Z()},[Z]);let Q=(0,v.useMemo)(()=>{let e=[];return O?.error&&e.push({hookName:`test`,message:O.error}),Object.entries(O?.hookResults||{}).forEach(([t,n])=>{n?.status===`error`&&e.push({hookName:t,message:n.error||`未知错误`,stack:n.stack})}),O?.realRequest?.fetchError&&e.push({hookName:`fetch`,message:O.realRequest.fetchError}),e},[O]),Me=Q.length>0&&!!X,Ne=!!I&&!!(V||G===`idle`&&I&&P&&I!==P),Pe=async(e,t,n)=>{K(`saving`);let r=await fetch(`/api/plugins/custom/${encodeURIComponent(X)}/code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e})});if(!r.ok){let e=await r.json();throw Error(e.error||`保存修复后的代码失败`)}K(`reloading`);let i=await fetch(`/api/plugins/reload`,{method:`POST`});if(!i.ok){let e=await i.json().catch(()=>({error:`热加载失败`}));throw Error(e.error||`热加载失败`)}F(e),H(e),U(`diff`),window.dispatchEvent(new CustomEvent(`plugins-custom-updated`)),S?.(),n&&(K(`retesting`),await Fe()),N({status:`success`,message:t}),K(`idle`)},Fe=async()=>{xe(!0),k(null),N(null);try{let e=await fetch(`/api/plugins/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pluginId:i,url:Se,method:we,integrated:E===`integrated`})});if(!e.ok){let t=await e.json();throw Error(t.error||`测试失败`)}k((await e.json()).results)}catch(e){k({error:e instanceof Error?e.message:`测试失败`})}finally{xe(!1)}},$=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(pe,{className:`px-6 pt-6 pb-4`,children:[(0,y.jsxs)(me,{className:`flex items-center gap-2`,children:[(0,y.jsx)(h,{className:`h-5 w-5`}),`测试插件: `,b]}),(0,y.jsx)(oe,{children:`发起真实 HTTP 请求,在请求/响应过程中运行插件代码`})]}),(0,y.jsx)(p,{}),(0,y.jsxs)(`div`,{className:`app-panel-content`,children:[(0,y.jsxs)(`div`,{className:`app-section`,children:[(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{htmlFor:`testUrl`,children:`请求 URL`}),(0,y.jsx)(ae,{id:`testUrl`,value:Se,onChange:e=>Ce(e.target.value),placeholder:`https://example.com/page`,disabled:C})]}),(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{children:`HTTP 方法`}),(0,y.jsx)(`div`,{className:`flex gap-2`,children:[`GET`,`POST`,`PUT`,`DELETE`].map(e=>(0,y.jsx)(r,{type:`button`,variant:we===e?`selected`:`outline`,size:`sm`,onClick:()=>Te(e),disabled:C,children:e},e))})]}),(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{children:`测试模式`}),(0,y.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,y.jsx)(r,{type:`button`,variant:E===`standalone`?`selected`:`outline`,size:`sm`,onClick:()=>D(`standalone`),disabled:C,title:`直接请求 URL,不走路由与 Mock,便于排查插件自身逻辑`,children:`单独测试`}),(0,y.jsx)(r,{type:`button`,variant:E===`integrated`?`selected`:`outline`,size:`sm`,onClick:()=>D(`integrated`),disabled:C,title:`与真实代理一致:先路由解析、Mock 匹配,再请求,便于排查整体链路`,children:`集成测试`})]}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E===`standalone`?`直接请求上述 URL,不经过路由规则和 Mock,适合验证插件逻辑。`:`先按路由规则解析目标、匹配 Mock,再请求,与经代理的真实请求一致,适合排查链路问题。`})]}),(0,y.jsx)(`div`,{className:`bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-900 rounded-md p-3`,children:(0,y.jsxs)(`p`,{className:`text-xs text-blue-700 dark:text-blue-300`,children:[(0,y.jsx)(`strong`,{children:`测试流程:`}),` 发起真实请求 → 获取服务器响应 → 运行插件 Hook(`,x.join(`, `),`)→ 展示对比结果`]})})]}),!!X&&(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(p,{}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(se,{className:`h-4 w-4`}),`插件代码`]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(l,{value:ke,onValueChange:e=>U(e),children:(0,y.jsxs)(u,{className:`h-7`,children:[(0,y.jsx)(d,{value:`normal`,className:`px-2 text-xs`,children:`正常视图`}),(0,y.jsx)(d,{value:`diff`,className:`px-2 text-xs`,disabled:!Ne,children:`Diff 视图`})]})}),(0,y.jsx)(g,{variant:`outline`,className:`text-xs font-normal`,children:X}),(0,y.jsx)(r,{size:`sm`,variant:`ghost`,onClick:Z,disabled:R||w,children:R?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(m,{className:`h-4 w-4 mr-1 animate-spin`}),`读取中`]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(c,{className:`h-4 w-4 mr-1`}),`刷新代码`]})})]})]}),z?(0,y.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50/80 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/20 dark:text-red-300`,children:z}):ke===`diff`&&Ne?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`左侧是原代码,右侧是 AI 修复后的代码`}),G!==`idle`&&(0,y.jsx)(g,{variant:`outline`,className:`text-xs font-normal`,children:be(G)})]}),(0,y.jsx)(ge,{original:I||P,modified:V||P,language:`javascript`,minHeight:`320px`})]}):(0,y.jsx)(he,{value:w&&V?V:P,onChange:()=>{},language:`javascript`,readOnly:!0,minHeight:`260px`}),(0,y.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,y.jsx)(f,{htmlFor:`plugin-extra-instruction`,children:`额外信息`}),(0,y.jsx)(_e,{id:`plugin-extra-instruction`,value:W,onChange:e=>Ae(e.target.value),placeholder:`例如:补充 onBeforeResponse 里对 JSON 响应的判空逻辑;保留现有 hooks 和 manifest,不要改插件 id。`,className:`min-h-[88px]`,disabled:w||R}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`输入额外要求后,AI 会基于当前插件代码直接更新并热加载。`}),(0,y.jsx)(r,{size:`sm`,variant:`outline`,onClick:async()=>{if(!(!X||!W.trim()||!Y||w)){T(!0),N(null),H(``),L(P);try{K(`generating`);let e=await fetch(`/api/plugins/revise-stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({originalCode:P,instruction:W.trim(),requirement:{name:b,description:`根据额外要求更新插件 ${b},并保持 hooks 行为正确。Hooks: ${x.join(`, `)}`,hooks:x},aiConfig:je})});if(!e.ok){let t=await e.json();throw Error(t.error||`AI 更新代码失败`)}let t=e.body?.getReader(),n=new TextDecoder;if(!t)throw Error(`无法读取 AI 更新流`);let r=``,i=``;for(;;){let{done:e,value:a}=await t.read();if(e)break;i+=n.decode(a,{stream:!0});let o=i.split(`
|
|
1
|
+
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{t as o}from"./circle-alert-Q8cZk9Rv.js";import{t as s}from"./circle-x-C9USji_R.js";import{t as ee}from"./pencil-line-Cqe41E4h.js";import{t as c}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./wand-sparkles-wkul5vje.js";import"./es2015-CfXu88Y7.js";import{i as ne,o as re,r as ie}from"./ai-config-store-DQXVJVn_.js";import{A as ae,B as l,H as u,U as d,_ as oe,b as f,ft as se,g as ce,h as le,lt as ue,m as p,ot as m,pt as de,q as h,st as fe,v as pe,y as me,z as g}from"./index-B8P4vdT0.js";import{t as _}from"./body-diff-view-D7dCWajG.js";import{n as he,t as ge}from"./monaco-editor-Bumwz1AX.js";import{t as _e}from"./textarea-vuxJwU0x.js";var ve=n(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=t(i(),1),y=e();function b(e){let t=new Map;return!e||typeof e!=`object`||Object.entries(e).forEach(([e,n])=>{t.set(e.toLowerCase(),{displayKey:e,value:n==null?``:String(n)})}),t}function x(e,t){let n=b(e),r=b(t);return Array.from(new Set([...n.keys(),...r.keys()])).sort().map(e=>{let t=n.get(e),i=r.get(e),a=t?.value??``,o=i?.value??``,s=`unchanged`;return!t&&i?s=`added`:t&&!i?s=`removed`:a!==o&&(s=`changed`),{key:e,displayKey:i?.displayKey??t?.displayKey??e,originalValue:a,modifiedValue:o,status:s}})}function S(e,t){let n=`rounded-md border px-2 py-1.5`;return e===`unchanged`?`${n} border-transparent`:e===`changed`?`${n} border-orange-300 bg-orange-500/10`:e===`added`?t===`modified`?`${n} border-green-300 bg-green-500/10`:`${n} border-transparent opacity-50`:e===`removed`?t===`original`?`${n} border-red-300 bg-red-500/10`:`${n} border-transparent opacity-50`:n}function ye({original:e,modified:t,mode:n=`split`}){let r=x(e,t);return n===`inline`?(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border px-2 py-1.5 ${e.status===`unchanged`?`border-transparent`:e.status===`changed`?`border-orange-300 bg-orange-500/10`:e.status===`added`?`border-green-300 bg-green-500/10`:`border-red-300 bg-red-500/10`}`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.displayKey}),(0,y.jsx)(g,{variant:`outline`,className:`h-5 px-1.5 text-[10px] font-normal`,children:e.status===`unchanged`?`未变`:e.status===`changed`?`修改`:e.status===`added`?`新增`:`删除`})]}),e.status===`changed`&&(0,y.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,y.jsxs)(`div`,{className:`text-red-700 dark:text-red-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`-`}),e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),(0,y.jsxs)(`div`,{className:`text-green-700 dark:text-green-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`+`}),e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]})]}),e.status===`added`&&(0,y.jsxs)(`div`,{className:`mt-1 text-green-700 dark:text-green-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`+`}),e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),e.status===`removed`&&(0,y.jsxs)(`div`,{className:`mt-1 text-red-700 dark:text-red-300`,children:[(0,y.jsx)(`span`,{className:`mr-1`,children:`-`}),e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]}),e.status===`unchanged`&&(0,y.jsx)(`div`,{className:`mt-1`,children:e.modifiedValue||e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})})]},e.key))}):(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:`原始`}),(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:S(e.status,`original`),children:[(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.displayKey,`:`]}),` `,e.originalValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]},`original-${e.key}`))})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:`修改后`}),(0,y.jsx)(`div`,{className:`bg-muted/50 rounded-md p-2 text-xs font-mono max-h-[220px] overflow-auto space-y-1`,children:r.map(e=>(0,y.jsxs)(`div`,{className:S(e.status,`modified`),children:[(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.displayKey,`:`]}),` `,e.modifiedValue||(0,y.jsx)(`span`,{className:`text-muted-foreground italic`,children:`(无)`})]},`modified-${e.key}`))})]})]})}function be(e){switch(e){case`generating`:return`AI 正在流式生成修复代码`;case`saving`:return`正在保存修复后的插件代码`;case`reloading`:return`正在热加载插件`;case`retesting`:return`正在重新执行插件测试`;default:return``}}function C({open:e=!1,onOpenChange:t,embedded:n=!1,pluginId:i,pluginName:b,hooks:x,onPluginFixed:S}){let[C,xe]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),[Se,Ce]=(0,v.useState)(`https://365.wps.cn/home`),[we,Te]=(0,v.useState)(`GET`),[E,D]=(0,v.useState)(`standalone`),[O,k]=(0,v.useState)(null),[A,Ee]=(0,v.useState)(`split`),[j,De]=(0,v.useState)(`inline`),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(``),[R,Oe]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(``),[ke,U]=(0,v.useState)(`normal`),[W,Ae]=(0,v.useState)(``),[G,K]=(0,v.useState)(`idle`),q=ie(),J=ne(q),je=J?{provider:J.provider,apiKey:J.apiKey,baseUrl:J.baseUrl,model:J.model}:{provider:q.provider,apiKey:q.apiKey,baseUrl:q.baseUrl,model:q.model},Y=re(q),X=i.startsWith(`local.`)?`${i.slice(6)}.js`:``,Z=(0,v.useCallback)(async()=>{if(!X||!e){F(``),L(``),B(null);return}Oe(!0),B(null);try{let e=await fetch(`/api/plugins/custom/${encodeURIComponent(X)}/code`);if(!e.ok){let t=await e.json();throw Error(t.error||`读取插件源码失败`)}let t=await e.json();F(t.code||``),!w&&!V&&L(t.code||``)}catch(e){F(``),L(``),B(e instanceof Error?e.message:`读取插件源码失败`)}finally{Oe(!1)}},[X,w,V,e]);(0,v.useEffect)(()=>{Z()},[Z]);let Q=(0,v.useMemo)(()=>{let e=[];return O?.error&&e.push({hookName:`test`,message:O.error}),Object.entries(O?.hookResults||{}).forEach(([t,n])=>{n?.status===`error`&&e.push({hookName:t,message:n.error||`未知错误`,stack:n.stack})}),O?.realRequest?.fetchError&&e.push({hookName:`fetch`,message:O.realRequest.fetchError}),e},[O]),Me=Q.length>0&&!!X,Ne=!!I&&!!(V||G===`idle`&&I&&P&&I!==P),Pe=async(e,t,n)=>{K(`saving`);let r=await fetch(`/api/plugins/custom/${encodeURIComponent(X)}/code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e})});if(!r.ok){let e=await r.json();throw Error(e.error||`保存修复后的代码失败`)}K(`reloading`);let i=await fetch(`/api/plugins/reload`,{method:`POST`});if(!i.ok){let e=await i.json().catch(()=>({error:`热加载失败`}));throw Error(e.error||`热加载失败`)}F(e),H(e),U(`diff`),window.dispatchEvent(new CustomEvent(`plugins-custom-updated`)),S?.(),n&&(K(`retesting`),await Fe()),N({status:`success`,message:t}),K(`idle`)},Fe=async()=>{xe(!0),k(null),N(null);try{let e=await fetch(`/api/plugins/test`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pluginId:i,url:Se,method:we,integrated:E===`integrated`})});if(!e.ok){let t=await e.json();throw Error(t.error||`测试失败`)}k((await e.json()).results)}catch(e){k({error:e instanceof Error?e.message:`测试失败`})}finally{xe(!1)}},$=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(pe,{className:`px-6 pt-6 pb-4`,children:[(0,y.jsxs)(me,{className:`flex items-center gap-2`,children:[(0,y.jsx)(h,{className:`h-5 w-5`}),`测试插件: `,b]}),(0,y.jsx)(oe,{children:`发起真实 HTTP 请求,在请求/响应过程中运行插件代码`})]}),(0,y.jsx)(p,{}),(0,y.jsxs)(`div`,{className:`app-panel-content`,children:[(0,y.jsxs)(`div`,{className:`app-section`,children:[(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{htmlFor:`testUrl`,children:`请求 URL`}),(0,y.jsx)(ae,{id:`testUrl`,value:Se,onChange:e=>Ce(e.target.value),placeholder:`https://example.com/page`,disabled:C})]}),(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{children:`HTTP 方法`}),(0,y.jsx)(`div`,{className:`flex gap-2`,children:[`GET`,`POST`,`PUT`,`DELETE`].map(e=>(0,y.jsx)(r,{type:`button`,variant:we===e?`selected`:`outline`,size:`sm`,onClick:()=>Te(e),disabled:C,children:e},e))})]}),(0,y.jsxs)(`div`,{className:`app-field-group`,children:[(0,y.jsx)(f,{children:`测试模式`}),(0,y.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,y.jsx)(r,{type:`button`,variant:E===`standalone`?`selected`:`outline`,size:`sm`,onClick:()=>D(`standalone`),disabled:C,title:`直接请求 URL,不走路由与 Mock,便于排查插件自身逻辑`,children:`单独测试`}),(0,y.jsx)(r,{type:`button`,variant:E===`integrated`?`selected`:`outline`,size:`sm`,onClick:()=>D(`integrated`),disabled:C,title:`与真实代理一致:先路由解析、Mock 匹配,再请求,便于排查整体链路`,children:`集成测试`})]}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:E===`standalone`?`直接请求上述 URL,不经过路由规则和 Mock,适合验证插件逻辑。`:`先按路由规则解析目标、匹配 Mock,再请求,与经代理的真实请求一致,适合排查链路问题。`})]}),(0,y.jsx)(`div`,{className:`bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-900 rounded-md p-3`,children:(0,y.jsxs)(`p`,{className:`text-xs text-blue-700 dark:text-blue-300`,children:[(0,y.jsx)(`strong`,{children:`测试流程:`}),` 发起真实请求 → 获取服务器响应 → 运行插件 Hook(`,x.join(`, `),`)→ 展示对比结果`]})})]}),!!X&&(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(p,{}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(se,{className:`h-4 w-4`}),`插件代码`]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(l,{value:ke,onValueChange:e=>U(e),children:(0,y.jsxs)(u,{className:`h-7`,children:[(0,y.jsx)(d,{value:`normal`,className:`px-2 text-xs`,children:`正常视图`}),(0,y.jsx)(d,{value:`diff`,className:`px-2 text-xs`,disabled:!Ne,children:`Diff 视图`})]})}),(0,y.jsx)(g,{variant:`outline`,className:`text-xs font-normal`,children:X}),(0,y.jsx)(r,{size:`sm`,variant:`ghost`,onClick:Z,disabled:R||w,children:R?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(m,{className:`h-4 w-4 mr-1 animate-spin`}),`读取中`]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(c,{className:`h-4 w-4 mr-1`}),`刷新代码`]})})]})]}),z?(0,y.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50/80 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/20 dark:text-red-300`,children:z}):ke===`diff`&&Ne?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`左侧是原代码,右侧是 AI 修复后的代码`}),G!==`idle`&&(0,y.jsx)(g,{variant:`outline`,className:`text-xs font-normal`,children:be(G)})]}),(0,y.jsx)(ge,{original:I||P,modified:V||P,language:`javascript`,minHeight:`320px`})]}):(0,y.jsx)(he,{value:w&&V?V:P,onChange:()=>{},language:`javascript`,readOnly:!0,minHeight:`260px`}),(0,y.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,y.jsx)(f,{htmlFor:`plugin-extra-instruction`,children:`额外信息`}),(0,y.jsx)(_e,{id:`plugin-extra-instruction`,value:W,onChange:e=>Ae(e.target.value),placeholder:`例如:补充 onBeforeResponse 里对 JSON 响应的判空逻辑;保留现有 hooks 和 manifest,不要改插件 id。`,className:`min-h-[88px]`,disabled:w||R}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`输入额外要求后,AI 会基于当前插件代码直接更新并热加载。`}),(0,y.jsx)(r,{size:`sm`,variant:`outline`,onClick:async()=>{if(!(!X||!W.trim()||!Y||w)){T(!0),N(null),H(``),L(P);try{K(`generating`);let e=await fetch(`/api/plugins/revise-stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({originalCode:P,instruction:W.trim(),requirement:{name:b,description:`根据额外要求更新插件 ${b},并保持 hooks 行为正确。Hooks: ${x.join(`, `)}`,hooks:x},aiConfig:je})});if(!e.ok){let t=await e.json();throw Error(t.error||`AI 更新代码失败`)}let t=e.body?.getReader(),n=new TextDecoder;if(!t)throw Error(`无法读取 AI 更新流`);let r=``,i=``;for(;;){let{done:e,value:a}=await t.read();if(e)break;i+=n.decode(a,{stream:!0});let o=i.split(`
|
|
2
2
|
`);i=o.pop()||``;for(let e of o){if(!e.startsWith(`data:`))continue;let t=e.slice(5).trim();if(t)try{let e=JSON.parse(t);if(e.status===`generating`)N({status:`success`,message:`AI 正在根据额外要求更新插件代码...`});else if(e.chunk)r=e.accumulated||`${r}${e.chunk}`,H(r),U(`diff`);else if(e.status===`success`)r=e.revisedCode||r,H(r),U(`diff`);else if(e.error)throw Error(e.error)}catch(e){if(e instanceof Error&&e.message!==`Unexpected end of JSON input`)throw e}}}if(!r||typeof r!=`string`)throw Error(`AI 未返回有效代码`);N({status:`success`,message:`AI 已生成更新后的代码,正在保存并热加载...`}),await Pe(r,`AI 已根据额外要求更新插件代码并完成热加载。`,!1),Ae(``)}catch(e){N({status:`error`,message:e instanceof Error?e.message:`AI 更新代码失败`})}finally{K(`idle`),T(!1)}}},disabled:!X||!W.trim()||!Y||w||R||!!z,children:w&&G!==`retesting`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(m,{className:`h-4 w-4 mr-1 animate-spin`}),`AI 更新中...`]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ee,{className:`h-4 w-4 mr-1`}),`根据额外信息更新代码`]})})]})]})]})]}),O&&(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(p,{}),O.error?(0,y.jsx)(`div`,{className:`bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900 rounded-md p-3`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,y.jsx)(s,{className:`h-4 w-4 text-red-600 mt-0.5 shrink-0`}),(0,y.jsx)(`span`,{className:`text-sm text-red-700 dark:text-red-300`,children:O.error})]})}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-4 items-center rounded-md border bg-muted/20 px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Header 对比`}),(0,y.jsx)(l,{value:A,onValueChange:e=>Ee(e),children:(0,y.jsxs)(u,{className:`h-7`,children:[(0,y.jsx)(d,{value:`split`,className:`px-2 text-xs`,children:`分栏`}),(0,y.jsx)(d,{value:`inline`,className:`px-2 text-xs`,children:`行内`})]})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Body 对比`}),(0,y.jsx)(l,{value:j,onValueChange:e=>De(e),children:(0,y.jsxs)(u,{className:`h-7`,children:[(0,y.jsx)(d,{value:`inline`,className:`px-2 text-xs`,children:`行内`}),(0,y.jsx)(d,{value:`split`,className:`px-2 text-xs`,children:`分栏`})]})})]})]}),O.realRequest&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(fe,{className:`h-4 w-4`}),`真实请求`,O.realRequest.testMode&&(0,y.jsx)(g,{variant:`outline`,className:`text-xs font-normal`,children:O.realRequest.testMode===`integrated`?`集成测试`:`单独测试`})]}),(0,y.jsxs)(`div`,{className:`bg-muted/50 rounded-md p-3 text-xs space-y-1`,children:[(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(g,{variant:`outline`,className:`text-xs`,children:O.realRequest.method}),(0,y.jsx)(`span`,{className:`font-mono break-all`,children:O.realRequest.url})]}),O.realRequest.fetchError?(0,y.jsxs)(`div`,{className:`text-red-600 flex items-center gap-1 mt-1`,children:[(0,y.jsx)(s,{className:`h-3 w-3`}),`请求失败: `,O.realRequest.fetchError]}):(0,y.jsxs)(`div`,{className:`text-muted-foreground space-y-0.5`,children:[(0,y.jsxs)(`div`,{children:[`耗时: `,O.realRequest.fetchDuration,`ms`,O.originalResponse&&(0,y.jsxs)(y.Fragment,{children:[` · 状态码: `,(0,y.jsx)(g,{variant:`outline`,className:`text-xs`,children:O.originalResponse.statusCode}),` · 响应大小: `,O.originalResponse.bodyLength,` 字符`]})]}),(O.realRequest.targetResolved||O.realRequest.usedMock)&&(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[O.realRequest.targetResolved&&(0,y.jsx)(g,{variant:`outline`,className:`text-xs text-blue-600 border-blue-300`,children:`路由已改写`}),O.realRequest.usedMock&&(0,y.jsx)(g,{variant:`outline`,className:`text-xs text-orange-600 border-orange-300`,children:`已使用 Mock`})]})]})]})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(h,{className:`h-4 w-4`}),`Hook 执行结果`]}),Object.keys(O.hookResults||{}).length===0?(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/50 rounded-md p-3`,children:`没有 Hook 被执行`}):(0,y.jsx)(`div`,{className:`space-y-2`,children:Object.entries(O.hookResults||{}).map(([e,t])=>(0,y.jsxs)(`div`,{className:`border rounded-md p-3 ${t.status===`success`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`}`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.status===`success`?(0,y.jsx)(de,{className:`h-4 w-4 text-green-600`}):(0,y.jsx)(s,{className:`h-4 w-4 text-red-600`}),(0,y.jsx)(`span`,{className:`font-medium text-sm`,children:e})]}),t.duration!==void 0&&(0,y.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[t.duration,`ms`]})]}),t.status===`error`&&(0,y.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,y.jsxs)(`div`,{className:`rounded-md border border-red-200 bg-red-100/60 px-2 py-2 text-xs text-red-800 dark:border-red-900 dark:bg-red-950/20 dark:text-red-300`,children:[(0,y.jsx)(`div`,{className:`font-medium mb-1`,children:`错误原因`}),(0,y.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap break-all`,children:t.error})]}),t.stack&&(0,y.jsxs)(`details`,{className:`rounded-md border border-red-200 bg-background/60 px-2 py-2 text-xs dark:border-red-900`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer text-red-700 dark:text-red-300`,children:`查看错误堆栈`}),(0,y.jsx)(`pre`,{className:`font-mono whitespace-pre-wrap break-all mt-2 text-muted-foreground`,children:t.stack})]})]}),t.targetChanged&&(0,y.jsxs)(`div`,{className:`text-xs text-blue-700 mt-1 flex items-center gap-1`,children:[(0,y.jsx)(a,{className:`h-3 w-3`}),`Target 已修改为: `,t.targetChanged]})]},e))})]}),Q.length>0&&(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,y.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(o,{className:`h-4 w-4 text-red-500`}),`错误详情`]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!Y&&(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`AI 未配置,无法自动修复`}),(0,y.jsx)(r,{size:`sm`,variant:`outline`,onClick:async()=>{if(!(!Me||!Y)){T(!0),N(null),H(``),L(P);try{K(`generating`);let e={code:P};if(!e.code)throw Error(`插件源码为空,无法修复`);let t=Q.map(e=>`Hook: ${e.hookName}\nError: ${e.message}${e.stack?`\nStack:\n${e.stack}`:``}`).join(`
|
|
3
3
|
|
|
4
4
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{A as o,Q as s,W as c,a as l,lt as u,ot as d,z as f}from"./index-
|
|
1
|
+
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import{t as a}from"./arrow-right-B4Mrlj2-.js";import{A as o,Q as s,W as c,a as l,lt as u,ot as d,z as f}from"./index-B8P4vdT0.js";var p=n(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),m=t(i(),1),h=e();function g({rules:e,activeFileName:t,embedded:n=!1,onRevealRule:i}){let[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(null),w=(0,m.useMemo)(()=>l(e),[e]),T=n?`global-route-preview-url`:`route-preview-url`;(0,m.useEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{document.getElementById(T)?.focus()});return()=>window.cancelAnimationFrame(e)},[n,T]);let E=(0,m.useCallback)(async()=>{let e=g.trim();if(!e){C(`请输入待预览的 URL`),x(null);return}y(!0),C(null);try{let t=await fetch(`/api/rules/preview`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,rulesText:w})}),n=await t.json();if(!t.ok)throw Error(n?.error||`预览失败`);x(n)}catch(e){x(null),C(e instanceof Error?e.message:`预览失败`)}finally{y(!1)}},[g,w]),D=(0,m.useCallback)(e=>{e.key===`Enter`&&E()},[E]);return(0,h.jsxs)(`div`,{className:n?`app-panel-content h-full`:`rounded-lg border bg-card p-4 space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(s,{className:`h-4 w-4 text-primary`}),(0,h.jsx)(`h3`,{className:`text-sm font-semibold`,children:`URL 预览`})]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`输入一个请求 URL,后端会用当前编辑中的规则直接计算真实转发地址。`})]}),t&&(0,h.jsxs)(f,{variant:`outline`,className:`text-[11px] font-normal`,children:[(0,h.jsx)(u,{className:`h-3 w-3 mr-1`}),t]})]}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(o,{id:T,value:g,onChange:e=>_(e.target.value),onKeyDown:D,placeholder:`https://solution.wps.cn/docs/price/detail.html?source=navbar`,className:`h-9 font-mono text-xs`}),(0,h.jsx)(r,{onClick:E,disabled:v,className:`h-9 shrink-0`,children:v?(0,h.jsx)(d,{className:`h-4 w-4 animate-spin`}):`预览`})]}),n&&(0,h.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`使用当前编辑区内尚未保存的规则进行计算,结果会与路由规则页的预览保持一致。`}),S&&(0,h.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(c,{className:`h-3.5 w-3.5 shrink-0`}),(0,h.jsx)(`span`,{children:S})]})}),b&&(0,h.jsxs)(`div`,{className:n?`min-h-0 flex-1 space-y-3 overflow-auto rounded-md border bg-muted/20 p-3`:`space-y-3 rounded-md border bg-muted/20 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(f,{className:b.matched?`bg-green-100 text-green-800 border-green-200`:`bg-blue-100 text-blue-800 border-blue-200`,children:b.matched?`已命中规则`:`未命中规则`}),b.matchedRule&&(0,h.jsx)(f,{variant:`outline`,className:`text-[11px] font-normal`,children:b.matchedRule.kind})]}),(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`真实 URL`}),(0,h.jsx)(`div`,{className:`rounded-md border bg-background px-3 py-2 font-mono text-xs break-all`,children:b.resolvedUrl})]}),b.matchedRule&&(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`命中规则`}),(0,h.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1 rounded-md border bg-background px-3 py-2 font-mono text-xs break-all`,children:[b.matchedRule.pattern,(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:` → `}),b.matchedRule.target]}),i&&(0,h.jsxs)(r,{type:`button`,variant:`outline`,size:`sm`,className:`h-auto shrink-0 gap-1.5 px-3 text-xs`,onClick:()=>b.matchedRule&&i(b.matchedRule),title:`在路由规则页面定位这条规则`,children:[(0,h.jsx)(p,{className:`h-3.5 w-3.5`}),`定位`]})]})]}),(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`说明`}),(0,h.jsx)(`div`,{className:`space-y-1 rounded-md border bg-background px-3 py-2 text-xs`,children:b.notes.length>0?b.notes.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(a,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,h.jsx)(`span`,{children:e})]},e)):(0,h.jsx)(`span`,{className:`text-muted-foreground`,children:`无`})})]})]})]})}export{g as RoutePreview};
|
package/web/dist/assets/{rule-ai-assistant-panel-B3zTS8S3.js → rule-ai-assistant-panel-jNusgNtU.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,f as t,t as n,u as r}from"./button-BTToMaBW.js";import{t as i}from"./wand-sparkles-wkul5vje.js";import{i as a,o,r as s}from"./ai-config-store-DQXVJVn_.js";import{X as c,a as l,i as u,ot as d,z as f}from"./index-
|
|
1
|
+
import{a as e,f as t,t as n,u as r}from"./button-BTToMaBW.js";import{t as i}from"./wand-sparkles-wkul5vje.js";import{i as a,o,r as s}from"./ai-config-store-DQXVJVn_.js";import{X as c,a as l,i as u,ot as d,z as f}from"./index-B8P4vdT0.js";import{n as p,t as m}from"./alert-Bve02Ufr.js";import{t as h}from"./textarea-vuxJwU0x.js";var g=t(r(),1);function _(e){return e.replace(/^```[a-z]*\n?/i,``).replace(/\n?```$/i,``).trim()}function v(){let e=s(),t=a(e);return t?{enabled:e.enabled,provider:t.provider,apiKey:t.apiKey,baseUrl:t.baseUrl,model:t.model}:e}function y(e,t){return{system:`你是 Meddle 的路由规则整理助手。你的任务是合并和精简用户的路由规则,在不改变语义的前提下尽量减少规则数量。
|
|
2
2
|
|
|
3
3
|
请严格遵守以下要求:
|
|
4
4
|
1. 只输出最终规则文本,不要输出解释、标题、Markdown 代码块或额外说明。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,l as r,n as i,t as a,u as o}from"./button-BTToMaBW.js";import{c as s}from"./dist-C6eaYCUo.js";import{n as c,t as l}from"./checkbox-
|
|
1
|
+
import{a as e,d as t,f as n,l as r,n as i,t as a,u as o}from"./button-BTToMaBW.js";import{c as s}from"./dist-C6eaYCUo.js";import{n as c,t as l}from"./checkbox-ChXVVrCY.js";import{t as u}from"./plus-tVxSydJ8.js";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./dist-CxdY_A67.js";import"./es2015-CfXu88Y7.js";import{$ as y,A as b,B as x,G as S,H as C,I as w,L as T,M as E,O as D,P as O,R as k,S as A,U as j,a as M,ct as N,d as P,f as F,i as I,k as L,mt as R,n as ee,ot as z,p as te,r as B,u as ne,z as V}from"./index-B8P4vdT0.js";import{r as H}from"./syntax-highlight-BHsSDUha.js";import{a as re,i as ie,n as ae,o as oe,r as U,t as se}from"./table-DymgLlcc.js";import{t as ce}from"./file-system-access-DK7FI6pN.js";var le=r(`arrow-up-to-line`,[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]),ue=r(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),de=r(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),fe=r(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),pe=r(`git-branch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),me=r(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),he=r(`toggle-left`,[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),ge=r(`toggle-right`,[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),_e=t((e=>{var t=o();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),o=r[0].inst,l=r[1];return s(function(){o.value=n,o.getSnapshot=t,u(o)&&l({inst:o})},[e,n,t]),a(function(){return u(o)&&l({inst:o}),e(function(){u(o)&&l({inst:o})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ve=t(((e,t)=>{t.exports=_e()})),W=n(o()),G=e();function ye({className:e,...t}){return(0,G.jsx)(z,{role:`status`,"aria-label":`Loading`,className:i(`size-4 animate-spin`,e),...t})}var be=n(s());function xe(){var e=[...arguments];return(0,W.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Se=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ce(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function we(e){return`nodeType`in e}function K(e){return e?Ce(e)?e:we(e)?e.ownerDocument?.defaultView??window:window:window}function Te(e){let{Document:t}=K(e);return e instanceof t}function Ee(e){return Ce(e)?!1:e instanceof K(e).HTMLElement}function De(e){return e instanceof K(e).SVGElement}function Oe(e){return e?Ce(e)?e.document:we(e)?Te(e)?e:Ee(e)||De(e)?e.ownerDocument:document:document:document}var ke=Se?W.useLayoutEffect:W.useEffect;function Ae(e){let t=(0,W.useRef)(e);return ke(()=>{t.current=e}),(0,W.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function je(){let e=(0,W.useRef)(null);return[(0,W.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,W.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Me(e,t){t===void 0&&(t=[e]);let n=(0,W.useRef)(e);return ke(()=>{n.current!==e&&(n.current=e)},t),n}function Ne(e,t){let n=(0,W.useRef)();return(0,W.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Pe(e){let t=Ae(e),n=(0,W.useRef)(null);return[n,(0,W.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Fe(e){let t=(0,W.useRef)();return(0,W.useEffect)(()=>{t.current=e},[e]),t.current}var Ie={};function Le(e,t){return(0,W.useMemo)(()=>{if(t)return t;let n=Ie[e]==null?0:Ie[e]+1;return Ie[e]=n,e+`-`+n},[e,t])}function Re(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var ze=Re(1),Be=Re(-1);function Ve(e){return`clientX`in e&&`clientY`in e}function He(e){if(!e)return!1;let{KeyboardEvent:t}=K(e.target);return t&&e instanceof t}function Ue(e){if(!e)return!1;let{TouchEvent:t}=K(e.target);return t&&e instanceof t}function We(e){if(Ue(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ve(e)?{x:e.clientX,y:e.clientY}:null}var Ge=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[Ge.Translate.toString(e),Ge.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Ke=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function qe(e){return e.matches(Ke)?e:e.querySelector(Ke)}var Je={display:`none`};function Ye(e){let{id:t,value:n}=e;return W.createElement(`div`,{id:t,style:Je},n)}function Xe(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return W.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Ze(){let[e,t]=(0,W.useState)(``);return{announce:(0,W.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Qe=(0,W.createContext)(null);function $e(e){let t=(0,W.useContext)(Qe);(0,W.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function et(){let[e]=(0,W.useState)(()=>new Set),t=(0,W.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,W.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var tt={draggable:`
|
|
2
2
|
To pick up a draggable item, press the space bar.
|
|
3
3
|
While dragging, use the arrow keys to move the item.
|
|
4
4
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,f as t,i as n,s as r,u as i}from"./button-BTToMaBW.js";import{a,c as o,n as s,o as c,r as l,t as u}from"./dist-C6eaYCUo.js";import{t as d}from"./chevron-down-CPngAx4M.js";import{n as f,t as p}from"./dist-Cn0y0IRn.js";import{n as m,t as h}from"./dist-Bb9TeEub.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./es2015-CfXu88Y7.js";import{n as S,t as C}from"./dist-D5Dj17P8.js";import{t as w}from"./dist-DZJ9SMlJ.js";import{mt as T}from"./index-BB8Kl9wK.js";var E=t(i(),1),D=e(),O=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),k=`VisuallyHidden`,A=E.forwardRef((e,t)=>(0,D.jsx)(c.span,{...e,ref:t,style:{...O,...e.style}}));A.displayName=k;var j=[`top`,`right`,`bottom`,`left`],M=Math.min,N=Math.max,P=Math.round,F=Math.floor,I=e=>({x:e,y:e}),ee={left:`right`,right:`left`,bottom:`top`,top:`bottom`},te={start:`end`,end:`start`};function ne(e,t,n){return N(e,M(t,n))}function L(e,t){return typeof e==`function`?e(t):e}function R(e){return e.split(`-`)[0]}function z(e){return e.split(`-`)[1]}function B(e){return e===`x`?`y`:`x`}function V(e){return e===`y`?`height`:`width`}var re=new Set([`top`,`bottom`]);function H(e){return re.has(R(e))?`y`:`x`}function ie(e){return B(H(e))}function ae(e,t,n){n===void 0&&(n=!1);let r=z(e),i=ie(e),a=V(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=me(o)),[o,me(o)]}function oe(e){let t=me(e);return[se(e),t,se(t)]}function se(e){return e.replace(/start|end/g,e=>te[e])}var ce=[`left`,`right`],le=[`right`,`left`],ue=[`top`,`bottom`],de=[`bottom`,`top`];function fe(e,t,n){switch(e){case`top`:case`bottom`:return n?t?le:ce:t?ce:le;case`left`:case`right`:return t?ue:de;default:return[]}}function pe(e,t,n,r){let i=z(e),a=fe(R(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(se)))),a}function me(e){return e.replace(/left|right|bottom|top/g,e=>ee[e])}function he(e){return{top:0,right:0,bottom:0,left:0,...e}}function ge(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:he(e)}function _e(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ve(e,t,n){let{reference:r,floating:i}=e,a=H(t),o=ie(t),s=V(o),c=R(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(z(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ye(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=L(t,e),p=ge(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=_e(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=_e(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var be=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ve(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??ye},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=ve(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},xe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=L(e,t)||{};if(l==null)return{};let d=ge(u),f={x:n,y:r},p=ie(i),m=V(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=M(d[_],T),D=M(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=ne(O,A,k),N=!c.arrow&&z(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,P=N?A<O?A-O:A-k:0;return{[p]:f[p]+P,data:{[p]:j,centerOffset:A-j-P,...N&&{alignmentOffset:P}},reset:N}}}),Se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=L(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=R(r),_=H(o),v=R(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[me(o)]:oe(o)),x=p!==`none`;!d&&x&&b.push(...pe(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ae(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==H(t))||T.every(e=>H(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=H(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function we(e){return j.some(t=>e[t]>=0)}var Te=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=L(e,t);switch(i){case`referenceHidden`:{let e=Ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:we(e)}}}case`escaped`:{let e=Ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:we(e)}}}default:return{}}}}},Ee=new Set([`left`,`top`]);async function De(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=R(n),s=z(n),c=H(n)===`y`,l=Ee.has(o)?-1:1,u=a&&c?-1:1,d=L(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Oe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await De(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ke=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=L(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=H(R(i)),p=B(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=ne(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=ne(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ae=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=L(e,t),u={x:n,y:r},d=H(i),f=B(d),p=u[f],m=u[d],h=L(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ee.has(R(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},je=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=L(e,t),u=await o.detectOverflow(t,l),d=R(i),f=z(i),p=H(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=M(h-u[g],v),x=M(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=N(u.left,0),t=N(u.right,0),n=N(u.top,0),r=N(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:N(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:N(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Me(){return typeof window<`u`}function Ne(e){return Pe(e)?(e.nodeName||``).toLowerCase():`#document`}function U(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function W(e){return((Pe(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Pe(e){return Me()?e instanceof Node||e instanceof U(e).Node:!1}function G(e){return Me()?e instanceof Element||e instanceof U(e).Element:!1}function K(e){return Me()?e instanceof HTMLElement||e instanceof U(e).HTMLElement:!1}function Fe(e){return!Me()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof U(e).ShadowRoot}var Ie=new Set([`inline`,`contents`]);function Le(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ie.has(i)}var Re=new Set([`table`,`td`,`th`]);function ze(e){return Re.has(Ne(e))}var Be=[`:popover-open`,`:modal`];function Ve(e){return Be.some(t=>{try{return e.matches(t)}catch{return!1}})}var He=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Ue=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],We=[`paint`,`layout`,`strict`,`content`];function Ge(e){let t=qe(),n=G(e)?q(e):e;return He.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||Ue.some(e=>(n.willChange||``).includes(e))||We.some(e=>(n.contain||``).includes(e))}function Ke(e){let t=J(e);for(;K(t)&&!Ye(t);){if(Ge(t))return t;if(Ve(t))return null;t=J(t)}return null}function qe(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var Je=new Set([`html`,`body`,`#document`]);function Ye(e){return Je.has(Ne(e))}function q(e){return U(e).getComputedStyle(e)}function Xe(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function J(e){if(Ne(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Fe(e)&&e.host||W(e);return Fe(t)?t.host:t}function Ze(e){let t=J(e);return Ye(t)?e.ownerDocument?e.ownerDocument.body:e.body:K(t)&&Le(t)?t:Ze(t)}function Qe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ze(e),i=r===e.ownerDocument?.body,a=U(r);if(i){let e=$e(a);return t.concat(a,a.visualViewport||[],Le(r)?r:[],e&&n?Qe(e):[])}return t.concat(r,Qe(r,[],n))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function et(e){let t=q(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=K(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=P(n)!==a||P(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tt(e){return G(e)?e:e.contextElement}function nt(e){let t=tt(e);if(!K(t))return I(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=et(t),o=(a?P(n.width):n.width)/r,s=(a?P(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var rt=I(0);function it(e){let t=U(e);return!qe()||!t.visualViewport?rt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function at(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==U(e)?!1:t}function Y(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tt(e),o=I(1);t&&(r?G(r)&&(o=nt(r)):o=nt(e));let s=at(a,n,r)?it(a):I(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=U(a),t=r&&G(r)?U(r):r,n=e,i=$e(n);for(;i&&r&&t!==n;){let e=nt(i),t=i.getBoundingClientRect(),r=q(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=U(i),i=$e(n)}}return _e({width:u,height:d,x:c,y:l})}function ot(e,t){let n=Xe(e).scrollLeft;return t?t.left+n:Y(W(e)).left+n}function st(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ot(e,n),y:n.top+t.scrollTop}}function ct(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=W(r),s=t?Ve(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=I(1),u=I(0),d=K(r);if((d||!d&&!a)&&((Ne(r)!==`body`||Le(o))&&(c=Xe(r)),K(r))){let e=Y(r);l=nt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?st(o,c):I(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function lt(e){return Array.from(e.getClientRects())}function ut(e){let t=W(e),n=Xe(e),r=e.ownerDocument.body,i=N(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=N(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+ot(e),s=-n.scrollTop;return q(r).direction===`rtl`&&(o+=N(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var dt=25;function ft(e,t){let n=U(e),r=W(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=qe();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=ot(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=dt&&(a-=o)}else l<=dt&&(a+=l);return{width:a,height:o,x:s,y:c}}var pt=new Set([`absolute`,`fixed`]);function mt(e,t){let n=Y(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=K(e)?nt(e):I(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ht(e,t,n){let r;if(t===`viewport`)r=ft(e,n);else if(t===`document`)r=ut(W(e));else if(G(t))r=mt(t,n);else{let n=it(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _e(r)}function gt(e,t){let n=J(e);return n===t||!G(n)||Ye(n)?!1:q(n).position===`fixed`||gt(n,t)}function _t(e,t){let n=t.get(e);if(n)return n;let r=Qe(e,[],!1).filter(e=>G(e)&&Ne(e)!==`body`),i=null,a=q(e).position===`fixed`,o=a?J(e):e;for(;G(o)&&!Ye(o);){let t=q(o),n=Ge(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&pt.has(i.position)||Le(o)&&!n&>(e,o))?r=r.filter(e=>e!==o):i=t,o=J(o)}return t.set(e,r),r}function vt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ve(t)?[]:_t(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=ht(t,n,i);return e.top=N(r.top,e.top),e.right=M(r.right,e.right),e.bottom=M(r.bottom,e.bottom),e.left=N(r.left,e.left),e},ht(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function yt(e){let{width:t,height:n}=et(e);return{width:t,height:n}}function bt(e,t,n){let r=K(t),i=W(t),a=n===`fixed`,o=Y(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=I(0);function l(){c.x=ot(i)}if(r||!r&&!a)if((Ne(t)!==`body`||Le(i))&&(s=Xe(t)),r){let e=Y(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?st(i,s):I(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function xt(e){return q(e).position===`static`}function St(e,t){if(!K(e)||q(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return W(e)===n&&(n=n.ownerDocument.body),n}function Ct(e,t){let n=U(e);if(Ve(e))return n;if(!K(e)){let t=J(e);for(;t&&!Ye(t);){if(G(t)&&!xt(t))return t;t=J(t)}return n}let r=St(e,t);for(;r&&ze(r)&&xt(r);)r=St(r,t);return r&&Ye(r)&&xt(r)&&!Ge(r)?n:r||Ke(e)||n}var wt=async function(e){let t=this.getOffsetParent||Ct,n=this.getDimensions,r=await n(e.floating);return{reference:bt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Tt(e){return q(e).direction===`rtl`}var Et={convertOffsetParentRelativeRectToViewportRelativeRect:ct,getDocumentElement:W,getClippingRect:vt,getOffsetParent:Ct,getElementRects:wt,getClientRects:lt,getDimensions:yt,getScale:nt,isElement:G,isRTL:Tt};function Dt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ot(e,t){let n=null,r,i=W(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=F(d),h=F(i.clientWidth-(u+f)),g=F(i.clientHeight-(d+p)),_=F(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:N(0,M(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Dt(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function kt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=tt(e),u=i||a?[...l?Qe(l):[],...Qe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ot(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?Y(e):null;c&&g();function g(){let t=Y(e);h&&!Dt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var At=Oe,jt=ke,Mt=Se,Nt=je,Pt=Te,Ft=xe,It=Ae,Lt=(e,t,n)=>{let r=new Map,i={platform:Et,...n},a={...i.platform,_c:r};return be(e,t,{...i,platform:a})},Rt=t(o(),1),zt=typeof document<`u`?E.useLayoutEffect:function(){};function Bt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Bt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ht(e,t){let n=Vt(e);return Math.round(t*n)/n}function Ut(e){let t=E.useRef(e);return zt(()=>{t.current=e}),t}function Wt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=E.useState(r);Bt(f,r)||p(r);let[m,h]=E.useState(null),[g,_]=E.useState(null),v=E.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=E.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=E.useRef(null),C=E.useRef(null),w=E.useRef(u),T=c!=null,D=Ut(c),O=Ut(i),k=Ut(l),A=E.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Lt(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Bt(w.current,t)&&(w.current=t,Rt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);zt(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=E.useRef(!1);zt(()=>(j.current=!0,()=>{j.current=!1}),[]),zt(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(D.current)return D.current(b,x,A);A()}},[b,x,A,D,T]);let M=E.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=E.useMemo(()=>({reference:b,floating:x}),[b,x]),P=E.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Ht(N.floating,u.x),r=Ht(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return E.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Gt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Ft({element:r.current,padding:i}).fn(n):r?Ft({element:r,padding:i}).fn(n):{}}}},Kt=(e,t)=>({...At(e),options:[e,t]}),qt=(e,t)=>({...jt(e),options:[e,t]}),Jt=(e,t)=>({...It(e),options:[e,t]}),Yt=(e,t)=>({...Mt(e),options:[e,t]}),Xt=(e,t)=>({...Nt(e),options:[e,t]}),Zt=(e,t)=>({...Pt(e),options:[e,t]}),Qt=(e,t)=>({...Gt(e),options:[e,t]}),$t=`Arrow`,en=E.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,D.jsx)(c.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,D.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});en.displayName=$t;var tn=en,nn=`Popper`,[rn,an]=a(nn),[on,sn]=rn(nn),cn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=E.useState(null);return(0,D.jsx)(on,{scope:t,anchor:r,onAnchorChange:i,children:n})};cn.displayName=nn;var ln=`PopperAnchor`,un=E.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:i,...a}=e,o=sn(ln,n),s=E.useRef(null),l=r(t,s),u=E.useRef(null);return E.useEffect(()=>{let e=u.current;u.current=i?.current||s.current,e!==u.current&&o.onAnchorChange(u.current)}),i?null:(0,D.jsx)(c.div,{...a,ref:l})});un.displayName=ln;var dn=`PopperContent`,[fn,pn]=rn(dn),mn=E.forwardRef((e,t)=>{let{__scopePopper:n,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:m=`partial`,hideWhenDetached:g=!1,updatePositionStrategy:_=`optimized`,onPlaced:v,...y}=e,b=sn(dn,n),[x,S]=E.useState(null),w=r(t,e=>S(e)),[T,O]=E.useState(null),k=C(T),A=k?.width??0,j=k?.height??0,M=i+(o===`center`?``:`-`+o),N=typeof p==`number`?p:{top:0,right:0,bottom:0,left:0,...p},P=Array.isArray(f)?f:[f],F=P.length>0,I={padding:N,boundary:P.filter(vn),altBoundary:F},{refs:ee,floatingStyles:te,placement:ne,isPositioned:L,middlewareData:R}=Wt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>kt(...e,{animationFrame:_===`always`}),elements:{reference:b.anchor},middleware:[Kt({mainAxis:a+j,alignmentAxis:l}),d&&qt({mainAxis:!0,crossAxis:!1,limiter:m===`partial`?Jt():void 0,...I}),d&&Yt({...I}),Xt({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Qt({element:T,padding:u}),yn({arrowWidth:A,arrowHeight:j}),g&&Zt({strategy:`referenceHidden`,...I})]}),[z,B]=bn(ne),V=h(v);s(()=>{L&&V?.()},[L,V]);let re=R.arrow?.x,H=R.arrow?.y,ie=R.arrow?.centerOffset!==0,[ae,oe]=E.useState();return s(()=>{x&&oe(window.getComputedStyle(x).zIndex)},[x]),(0,D.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:L?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(` `),...R.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,D.jsx)(fn,{scope:n,placedSide:z,onArrowChange:O,arrowX:re,arrowY:H,shouldHideArrow:ie,children:(0,D.jsx)(c.div,{"data-side":z,"data-align":B,...y,ref:w,style:{...y.style,animation:L?void 0:`none`}})})})});mn.displayName=dn;var hn=`PopperArrow`,gn={top:`bottom`,right:`left`,bottom:`top`,left:`right`},_n=E.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=pn(hn,n),a=gn[i.placedSide];return(0,D.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,D.jsx)(tn,{...r,ref:t,style:{...r.style,display:`block`}})})});_n.displayName=hn;function vn(e){return e!==null}var yn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=bn(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function bn(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var xn=cn,Sn=un,Cn=mn,wn=_n,Tn=[` `,`Enter`,`ArrowUp`,`ArrowDown`],En=[` `,`Enter`],X=`Select`,[Dn,On,kn]=f(X),[An,jn]=a(X,[kn,an]),Mn=an(),[Nn,Z]=An(X),[Pn,Fn]=An(X),In=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:h,required:g,form:_}=e,v=Mn(t),[y,b]=E.useState(null),[x,S]=E.useState(null),[C,w]=E.useState(!1),T=p(l),[O,k]=u({prop:r,defaultProp:i??!1,onChange:a,caller:X}),[A,j]=u({prop:o,defaultProp:s,onChange:c,caller:X}),M=E.useRef(null),N=y?_||!!y.closest(`form`):!0,[P,F]=E.useState(new Set),I=Array.from(P).map(e=>e.props.value).join(`;`);return(0,D.jsx)(xn,{...v,children:(0,D.jsxs)(Nn,{required:g,scope:t,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:m(),value:A,onValueChange:j,open:O,onOpenChange:k,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[(0,D.jsx)(Dn.Provider,{scope:t,children:(0,D.jsx)(Pn,{scope:e.__scopeSelect,onNativeOptionAdd:E.useCallback(e=>{F(t=>new Set(t).add(e))},[]),onNativeOptionRemove:E.useCallback(e=>{F(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),N?(0,D.jsxs)(kr,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:e=>j(e.target.value),disabled:h,form:_,children:[A===void 0?(0,D.jsx)(`option`,{value:``}):null,Array.from(P)]},I):null]})})};In.displayName=X;var Ln=`SelectTrigger`,Rn=E.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:i=!1,...a}=e,o=Mn(n),s=Z(Ln,n),u=s.disabled||i,d=r(t,s.onTriggerChange),f=On(n),p=E.useRef(`touch`),[m,h,g]=jr(e=>{let t=f().filter(e=>!e.disabled),n=Mr(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),_=e=>{u||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,D.jsx)(Sn,{asChild:!0,...o,children:(0,D.jsx)(c.button,{type:`button`,role:`combobox`,"aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:u,"data-disabled":u?``:void 0,"data-placeholder":Ar(s.value)?``:void 0,...a,ref:d,onClick:l(a.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:l(a.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:l(a.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&h(e.key),!(t&&e.key===` `)&&Tn.includes(e.key)&&(_(),e.preventDefault())})})})});Rn.displayName=Ln;var zn=`SelectValue`,Bn=E.forwardRef((e,t)=>{let{__scopeSelect:n,className:i,style:a,children:o,placeholder:l=``,...u}=e,d=Z(zn,n),{onValueNodeHasChildrenChange:f}=d,p=o!==void 0,m=r(t,d.onValueNodeChange);return s(()=>{f(p)},[f,p]),(0,D.jsx)(c.span,{...u,ref:m,style:{pointerEvents:`none`},children:Ar(d.value)?(0,D.jsx)(D.Fragment,{children:l}):o})});Bn.displayName=zn;var Vn=`SelectIcon`,Hn=E.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,D.jsx)(c.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Hn.displayName=Vn;var Un=`SelectPortal`,Wn=e=>(0,D.jsx)(_,{asChild:!0,...e});Wn.displayName=Un;var Gn=`SelectContent`,Kn=E.forwardRef((e,t)=>{let n=Z(Gn,e.__scopeSelect),[r,i]=E.useState();if(s(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Rt.createPortal((0,D.jsx)(qn,{scope:e.__scopeSelect,children:(0,D.jsx)(Dn.Slot,{scope:e.__scopeSelect,children:(0,D.jsx)(`div`,{children:e.children})})}),t):null}return(0,D.jsx)(Xn,{...e,ref:t})});Kn.displayName=Gn;var Q=10,[qn,$]=An(Gn),Jn=`SelectContentImpl`,Yn=n(`SelectContent.RemoveScroll`),Xn=E.forwardRef((e,t)=>{let{__scopeSelect:n,position:i=`item-aligned`,onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=Z(Gn,n),[O,k]=E.useState(null),[A,j]=E.useState(null),M=r(t,e=>k(e)),[N,P]=E.useState(null),[F,I]=E.useState(null),ee=On(n),[te,ne]=E.useState(!1),L=E.useRef(!1);E.useEffect(()=>{if(O)return x(O)},[O]),b();let R=E.useCallback(e=>{let[t,...n]=ee().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&A&&(A.scrollTop=0),n===r&&A&&(A.scrollTop=A.scrollHeight),n?.focus(),document.activeElement!==i))return},[ee,A]),z=E.useCallback(()=>R([N,O]),[R,N,O]);E.useEffect(()=>{te&&z()},[te,z]);let{onOpenChange:B,triggerPointerDownPosRef:V}=T;E.useEffect(()=>{if(O){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(V.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(V.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():O.contains(n.target)||B(!1),document.removeEventListener(`pointermove`,t),V.current=null};return V.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[O,B,V]),E.useEffect(()=>{let e=()=>B(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[B]);let[re,H]=jr(e=>{let t=ee().filter(e=>!e.disabled),n=Mr(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ie=E.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&(P(e),r&&(L.current=!0))},[T.value]),ae=E.useCallback(()=>O?.focus(),[O]),oe=E.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&I(e)},[T.value]),se=i===`popper`?er:Qn,ce=se===er?{side:c,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,D.jsx)(qn,{scope:n,content:O,viewport:A,onViewportChange:j,itemRefCallback:ie,selectedItem:N,onItemLeave:ae,itemTextRefCallback:oe,focusSelectedItem:z,selectedItemText:F,position:i,isPositioned:te,searchRef:re,children:(0,D.jsx)(v,{as:Yn,allowPinchZoom:!0,children:(0,D.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:l(a,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,D.jsx)(y,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,D.jsx)(se,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ce,onPlaced:()=>ne(!0),ref:M,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:l(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&H(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=ee().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>R(t)),e.preventDefault()}})})})})})})});Xn.displayName=Jn;var Zn=`SelectItemAlignedPosition`,Qn=E.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:i,...a}=e,o=Z(Gn,n),l=$(Gn,n),[u,d]=E.useState(null),[f,p]=E.useState(null),m=r(t,e=>p(e)),h=On(n),g=E.useRef(!1),_=E.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=l,S=E.useCallback(()=>{if(o.trigger&&o.valueNode&&u&&f&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if(o.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-Q,d=w(a,[Q,Math.max(Q,l-c)]);u.style.minWidth=s+`px`,u.style.left=d+`px`}else{let i=t.right-r.right,a=window.innerWidth-n.right-i,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-Q,d=w(a,[Q,Math.max(Q,l-c)]);u.style.minWidth=s+`px`,u.style.right=d+`px`}let a=h(),s=window.innerHeight-Q*2,c=v.scrollHeight,l=window.getComputedStyle(f),d=parseInt(l.borderTopWidth,10),p=parseInt(l.paddingTop,10),m=parseInt(l.borderBottomWidth,10),_=parseInt(l.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-Q,O=s-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=d+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;u.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);u.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;u.style.top=`0px`;let t=Math.max(D,d+v.offsetTop+(e?T:0)+k)+M;u.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}u.style.margin=`${Q}px 0`,u.style.minHeight=S+`px`,u.style.maxHeight=s+`px`,i?.(),requestAnimationFrame(()=>g.current=!0)}},[h,o.trigger,o.valueNode,u,f,v,y,b,o.dir,i]);s(()=>S(),[S]);let[C,T]=E.useState();return s(()=>{f&&T(window.getComputedStyle(f).zIndex)},[f]),(0,D.jsx)(tr,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:E.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]),children:(0,D.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,D.jsx)(c.div,{...a,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.style}})})})});Qn.displayName=Zn;var $n=`SelectPopperPosition`,er=E.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Q,...a}=e,o=Mn(n);return(0,D.jsx)(Cn,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});er.displayName=$n;var[tr,nr]=An(Gn,{}),rr=`SelectViewport`,ir=E.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:i,...a}=e,o=$(rr,n),s=nr(rr,n),u=r(t,o.onViewportChange),d=E.useRef(0);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,D.jsx)(Dn.Slot,{scope:n,children:(0,D.jsx)(c.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:u,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:l(a.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(d.current-t.scrollTop);if(e>0){let r=window.innerHeight-Q*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}d.current=t.scrollTop})})})]})});ir.displayName=rr;var ar=`SelectGroup`,[or,sr]=An(ar),cr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=m();return(0,D.jsx)(or,{scope:n,id:i,children:(0,D.jsx)(c.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});cr.displayName=ar;var lr=`SelectLabel`,ur=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=sr(lr,n);return(0,D.jsx)(c.div,{id:i.id,...r,ref:t})});ur.displayName=lr;var dr=`SelectItem`,[fr,pr]=An(dr),mr=E.forwardRef((e,t)=>{let{__scopeSelect:n,value:i,disabled:a=!1,textValue:o,...s}=e,u=Z(dr,n),d=$(dr,n),f=u.value===i,[p,h]=E.useState(o??``),[g,_]=E.useState(!1),v=r(t,e=>d.itemRefCallback?.(e,i,a)),y=m(),b=E.useRef(`touch`),x=()=>{a||(u.onValueChange(i),u.onOpenChange(!1))};if(i===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,D.jsx)(fr,{scope:n,value:i,disabled:a,textId:y,isSelected:f,onItemTextChange:E.useCallback(e=>{h(t=>t||(e?.textContent??``).trim())},[]),children:(0,D.jsx)(Dn.ItemSlot,{scope:n,value:i,disabled:a,textValue:p,children:(0,D.jsx)(c.div,{role:`option`,"aria-labelledby":y,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...s,ref:v,onFocus:l(s.onFocus,()=>_(!0)),onBlur:l(s.onBlur,()=>_(!1)),onClick:l(s.onClick,()=>{b.current!==`mouse`&&x()}),onPointerUp:l(s.onPointerUp,()=>{b.current===`mouse`&&x()}),onPointerDown:l(s.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:l(s.onPointerMove,e=>{b.current=e.pointerType,a?d.onItemLeave?.():b.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:l(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:l(s.onKeyDown,e=>{d.searchRef?.current!==``&&e.key===` `||(En.includes(e.key)&&x(),e.key===` `&&e.preventDefault())})})})})});mr.displayName=dr;var hr=`SelectItemText`,gr=E.forwardRef((e,t)=>{let{__scopeSelect:n,className:i,style:a,...o}=e,l=Z(hr,n),u=$(hr,n),d=pr(hr,n),f=Fn(hr,n),[p,m]=E.useState(null),h=r(t,e=>m(e),d.onItemTextChange,e=>u.itemTextRefCallback?.(e,d.value,d.disabled)),g=p?.textContent,_=E.useMemo(()=>(0,D.jsx)(`option`,{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=f;return s(()=>(v(_),()=>y(_)),[v,y,_]),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(c.span,{id:d.textId,...o,ref:h}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Rt.createPortal(o.children,l.valueNode):null]})});gr.displayName=hr;var _r=`SelectItemIndicator`,vr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return pr(_r,n).isSelected?(0,D.jsx)(c.span,{"aria-hidden":!0,...r,ref:t}):null});vr.displayName=_r;var yr=`SelectScrollUpButton`,br=E.forwardRef((e,t)=>{let n=$(yr,e.__scopeSelect),i=nr(yr,e.__scopeSelect),[a,o]=E.useState(!1),c=r(t,i.onScrollButtonChange);return s(()=>{if(n.viewport&&n.isPositioned){let e=function(){o(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),a?(0,D.jsx)(Cr,{...e,ref:c,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});br.displayName=yr;var xr=`SelectScrollDownButton`,Sr=E.forwardRef((e,t)=>{let n=$(xr,e.__scopeSelect),i=nr(xr,e.__scopeSelect),[a,o]=E.useState(!1),c=r(t,i.onScrollButtonChange);return s(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;o(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),a?(0,D.jsx)(Cr,{...e,ref:c,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Sr.displayName=xr;var Cr=E.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=$(`SelectScrollButton`,n),o=E.useRef(null),u=On(n),d=E.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return E.useEffect(()=>()=>d(),[d]),s(()=>{u().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[u]),(0,D.jsx)(c.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:l(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:l(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:l(i.onPointerLeave,()=>{d()})})}),wr=`SelectSeparator`,Tr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,D.jsx)(c.div,{"aria-hidden":!0,...r,ref:t})});Tr.displayName=wr;var Er=`SelectArrow`,Dr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Mn(n),a=Z(Er,n),o=$(Er,n);return a.open&&o.position===`popper`?(0,D.jsx)(wn,{...i,...r,ref:t}):null});Dr.displayName=Er;var Or=`SelectBubbleInput`,kr=E.forwardRef(({__scopeSelect:e,value:t,...n},i)=>{let a=E.useRef(null),o=r(i,a),s=S(t);return E.useEffect(()=>{let e=a.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(s!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[s,t]),(0,D.jsx)(c.select,{...n,style:{...O,...n.style},ref:o,defaultValue:t})});kr.displayName=Or;function Ar(e){return e===``||e===void 0}function jr(e){let t=h(e),n=E.useRef(``),r=E.useRef(0),i=E.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=E.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Mr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Nr(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Nr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Pr=In,Fr=Rn,Ir=Bn,Lr=Hn,Rr=Wn,zr=Kn,Br=ir,Vr=cr,Hr=mr,Ur=gr,Wr=vr,Gr=Pr,Kr=Vr,qr=Ir,Jr=E.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(Fr,{ref:r,className:Zr(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,D.jsx)(Lr,{asChild:!0,children:(0,D.jsx)(d,{className:`h-4 w-4 opacity-50`})})]}));Jr.displayName=Fr.displayName;var Yr=E.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,D.jsx)(Rr,{children:(0,D.jsx)(zr,{ref:i,className:Zr(`relative z-[100] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:(0,D.jsx)(Br,{className:Zr(`p-1`,n===`popper`&&`w-full min-w-[var(--radix-select-trigger-width)]`),children:t})})}));Yr.displayName=zr.displayName;var Xr=E.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(Hr,{ref:r,className:Zr(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,D.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,D.jsx)(Wr,{children:(0,D.jsx)(T,{className:`h-4 w-4`})})}),(0,D.jsx)(Ur,{children:t})]}));Xr.displayName=Hr.displayName;function Zr(...e){return e.filter(Boolean).join(` `)}export{Jr as a,Xr as i,Yr as n,qr as o,Kr as r,Gr as t};
|
|
1
|
+
import{a as e,f as t,i as n,s as r,u as i}from"./button-BTToMaBW.js";import{a,c as o,n as s,o as c,r as l,t as u}from"./dist-C6eaYCUo.js";import{t as d}from"./chevron-down-CPngAx4M.js";import{n as f,t as p}from"./dist-Cn0y0IRn.js";import{n as m,t as h}from"./dist-Bb9TeEub.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./es2015-CfXu88Y7.js";import{n as S,t as C}from"./dist-D5Dj17P8.js";import{t as w}from"./dist-DZJ9SMlJ.js";import{mt as T}from"./index-B8P4vdT0.js";var E=t(i(),1),D=e(),O=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),k=`VisuallyHidden`,A=E.forwardRef((e,t)=>(0,D.jsx)(c.span,{...e,ref:t,style:{...O,...e.style}}));A.displayName=k;var j=[`top`,`right`,`bottom`,`left`],M=Math.min,N=Math.max,P=Math.round,F=Math.floor,I=e=>({x:e,y:e}),ee={left:`right`,right:`left`,bottom:`top`,top:`bottom`},te={start:`end`,end:`start`};function ne(e,t,n){return N(e,M(t,n))}function L(e,t){return typeof e==`function`?e(t):e}function R(e){return e.split(`-`)[0]}function z(e){return e.split(`-`)[1]}function B(e){return e===`x`?`y`:`x`}function V(e){return e===`y`?`height`:`width`}var re=new Set([`top`,`bottom`]);function H(e){return re.has(R(e))?`y`:`x`}function ie(e){return B(H(e))}function ae(e,t,n){n===void 0&&(n=!1);let r=z(e),i=ie(e),a=V(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=me(o)),[o,me(o)]}function oe(e){let t=me(e);return[se(e),t,se(t)]}function se(e){return e.replace(/start|end/g,e=>te[e])}var ce=[`left`,`right`],le=[`right`,`left`],ue=[`top`,`bottom`],de=[`bottom`,`top`];function fe(e,t,n){switch(e){case`top`:case`bottom`:return n?t?le:ce:t?ce:le;case`left`:case`right`:return t?ue:de;default:return[]}}function pe(e,t,n,r){let i=z(e),a=fe(R(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(se)))),a}function me(e){return e.replace(/left|right|bottom|top/g,e=>ee[e])}function he(e){return{top:0,right:0,bottom:0,left:0,...e}}function ge(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:he(e)}function _e(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ve(e,t,n){let{reference:r,floating:i}=e,a=H(t),o=ie(t),s=V(o),c=R(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(z(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function ye(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=L(t,e),p=ge(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=_e(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=_e(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var be=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ve(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??ye},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=ve(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},xe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=L(e,t)||{};if(l==null)return{};let d=ge(u),f={x:n,y:r},p=ie(i),m=V(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=M(d[_],T),D=M(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=ne(O,A,k),N=!c.arrow&&z(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,P=N?A<O?A-O:A-k:0;return{[p]:f[p]+P,data:{[p]:j,centerOffset:A-j-P,...N&&{alignmentOffset:P}},reset:N}}}),Se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=L(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=R(r),_=H(o),v=R(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[me(o)]:oe(o)),x=p!==`none`;!d&&x&&b.push(...pe(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ae(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==H(t))||T.every(e=>H(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=H(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function we(e){return j.some(t=>e[t]>=0)}var Te=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=L(e,t);switch(i){case`referenceHidden`:{let e=Ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:we(e)}}}case`escaped`:{let e=Ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:we(e)}}}default:return{}}}}},Ee=new Set([`left`,`top`]);async function De(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=R(n),s=z(n),c=H(n)===`y`,l=Ee.has(o)?-1:1,u=a&&c?-1:1,d=L(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Oe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await De(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ke=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=L(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=H(R(i)),p=B(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=ne(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=ne(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ae=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=L(e,t),u={x:n,y:r},d=H(i),f=B(d),p=u[f],m=u[d],h=L(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ee.has(R(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},je=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=L(e,t),u=await o.detectOverflow(t,l),d=R(i),f=z(i),p=H(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=M(h-u[g],v),x=M(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=N(u.left,0),t=N(u.right,0),n=N(u.top,0),r=N(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:N(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:N(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Me(){return typeof window<`u`}function Ne(e){return Pe(e)?(e.nodeName||``).toLowerCase():`#document`}function U(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function W(e){return((Pe(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Pe(e){return Me()?e instanceof Node||e instanceof U(e).Node:!1}function G(e){return Me()?e instanceof Element||e instanceof U(e).Element:!1}function K(e){return Me()?e instanceof HTMLElement||e instanceof U(e).HTMLElement:!1}function Fe(e){return!Me()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof U(e).ShadowRoot}var Ie=new Set([`inline`,`contents`]);function Le(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=q(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ie.has(i)}var Re=new Set([`table`,`td`,`th`]);function ze(e){return Re.has(Ne(e))}var Be=[`:popover-open`,`:modal`];function Ve(e){return Be.some(t=>{try{return e.matches(t)}catch{return!1}})}var He=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Ue=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],We=[`paint`,`layout`,`strict`,`content`];function Ge(e){let t=qe(),n=G(e)?q(e):e;return He.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||Ue.some(e=>(n.willChange||``).includes(e))||We.some(e=>(n.contain||``).includes(e))}function Ke(e){let t=J(e);for(;K(t)&&!Ye(t);){if(Ge(t))return t;if(Ve(t))return null;t=J(t)}return null}function qe(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var Je=new Set([`html`,`body`,`#document`]);function Ye(e){return Je.has(Ne(e))}function q(e){return U(e).getComputedStyle(e)}function Xe(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function J(e){if(Ne(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Fe(e)&&e.host||W(e);return Fe(t)?t.host:t}function Ze(e){let t=J(e);return Ye(t)?e.ownerDocument?e.ownerDocument.body:e.body:K(t)&&Le(t)?t:Ze(t)}function Qe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ze(e),i=r===e.ownerDocument?.body,a=U(r);if(i){let e=$e(a);return t.concat(a,a.visualViewport||[],Le(r)?r:[],e&&n?Qe(e):[])}return t.concat(r,Qe(r,[],n))}function $e(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function et(e){let t=q(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=K(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=P(n)!==a||P(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tt(e){return G(e)?e:e.contextElement}function nt(e){let t=tt(e);if(!K(t))return I(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=et(t),o=(a?P(n.width):n.width)/r,s=(a?P(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var rt=I(0);function it(e){let t=U(e);return!qe()||!t.visualViewport?rt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function at(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==U(e)?!1:t}function Y(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tt(e),o=I(1);t&&(r?G(r)&&(o=nt(r)):o=nt(e));let s=at(a,n,r)?it(a):I(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=U(a),t=r&&G(r)?U(r):r,n=e,i=$e(n);for(;i&&r&&t!==n;){let e=nt(i),t=i.getBoundingClientRect(),r=q(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=U(i),i=$e(n)}}return _e({width:u,height:d,x:c,y:l})}function ot(e,t){let n=Xe(e).scrollLeft;return t?t.left+n:Y(W(e)).left+n}function st(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ot(e,n),y:n.top+t.scrollTop}}function ct(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=W(r),s=t?Ve(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=I(1),u=I(0),d=K(r);if((d||!d&&!a)&&((Ne(r)!==`body`||Le(o))&&(c=Xe(r)),K(r))){let e=Y(r);l=nt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?st(o,c):I(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function lt(e){return Array.from(e.getClientRects())}function ut(e){let t=W(e),n=Xe(e),r=e.ownerDocument.body,i=N(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=N(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+ot(e),s=-n.scrollTop;return q(r).direction===`rtl`&&(o+=N(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var dt=25;function ft(e,t){let n=U(e),r=W(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=qe();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=ot(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=dt&&(a-=o)}else l<=dt&&(a+=l);return{width:a,height:o,x:s,y:c}}var pt=new Set([`absolute`,`fixed`]);function mt(e,t){let n=Y(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=K(e)?nt(e):I(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function ht(e,t,n){let r;if(t===`viewport`)r=ft(e,n);else if(t===`document`)r=ut(W(e));else if(G(t))r=mt(t,n);else{let n=it(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _e(r)}function gt(e,t){let n=J(e);return n===t||!G(n)||Ye(n)?!1:q(n).position===`fixed`||gt(n,t)}function _t(e,t){let n=t.get(e);if(n)return n;let r=Qe(e,[],!1).filter(e=>G(e)&&Ne(e)!==`body`),i=null,a=q(e).position===`fixed`,o=a?J(e):e;for(;G(o)&&!Ye(o);){let t=q(o),n=Ge(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&pt.has(i.position)||Le(o)&&!n&>(e,o))?r=r.filter(e=>e!==o):i=t,o=J(o)}return t.set(e,r),r}function vt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ve(t)?[]:_t(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=ht(t,n,i);return e.top=N(r.top,e.top),e.right=M(r.right,e.right),e.bottom=M(r.bottom,e.bottom),e.left=N(r.left,e.left),e},ht(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function yt(e){let{width:t,height:n}=et(e);return{width:t,height:n}}function bt(e,t,n){let r=K(t),i=W(t),a=n===`fixed`,o=Y(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=I(0);function l(){c.x=ot(i)}if(r||!r&&!a)if((Ne(t)!==`body`||Le(i))&&(s=Xe(t)),r){let e=Y(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?st(i,s):I(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function xt(e){return q(e).position===`static`}function St(e,t){if(!K(e)||q(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return W(e)===n&&(n=n.ownerDocument.body),n}function Ct(e,t){let n=U(e);if(Ve(e))return n;if(!K(e)){let t=J(e);for(;t&&!Ye(t);){if(G(t)&&!xt(t))return t;t=J(t)}return n}let r=St(e,t);for(;r&&ze(r)&&xt(r);)r=St(r,t);return r&&Ye(r)&&xt(r)&&!Ge(r)?n:r||Ke(e)||n}var wt=async function(e){let t=this.getOffsetParent||Ct,n=this.getDimensions,r=await n(e.floating);return{reference:bt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Tt(e){return q(e).direction===`rtl`}var Et={convertOffsetParentRelativeRectToViewportRelativeRect:ct,getDocumentElement:W,getClippingRect:vt,getOffsetParent:Ct,getElementRects:wt,getClientRects:lt,getDimensions:yt,getScale:nt,isElement:G,isRTL:Tt};function Dt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ot(e,t){let n=null,r,i=W(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=F(d),h=F(i.clientWidth-(u+f)),g=F(i.clientHeight-(d+p)),_=F(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:N(0,M(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Dt(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function kt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=tt(e),u=i||a?[...l?Qe(l):[],...Qe(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ot(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?Y(e):null;c&&g();function g(){let t=Y(e);h&&!Dt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var At=Oe,jt=ke,Mt=Se,Nt=je,Pt=Te,Ft=xe,It=Ae,Lt=(e,t,n)=>{let r=new Map,i={platform:Et,...n},a={...i.platform,_c:r};return be(e,t,{...i,platform:a})},Rt=t(o(),1),zt=typeof document<`u`?E.useLayoutEffect:function(){};function Bt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Bt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ht(e,t){let n=Vt(e);return Math.round(t*n)/n}function Ut(e){let t=E.useRef(e);return zt(()=>{t.current=e}),t}function Wt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=E.useState(r);Bt(f,r)||p(r);let[m,h]=E.useState(null),[g,_]=E.useState(null),v=E.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=E.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=E.useRef(null),C=E.useRef(null),w=E.useRef(u),T=c!=null,D=Ut(c),O=Ut(i),k=Ut(l),A=E.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Lt(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Bt(w.current,t)&&(w.current=t,Rt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);zt(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=E.useRef(!1);zt(()=>(j.current=!0,()=>{j.current=!1}),[]),zt(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(D.current)return D.current(b,x,A);A()}},[b,x,A,D,T]);let M=E.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=E.useMemo(()=>({reference:b,floating:x}),[b,x]),P=E.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Ht(N.floating,u.x),r=Ht(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return E.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Gt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Ft({element:r.current,padding:i}).fn(n):r?Ft({element:r,padding:i}).fn(n):{}}}},Kt=(e,t)=>({...At(e),options:[e,t]}),qt=(e,t)=>({...jt(e),options:[e,t]}),Jt=(e,t)=>({...It(e),options:[e,t]}),Yt=(e,t)=>({...Mt(e),options:[e,t]}),Xt=(e,t)=>({...Nt(e),options:[e,t]}),Zt=(e,t)=>({...Pt(e),options:[e,t]}),Qt=(e,t)=>({...Gt(e),options:[e,t]}),$t=`Arrow`,en=E.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,D.jsx)(c.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,D.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});en.displayName=$t;var tn=en,nn=`Popper`,[rn,an]=a(nn),[on,sn]=rn(nn),cn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=E.useState(null);return(0,D.jsx)(on,{scope:t,anchor:r,onAnchorChange:i,children:n})};cn.displayName=nn;var ln=`PopperAnchor`,un=E.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:i,...a}=e,o=sn(ln,n),s=E.useRef(null),l=r(t,s),u=E.useRef(null);return E.useEffect(()=>{let e=u.current;u.current=i?.current||s.current,e!==u.current&&o.onAnchorChange(u.current)}),i?null:(0,D.jsx)(c.div,{...a,ref:l})});un.displayName=ln;var dn=`PopperContent`,[fn,pn]=rn(dn),mn=E.forwardRef((e,t)=>{let{__scopePopper:n,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:m=`partial`,hideWhenDetached:g=!1,updatePositionStrategy:_=`optimized`,onPlaced:v,...y}=e,b=sn(dn,n),[x,S]=E.useState(null),w=r(t,e=>S(e)),[T,O]=E.useState(null),k=C(T),A=k?.width??0,j=k?.height??0,M=i+(o===`center`?``:`-`+o),N=typeof p==`number`?p:{top:0,right:0,bottom:0,left:0,...p},P=Array.isArray(f)?f:[f],F=P.length>0,I={padding:N,boundary:P.filter(vn),altBoundary:F},{refs:ee,floatingStyles:te,placement:ne,isPositioned:L,middlewareData:R}=Wt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>kt(...e,{animationFrame:_===`always`}),elements:{reference:b.anchor},middleware:[Kt({mainAxis:a+j,alignmentAxis:l}),d&&qt({mainAxis:!0,crossAxis:!1,limiter:m===`partial`?Jt():void 0,...I}),d&&Yt({...I}),Xt({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Qt({element:T,padding:u}),yn({arrowWidth:A,arrowHeight:j}),g&&Zt({strategy:`referenceHidden`,...I})]}),[z,B]=bn(ne),V=h(v);s(()=>{L&&V?.()},[L,V]);let re=R.arrow?.x,H=R.arrow?.y,ie=R.arrow?.centerOffset!==0,[ae,oe]=E.useState();return s(()=>{x&&oe(window.getComputedStyle(x).zIndex)},[x]),(0,D.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:L?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(` `),...R.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,D.jsx)(fn,{scope:n,placedSide:z,onArrowChange:O,arrowX:re,arrowY:H,shouldHideArrow:ie,children:(0,D.jsx)(c.div,{"data-side":z,"data-align":B,...y,ref:w,style:{...y.style,animation:L?void 0:`none`}})})})});mn.displayName=dn;var hn=`PopperArrow`,gn={top:`bottom`,right:`left`,bottom:`top`,left:`right`},_n=E.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=pn(hn,n),a=gn[i.placedSide];return(0,D.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,D.jsx)(tn,{...r,ref:t,style:{...r.style,display:`block`}})})});_n.displayName=hn;function vn(e){return e!==null}var yn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=bn(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function bn(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var xn=cn,Sn=un,Cn=mn,wn=_n,Tn=[` `,`Enter`,`ArrowUp`,`ArrowDown`],En=[` `,`Enter`],X=`Select`,[Dn,On,kn]=f(X),[An,jn]=a(X,[kn,an]),Mn=an(),[Nn,Z]=An(X),[Pn,Fn]=An(X),In=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:h,required:g,form:_}=e,v=Mn(t),[y,b]=E.useState(null),[x,S]=E.useState(null),[C,w]=E.useState(!1),T=p(l),[O,k]=u({prop:r,defaultProp:i??!1,onChange:a,caller:X}),[A,j]=u({prop:o,defaultProp:s,onChange:c,caller:X}),M=E.useRef(null),N=y?_||!!y.closest(`form`):!0,[P,F]=E.useState(new Set),I=Array.from(P).map(e=>e.props.value).join(`;`);return(0,D.jsx)(xn,{...v,children:(0,D.jsxs)(Nn,{required:g,scope:t,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:m(),value:A,onValueChange:j,open:O,onOpenChange:k,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[(0,D.jsx)(Dn.Provider,{scope:t,children:(0,D.jsx)(Pn,{scope:e.__scopeSelect,onNativeOptionAdd:E.useCallback(e=>{F(t=>new Set(t).add(e))},[]),onNativeOptionRemove:E.useCallback(e=>{F(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),N?(0,D.jsxs)(kr,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:e=>j(e.target.value),disabled:h,form:_,children:[A===void 0?(0,D.jsx)(`option`,{value:``}):null,Array.from(P)]},I):null]})})};In.displayName=X;var Ln=`SelectTrigger`,Rn=E.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:i=!1,...a}=e,o=Mn(n),s=Z(Ln,n),u=s.disabled||i,d=r(t,s.onTriggerChange),f=On(n),p=E.useRef(`touch`),[m,h,g]=jr(e=>{let t=f().filter(e=>!e.disabled),n=Mr(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),_=e=>{u||(s.onOpenChange(!0),g()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,D.jsx)(Sn,{asChild:!0,...o,children:(0,D.jsx)(c.button,{type:`button`,role:`combobox`,"aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:u,"data-disabled":u?``:void 0,"data-placeholder":Ar(s.value)?``:void 0,...a,ref:d,onClick:l(a.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:l(a.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:l(a.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&h(e.key),!(t&&e.key===` `)&&Tn.includes(e.key)&&(_(),e.preventDefault())})})})});Rn.displayName=Ln;var zn=`SelectValue`,Bn=E.forwardRef((e,t)=>{let{__scopeSelect:n,className:i,style:a,children:o,placeholder:l=``,...u}=e,d=Z(zn,n),{onValueNodeHasChildrenChange:f}=d,p=o!==void 0,m=r(t,d.onValueNodeChange);return s(()=>{f(p)},[f,p]),(0,D.jsx)(c.span,{...u,ref:m,style:{pointerEvents:`none`},children:Ar(d.value)?(0,D.jsx)(D.Fragment,{children:l}):o})});Bn.displayName=zn;var Vn=`SelectIcon`,Hn=E.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,D.jsx)(c.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Hn.displayName=Vn;var Un=`SelectPortal`,Wn=e=>(0,D.jsx)(_,{asChild:!0,...e});Wn.displayName=Un;var Gn=`SelectContent`,Kn=E.forwardRef((e,t)=>{let n=Z(Gn,e.__scopeSelect),[r,i]=E.useState();if(s(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Rt.createPortal((0,D.jsx)(qn,{scope:e.__scopeSelect,children:(0,D.jsx)(Dn.Slot,{scope:e.__scopeSelect,children:(0,D.jsx)(`div`,{children:e.children})})}),t):null}return(0,D.jsx)(Xn,{...e,ref:t})});Kn.displayName=Gn;var Q=10,[qn,$]=An(Gn),Jn=`SelectContentImpl`,Yn=n(`SelectContent.RemoveScroll`),Xn=E.forwardRef((e,t)=>{let{__scopeSelect:n,position:i=`item-aligned`,onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:_,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=Z(Gn,n),[O,k]=E.useState(null),[A,j]=E.useState(null),M=r(t,e=>k(e)),[N,P]=E.useState(null),[F,I]=E.useState(null),ee=On(n),[te,ne]=E.useState(!1),L=E.useRef(!1);E.useEffect(()=>{if(O)return x(O)},[O]),b();let R=E.useCallback(e=>{let[t,...n]=ee().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&A&&(A.scrollTop=0),n===r&&A&&(A.scrollTop=A.scrollHeight),n?.focus(),document.activeElement!==i))return},[ee,A]),z=E.useCallback(()=>R([N,O]),[R,N,O]);E.useEffect(()=>{te&&z()},[te,z]);let{onOpenChange:B,triggerPointerDownPosRef:V}=T;E.useEffect(()=>{if(O){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(V.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(V.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():O.contains(n.target)||B(!1),document.removeEventListener(`pointermove`,t),V.current=null};return V.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[O,B,V]),E.useEffect(()=>{let e=()=>B(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[B]);let[re,H]=jr(e=>{let t=ee().filter(e=>!e.disabled),n=Mr(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ie=E.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&(P(e),r&&(L.current=!0))},[T.value]),ae=E.useCallback(()=>O?.focus(),[O]),oe=E.useCallback((e,t,n)=>{let r=!L.current&&!n;(T.value!==void 0&&T.value===t||r)&&I(e)},[T.value]),se=i===`popper`?er:Qn,ce=se===er?{side:c,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:_,hideWhenDetached:S,avoidCollisions:C}:{};return(0,D.jsx)(qn,{scope:n,content:O,viewport:A,onViewportChange:j,itemRefCallback:ie,selectedItem:N,onItemLeave:ae,itemTextRefCallback:oe,focusSelectedItem:z,selectedItemText:F,position:i,isPositioned:te,searchRef:re,children:(0,D.jsx)(v,{as:Yn,allowPinchZoom:!0,children:(0,D.jsx)(g,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:l(a,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,D.jsx)(y,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,D.jsx)(se,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ce,onPlaced:()=>ne(!0),ref:M,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:l(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&H(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=ee().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>R(t)),e.preventDefault()}})})})})})})});Xn.displayName=Jn;var Zn=`SelectItemAlignedPosition`,Qn=E.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:i,...a}=e,o=Z(Gn,n),l=$(Gn,n),[u,d]=E.useState(null),[f,p]=E.useState(null),m=r(t,e=>p(e)),h=On(n),g=E.useRef(!1),_=E.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=l,S=E.useCallback(()=>{if(o.trigger&&o.valueNode&&u&&f&&v&&y&&b){let e=o.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if(o.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-Q,d=w(a,[Q,Math.max(Q,l-c)]);u.style.minWidth=s+`px`,u.style.left=d+`px`}else{let i=t.right-r.right,a=window.innerWidth-n.right-i,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),l=window.innerWidth-Q,d=w(a,[Q,Math.max(Q,l-c)]);u.style.minWidth=s+`px`,u.style.right=d+`px`}let a=h(),s=window.innerHeight-Q*2,c=v.scrollHeight,l=window.getComputedStyle(f),d=parseInt(l.borderTopWidth,10),p=parseInt(l.paddingTop,10),m=parseInt(l.borderBottomWidth,10),_=parseInt(l.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-Q,O=s-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=d+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;u.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);u.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;u.style.top=`0px`;let t=Math.max(D,d+v.offsetTop+(e?T:0)+k)+M;u.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}u.style.margin=`${Q}px 0`,u.style.minHeight=S+`px`,u.style.maxHeight=s+`px`,i?.(),requestAnimationFrame(()=>g.current=!0)}},[h,o.trigger,o.valueNode,u,f,v,y,b,o.dir,i]);s(()=>S(),[S]);let[C,T]=E.useState();return s(()=>{f&&T(window.getComputedStyle(f).zIndex)},[f]),(0,D.jsx)(tr,{scope:n,contentWrapper:u,shouldExpandOnScrollRef:g,onScrollButtonChange:E.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]),children:(0,D.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,D.jsx)(c.div,{...a,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.style}})})})});Qn.displayName=Zn;var $n=`SelectPopperPosition`,er=E.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Q,...a}=e,o=Mn(n);return(0,D.jsx)(Cn,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});er.displayName=$n;var[tr,nr]=An(Gn,{}),rr=`SelectViewport`,ir=E.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:i,...a}=e,o=$(rr,n),s=nr(rr,n),u=r(t,o.onViewportChange),d=E.useRef(0);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,D.jsx)(Dn.Slot,{scope:n,children:(0,D.jsx)(c.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:u,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:l(a.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(d.current-t.scrollTop);if(e>0){let r=window.innerHeight-Q*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}d.current=t.scrollTop})})})]})});ir.displayName=rr;var ar=`SelectGroup`,[or,sr]=An(ar),cr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=m();return(0,D.jsx)(or,{scope:n,id:i,children:(0,D.jsx)(c.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});cr.displayName=ar;var lr=`SelectLabel`,ur=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=sr(lr,n);return(0,D.jsx)(c.div,{id:i.id,...r,ref:t})});ur.displayName=lr;var dr=`SelectItem`,[fr,pr]=An(dr),mr=E.forwardRef((e,t)=>{let{__scopeSelect:n,value:i,disabled:a=!1,textValue:o,...s}=e,u=Z(dr,n),d=$(dr,n),f=u.value===i,[p,h]=E.useState(o??``),[g,_]=E.useState(!1),v=r(t,e=>d.itemRefCallback?.(e,i,a)),y=m(),b=E.useRef(`touch`),x=()=>{a||(u.onValueChange(i),u.onOpenChange(!1))};if(i===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,D.jsx)(fr,{scope:n,value:i,disabled:a,textId:y,isSelected:f,onItemTextChange:E.useCallback(e=>{h(t=>t||(e?.textContent??``).trim())},[]),children:(0,D.jsx)(Dn.ItemSlot,{scope:n,value:i,disabled:a,textValue:p,children:(0,D.jsx)(c.div,{role:`option`,"aria-labelledby":y,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...s,ref:v,onFocus:l(s.onFocus,()=>_(!0)),onBlur:l(s.onBlur,()=>_(!1)),onClick:l(s.onClick,()=>{b.current!==`mouse`&&x()}),onPointerUp:l(s.onPointerUp,()=>{b.current===`mouse`&&x()}),onPointerDown:l(s.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:l(s.onPointerMove,e=>{b.current=e.pointerType,a?d.onItemLeave?.():b.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:l(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:l(s.onKeyDown,e=>{d.searchRef?.current!==``&&e.key===` `||(En.includes(e.key)&&x(),e.key===` `&&e.preventDefault())})})})})});mr.displayName=dr;var hr=`SelectItemText`,gr=E.forwardRef((e,t)=>{let{__scopeSelect:n,className:i,style:a,...o}=e,l=Z(hr,n),u=$(hr,n),d=pr(hr,n),f=Fn(hr,n),[p,m]=E.useState(null),h=r(t,e=>m(e),d.onItemTextChange,e=>u.itemTextRefCallback?.(e,d.value,d.disabled)),g=p?.textContent,_=E.useMemo(()=>(0,D.jsx)(`option`,{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=f;return s(()=>(v(_),()=>y(_)),[v,y,_]),(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(c.span,{id:d.textId,...o,ref:h}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Rt.createPortal(o.children,l.valueNode):null]})});gr.displayName=hr;var _r=`SelectItemIndicator`,vr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return pr(_r,n).isSelected?(0,D.jsx)(c.span,{"aria-hidden":!0,...r,ref:t}):null});vr.displayName=_r;var yr=`SelectScrollUpButton`,br=E.forwardRef((e,t)=>{let n=$(yr,e.__scopeSelect),i=nr(yr,e.__scopeSelect),[a,o]=E.useState(!1),c=r(t,i.onScrollButtonChange);return s(()=>{if(n.viewport&&n.isPositioned){let e=function(){o(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),a?(0,D.jsx)(Cr,{...e,ref:c,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});br.displayName=yr;var xr=`SelectScrollDownButton`,Sr=E.forwardRef((e,t)=>{let n=$(xr,e.__scopeSelect),i=nr(xr,e.__scopeSelect),[a,o]=E.useState(!1),c=r(t,i.onScrollButtonChange);return s(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;o(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),a?(0,D.jsx)(Cr,{...e,ref:c,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Sr.displayName=xr;var Cr=E.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=$(`SelectScrollButton`,n),o=E.useRef(null),u=On(n),d=E.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return E.useEffect(()=>()=>d(),[d]),s(()=>{u().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[u]),(0,D.jsx)(c.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:l(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:l(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:l(i.onPointerLeave,()=>{d()})})}),wr=`SelectSeparator`,Tr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,D.jsx)(c.div,{"aria-hidden":!0,...r,ref:t})});Tr.displayName=wr;var Er=`SelectArrow`,Dr=E.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Mn(n),a=Z(Er,n),o=$(Er,n);return a.open&&o.position===`popper`?(0,D.jsx)(wn,{...i,...r,ref:t}):null});Dr.displayName=Er;var Or=`SelectBubbleInput`,kr=E.forwardRef(({__scopeSelect:e,value:t,...n},i)=>{let a=E.useRef(null),o=r(i,a),s=S(t);return E.useEffect(()=>{let e=a.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(s!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[s,t]),(0,D.jsx)(c.select,{...n,style:{...O,...n.style},ref:o,defaultValue:t})});kr.displayName=Or;function Ar(e){return e===``||e===void 0}function jr(e){let t=h(e),n=E.useRef(``),r=E.useRef(0),i=E.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=E.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Mr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Nr(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Nr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Pr=In,Fr=Rn,Ir=Bn,Lr=Hn,Rr=Wn,zr=Kn,Br=ir,Vr=cr,Hr=mr,Ur=gr,Wr=vr,Gr=Pr,Kr=Vr,qr=Ir,Jr=E.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(Fr,{ref:r,className:Zr(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,D.jsx)(Lr,{asChild:!0,children:(0,D.jsx)(d,{className:`h-4 w-4 opacity-50`})})]}));Jr.displayName=Fr.displayName;var Yr=E.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,D.jsx)(Rr,{children:(0,D.jsx)(zr,{ref:i,className:Zr(`relative z-[100] max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:(0,D.jsx)(Br,{className:Zr(`p-1`,n===`popper`&&`w-full min-w-[var(--radix-select-trigger-width)]`),children:t})})}));Yr.displayName=zr.displayName;var Xr=E.forwardRef(({className:e,children:t,...n},r)=>(0,D.jsxs)(Hr,{ref:r,className:Zr(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,D.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,D.jsx)(Wr,{children:(0,D.jsx)(T,{className:`h-4 w-4`})})}),(0,D.jsx)(Ur,{children:t})]}));Xr.displayName=Hr.displayName;function Zr(...e){return e.filter(Boolean).join(` `)}export{Jr as a,Xr as i,Yr as n,qr as o,Kr as r,Gr as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./circle-alert-Q8cZk9Rv.js";import{t as o}from"./circle-x-C9USji_R.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as ee}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./rotate-ccw-CAYM6Vv0.js";import{t as c}from"./smartphone-DKeDuJTU.js";import{a as ne,i as l,n as re,o as ie,r as ae,t as oe}from"./select-DozhHbSJ.js";import"./es2015-CfXu88Y7.js";import{t as se}from"./switch-C-Xk56TK.js";import{a as u,c as ce,l as le,n as ue,o as d,r as f,s as de,t as fe}from"./ai-config-store-DQXVJVn_.js";import{$ as p,A as m,B as pe,G as me,H as he,J as ge,O as h,U as g,V as _,X as _e,Z as ve,_ as ye,at as be,b as v,c as xe,d as Se,f as Ce,g as we,h as Te,it as Ee,k as y,l as b,lt as x,m as S,mt as De,o as Oe,p as C,pt as w,s as ke,u as T,v as Ae,y as je,z as E}from"./index-BB8Kl9wK.js";import{n as Me,r as Ne,t as Pe}from"./alert-Bve02Ufr.js";var Fe=n(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=n(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Le=n(`stethoscope`,[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]),D=t(i(),1),O=e(),Re=[{value:`75`,label:`75%`,scale:.75},{value:`90`,label:`90%`,scale:.9},{value:`100`,label:`100%`,scale:1},{value:`110`,label:`110%`,scale:1.1},{value:`125`,label:`125%`,scale:1.25},{value:`150`,label:`150%`,scale:1.5}],ze=[{value:`auto`,label:`自动`,color:`linear-gradient(135deg, oklch(0.623 0.214 259.815), oklch(0.606 0.25 292.717))`},{value:`neutral`,label:`中性`,color:`oklch(0.556 0 0)`},{value:`blue`,label:`蓝色`,color:`oklch(0.623 0.214 259.815)`},{value:`violet`,label:`紫色`,color:`oklch(0.606 0.25 292.717)`},{value:`green`,label:`绿色`,color:`oklch(0.627 0.194 149.214)`},{value:`orange`,label:`橙色`,color:`oklch(0.646 0.222 41.116)`},{value:`rose`,label:`玫红`,color:`oklch(0.645 0.246 16.439)`}],k=`app-panel-content mt-0`,A=`app-field-group`,j=`app-section`,M=e=>{if(!e)return`100`;let t={small:`90`,medium:`100`,large:`110`};return e in t?t[e]:Re.some(t=>t.value===e)?e:`100`};function Be({open:e=!1,onOpenChange:t,embedded:n=!1}){let{theme:i,accentColor:Be,setTheme:Ve,setAccentColor:He,setZoom:N}=Oe(),[P,Ue]=(0,D.useState)(`preferences`),[F,I]=(0,D.useState)(()=>f()),[L,We]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[Ge,H]=(0,D.useState)(``),[U,W]=(0,D.useState)(null),[G,Ke]=(0,D.useState)(``),[qe,Je]=(0,D.useState)([]),[K,q]=(0,D.useState)({}),[J,Ye]=(0,D.useState)(``),[Y,Xe]=(0,D.useState)(``),[X,Z]=(0,D.useState)(null),[Ze,Qe]=(0,D.useState)(!1),[Q,$e]=(0,D.useState)(()=>M(ke().fontSize)),[et,tt]=(0,D.useState)(!1);(0,D.useEffect)(()=>{xe().then(e=>{let t=M(e.fontSize);$e(t),N(parseInt(t,10)/100),tt(!0)}).catch(()=>{tt(!0)})},[N]),(0,D.useEffect)(()=>{if(!et)return;let e=M(Q);N(parseInt(e,10)/100),b({fontSize:e}).catch(console.error)},[N,et,Q]),(0,D.useEffect)(()=>{(e||n)&&(xe().then(e=>{I(e.aiConfig),Ke(e.mocksFilePath||``),q(e.clientAliases||{})}).catch(()=>{I(f())}),V(null),H(``),fetch(`/api/rule-files`).then(e=>e.json()).then(e=>{Array.isArray(e)&&Je(e)}).catch(()=>{}))},[e,n]);let nt=e=>{let t=u(e);I({...F,provider:e,baseUrl:t.baseUrl,model:t.model})},rt=async()=>{z(!0);try{await b({aiConfig:F}),ce(F),V(`success`),H(`AI 配置保存成功`),T.success(`AI 配置保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},it=()=>{de(),I(f()),V(null),H(``)},at=async()=>{if(!d(F)){V(`error`),H(`请填写完整的配置信息`);return}z(!0),V(null),H(`测试中...`);try{let e=F.baseUrl,t={"Content-Type":`application/json`},n;F.provider===`anthropic`?(t[`x-api-key`]=F.apiKey,t[`anthropic-version`]=`2023-06-01`,n={model:F.model,max_tokens:100,system:`You are a helpful assistant.`,messages:[{role:`user`,content:`Say "test successful"`}],temperature:.3}):(t.Authorization=`Bearer ${F.apiKey}`,n={model:F.model,messages:[{role:`system`,content:`You are a helpful assistant.`},{role:`user`,content:`Say "test successful"`}],temperature:.3,max_tokens:100});let r=await fetch(e,{method:`POST`,headers:t,body:JSON.stringify(n)});if(!r.ok){let e=await r.text();throw Error(`API错误 (${r.status}): ${e}`)}let i=await r.json();if(F.provider===`anthropic`){if(!i.content?.[0]?.text)throw Error(`API响应格式不正确`)}else if(!i.choices?.[0]?.message?.content)throw Error(`API响应格式不正确`);V(`success`),H(`连接测试成功! API配置正常`)}catch(e){V(`error`),H(e instanceof Error?e.message:`测试失败`)}finally{z(!1)}},ot=(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/refresh-config`,{method:`POST`});if(e.ok){let t=await e.json();V(`success`),H(t.message||`配置已刷新`),setTimeout(()=>{V(null),H(``)},2e3)}else{let t=await e.json();V(`error`),H(t.error||`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}}catch(e){console.error(`刷新配置失败:`,e),V(`error`),H(`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}},[]),st=(0,D.useCallback)(async()=>{Qe(!0),Z(null);try{let e=await fetch(`/api/config-doctor`);e.ok?Z(await e.json()):(V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3))}catch(e){console.error(`诊断失败:`,e),V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3)}finally{Qe(!1)}},[]),ct=()=>{let e=J.trim(),t=Y.trim();!e||!t||(q(n=>({...n,[e]:t})),Ye(``),Xe(``))},lt=async()=>{z(!0);try{await b({clientAliases:K}),V(`success`),H(`客户端名称已保存,新请求立即生效`),T.success(`客户端名称保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},ut=async()=>{z(!0);try{await b({mocksFilePath:G}),V(`success`),H(`Mock 文件路径已更新,刷新页面后生效`),T.success(`Mock 文件路径保存成功`),setTimeout(()=>{V(null),H(``)},3e3)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}};Se({active:(e||n)&&P!==`preferences`,enabled:!R,priority:Ce.panel,onSave:()=>{if(P===`config`)return ut();if(P===`clients`)return lt();if(P===`ai`)return rt()}});let $=(0,O.jsxs)(O.Fragment,{children:[!n&&(0,O.jsxs)(Ae,{className:`px-6 pt-6 pb-4`,children:[(0,O.jsxs)(je,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ve,{className:`h-5 w-5`}),`系统设置`]}),(0,O.jsx)(ye,{children:`管理系统偏好、配置和 AI 功能`})]}),(0,O.jsxs)(pe,{value:P,onValueChange:e=>Ue(e),orientation:`vertical`,className:`min-h-0 flex-1 gap-0`,children:[(0,O.jsxs)(he,{"aria-label":`设置分类`,className:`h-full w-14 shrink-0 self-stretch justify-start gap-1 rounded-none border-r bg-muted/25 p-2 group-data-[orientation=vertical]/tabs:!h-full sm:w-44 sm:p-3`,children:[(0,O.jsxs)(g,{value:`preferences`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(ve,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`偏好设置`})]}),(0,O.jsxs)(g,{value:`config`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(x,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`配置文件`})]}),(0,O.jsxs)(g,{value:`clients`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(c,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`客户端`})]}),(0,O.jsxs)(g,{value:`ai`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(_e,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`AI 配置`})]})]}),(0,O.jsxs)(_,{value:`preferences`,className:k,children:[(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`主题`}),(0,O.jsxs)(oe,{value:i,onValueChange:e=>Ve(e),children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择主题`})}),(0,O.jsx)(re,{children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(l,{value:`system`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(be,{className:`size-4`}),`跟随系统`]})}),(0,O.jsx)(l,{value:`light`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ge,{className:`size-4`}),`浅色模式`]})}),(0,O.jsx)(l,{value:`dark`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ee,{className:`size-4`}),`深色模式`]})})]})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`强调色`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`统一按钮、状态、选中项和焦点样式。自动模式会根据明暗主题选择合适的颜色。`})]}),(0,O.jsx)(h,{type:`single`,value:Be,onValueChange:e=>{e&&He(e)},variant:`outline`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`强调色`,children:ze.map(e=>(0,O.jsxs)(y,{value:e.value,"aria-label":e.label,children:[e.value===`auto`?(0,O.jsx)(_e,{"data-icon":`inline-start`}):(0,O.jsx)(`span`,{className:`size-3 rounded-full border border-foreground/10`,style:{background:e.color}}),e.label]},e.value))})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`缩放比例`}),(0,O.jsxs)(oe,{value:Q,onValueChange:$e,children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择缩放比例`})}),(0,O.jsx)(re,{children:(0,O.jsx)(ae,{children:Re.map(e=>(0,O.jsx)(l,{value:e.value,children:e.label},e.value))})})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`关于`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Meddle - HTTP 调试代理工具`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`版本: 1.0.0`})]})]}),(0,O.jsxs)(_,{value:`config`,className:k,children:[(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`路由规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:`~/.meddle/route-rules/`})]}),qe.length>0?(0,O.jsx)(`div`,{className:`space-y-2`,children:qe.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2.5 text-sm`,children:[(0,O.jsx)(E,{variant:e.enabled?`default`:`secondary`,className:`text-[10px]`,children:e.enabled?`已启用`:`未启用`}),(0,O.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[e.name,`.txt`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.ruleCount,` 条规则`]})]},e.name))}):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`暂无规则文件`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`规则文件存放于 ~/.meddle/route-rules/ 目录,纯文本格式。在"路由规则"页面管理。`})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`Mock 规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:G||`默认: ~/.meddle/mocks.json`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`mocksPath`,className:`text-xs text-muted-foreground`,children:`自定义 Mock 规则文件路径(留空使用默认)`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`mocksPath`,value:G,onChange:e=>Ke(e.target.value),placeholder:`如: /path/to/my-mocks.json`,className:`flex-1 h-8 text-sm font-mono`}),(0,O.jsxs)(C,{variant:`outline`,size:`sm`,onClick:ut,disabled:R,className:`h-8`,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-3 w-3`}),`应用`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`必须是 JSON 格式的 Mock 规则文件`})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`操作`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:ot,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1`}),`重新加载配置`]}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:st,disabled:Ze,children:[(0,O.jsx)(Le,{className:`h-4 w-4 mr-1`}),Ze?`诊断中...`:`诊断配置`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`点击重新加载可应用修改后的配置文件,点击诊断配置可检查配置有效性`})]}),X&&(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-medium`,children:[(0,O.jsx)(Le,{className:`h-4 w-4`}),`诊断结果`]}),(0,O.jsxs)(`div`,{className:`mb-3 p-3 rounded-md border ${X.status===`ok`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:X.status===`warning`?`bg-yellow-50 dark:bg-yellow-950/20 border-yellow-200 dark:border-yellow-900`:`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`}`,children:[X.status===`ok`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(w,{className:`h-5 w-5 text-green-600 dark:text-green-400`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-green-300`,children:`所有检查通过!配置正常。`})]}),X.status===`warning`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(a,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-yellow-700 dark:text-yellow-300`,children:[`发现 `,X.warnings.length,` 个警告`]})]}),X.status===`error`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-red-600 dark:text-red-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:[`发现 `,X.errors.length,` 个错误`]})]})]}),(0,O.jsx)(`div`,{className:A,children:X.checks.map((e,t)=>(0,O.jsx)(`div`,{className:`p-2 rounded border bg-card`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(w,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5 shrink-0`}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:e.path}),e.details&&(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.details.totalFiles!==void 0&&`${e.details.enabledFiles}/${e.details.totalFiles} 个文件已启用`,e.details.totalRules!==void 0&&` · ${e.details.totalRules} 条规则`,e.details.rules!==void 0&&`${e.details.rules} 条规则`,e.details.total!==void 0&&`${e.details.total} 条规则 (${e.details.enabled} 已启用)`,e.details.size!==void 0&&` · ${e.details.size} bytes`]})]})]})},t))}),X.warnings&&X.warnings.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-yellow-700 dark:text-yellow-300`,children:`警告:`}),X.warnings.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,O.jsx)(a,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]}),X.errors&&X.errors.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-red-700 dark:text-red-300`,children:`错误:`}),X.errors.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-red-600 dark:text-red-400`,children:[(0,O.jsx)(o,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]})]})]})]}),(0,O.jsxs)(_,{value:`clients`,className:k,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4`}),`远程客户端名称`]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将日志中的客户端 IP 映射为设备名称。保存后新请求立即生效,无需重启代理。`})]}),(0,O.jsx)(`div`,{className:A,children:Object.entries(K).length===0?(0,O.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground`,children:`尚未配置设备名称`}):Object.entries(K).map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:e,readOnly:!0,className:`h-8 flex-1 font-mono text-xs bg-muted/40`,"aria-label":`客户端 IP ${e}`}),(0,O.jsx)(m,{value:t,onChange:t=>{let n=t.target.value;q(t=>({...t,[e]:n}))},className:`h-8 flex-1 text-sm`,"aria-label":`${e} 的设备名称`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{q(t=>{let n={...t};return delete n[e],n})},title:`删除设备名称`,children:(0,O.jsx)(me,{className:`h-4 w-4`})})]},e))}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`添加设备`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:J,onChange:e=>Ye(e.target.value),placeholder:`客户端 IP,例如 10.13.232.187`,className:`h-8 flex-1 font-mono text-xs`}),(0,O.jsx)(m,{value:Y,onChange:e=>Xe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ct()},placeholder:`设备名称,例如 iPhone`,className:`h-8 flex-1 text-sm`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-8`,onClick:ct,disabled:!J.trim()||!Y.trim(),children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加`]})]})]}),(0,O.jsxs)(C,{onClick:lt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存客户端名称`]})]}),(0,O.jsxs)(_,{value:`ai`,className:k,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`启用 AI 功能`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`启用智能代码修复功能`})]}),(0,O.jsx)(se,{checked:F.enabled,onCheckedChange:e=>I({...F,enabled:e}),"aria-label":`启用 AI 功能`})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`AI 模型配置`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:()=>{W({name:``,provider:`openai`,apiKey:``,baseUrl:`https://api.openai.com/v1/chat/completions`,model:`gpt-4o-mini`})},children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加模型`]})]}),(0,O.jsx)(`div`,{className:A,children:F.models&&F.models.length>0?F.models.map(e=>(0,O.jsx)(`div`,{className:`p-3 rounded-md border ${F.activeModelId===e.id?`border-primary bg-primary/5`:`border-border`}`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),F.activeModelId===e.id&&(0,O.jsx)(E,{variant:`default`,className:`text-xs`,children:`当前使用`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[e.provider===`openai`?`OpenAI`:`Anthropic`,` - `,e.model]})]}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[F.activeModelId!==e.id&&(0,O.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(le(F,e.id)),className:`h-7 text-xs`,children:[(0,O.jsx)(De,{className:`h-3 w-3 mr-1`}),`使用`]}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(ue(F,e.id)),className:`h-7 w-7 p-0 text-destructive`,children:(0,O.jsx)(me,{className:`h-3 w-3`})})]})]})},e.id)):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground italic py-4 text-center`,children:`暂无模型配置,点击"添加模型"创建`})}),U&&(0,O.jsxs)(`div`,{className:`space-y-5 rounded-md border border-primary bg-primary/5 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`新增模型`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>W(null),className:`h-6 w-6 p-0`,children:(0,O.jsx)(o,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelName`,className:`text-xs`,children:`模型名称`}),(0,O.jsx)(m,{id:`newModelName`,value:U.name||``,onChange:e=>W({...U,name:e.target.value}),placeholder:`如:GPT-4o Mini`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`服务商`}),(0,O.jsxs)(h,{type:`single`,value:U.provider,onValueChange:e=>{if(e===`openai`){let e=u(`openai`);W({...U,provider:`openai`,baseUrl:e.baseUrl,model:e.model})}else if(e===`anthropic`){let e=u(`anthropic`);W({...U,provider:`anthropic`,baseUrl:e.baseUrl,model:e.model})}},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelApiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsx)(m,{id:`newModelApiKey`,type:L?`text`:`password`,value:U.apiKey||``,onChange:e=>W({...U,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelModel`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`newModelModel`,value:U.model||``,onChange:e=>W({...U,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelBaseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`newModelBaseUrl`,value:U.baseUrl||``,onChange:e=>W({...U,baseUrl:e.target.value}),placeholder:`API 端点`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>W(null),className:`h-7 text-xs`,children:`取消`}),(0,O.jsxs)(r,{size:`sm`,onClick:()=>{U.name&&U.apiKey&&U.model&&U.baseUrl&&(I(fe(F,U)),W(null))},disabled:!U.name||!U.apiKey||!U.model||!U.baseUrl,className:`h-7 text-xs`,children:[(0,O.jsx)(s,{className:`h-3 w-3 mr-1`}),`添加`]})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`传统配置(向后兼容)`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`如果未配置多模型,将使用此配置`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`AI 服务商`}),(0,O.jsxs)(h,{type:`single`,value:F.provider,onValueChange:e=>{(e===`openai`||e===`anthropic`)&&nt(e)},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`apiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`apiKey`,type:L?`text`:`password`,value:F.apiKey,onChange:e=>I({...F,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`flex-1 h-8 text-sm`}),(0,O.jsx)(r,{variant:`outline`,size:`icon`,onClick:()=>We(!L),className:`h-8 w-8`,children:L?(0,O.jsx)(Fe,{className:`h-4 w-4`}):(0,O.jsx)(Ie,{className:`h-4 w-4`})})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`model`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`model`,value:F.model,onChange:e=>I({...F,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`baseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I({...F,baseUrl:e.target.value}),placeholder:F.provider===`openai`?`https://api.openai.com/v1/chat/completions`:`https://api.anthropic.com/v1/messages`,className:`h-8 text-sm`})]}),Ge&&(0,O.jsxs)(Pe,{variant:B===`error`?`destructive`:`default`,children:[B===`success`?(0,O.jsx)(w,{}):B===`error`?(0,O.jsx)(o,{}):(0,O.jsx)(a,{}),(0,O.jsx)(Ne,{children:B===`success`?`操作成功`:B===`error`?`操作失败`:`处理中`}),(0,O.jsx)(Me,{children:Ge})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`flex justify-between`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:it,children:[(0,O.jsx)(te,{className:`h-4 w-4 mr-1`}),`重置`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:at,disabled:!d(F)||R,children:`测试连接`}),(0,O.jsxs)(C,{size:`sm`,onClick:rt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存`]})]})]})]})]})]});return n?(0,O.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:$}):(0,O.jsx)(Te,{open:e,onOpenChange:t,children:(0,O.jsx)(we,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:600,storageKey:`settings-panel`,children:$})})}export{Be as SettingsPanel};
|
|
1
|
+
import{a as e,f as t,l as n,t as r,u as i}from"./button-BTToMaBW.js";import"./dist-C6eaYCUo.js";import{t as a}from"./circle-alert-Q8cZk9Rv.js";import{t as o}from"./circle-x-C9USji_R.js";import{t as s}from"./plus-tVxSydJ8.js";import{t as ee}from"./refresh-cw-CG3HaiQT.js";import{t as te}from"./rotate-ccw-CAYM6Vv0.js";import{t as c}from"./smartphone-DKeDuJTU.js";import{a as ne,i as l,n as re,o as ie,r as ae,t as oe}from"./select-hRbutLaS.js";import"./es2015-CfXu88Y7.js";import{t as se}from"./switch-C-Xk56TK.js";import{a as u,c as ce,l as le,n as ue,o as d,r as f,s as de,t as fe}from"./ai-config-store-DQXVJVn_.js";import{$ as p,A as m,B as pe,G as me,H as he,J as ge,O as h,U as g,V as _,X as _e,Z as ve,_ as ye,at as be,b as v,c as xe,d as Se,f as Ce,g as we,h as Te,it as Ee,k as y,l as b,lt as x,m as S,mt as De,o as Oe,p as C,pt as w,s as ke,u as T,v as Ae,y as je,z as E}from"./index-B8P4vdT0.js";import{n as Me,r as Ne,t as Pe}from"./alert-Bve02Ufr.js";var Fe=n(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=n(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Le=n(`stethoscope`,[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]),D=t(i(),1),O=e(),Re=[{value:`75`,label:`75%`,scale:.75},{value:`90`,label:`90%`,scale:.9},{value:`100`,label:`100%`,scale:1},{value:`110`,label:`110%`,scale:1.1},{value:`125`,label:`125%`,scale:1.25},{value:`150`,label:`150%`,scale:1.5}],ze=[{value:`auto`,label:`自动`,color:`linear-gradient(135deg, oklch(0.623 0.214 259.815), oklch(0.606 0.25 292.717))`},{value:`neutral`,label:`中性`,color:`oklch(0.556 0 0)`},{value:`blue`,label:`蓝色`,color:`oklch(0.623 0.214 259.815)`},{value:`violet`,label:`紫色`,color:`oklch(0.606 0.25 292.717)`},{value:`green`,label:`绿色`,color:`oklch(0.627 0.194 149.214)`},{value:`orange`,label:`橙色`,color:`oklch(0.646 0.222 41.116)`},{value:`rose`,label:`玫红`,color:`oklch(0.645 0.246 16.439)`}],k=`app-panel-content mt-0`,A=`app-field-group`,j=`app-section`,M=e=>{if(!e)return`100`;let t={small:`90`,medium:`100`,large:`110`};return e in t?t[e]:Re.some(t=>t.value===e)?e:`100`};function Be({open:e=!1,onOpenChange:t,embedded:n=!1}){let{theme:i,accentColor:Be,setTheme:Ve,setAccentColor:He,setZoom:N}=Oe(),[P,Ue]=(0,D.useState)(`preferences`),[F,I]=(0,D.useState)(()=>f()),[L,We]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[Ge,H]=(0,D.useState)(``),[U,W]=(0,D.useState)(null),[G,Ke]=(0,D.useState)(``),[qe,Je]=(0,D.useState)([]),[K,q]=(0,D.useState)({}),[J,Ye]=(0,D.useState)(``),[Y,Xe]=(0,D.useState)(``),[X,Z]=(0,D.useState)(null),[Ze,Qe]=(0,D.useState)(!1),[Q,$e]=(0,D.useState)(()=>M(ke().fontSize)),[et,tt]=(0,D.useState)(!1);(0,D.useEffect)(()=>{xe().then(e=>{let t=M(e.fontSize);$e(t),N(parseInt(t,10)/100),tt(!0)}).catch(()=>{tt(!0)})},[N]),(0,D.useEffect)(()=>{if(!et)return;let e=M(Q);N(parseInt(e,10)/100),b({fontSize:e}).catch(console.error)},[N,et,Q]),(0,D.useEffect)(()=>{(e||n)&&(xe().then(e=>{I(e.aiConfig),Ke(e.mocksFilePath||``),q(e.clientAliases||{})}).catch(()=>{I(f())}),V(null),H(``),fetch(`/api/rule-files`).then(e=>e.json()).then(e=>{Array.isArray(e)&&Je(e)}).catch(()=>{}))},[e,n]);let nt=e=>{let t=u(e);I({...F,provider:e,baseUrl:t.baseUrl,model:t.model})},rt=async()=>{z(!0);try{await b({aiConfig:F}),ce(F),V(`success`),H(`AI 配置保存成功`),T.success(`AI 配置保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},it=()=>{de(),I(f()),V(null),H(``)},at=async()=>{if(!d(F)){V(`error`),H(`请填写完整的配置信息`);return}z(!0),V(null),H(`测试中...`);try{let e=F.baseUrl,t={"Content-Type":`application/json`},n;F.provider===`anthropic`?(t[`x-api-key`]=F.apiKey,t[`anthropic-version`]=`2023-06-01`,n={model:F.model,max_tokens:100,system:`You are a helpful assistant.`,messages:[{role:`user`,content:`Say "test successful"`}],temperature:.3}):(t.Authorization=`Bearer ${F.apiKey}`,n={model:F.model,messages:[{role:`system`,content:`You are a helpful assistant.`},{role:`user`,content:`Say "test successful"`}],temperature:.3,max_tokens:100});let r=await fetch(e,{method:`POST`,headers:t,body:JSON.stringify(n)});if(!r.ok){let e=await r.text();throw Error(`API错误 (${r.status}): ${e}`)}let i=await r.json();if(F.provider===`anthropic`){if(!i.content?.[0]?.text)throw Error(`API响应格式不正确`)}else if(!i.choices?.[0]?.message?.content)throw Error(`API响应格式不正确`);V(`success`),H(`连接测试成功! API配置正常`)}catch(e){V(`error`),H(e instanceof Error?e.message:`测试失败`)}finally{z(!1)}},ot=(0,D.useCallback)(async()=>{try{let e=await fetch(`/api/refresh-config`,{method:`POST`});if(e.ok){let t=await e.json();V(`success`),H(t.message||`配置已刷新`),setTimeout(()=>{V(null),H(``)},2e3)}else{let t=await e.json();V(`error`),H(t.error||`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}}catch(e){console.error(`刷新配置失败:`,e),V(`error`),H(`刷新配置失败`),setTimeout(()=>{V(null),H(``)},2e3)}},[]),st=(0,D.useCallback)(async()=>{Qe(!0),Z(null);try{let e=await fetch(`/api/config-doctor`);e.ok?Z(await e.json()):(V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3))}catch(e){console.error(`诊断失败:`,e),V(`error`),H(`诊断失败`),setTimeout(()=>{V(null),H(``)},2e3)}finally{Qe(!1)}},[]),ct=()=>{let e=J.trim(),t=Y.trim();!e||!t||(q(n=>({...n,[e]:t})),Ye(``),Xe(``))},lt=async()=>{z(!0);try{await b({clientAliases:K}),V(`success`),H(`客户端名称已保存,新请求立即生效`),T.success(`客户端名称保存成功`)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}},ut=async()=>{z(!0);try{await b({mocksFilePath:G}),V(`success`),H(`Mock 文件路径已更新,刷新页面后生效`),T.success(`Mock 文件路径保存成功`),setTimeout(()=>{V(null),H(``)},3e3)}catch(e){let t=e instanceof Error?e.message:`保存失败`;V(`error`),H(t),T.error(t)}finally{z(!1)}};Se({active:(e||n)&&P!==`preferences`,enabled:!R,priority:Ce.panel,onSave:()=>{if(P===`config`)return ut();if(P===`clients`)return lt();if(P===`ai`)return rt()}});let $=(0,O.jsxs)(O.Fragment,{children:[!n&&(0,O.jsxs)(Ae,{className:`px-6 pt-6 pb-4`,children:[(0,O.jsxs)(je,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ve,{className:`h-5 w-5`}),`系统设置`]}),(0,O.jsx)(ye,{children:`管理系统偏好、配置和 AI 功能`})]}),(0,O.jsxs)(pe,{value:P,onValueChange:e=>Ue(e),orientation:`vertical`,className:`min-h-0 flex-1 gap-0`,children:[(0,O.jsxs)(he,{"aria-label":`设置分类`,className:`h-full w-14 shrink-0 self-stretch justify-start gap-1 rounded-none border-r bg-muted/25 p-2 group-data-[orientation=vertical]/tabs:!h-full sm:w-44 sm:p-3`,children:[(0,O.jsxs)(g,{value:`preferences`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(ve,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`偏好设置`})]}),(0,O.jsxs)(g,{value:`config`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(x,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`配置文件`})]}),(0,O.jsxs)(g,{value:`clients`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(c,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`客户端`})]}),(0,O.jsxs)(g,{value:`ai`,className:`h-9 w-full flex-none justify-start px-2.5 sm:px-3`,children:[(0,O.jsx)(_e,{}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`AI 配置`})]})]}),(0,O.jsxs)(_,{value:`preferences`,className:k,children:[(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`主题`}),(0,O.jsxs)(oe,{value:i,onValueChange:e=>Ve(e),children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择主题`})}),(0,O.jsx)(re,{children:(0,O.jsxs)(ae,{children:[(0,O.jsx)(l,{value:`system`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(be,{className:`size-4`}),`跟随系统`]})}),(0,O.jsx)(l,{value:`light`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(ge,{className:`size-4`}),`浅色模式`]})}),(0,O.jsx)(l,{value:`dark`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(Ee,{className:`size-4`}),`深色模式`]})})]})})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`强调色`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`统一按钮、状态、选中项和焦点样式。自动模式会根据明暗主题选择合适的颜色。`})]}),(0,O.jsx)(h,{type:`single`,value:Be,onValueChange:e=>{e&&He(e)},variant:`outline`,spacing:1,className:`flex-wrap justify-start`,"aria-label":`强调色`,children:ze.map(e=>(0,O.jsxs)(y,{value:e.value,"aria-label":e.label,children:[e.value===`auto`?(0,O.jsx)(_e,{"data-icon":`inline-start`}):(0,O.jsx)(`span`,{className:`size-3 rounded-full border border-foreground/10`,style:{background:e.color}}),e.label]},e.value))})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`缩放比例`}),(0,O.jsxs)(oe,{value:Q,onValueChange:$e,children:[(0,O.jsx)(ne,{children:(0,O.jsx)(ie,{placeholder:`选择缩放比例`})}),(0,O.jsx)(re,{children:(0,O.jsx)(ae,{children:Re.map(e=>(0,O.jsx)(l,{value:e.value,children:e.label},e.value))})})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`关于`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Meddle - HTTP 调试代理工具`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`版本: 1.0.0`})]})]}),(0,O.jsxs)(_,{value:`config`,className:k,children:[(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`路由规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:`~/.meddle/route-rules/`})]}),qe.length>0?(0,O.jsx)(`div`,{className:`space-y-2`,children:qe.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2.5 text-sm`,children:[(0,O.jsx)(E,{variant:e.enabled?`default`:`secondary`,className:`text-[10px]`,children:e.enabled?`已启用`:`未启用`}),(0,O.jsxs)(`span`,{className:`flex-1 truncate text-xs`,children:[e.name,`.txt`]}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.ruleCount,` 条规则`]})]},e.name))}):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`暂无规则文件`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`规则文件存放于 ~/.meddle/route-rules/ 目录,纯文本格式。在"路由规则"页面管理。`})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`Mock 规则文件`}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-muted rounded-md`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,O.jsx)(`span`,{className:`text-xs font-mono truncate flex-1`,children:G||`默认: ~/.meddle/mocks.json`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`mocksPath`,className:`text-xs text-muted-foreground`,children:`自定义 Mock 规则文件路径(留空使用默认)`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`mocksPath`,value:G,onChange:e=>Ke(e.target.value),placeholder:`如: /path/to/my-mocks.json`,className:`flex-1 h-8 text-sm font-mono`}),(0,O.jsxs)(C,{variant:`outline`,size:`sm`,onClick:ut,disabled:R,className:`h-8`,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-3 w-3`}),`应用`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`必须是 JSON 格式的 Mock 规则文件`})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(`h3`,{className:`text-sm font-medium`,children:`操作`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:ot,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mr-1`}),`重新加载配置`]}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:st,disabled:Ze,children:[(0,O.jsx)(Le,{className:`h-4 w-4 mr-1`}),Ze?`诊断中...`:`诊断配置`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`点击重新加载可应用修改后的配置文件,点击诊断配置可检查配置有效性`})]}),X&&(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-medium`,children:[(0,O.jsx)(Le,{className:`h-4 w-4`}),`诊断结果`]}),(0,O.jsxs)(`div`,{className:`mb-3 p-3 rounded-md border ${X.status===`ok`?`bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900`:X.status===`warning`?`bg-yellow-50 dark:bg-yellow-950/20 border-yellow-200 dark:border-yellow-900`:`bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900`}`,children:[X.status===`ok`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(w,{className:`h-5 w-5 text-green-600 dark:text-green-400`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-green-300`,children:`所有检查通过!配置正常。`})]}),X.status===`warning`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(a,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-yellow-700 dark:text-yellow-300`,children:[`发现 `,X.warnings.length,` 个警告`]})]}),X.status===`error`&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-5 w-5 text-red-600 dark:text-red-400`}),(0,O.jsxs)(`span`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:[`发现 `,X.errors.length,` 个错误`]})]})]}),(0,O.jsx)(`div`,{className:A,children:X.checks.map((e,t)=>(0,O.jsx)(`div`,{className:`p-2 rounded border bg-card`,children:(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(w,{className:`h-4 w-4 text-green-600 dark:text-green-400 mt-0.5 shrink-0`}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono truncate`,children:e.path}),e.details&&(0,O.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.details.totalFiles!==void 0&&`${e.details.enabledFiles}/${e.details.totalFiles} 个文件已启用`,e.details.totalRules!==void 0&&` · ${e.details.totalRules} 条规则`,e.details.rules!==void 0&&`${e.details.rules} 条规则`,e.details.total!==void 0&&`${e.details.total} 条规则 (${e.details.enabled} 已启用)`,e.details.size!==void 0&&` · ${e.details.size} bytes`]})]})]})},t))}),X.warnings&&X.warnings.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-yellow-700 dark:text-yellow-300`,children:`警告:`}),X.warnings.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-yellow-600 dark:text-yellow-400`,children:[(0,O.jsx)(a,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]}),X.errors&&X.errors.length>0&&(0,O.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-red-700 dark:text-red-300`,children:`错误:`}),X.errors.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-red-600 dark:text-red-400`,children:[(0,O.jsx)(o,{className:`h-3 w-3 mt-0.5 shrink-0`}),(0,O.jsx)(`span`,{children:e})]},t))]})]})]})]}),(0,O.jsxs)(_,{value:`clients`,className:k,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4`}),`远程客户端名称`]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将日志中的客户端 IP 映射为设备名称。保存后新请求立即生效,无需重启代理。`})]}),(0,O.jsx)(`div`,{className:A,children:Object.entries(K).length===0?(0,O.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground`,children:`尚未配置设备名称`}):Object.entries(K).map(([e,t])=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:e,readOnly:!0,className:`h-8 flex-1 font-mono text-xs bg-muted/40`,"aria-label":`客户端 IP ${e}`}),(0,O.jsx)(m,{value:t,onChange:t=>{let n=t.target.value;q(t=>({...t,[e]:n}))},className:`h-8 flex-1 text-sm`,"aria-label":`${e} 的设备名称`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>{q(t=>{let n={...t};return delete n[e],n})},title:`删除设备名称`,children:(0,O.jsx)(me,{className:`h-4 w-4`})})]},e))}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-sm`,children:`添加设备`}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{value:J,onChange:e=>Ye(e.target.value),placeholder:`客户端 IP,例如 10.13.232.187`,className:`h-8 flex-1 font-mono text-xs`}),(0,O.jsx)(m,{value:Y,onChange:e=>Xe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ct()},placeholder:`设备名称,例如 iPhone`,className:`h-8 flex-1 text-sm`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,className:`h-8`,onClick:ct,disabled:!J.trim()||!Y.trim(),children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加`]})]})]}),(0,O.jsxs)(C,{onClick:lt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存客户端名称`]})]}),(0,O.jsxs)(_,{value:`ai`,className:k,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`启用 AI 功能`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`启用智能代码修复功能`})]}),(0,O.jsx)(se,{checked:F.enabled,onCheckedChange:e=>I({...F,enabled:e}),"aria-label":`启用 AI 功能`})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:j,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`AI 模型配置`}),(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:()=>{W({name:``,provider:`openai`,apiKey:``,baseUrl:`https://api.openai.com/v1/chat/completions`,model:`gpt-4o-mini`})},children:[(0,O.jsx)(s,{className:`h-4 w-4 mr-1`}),`添加模型`]})]}),(0,O.jsx)(`div`,{className:A,children:F.models&&F.models.length>0?F.models.map(e=>(0,O.jsx)(`div`,{className:`p-3 rounded-md border ${F.activeModelId===e.id?`border-primary bg-primary/5`:`border-border`}`,children:(0,O.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),F.activeModelId===e.id&&(0,O.jsx)(E,{variant:`default`,className:`text-xs`,children:`当前使用`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[e.provider===`openai`?`OpenAI`:`Anthropic`,` - `,e.model]})]}),(0,O.jsxs)(`div`,{className:`flex gap-1`,children:[F.activeModelId!==e.id&&(0,O.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(le(F,e.id)),className:`h-7 text-xs`,children:[(0,O.jsx)(De,{className:`h-3 w-3 mr-1`}),`使用`]}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>I(ue(F,e.id)),className:`h-7 w-7 p-0 text-destructive`,children:(0,O.jsx)(me,{className:`h-3 w-3`})})]})]})},e.id)):(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground italic py-4 text-center`,children:`暂无模型配置,点击"添加模型"创建`})}),U&&(0,O.jsxs)(`div`,{className:`space-y-5 rounded-md border border-primary bg-primary/5 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(v,{className:`text-sm font-medium`,children:`新增模型`}),(0,O.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>W(null),className:`h-6 w-6 p-0`,children:(0,O.jsx)(o,{className:`h-4 w-4`})})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelName`,className:`text-xs`,children:`模型名称`}),(0,O.jsx)(m,{id:`newModelName`,value:U.name||``,onChange:e=>W({...U,name:e.target.value}),placeholder:`如:GPT-4o Mini`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`服务商`}),(0,O.jsxs)(h,{type:`single`,value:U.provider,onValueChange:e=>{if(e===`openai`){let e=u(`openai`);W({...U,provider:`openai`,baseUrl:e.baseUrl,model:e.model})}else if(e===`anthropic`){let e=u(`anthropic`);W({...U,provider:`anthropic`,baseUrl:e.baseUrl,model:e.model})}},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelApiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsx)(m,{id:`newModelApiKey`,type:L?`text`:`password`,value:U.apiKey||``,onChange:e=>W({...U,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelModel`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`newModelModel`,value:U.model||``,onChange:e=>W({...U,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`newModelBaseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`newModelBaseUrl`,value:U.baseUrl||``,onChange:e=>W({...U,baseUrl:e.target.value}),placeholder:`API 端点`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:()=>W(null),className:`h-7 text-xs`,children:`取消`}),(0,O.jsxs)(r,{size:`sm`,onClick:()=>{U.name&&U.apiKey&&U.model&&U.baseUrl&&(I(fe(F,U)),W(null))},disabled:!U.name||!U.apiKey||!U.model||!U.baseUrl,className:`h-7 text-xs`,children:[(0,O.jsx)(s,{className:`h-3 w-3 mr-1`}),`添加`]})]})]})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(v,{className:`text-sm`,children:`传统配置(向后兼容)`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`如果未配置多模型,将使用此配置`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{className:`text-xs`,children:`AI 服务商`}),(0,O.jsxs)(h,{type:`single`,value:F.provider,onValueChange:e=>{(e===`openai`||e===`anthropic`)&&nt(e)},variant:`outline`,size:`sm`,spacing:0,children:[(0,O.jsx)(y,{value:`openai`,children:`OpenAI`}),(0,O.jsx)(y,{value:`anthropic`,children:`Anthropic`})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`apiKey`,className:`text-xs`,children:`API Key`}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(m,{id:`apiKey`,type:L?`text`:`password`,value:F.apiKey,onChange:e=>I({...F,apiKey:e.target.value}),placeholder:`输入 API Key`,className:`flex-1 h-8 text-sm`}),(0,O.jsx)(r,{variant:`outline`,size:`icon`,onClick:()=>We(!L),className:`h-8 w-8`,children:L?(0,O.jsx)(Fe,{className:`h-4 w-4`}):(0,O.jsx)(Ie,{className:`h-4 w-4`})})]})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`model`,className:`text-xs`,children:`模型`}),(0,O.jsx)(m,{id:`model`,value:F.model,onChange:e=>I({...F,model:e.target.value}),placeholder:`模型名称`,className:`h-8 text-sm`})]}),(0,O.jsxs)(`div`,{className:A,children:[(0,O.jsx)(v,{htmlFor:`baseUrl`,className:`text-xs`,children:`API 端点`}),(0,O.jsx)(m,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I({...F,baseUrl:e.target.value}),placeholder:F.provider===`openai`?`https://api.openai.com/v1/chat/completions`:`https://api.anthropic.com/v1/messages`,className:`h-8 text-sm`})]}),Ge&&(0,O.jsxs)(Pe,{variant:B===`error`?`destructive`:`default`,children:[B===`success`?(0,O.jsx)(w,{}):B===`error`?(0,O.jsx)(o,{}):(0,O.jsx)(a,{}),(0,O.jsx)(Ne,{children:B===`success`?`操作成功`:B===`error`?`操作失败`:`处理中`}),(0,O.jsx)(Me,{children:Ge})]}),(0,O.jsx)(S,{}),(0,O.jsxs)(`div`,{className:`flex justify-between`,children:[(0,O.jsxs)(r,{variant:`outline`,size:`sm`,onClick:it,children:[(0,O.jsx)(te,{className:`h-4 w-4 mr-1`}),`重置`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(r,{variant:`outline`,size:`sm`,onClick:at,disabled:!d(F)||R,children:`测试连接`}),(0,O.jsxs)(C,{size:`sm`,onClick:rt,disabled:R,children:[(0,O.jsx)(p,{"data-icon":`inline-start`,className:`h-4 w-4`}),R?`保存中...`:`保存`]})]})]})]})]})]});return n?(0,O.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:$}):(0,O.jsx)(Te,{open:e,onOpenChange:t,children:(0,O.jsx)(we,{className:`p-0 flex flex-col`,resizable:!0,defaultWidth:600,storageKey:`settings-panel`,children:$})})}export{Be as SettingsPanel};
|
package/web/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>web</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-B8P4vdT0.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/button-BTToMaBW.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/dist-DZJ9SMlJ.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/dist-C6eaYCUo.js">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/dist-CxdY_A67.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/dist-B8XUKgXe.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/ai-config-store-DQXVJVn_.js">
|
|
19
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
19
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DQtOwhpd.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
|
22
22
|
<div id="root"></div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=750;function t(t){return new Promise((n,r)=>{let i=window.setTimeout(()=>{r(Error(`写入剪贴板超时`))},e);navigator.clipboard.writeText(t).then(()=>{window.clearTimeout(i),n()},e=>{window.clearTimeout(i),r(e)})})}function n(e,t){if(e?.focus(),!t)return;let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function r(e){let t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=window.getSelection(),i=r&&r.rangeCount>0?r.getRangeAt(0):null,a=document.createElement(`textarea`);a.value=e,a.readOnly=!0,a.setAttribute(`aria-hidden`,`true`),a.style.position=`fixed`,a.style.inset=`0 auto auto 0`,a.style.opacity=`0`,a.style.pointerEvents=`none`,document.body.appendChild(a),a.focus(),a.select(),a.setSelectionRange(0,e.length);try{if(!document.execCommand(`copy`))throw Error(`浏览器未允许复制到剪贴板`)}finally{a.remove(),n(t,i)}}async function i(e){let n;if(typeof navigator<`u`&&`clipboard`in navigator)try{await t(e);return}catch(e){n=e}try{r(e)}catch(e){throw Error(`浏览器未允许复制到剪贴板`,{cause:n||e})}}export{i as t};
|