@lakphy/local-router 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/config.schema.json +15 -0
- package/dist/cli.js +11 -0
- package/dist/entry.js +11 -0
- package/dist/web/assets/{index-BglOyVTU.js → index-BbfScfK-.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ local-router init
|
|
|
51
51
|
type: "openai-completions",
|
|
52
52
|
base: "https://api.openai.com/v1",
|
|
53
53
|
apiKey: "sk-xxxx",
|
|
54
|
+
proxy: "http://127.0.0.1:7890", // 可选:仅该 provider 走代理
|
|
54
55
|
models: {
|
|
55
56
|
"gpt-4o-mini": {}
|
|
56
57
|
}
|
|
@@ -121,6 +122,7 @@ curl -X POST "http://127.0.0.1:4099/openai-completions/v1/chat/completions" \
|
|
|
121
122
|
## 配置规则(必须知道)
|
|
122
123
|
|
|
123
124
|
- `providers`:定义上游服务(类型、地址、密钥、模型)
|
|
125
|
+
- `providers.*.proxy`:可选,provider 级代理 URL(仅该 provider 生效)
|
|
124
126
|
- `routes`:定义路由映射(传入 model -> 目标 provider/model)
|
|
125
127
|
- 每个入口都必须有 `*` 兜底规则
|
|
126
128
|
- `routes` 里引用的 `provider` 必须在 `providers` 中存在
|
|
@@ -128,6 +130,42 @@ curl -X POST "http://127.0.0.1:4099/openai-completions/v1/chat/completions" \
|
|
|
128
130
|
|
|
129
131
|
完整 schema:`config.schema.json`
|
|
130
132
|
|
|
133
|
+
### Provider 级代理示例
|
|
134
|
+
|
|
135
|
+
```json5
|
|
136
|
+
{
|
|
137
|
+
providers: {
|
|
138
|
+
openai: {
|
|
139
|
+
type: "openai-completions",
|
|
140
|
+
base: "https://api.openai.com/v1",
|
|
141
|
+
apiKey: "sk-openai",
|
|
142
|
+
proxy: "http://127.0.0.1:7890",
|
|
143
|
+
models: { "gpt-4o-mini": {} }
|
|
144
|
+
},
|
|
145
|
+
anthropic: {
|
|
146
|
+
type: "anthropic-messages",
|
|
147
|
+
base: "https://api.anthropic.com",
|
|
148
|
+
apiKey: "sk-ant",
|
|
149
|
+
// 省略或空字符串表示直连
|
|
150
|
+
proxy: "",
|
|
151
|
+
models: { "claude-sonnet-4-5": {} }
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
routes: {
|
|
155
|
+
"openai-completions": {
|
|
156
|
+
"*": { provider: "openai", model: "gpt-4o-mini" }
|
|
157
|
+
},
|
|
158
|
+
"anthropic-messages": {
|
|
159
|
+
"*": { provider: "anthropic", model: "claude-sonnet-4-5" }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
说明:
|
|
166
|
+
- `proxy` 仅影响当前 provider,不会影响其他 provider。
|
|
167
|
+
- 当前版本代理来源仅 `providers.*.proxy`,不会读取 `HTTP_PROXY/HTTPS_PROXY` 环境变量。
|
|
168
|
+
|
|
131
169
|
## 日志与管理面板
|
|
132
170
|
|
|
133
171
|
- 面板地址:`/admin`
|
package/config.schema.json
CHANGED
|
@@ -140,6 +140,21 @@
|
|
|
140
140
|
"minLength": 1,
|
|
141
141
|
"description": "访问上游服务的密钥。建议通过环境变量注入后再生成配置文件,避免在仓库中明文保存。"
|
|
142
142
|
},
|
|
143
|
+
"proxy": {
|
|
144
|
+
"description": "可选。该 provider 专属代理地址。配置后仅此 provider 的上游请求会通过该代理发送;留空或省略表示直连上游。",
|
|
145
|
+
"anyOf": [
|
|
146
|
+
{
|
|
147
|
+
"type": "string",
|
|
148
|
+
"format": "uri",
|
|
149
|
+
"minLength": 1
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "string",
|
|
153
|
+
"const": ""
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"examples": ["http://127.0.0.1:7890", "https://user:pass@proxy.example.com:8443", ""]
|
|
157
|
+
},
|
|
143
158
|
"models": {
|
|
144
159
|
"type": "object",
|
|
145
160
|
"minProperties": 1,
|
package/dist/cli.js
CHANGED
|
@@ -7858,6 +7858,7 @@ var DEFAULT_CONFIG = `{
|
|
|
7858
7858
|
// type: "openai-completions",
|
|
7859
7859
|
// base: "https://api.openai.com/v1",
|
|
7860
7860
|
// apiKey: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
7861
|
+
// proxy: "http://127.0.0.1:7890",
|
|
7861
7862
|
// models: {
|
|
7862
7863
|
// "gpt-4o": { "image-input": true },
|
|
7863
7864
|
// "gpt-4o-mini": {},
|
|
@@ -7869,6 +7870,7 @@ var DEFAULT_CONFIG = `{
|
|
|
7869
7870
|
// type: "anthropic-messages",
|
|
7870
7871
|
// base: "https://api.anthropic.com",
|
|
7871
7872
|
// apiKey: "sk-ant-xxxxx",
|
|
7873
|
+
// proxy: "http://127.0.0.1:7890",
|
|
7872
7874
|
// models: {
|
|
7873
7875
|
// "claude-sonnet-4-5": { "image-input": true, reasoning: true },
|
|
7874
7876
|
// "claude-haiku-4-5": {},
|
|
@@ -11603,6 +11605,7 @@ class Logger {
|
|
|
11603
11605
|
if (!this._enabled)
|
|
11604
11606
|
return;
|
|
11605
11607
|
try {
|
|
11608
|
+
this.ensureDirs();
|
|
11606
11609
|
const dateStr = event.ts_start.slice(0, 10);
|
|
11607
11610
|
const filePath = join7(this.eventsDir, `${dateStr}.jsonl`);
|
|
11608
11611
|
appendFileSync(filePath, `${JSON.stringify(event)}
|
|
@@ -11637,6 +11640,9 @@ function initLogger(baseDir, config) {
|
|
|
11637
11640
|
function getLogger() {
|
|
11638
11641
|
return instance;
|
|
11639
11642
|
}
|
|
11643
|
+
function resetLogger() {
|
|
11644
|
+
instance = null;
|
|
11645
|
+
}
|
|
11640
11646
|
function maskHeaders(headers) {
|
|
11641
11647
|
const result = {};
|
|
11642
11648
|
headers.forEach((value, key2) => {
|
|
@@ -12866,12 +12872,14 @@ async function proxyRequest(c2, options) {
|
|
|
12866
12872
|
const shouldLog = logger?.enabled ?? false;
|
|
12867
12873
|
const headers = buildUpstreamHeaders(c2.req.raw.headers, options.apiKey, options.authType);
|
|
12868
12874
|
const requestBody = shouldLog && logger?.bodyPolicy !== "off" ? JSON.parse(options.body) : undefined;
|
|
12875
|
+
const proxy = options.proxy?.trim() ? options.proxy.trim() : undefined;
|
|
12869
12876
|
let upstreamRes;
|
|
12870
12877
|
try {
|
|
12871
12878
|
upstreamRes = await fetch(options.targetUrl, {
|
|
12872
12879
|
method: c2.req.method,
|
|
12873
12880
|
headers,
|
|
12874
12881
|
body: options.body,
|
|
12882
|
+
...proxy ? { proxy } : {},
|
|
12875
12883
|
decompress: true
|
|
12876
12884
|
});
|
|
12877
12885
|
} catch (err) {
|
|
@@ -13010,6 +13018,7 @@ function createModelRoutingHandler(options) {
|
|
|
13010
13018
|
return proxyRequest(c2, {
|
|
13011
13019
|
targetUrl,
|
|
13012
13020
|
apiKey: provider.apiKey,
|
|
13021
|
+
proxy: provider.proxy,
|
|
13013
13022
|
authType,
|
|
13014
13023
|
body,
|
|
13015
13024
|
logMeta
|
|
@@ -13642,6 +13651,8 @@ function createApp(store, options) {
|
|
|
13642
13651
|
if (config.log) {
|
|
13643
13652
|
const logBaseDir = resolveLogBaseDir(config.log);
|
|
13644
13653
|
initLogger(logBaseDir, config.log);
|
|
13654
|
+
} else {
|
|
13655
|
+
resetLogger();
|
|
13645
13656
|
}
|
|
13646
13657
|
const stopLogStorageTask = startLogStorageBackgroundTask(config.log);
|
|
13647
13658
|
options?.registerCleanup?.(stopLogStorageTask);
|
package/dist/entry.js
CHANGED
|
@@ -9888,6 +9888,7 @@ var DEFAULT_CONFIG = `{
|
|
|
9888
9888
|
// type: "openai-completions",
|
|
9889
9889
|
// base: "https://api.openai.com/v1",
|
|
9890
9890
|
// apiKey: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
9891
|
+
// proxy: "http://127.0.0.1:7890",
|
|
9891
9892
|
// models: {
|
|
9892
9893
|
// "gpt-4o": { "image-input": true },
|
|
9893
9894
|
// "gpt-4o-mini": {},
|
|
@@ -9899,6 +9900,7 @@ var DEFAULT_CONFIG = `{
|
|
|
9899
9900
|
// type: "anthropic-messages",
|
|
9900
9901
|
// base: "https://api.anthropic.com",
|
|
9901
9902
|
// apiKey: "sk-ant-xxxxx",
|
|
9903
|
+
// proxy: "http://127.0.0.1:7890",
|
|
9902
9904
|
// models: {
|
|
9903
9905
|
// "claude-sonnet-4-5": { "image-input": true, reasoning: true },
|
|
9904
9906
|
// "claude-haiku-4-5": {},
|
|
@@ -11587,6 +11589,7 @@ class Logger {
|
|
|
11587
11589
|
if (!this._enabled)
|
|
11588
11590
|
return;
|
|
11589
11591
|
try {
|
|
11592
|
+
this.ensureDirs();
|
|
11590
11593
|
const dateStr = event.ts_start.slice(0, 10);
|
|
11591
11594
|
const filePath = join7(this.eventsDir, `${dateStr}.jsonl`);
|
|
11592
11595
|
appendFileSync(filePath, `${JSON.stringify(event)}
|
|
@@ -11621,6 +11624,9 @@ function initLogger(baseDir, config) {
|
|
|
11621
11624
|
function getLogger() {
|
|
11622
11625
|
return instance;
|
|
11623
11626
|
}
|
|
11627
|
+
function resetLogger() {
|
|
11628
|
+
instance = null;
|
|
11629
|
+
}
|
|
11624
11630
|
function maskHeaders(headers) {
|
|
11625
11631
|
const result = {};
|
|
11626
11632
|
headers.forEach((value, key2) => {
|
|
@@ -12850,12 +12856,14 @@ async function proxyRequest(c2, options) {
|
|
|
12850
12856
|
const shouldLog = logger?.enabled ?? false;
|
|
12851
12857
|
const headers = buildUpstreamHeaders(c2.req.raw.headers, options.apiKey, options.authType);
|
|
12852
12858
|
const requestBody = shouldLog && logger?.bodyPolicy !== "off" ? JSON.parse(options.body) : undefined;
|
|
12859
|
+
const proxy = options.proxy?.trim() ? options.proxy.trim() : undefined;
|
|
12853
12860
|
let upstreamRes;
|
|
12854
12861
|
try {
|
|
12855
12862
|
upstreamRes = await fetch(options.targetUrl, {
|
|
12856
12863
|
method: c2.req.method,
|
|
12857
12864
|
headers,
|
|
12858
12865
|
body: options.body,
|
|
12866
|
+
...proxy ? { proxy } : {},
|
|
12859
12867
|
decompress: true
|
|
12860
12868
|
});
|
|
12861
12869
|
} catch (err) {
|
|
@@ -12994,6 +13002,7 @@ function createModelRoutingHandler(options) {
|
|
|
12994
13002
|
return proxyRequest(c2, {
|
|
12995
13003
|
targetUrl,
|
|
12996
13004
|
apiKey: provider.apiKey,
|
|
13005
|
+
proxy: provider.proxy,
|
|
12997
13006
|
authType,
|
|
12998
13007
|
body,
|
|
12999
13008
|
logMeta
|
|
@@ -13626,6 +13635,8 @@ function createApp(store, options) {
|
|
|
13626
13635
|
if (config.log) {
|
|
13627
13636
|
const logBaseDir = resolveLogBaseDir(config.log);
|
|
13628
13637
|
initLogger(logBaseDir, config.log);
|
|
13638
|
+
} else {
|
|
13639
|
+
resetLogger();
|
|
13629
13640
|
}
|
|
13630
13641
|
const stopLogStorageTask = startLogStorageBackgroundTask(config.log);
|
|
13631
13642
|
options?.registerCleanup?.(stopLogStorageTask);
|
|
@@ -187,4 +187,4 @@ OPENAI_BASE_URL="http://localhost:4099/openai-responses"
|
|
|
187
187
|
`),n=[];return t.forEach((e,t)=>{let r=e.trim();if(!r)return;let i=t+1;if(r.startsWith(`data:`)){let e=r.slice(5).trim();if(!e)return;try{n.push({type:`json`,lineNo:i,value:JSON.parse(e)})}catch{n.push({type:`raw`,lineNo:i,value:r})}return}try{n.push({type:`json`,lineNo:i,value:JSON.parse(r)})}catch{n.push({type:`raw`,lineNo:i,value:r})}}),n}function nA({title:e,content:t,emptyText:n}){let r=(0,F.useMemo)(()=>t?tA(t):[],[t]),i=(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,disabled:!t,onClick:async()=>{t&&(await navigator.clipboard.writeText(t),Ei.success(`已复制 stream content`))},children:[(0,I.jsx)(oa,{className:`h-3.5 w-3.5`}),`复制`]})]});return!t||r.length===0?(0,I.jsxs)(`div`,{className:`space-y-1`,children:[i,(0,I.jsx)(`pre`,{className:`max-h-[320px] overflow-auto rounded-md border bg-muted/30 p-3 text-xs`,children:n??`-`})]}):(0,I.jsxs)(`div`,{className:`space-y-1`,children:[i,(0,I.jsx)(`div`,{className:`max-h-[420px] space-y-2 overflow-auto rounded-md border bg-muted/30 p-3`,children:r.map(e=>(0,I.jsxs)(`div`,{className:`space-y-1 rounded-md border bg-background/80 p-2`,children:[(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`line `,e.lineNo]}),(0,I.jsx)(`pre`,{className:`overflow-auto rounded bg-muted/40 p-2 text-xs`,children:e.type===`json`?qk(e.value):e.value})]},`${e.lineNo}-${e.type}`))})]})}function rA({title:e,value:t,emptyText:n}){return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),(0,I.jsx)(`pre`,{className:`max-h-[320px] overflow-auto rounded-md border bg-muted/30 p-3 text-xs`,children:t==null?n??`-`:qk(t)})]})}function iA(e,t){return typeof e==`function`?e(t):e}function aA(e,t){return n=>{t.setState(t=>({...t,[e]:iA(n,t[e])}))}}function oA(e){return e instanceof Function}function sA(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function cA(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function Q(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
188
188
|
font-size: .6rem;
|
|
189
189
|
font-weight: bold;
|
|
190
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function $(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function lA(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:Q(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),$(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function uA(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:Q(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],$(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:Q(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},$(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var dA=`debugHeaders`;function fA(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var pA={createTable:e=>{e.getHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return mA(t,[...a,...s,...o],e)},$(e.options,dA,`getHeaderGroups`)),e.getCenterHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),mA(t,n,e,`center`)),$(e.options,dA,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>mA(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),$(e.options,dA,`getLeftHeaderGroups`)),e.getRightHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>mA(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),$(e.options,dA,`getRightHeaderGroups`)),e.getFooterGroups=Q(()=>[e.getHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getFooterGroups`)),e.getLeftFooterGroups=Q(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getLeftFooterGroups`)),e.getCenterFooterGroups=Q(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getCenterFooterGroups`)),e.getRightFooterGroups=Q(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getRightFooterGroups`)),e.getFlatHeaders=Q(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getFlatHeaders`)),e.getLeftFlatHeaders=Q(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=Q(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getCenterFlatHeaders`)),e.getRightFlatHeaders=Q(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getRightFlatHeaders`)),e.getCenterLeafHeaders=Q(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=Q(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getLeftLeafHeaders`)),e.getRightLeafHeaders=Q(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getRightLeafHeaders`)),e.getLeafHeaders=Q(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),$(e.options,dA,`getLeafHeaders`))}};function mA(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=fA(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>fA(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var hA=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>cA(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:Q(()=>[e.getAllLeafColumns()],t=>t.map(t=>lA(e,s,t,t.id)),$(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:Q(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),$(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},gA={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},_A=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};_A.autoRemove=e=>DA(e);var vA=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};vA.autoRemove=e=>DA(e);var yA=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};yA.autoRemove=e=>DA(e);var bA=(e,t,n)=>e.getValue(t)?.includes(n);bA.autoRemove=e=>DA(e);var xA=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});xA.autoRemove=e=>DA(e)||!(e!=null&&e.length);var SA=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));SA.autoRemove=e=>DA(e)||!(e!=null&&e.length);var CA=(e,t,n)=>e.getValue(t)===n;CA.autoRemove=e=>DA(e);var wA=(e,t,n)=>e.getValue(t)==n;wA.autoRemove=e=>DA(e);var TA=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};TA.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},TA.autoRemove=e=>DA(e)||DA(e[0])&&DA(e[1]);var EA={includesString:_A,includesStringSensitive:vA,equalsString:yA,arrIncludes:bA,arrIncludesAll:xA,arrIncludesSome:SA,equals:CA,weakEquals:wA,inNumberRange:TA};function DA(e){return e==null||e===``}var OA={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:aA(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?EA.includesString:typeof n==`number`?EA.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?EA.equals:Array.isArray(n)?EA.arrIncludes:EA.weakEquals},e.getFilterFn=()=>oA(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??EA[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=iA(n,i?i.value:void 0);if(kA(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>iA(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&kA(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function kA(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var AA={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!sA(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},jA={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:aA(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return AA.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return AA.extent},e.getAggregationFn=()=>{if(!e)throw Error();return oA(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??AA[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function MA(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var NA={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:aA(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=Q(e=>[WA(t,e)],t=>t.findIndex(t=>t.id===e.id),$(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>WA(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=WA(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=Q(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return MA(i,t,n)},$(e.options,`debugTable`,`_getOrderColumnsFn`))}},PA=()=>({left:[],right:[]}),FA={getInitialState:e=>({columnPinning:PA(),...e}),getDefaultOptions:e=>({onColumnPinningChange:aA(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},$(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),$(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),$(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?PA():e.initialState?.columnPinning??PA()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),$(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),$(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},$(e.options,`debugColumns`,`getCenterLeafColumns`))}};function IA(e){return e||(typeof document<`u`?document:null)}var LA={size:150,minSize:20,maxSize:2**53-1},RA=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),zA={getDefaultColumnDef:()=>LA,getInitialState:e=>({columnSizing:{},columnSizingInfo:RA(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:aA(`columnSizing`,e),onColumnSizingInfoChange:aA(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??LA.minSize,n??e.columnDef.size??LA.size),e.columnDef.maxSize??LA.maxSize)},e.getStart=Q(e=>[e,WA(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),$(t.options,`debugColumns`,`getStart`)),e.getAfter=Q(e=>[e,WA(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),$(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),HA(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=HA(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=IA(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=VA()?{passive:!1}:!1;HA(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?RA():e.initialState.columnSizingInfo??RA())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},BA=null;function VA(){if(typeof BA==`boolean`)return BA;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return BA=e,BA}function HA(e){return e.type===`touchstart`}var UA={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:aA(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=Q(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),$(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=Q(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],$(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>Q(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),$(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function WA(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var GA={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},KA={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:aA(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>EA.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return oA(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??EA[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},qA={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:aA(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},JA=0,YA=10,XA=()=>({pageIndex:JA,pageSize:YA}),ZA={getInitialState:e=>({...e,pagination:{...XA(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:aA(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>iA(t,e)),e.resetPagination=t=>{e.setPagination(t?XA():e.initialState.pagination??XA())},e.setPageIndex=t=>{e.setPagination(n=>{let r=iA(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?JA:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??JA)},e.resetPageSize=t=>{var n;e.setPageSize(t?YA:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??YA)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,iA(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=iA(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=Q(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},$(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},QA=()=>({top:[],bottom:[]}),$A={getInitialState:e=>({rowPinning:QA(),...e}),getDefaultOptions:e=>({onRowPinningChange:aA(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?QA():e.initialState?.rowPinning??QA()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),$(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),$(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},$(e.options,`debugRows`,`getCenterRows`))}},ej={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:aA(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{tj(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return tj(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return rj(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return ij(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return ij(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},tj=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>tj(e,t.id,n,r,i))};function nj(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=rj(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function rj(e,t){return t[e.id]??!1}function ij(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(rj(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=ij(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var aj=/([0-9]+)/gm,oj=(e,t,n)=>mj(pj(e.getValue(n)).toLowerCase(),pj(t.getValue(n)).toLowerCase()),sj=(e,t,n)=>mj(pj(e.getValue(n)),pj(t.getValue(n))),cj=(e,t,n)=>fj(pj(e.getValue(n)).toLowerCase(),pj(t.getValue(n)).toLowerCase()),lj=(e,t,n)=>fj(pj(e.getValue(n)),pj(t.getValue(n))),uj=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},dj=(e,t,n)=>fj(e.getValue(n),t.getValue(n));function fj(e,t){return e===t?0:e>t?1:-1}function pj(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function mj(e,t){let n=e.split(aj).filter(Boolean),r=t.split(aj).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var hj={alphanumeric:oj,alphanumericCaseSensitive:sj,text:cj,textCaseSensitive:lj,datetime:uj,basic:dj},gj=[pA,UA,NA,FA,gA,OA,GA,KA,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:aA(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return hj.datetime;if(typeof n==`string`&&(r=!0,n.split(aj).length>1))return hj.alphanumeric}return r?hj.text:hj.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return oA(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??hj[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},jA,qA,ZA,$A,ej,zA];function _j(e){let t=[...gj,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(iA(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:Q(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),$(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:Q(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=uA(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},$(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:Q(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),$(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:Q(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),$(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:Q(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),$(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function vj(){return e=>Q(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=hA(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},$(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function yj(e,t){return e?bj(e)?F.createElement(e,t):e:null}function bj(e){return xj(e)||typeof e==`function`||Sj(e)}function xj(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Sj(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function Cj(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=F.useState(()=>({current:_j(t)})),[r,i]=F.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}function wj({level:e}){return e===`error`?(0,I.jsx)(X,{variant:`destructive`,children:`error`}):(0,I.jsx)(X,{variant:`outline`,children:`info`})}function Tj({statusClass:e}){return e===`2xx`?(0,I.jsx)(X,{variant:`outline`,children:`2xx`}):e===`4xx`?(0,I.jsx)(X,{variant:`secondary`,children:`4xx`}):e===`5xx`?(0,I.jsx)(X,{variant:`destructive`,children:`5xx`}):(0,I.jsx)(X,{variant:`secondary`,children:`network`})}function Ej(e,t){return[{accessorKey:`ts`,header:()=>(0,I.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-1`,onClick:()=>e(t===`time_desc`?`time_asc`:`time_desc`),children:[`时间`,(0,I.jsx)(Qi,{className:`h-3.5 w-3.5`})]}),cell:({row:e})=>{let t=e.original.ts;return(0,I.jsx)(`div`,{className:`text-xs tabular-nums`,children:new Date(t).toLocaleString()})}},{accessorKey:`level`,header:`级别`,cell:({row:e})=>(0,I.jsx)(wj,{level:e.original.level})},{accessorKey:`provider`,header:`Provider`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[140px] truncate text-xs`,title:e.original.provider,children:e.original.provider})},{accessorKey:`routeType`,header:`路由`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[160px] truncate text-xs`,title:e.original.routeType,children:e.original.routeType})},{accessorKey:`modelIn`,header:`模型链路`,cell:({row:e})=>(0,I.jsxs)(`div`,{className:`max-w-[260px] truncate font-mono text-xs`,title:`${e.original.modelIn} -> ${e.original.modelOut}`,children:[e.original.modelIn,` -> `,e.original.modelOut]})},{accessorKey:`message`,header:`消息`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[400px] truncate text-xs`,title:e.original.message,children:e.original.message})},{accessorKey:`latencyMs`,header:`延迟`,cell:({row:e})=>(0,I.jsxs)(`div`,{className:`text-xs tabular-nums`,children:[e.original.latencyMs,` ms`]})},{accessorKey:`statusClass`,header:`状态`,cell:({row:e})=>(0,I.jsx)(Tj,{statusClass:e.original.statusClass})},{accessorKey:`userKey`,header:`用户`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[180px] truncate font-mono text-xs`,title:e.original.userKey??`-`,children:e.original.userKey??`-`})},{accessorKey:`sessionId`,header:`会话`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[220px] truncate font-mono text-xs`,title:e.original.sessionId??`-`,children:e.original.sessionId??`-`})},{accessorKey:`requestId`,header:`Request ID`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[220px] truncate font-mono text-xs`,title:e.original.requestId,children:e.original.requestId})}]}function Dj(e){let{data:t,sort:n,onSortChange:r,onRowClick:i}=e,[a,o]=(0,F.useState)({}),s=(0,F.useMemo)(()=>Ej(r,n),[r,n]),c=Cj({data:t,columns:s,getCoreRowModel:vj(),state:{columnVisibility:a},onColumnVisibilityChange:o});return(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:c.getHeaderGroups().map(e=>(0,I.jsx)(UO,{children:e.headers.map(e=>(0,I.jsx)(WO,{children:e.isPlaceholder?null:yj(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,I.jsx)(VO,{children:c.getRowModel().rows?.length?c.getRowModel().rows.map(e=>(0,I.jsx)(Oj,{row:e,onClick:i},e.id)):(0,I.jsx)(UO,{children:(0,I.jsx)(GO,{colSpan:s.length,className:`h-24 text-center text-sm text-muted-foreground`,children:`暂无日志数据`})})})]})})}function Oj({row:e,onClick:t}){return(0,I.jsx)(UO,{className:`cursor-pointer`,onClick:()=>t(e.original),children:e.getVisibleCells().map(e=>(0,I.jsx)(GO,{children:yj(e.column.columnDef.cell,e.getContext())},e.id))})}function kj({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}function Aj({className:e,...t}){return(0,I.jsx)(fp,{"data-slot":`label`,className:q(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function jj({...e}){return(0,I.jsx)(ph,{"data-slot":`select`,...e})}function Mj({...e}){return(0,I.jsx)(bh,{"data-slot":`select-group`,...e})}function Nj({...e}){return(0,I.jsx)(hh,{"data-slot":`select-value`,...e})}function Pj({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(mh,{"data-slot":`select-trigger`,"data-size":t,className:q(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(gh,{asChild:!0,children:(0,I.jsx)(ta,{className:`size-4 opacity-50`})})]})}function Fj({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(_h,{children:(0,I.jsxs)(vh,{"data-slot":`select-content`,className:q(`bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,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,align:r,...i,children:[(0,I.jsx)(Rj,{}),(0,I.jsx)(yh,{className:q(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(zj,{})]})})}function Ij({className:e,...t}){return(0,I.jsx)(xh,{"data-slot":`select-label`,className:q(`text-muted-foreground px-2 py-1.5 text-xs`,e),...t})}function Lj({className:e,children:t,...n}){return(0,I.jsxs)(Sh,{"data-slot":`select-item`,className:q(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(wh,{children:(0,I.jsx)(ea,{className:`size-4`})})}),(0,I.jsx)(Ch,{children:t})]})}function Rj({className:e,...t}){return(0,I.jsx)(Th,{"data-slot":`select-scroll-up-button`,className:q(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(ra,{className:`size-4`})})}function zj({className:e,...t}){return(0,I.jsx)(Eh,{"data-slot":`select-scroll-down-button`,className:q(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(ta,{className:`size-4`})})}function Bj({className:e,size:t=`default`,...n}){return(0,I.jsx)(Wh,{"data-slot":`switch`,"data-size":t,className:q(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6`,e),...n,children:(0,I.jsx)(Gh,{"data-slot":`switch-thumb`,className:q(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var Vj={window:`24h`,from:``,to:``,levels:[],provider:``,routeType:``,modelIn:``,modelOut:``,user:``,session:``,statusClass:[],hasError:`all`,q:``},Hj=null,Uj=null;function Wj(e,t){return{window:e.filters.window,from:e.filters.from||void 0,to:e.filters.to||void 0,levels:e.filters.levels,provider:e.filters.provider||void 0,routeType:e.filters.routeType||void 0,modelIn:e.filters.modelIn||void 0,modelOut:e.filters.modelOut||void 0,user:e.filters.user||void 0,session:e.filters.session||void 0,statusClass:e.filters.statusClass,hasError:e.filters.hasError===`all`?void 0:e.filters.hasError===`true`,q:e.filters.q||void 0,sort:e.sort,limit:50,cursor:t??void 0}}function Gj(e,t){let n=new Map;for(let t of e)n.set(t.id,t);for(let e of t)n.set(e.id,e);return Array.from(n.values()).sort((e,t)=>Date.parse(t.ts)-Date.parse(e.ts))}const Kj=Ev((e,t)=>({filters:{...Vj},sort:`time_desc`,items:[],nextCursor:null,hasMore:!1,stats:null,meta:null,loading:!1,loadingMore:!1,error:null,autoRefreshEnabled:!1,refreshIntervalSec:5,savedViews:[],tailEnabled:!1,tailConnected:!1,tailError:null,setFilter:(t,n)=>{e(e=>({filters:{...e.filters,[t]:n}}))},setSort:t=>e({sort:t}),applyFilters:async()=>{await t().fetchFirstPage()},resetFilters:async()=>{e({filters:{...Vj},sort:`time_desc`}),await t().fetchFirstPage()},fetchFirstPage:async()=>{e({loading:!0,error:null});try{let n=await Gv(Wj(t()));e({items:n.items,nextCursor:n.nextCursor,hasMore:n.hasMore,stats:n.stats,meta:n.meta,loading:!1,loadingMore:!1})}catch(t){e({loading:!1,loadingMore:!1,error:t instanceof Error?t.message:`日志查询失败`})}},fetchNextPage:async()=>{let n=t();if(!(!n.nextCursor||n.loadingMore)){e({loadingMore:!0,error:null});try{let t=await Gv(Wj(n,n.nextCursor));e({items:[...n.items,...t.items],nextCursor:t.nextCursor,hasMore:t.hasMore,stats:t.stats,meta:t.meta,loadingMore:!1})}catch(t){e({loadingMore:!1,error:t instanceof Error?t.message:`加载更多日志失败`})}}},setAutoRefreshEnabled:n=>{e({autoRefreshEnabled:n}),n?t().startAutoRefresh():t().stopAutoRefresh()},setRefreshIntervalSec:n=>{e({refreshIntervalSec:Math.max(2,Math.min(60,n))}),t().autoRefreshEnabled&&t().startAutoRefresh()},startAutoRefresh:()=>{Hj&&=(clearInterval(Hj),null);let e=Math.max(2,t().refreshIntervalSec)*1e3;Hj=setInterval(()=>{t().fetchFirstPage()},e)},stopAutoRefresh:()=>{Hj&&=(clearInterval(Hj),null)},setTailEnabled:n=>{e({tailEnabled:n}),n?t().startTail():t().stopTail()},startTail:()=>{Uj&&=(Uj(),null);let n=t();Uj=Jv({window:n.filters.window,levels:n.filters.levels,provider:n.filters.provider||void 0,routeType:n.filters.routeType||void 0,modelIn:n.filters.modelIn||void 0,modelOut:n.filters.modelOut||void 0,user:n.filters.user||void 0,session:n.filters.session||void 0,statusClass:n.filters.statusClass,hasError:n.filters.hasError===`all`?void 0:n.filters.hasError===`true`,q:n.filters.q||void 0,sort:n.sort},{onReady:()=>{e({tailConnected:!0,tailError:null})},onEvents:t=>{e(e=>({tailConnected:!0,tailError:null,items:Gj(e.items,t.items),stats:t.stats,meta:t.meta}))},onError:t=>{e({tailConnected:!1,tailError:t})}})},stopTail:()=>{Uj&&=(Uj(),null),e({tailConnected:!1,tailError:null})},saveCurrentView:n=>{let r=n.trim();if(!r)return;let i=t(),a={id:crypto.randomUUID(),name:r,filters:{...i.filters},sort:i.sort};e(e=>({savedViews:[a,...e.savedViews].slice(0,20)}))},applySavedView:async n=>{let r=t().savedViews.find(e=>e.id===n);r&&(e({filters:{...r.filters},sort:r.sort}),await t().fetchFirstPage())},deleteSavedView:t=>{e(e=>({savedViews:e.savedViews.filter(e=>e.id!==t)}))}}));function qj(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function Jj(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}T${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Yj(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString()}function Xj(){let e=Sr(),t=xr({from:`/logs`}),n=Kj(e=>e.filters),r=Kj(e=>e.sort),i=Kj(e=>e.items),a=Kj(e=>e.hasMore),o=Kj(e=>e.stats),s=Kj(e=>e.meta),c=Kj(e=>e.loading),l=Kj(e=>e.loadingMore),u=Kj(e=>e.error),d=Kj(e=>e.autoRefreshEnabled),f=Kj(e=>e.refreshIntervalSec),p=Kj(e=>e.savedViews),m=Kj(e=>e.tailEnabled),h=Kj(e=>e.tailConnected),g=Kj(e=>e.tailError),_=Kj(e=>e.setFilter),v=Kj(e=>e.setSort),y=Kj(e=>e.applyFilters),b=Kj(e=>e.resetFilters),x=Kj(e=>e.fetchNextPage),S=Kj(e=>e.setAutoRefreshEnabled),C=Kj(e=>e.setRefreshIntervalSec),w=Kj(e=>e.saveCurrentView),T=Kj(e=>e.applySavedView),E=Kj(e=>e.deleteSavedView),ee=Kj(e=>e.setTailEnabled),[D,te]=(0,F.useState)(``);(0,F.useEffect)(()=>{t.user&&_(`user`,t.user),t.session&&_(`session`,t.session),y()},[y,t.user,t.session,_]);let O=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.provider))).sort((e,t)=>e.localeCompare(t)),[i]),ne=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.routeType))).sort((e,t)=>e.localeCompare(t)),[i]),k=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.modelIn).filter(Boolean))).sort((e,t)=>e.localeCompare(t)),[i]),A=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.modelOut).filter(Boolean))).sort((e,t)=>e.localeCompare(t)),[i]);async function re(e){try{qj(await qv({window:n.window,from:n.from||void 0,to:n.to||void 0,levels:n.levels,provider:n.provider||void 0,routeType:n.routeType||void 0,modelIn:n.modelIn||void 0,modelOut:n.modelOut||void 0,user:n.user||void 0,session:n.session||void 0,statusClass:n.statusClass,hasError:n.hasError===`all`?void 0:n.hasError===`true`,q:n.q||void 0,sort:r},e),`logs-export.${e}`),Ei.success(`已导出 ${e.toUpperCase()} 文件`)}catch(e){Ei.error(e instanceof Error?e.message:`导出失败`)}}return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`日志检索`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`多条件过滤、详情定位、导出与实时追踪`})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`检索条件`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`支持窗口、范围、关键词与多维过滤`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`时间窗口`}),(0,I.jsxs)(jj,{value:n.window,onValueChange:e=>_(`window`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`1h`,children:`最近 1 小时`}),(0,I.jsx)(Lj,{value:`6h`,children:`最近 6 小时`}),(0,I.jsx)(Lj,{value:`24h`,children:`最近 24 小时`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`from`,children:`起始时间`}),(0,I.jsx)(kj,{id:`from`,type:`datetime-local`,className:`h-8`,value:Jj(n.from),onChange:e=>_(`from`,Yj(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`to`,children:`结束时间`}),(0,I.jsx)(kj,{id:`to`,type:`datetime-local`,className:`h-8`,value:Jj(n.to),onChange:e=>_(`to`,Yj(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`keyword`,children:`关键词`}),(0,I.jsx)(kj,{id:`keyword`,className:`h-8`,value:n.q,onChange:e=>_(`q`,e.target.value),placeholder:`request id / path / message`})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`级别`}),(0,I.jsxs)(jj,{value:n.levels.length===0?`all`:n.levels.join(`,`),onValueChange:e=>_(`levels`,e===`all`?[]:e.split(`,`)),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),(0,I.jsx)(Lj,{value:`info`,children:`info`}),(0,I.jsx)(Lj,{value:`error`,children:`error`}),(0,I.jsx)(Lj,{value:`info,error`,children:`info + error`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`Provider`}),(0,I.jsxs)(jj,{value:n.provider||`all`,onValueChange:e=>_(`provider`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),O.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`路由类型`}),(0,I.jsxs)(jj,{value:n.routeType||`all`,onValueChange:e=>_(`routeType`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),ne.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`原始模型`}),(0,I.jsxs)(jj,{value:n.modelIn||`all`,onValueChange:e=>_(`modelIn`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),k.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`路由模型`}),(0,I.jsxs)(jj,{value:n.modelOut||`all`,onValueChange:e=>_(`modelOut`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),A.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`是否错误`}),(0,I.jsxs)(jj,{value:n.hasError,onValueChange:e=>_(`hasError`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),(0,I.jsx)(Lj,{value:`true`,children:`仅错误`}),(0,I.jsx)(Lj,{value:`false`,children:`仅成功`})]})]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`user-key`,children:`用户标识`}),(0,I.jsx)(kj,{id:`user-key`,className:`h-8`,value:n.user,onChange:e=>_(`user`,e.target.value),placeholder:`userKey 或原始 user_id`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`session-id`,children:`会话 ID`}),(0,I.jsx)(kj,{id:`session-id`,className:`h-8`,value:n.session,onChange:e=>_(`session`,e.target.value),placeholder:`sessionId`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(J,{size:`sm`,onClick:()=>void y(),disabled:c,children:`查询`}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:c,children:`重置`}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void re(`csv`),children:[(0,I.jsx)(sa,{className:`h-3.5 w-3.5`}),`导出 CSV`]}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void re(`json`),children:[(0,I.jsx)(sa,{className:`h-3.5 w-3.5`}),`导出 JSON`]})]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-5`,children:[(0,I.jsx)(Zj,{title:`总条数`,value:o?.total??0}),(0,I.jsx)(Zj,{title:`错误率`,value:`${o?.errorRate??0}%`}),(0,I.jsx)(Zj,{title:`P95`,value:`${o?.p95LatencyMs??0} ms`}),(0,I.jsx)(Zj,{title:`平均延迟`,value:`${o?.avgLatencyMs??0} ms`}),(0,I.jsx)(Zj,{title:`扫描行数`,value:s?.scannedLines??0})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`结果列表`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s?`文件 ${s.scannedFiles} · 行 ${s.scannedLines} · 解析异常 ${s.parseErrors}${s.truncated?` · 已截断`:``}`:`等待查询`})]}),(0,I.jsx)(`div`,{className:`space-y-3 px-3 py-3`,children:u?(0,I.jsx)(EO,{className:`min-h-[160px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`日志检索失败`}),(0,I.jsx)(jO,{children:u})]})}):c?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`})]}):i.length===0?(0,I.jsx)(EO,{className:`min-h-[200px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`没有匹配日志`}),(0,I.jsx)(jO,{children:`请调整筛选条件后重试`})]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Dj,{data:i,sort:r,onSortChange:v,onRowClick:t=>void e({to:`/logs/$id`,params:{id:t.id}})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`已加载 `,i.length,` 条`]}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,disabled:!a||l,onClick:()=>void x(),children:l?`加载中...`:a?`加载更多`:`已到底部`})]})]})})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`增强功能`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`预设视图、自动刷新、实时追踪(可选)`})]}),(0,I.jsxs)(`div`,{className:`space-y-4 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Bj,{checked:d,onCheckedChange:S}),(0,I.jsx)(`span`,{className:`text-sm`,children:`自动刷新`}),(0,I.jsx)(wa,{className:`h-4 w-4 text-muted-foreground`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Aj,{className:`text-sm`,children:`间隔`}),(0,I.jsxs)(jj,{value:String(f),onValueChange:e=>C(Number.parseInt(e,10)||5),children:[(0,I.jsx)(Pj,{className:`h-8 w-[120px]`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`3`,children:`3 秒`}),(0,I.jsx)(Lj,{value:`5`,children:`5 秒`}),(0,I.jsx)(Lj,{value:`10`,children:`10 秒`}),(0,I.jsx)(Lj,{value:`30`,children:`30 秒`})]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Bj,{checked:m,onCheckedChange:ee}),(0,I.jsx)(`span`,{className:`text-sm`,children:`实时追踪`}),(0,I.jsx)(Ca,{className:`h-4 w-4 text-muted-foreground`}),m?(0,I.jsx)(X,{variant:h?`outline`:`secondary`,children:h?`已连接`:`连接中`}):null]})]}),g?(0,I.jsx)(`div`,{className:`text-xs text-destructive`,children:g}):null,(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(kj,{className:`h-8 max-w-sm`,value:D,onChange:e=>te(e.target.value),placeholder:`输入视图名称`}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>{D.trim()&&(w(D.trim()),te(``))},children:[(0,I.jsx)(Da,{className:`h-3.5 w-3.5`}),`保存当前筛选`]})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:p.length===0?(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`暂无预设视图`}):p.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border px-2 py-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-xs hover:underline`,onClick:()=>void T(e.id),children:e.name}),(0,I.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-destructive`,onClick:()=>E(e.id),children:`删除`})]},e.id))})]})]})]})]})}function Zj({title:e,value:t}){return(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background px-3 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,I.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:t})]})}function Qj(e){return e.log??{}}function $j(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft);if(!e)return null;let n=e.log,r=n?.enabled!==!1&&n!==void 0;function i(e){t(t=>(t.log=e(Qj(t)),t))}return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-6 lg:overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`shrink-0`,children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`日志配置`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`控制请求/响应日志的记录方式与存储策略`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-lg border bg-background`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`启用日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`开启后将记录所有代理请求的元数据`})]}),(0,I.jsx)(Bj,{checked:r,onCheckedChange:e=>{e?i(e=>({...e,enabled:!0})):n&&i(e=>({...e,enabled:!1}))}})]})}),n?(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`通用设置`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`日志目录、Body 记录策略等通用配置`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`Body 记录策略`}),(0,I.jsxs)(jj,{value:n.bodyPolicy??`off`,onValueChange:e=>i(t=>({...t,bodyPolicy:e})),children:[(0,I.jsx)(Pj,{className:`h-8`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`off`,children:`off — 不记录 body(推荐)`}),(0,I.jsx)(Lj,{value:`masked`,children:`masked — 脱敏记录`}),(0,I.jsx)(Lj,{value:`full`,children:`full — 完整记录(仅调试)`})]})]}),n.bodyPolicy===`full`&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`当前为完整记录模式,可能包含敏感信息,建议仅在排障时临时开启。`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`log-basedir`,children:`日志目录`}),(0,I.jsx)(kj,{id:`log-basedir`,value:n.baseDir??``,onChange:e=>i(t=>({...t,baseDir:e.target.value||void 0})),placeholder:`默认: ~/.local-router/logs/`,className:`h-8`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`留空则使用默认路径`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`事件日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`按天分片的 JSONL 格式结构化日志`})]}),(0,I.jsx)(`div`,{className:`px-3 py-3`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`events-retain`,children:`保留天数`}),(0,I.jsx)(kj,{id:`events-retain`,type:`number`,min:1,value:n.events?.retainDays??14,onChange:e=>i(t=>({...t,events:{...t.events,retainDays:Number.parseInt(e.target.value)||14}})),className:`h-8`})]})})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsx)(`div`,{className:`border-b px-3 py-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`流式日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`SSE 原始响应文本`})]}),(0,I.jsx)(Bj,{checked:n.streams?.enabled!==!1,onCheckedChange:e=>i(t=>({...t,streams:{...t.streams,enabled:e}}))})]})}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`streams-retain`,children:`保留天数`}),(0,I.jsx)(kj,{id:`streams-retain`,type:`number`,min:1,value:n.streams?.retainDays??7,onChange:e=>i(t=>({...t,streams:{...t.streams,retainDays:Number.parseInt(e.target.value)||7}})),className:`h-8`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`streams-maxbytes`,children:`单请求最大字节数`}),(0,I.jsx)(kj,{id:`streams-maxbytes`,type:`number`,min:1,value:n.streams?.maxBytesPerRequest??10485760,onChange:e=>i(t=>({...t,streams:{...t.streams,maxBytesPerRequest:Number.parseInt(e.target.value)||10485760}})),className:`h-8`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`默认 10MB (10485760),超出部分将被截断`})]})]})]})]})]}):(0,I.jsx)(`div`,{className:`rounded-lg border bg-background py-12 text-center text-sm text-muted-foreground`,children:`当前未启用日志配置,请先打开上方开关`})]})]})}function eM({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,I.jsx)(Mh,{"data-slot":`separator`,decorative:n,orientation:t,className:q(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function tM({models:e,onChange:t}){let n=Object.entries(e),r=(0,F.useRef)(new Map),i=(0,F.useRef)(0),a=new Set(n.map(([e])=>e));for(let e of r.current.keys())a.has(e)||r.current.delete(e);function o(e){let t=r.current.get(e);if(t)return t;i.current+=1;let n=`model-row-${i.current}`;return r.current.set(e,n),n}function s(){let n=`model-${Date.now()}`;t({...e,[n]:{}})}function c(n){let r={...e};delete r[n],t(r)}function l(n,i){if(i===n)return;let a=r.current.get(n);a&&(r.current.delete(n),r.current.set(i,a));let o={};for(let[t,r]of Object.entries(e))o[t===n?i:t]=r;t(o)}function u(n,r,i){t({...e,[n]:{...e[n],[r]:i}})}return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Aj,{className:`text-sm font-medium`,children:`模型列表`}),(0,I.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,I.jsx)(Sa,{className:`h-3.5 w-3.5 mr-1`}),`添加模型`]})]}),n.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`暂无模型,点击上方按钮添加`}):(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:(0,I.jsxs)(UO,{children:[(0,I.jsx)(WO,{children:`模型ID`}),(0,I.jsx)(WO,{className:`w-24 text-center`,children:`图像输入`}),(0,I.jsx)(WO,{className:`w-24 text-center`,children:`推理输出`}),(0,I.jsx)(WO,{className:`w-16`})]})}),(0,I.jsx)(VO,{children:n.map(([e,t])=>(0,I.jsxs)(UO,{children:[(0,I.jsx)(GO,{children:(0,I.jsx)(kj,{value:e,onChange:t=>l(e,t.target.value),className:`h-8 text-sm`})}),(0,I.jsx)(GO,{className:`text-center`,children:(0,I.jsx)(Bj,{checked:t[`image-input`]??!1,onCheckedChange:t=>u(e,`image-input`,t)})}),(0,I.jsx)(GO,{className:`text-center`,children:(0,I.jsx)(Bj,{checked:t.reasoning??!1,onCheckedChange:t=>u(e,`reasoning`,t)})}),(0,I.jsx)(GO,{children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,onClick:()=>c(e),children:(0,I.jsx)(Aa,{className:`h-3.5 w-3.5`})})})]},o(e)))})]})})]})}var nM=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`}],rM={"openai-completions":`/v1/chat/completions`,"openai-responses":`/v1/responses`,"anthropic-messages":`/v1/messages`};function iM({name:e,config:t,isNew:n,onChange:r}){let[i,a]=(0,F.useState)(!1),o=`${t.base.replace(/\/+$/,``)}${rM[t.type]}`;return(0,I.jsxs)(`div`,{className:`space-y-5`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-name`,children:`Provider 名称`}),(0,I.jsx)(kj,{id:`provider-name`,value:e,disabled:!n,readOnly:!n,className:`font-mono`}),!n&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`名称在创建后不可修改`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`协议类型`}),(0,I.jsxs)(jj,{value:t.type,onValueChange:e=>r({...t,type:e}),children:[(0,I.jsx)(Pj,{children:(0,I.jsx)(Nj,{})}),(0,I.jsx)(Fj,{children:nM.map(e=>(0,I.jsx)(Lj,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-base`,children:`Base URL`}),(0,I.jsx)(kj,{id:`provider-base`,value:t.base,onChange:e=>r({...t,base:e.target.value}),placeholder:`https://api.example.com`}),t.base&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`预览 URL: `,(0,I.jsx)(`span`,{className:`font-mono`,children:o})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-apikey`,children:`API Key`}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(kj,{id:`provider-apikey`,type:i?`text`:`password`,value:t.apiKey,onChange:e=>r({...t,apiKey:e.target.value}),className:`pr-10 font-mono`,placeholder:`sk-...`}),(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-full px-3 hover:bg-transparent`,onClick:()=>a(!i),children:i?(0,I.jsx)(ca,{className:`h-4 w-4`}):(0,I.jsx)(la,{className:`h-4 w-4`})})]})]}),(0,I.jsx)(eM,{}),(0,I.jsx)(tM,{models:t.models,onChange:e=>r({...t,models:e})})]})}function aM({...e}){return(0,I.jsx)(Jl,{"data-slot":`alert-dialog`,...e})}function oM({...e}){return(0,I.jsx)(Yl,{"data-slot":`alert-dialog-trigger`,...e})}function sM({...e}){return(0,I.jsx)(Xl,{"data-slot":`alert-dialog-portal`,...e})}function cM({className:e,...t}){return(0,I.jsx)(Zl,{"data-slot":`alert-dialog-overlay`,className:q(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50`,e),...t})}function lM({className:e,size:t=`default`,...n}){return(0,I.jsxs)(sM,{children:[(0,I.jsx)(cM,{}),(0,I.jsx)(Ql,{"data-slot":`alert-dialog-content`,"data-size":t,className:q(`bg-background 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 group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg`,e),...n})]})}function uM({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:q(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function dM({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:q(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function fM({className:e,...t}){return(0,I.jsx)(tu,{"data-slot":`alert-dialog-title`,className:q(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function pM({className:e,...t}){return(0,I.jsx)(nu,{"data-slot":`alert-dialog-description`,className:q(`text-muted-foreground text-sm`,e),...t})}function mM({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,I.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,I.jsx)($l,{"data-slot":`alert-dialog-action`,className:q(e),...r})})}function hM({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,I.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(eu,{"data-slot":`alert-dialog-cancel`,className:q(e),...r})})}function gM(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function _M(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function vM(e){return e/100*window.innerHeight}function yM(e){return e/100*window.innerWidth}function bM(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function xM({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=bM(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=_M(t,i);break;case`em`:r=gM(t,i);break;case`vh`:r=vM(i);break;case`vw`:r=yM(i);break}return r}function SM(e){return parseFloat(e.toFixed(3))}function CM({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function wM(e){let{panels:t}=e,n=CM({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=SM(xM({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=SM(xM({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=SM(xM({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=SM(xM({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function TM(e,t=`Assertion error`){if(!e)throw Error(t)}function EM(e,t){return Array.from(t).sort(e===`horizontal`?DM:OM)}function DM(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function OM(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function kM(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function AM(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function jM({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=AM(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return TM(i,`No rect found`),i}var MM;function NM(){return MM===void 0&&(MM=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),MM}function PM(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=EM(n,Array.from(t.children).filter(kM).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,jM({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=NM()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:CM({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var FM=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},IM=new Map,LM=new FM;function RM(e){IM=new Map(IM),IM.delete(e)}function zM(e,t){for(let[t]of IM)if(t.id===e)return t}function BM(e,t){for(let[t,n]of IM)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function VM(){return IM}function HM(e,t){return LM.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function UM(e,t){let n=IM.get(e);IM=new Map(IM),IM.set(e,t),LM.emit(`groupChange`,{group:e,prev:n,next:t})}function WM(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=AM(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function GM(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function KM(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:QM(e),b:QM(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();TM(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:ZM(XM(n.a)),b:ZM(XM(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var qM=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JM(e){let t=getComputedStyle($M(e)??e).display;return t===`flex`||t===`inline-flex`}function YM(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||JM(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||qM.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function XM(e){let t=e.length;for(;t--;){let n=e[t];if(TM(n,`Missing node`),YM(n))return n}return null}function ZM(e){return e&&Number(getComputedStyle(e).zIndex)||0}function QM(e){let t=[];for(;e;)t.push(e),e=$M(e);return t}function $M(e){let{parentNode:t}=e;return GM(t)?t.host:t}function eN(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function tN({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!kM(n)||n.contains(e)||e.contains(n))return!0;if(KM(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(eN(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function nN(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=PM(r),a=WM(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&tN({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function rN(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function iN(e,t,n=0){return Math.abs(SM(e)-SM(t))<=n}function aN(e,t){return iN(e,t)?0:e>t?1:-1}function oN({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(aN(r,c)<0)if(a){let e=(i+c)/2;r=aN(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=SM(r),r}function sN({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(iN(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;TM(u!=null,`Invalid first pivot index`),TM(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];TM(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(TM(n!=null,`Previous layout not found for panel index ${t}`),iN(n,i)){let t=o-n;aN(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];TM(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(TM(n!=null,`Previous layout not found for panel index ${t}`),iN(n,o)){let t=n-i;aN(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];TM(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&aN(i,c)<0)if(e>0){let t=c-o,n=t/2;aN(i+e,c)<0&&(e=aN(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;aN(i-e,c)<0&&(e=aN(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];TM(e!=null,`Previous layout not found for panel index ${r}`);let a=oN({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];TM(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=oN({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!iN(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(rN(c,l))return i;{let t=e<0?d:u,r=s[t];TM(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=oN({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!iN(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];TM(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=oN({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(iN(i,s)||(t-=s-i,l[r]=s),iN(t,0))break;e>0?r--:r++}}}if(!iN(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function cN(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||aN(e[n],t[n])!==0)return!1;return!0}function lN({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!iN(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];TM(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];TM(i!=null,`No layout data found for index ${e}`);let o=r[e];TM(o!=null,`No layout data found for index ${e}`);let s=oN({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!iN(a,0))for(let e=0;e<t.length;e++){let n=r[e];TM(n!=null,`No layout data found for index ${e}`);let i=n+a,o=oN({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,iN(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function uN({groupId:e,panelId:t}){let n=()=>{let t=VM();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=lN({layout:sN({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});cN(l,p)||UM(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&iN(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=SM(e/CM({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function dN(e){e.defaultPrevented||nN(e,VM()).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=uN({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function fN(e){let t=VM();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function pN({groupId:e}){let t=()=>{let t=VM();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=lN({layout:e,panelConstraints:r});return n?o:(cN(o,c)||UM(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function mN(e,t){let n=fN(e),r=BM(n.id,!0),i=n.separators.find(t=>t.element===e);TM(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);TM(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=pN({groupId:n.id}).getLayout(),c=lN({layout:sN({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});cN(s,c)||UM(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function hN(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=fN(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&mN(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&mN(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&mN(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&mN(t,-5);break;case`End`:e.preventDefault(),mN(t,100);break;case`Enter`:{e.preventDefault();let n=fN(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=BM(n.id,!0),o=n.separators.find(e=>e.element===t);TM(o,`Matching separator not found`);let s=a.get(o);TM(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(TM(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];mN(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=fN(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);TM(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),mN(t,-100);break}}var gN={cursorFlags:0,state:`inactive`},_N=new FM;function vN(){return gN}function yN(e){return _N.addListener(`change`,e)}function bN(e){let t=gN,n={...gN};n.cursorFlags=e,gN=n,_N.emit(`change`,{prev:t,next:n})}function xN(e){let t=gN;gN=e,_N.emit(`change`,{prev:t,next:e})}function SN(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=VM(),n=nN(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),xN({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var CN=e=>e,wN=()=>{},TN=1,EN=2,DN=4,ON=8,kN=3,AN=12,jN;function MN(){return jN===void 0&&(jN=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(jN=!0)),jN}function NN({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&MN()){let t=(e&TN)!==0,n=(e&EN)!==0,r=(e&DN)!==0,i=(e&ON)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return MN()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var PN=new WeakMap;function FN(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=PN.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=vN();switch(r.state){case`active`:case`hover`:{let e=NN({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}PN.set(e,{prevStyle:t,styleSheet:n})}function IN({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=sN({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(cN(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?TN:EN;break;case`vertical`:s|=d<0?DN:ON;break}}else UM(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&kN:c|=s&kN,t.movementY===0?c|=o&AN:c|=s&AN,bN(c),FN(e)}function LN(e){let t=VM(),n=vN();switch(n.state){case`active`:IN({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function RN(e){if(e.defaultPrevented)return;let t=vN(),n=VM();switch(t.state){case`active`:if(e.buttons===0){xN({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=BM(e.group.id,!0);UM(e.group,t)});return}IN({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=nN(e,n);r.length===0?t.state!==`inactive`&&xN({cursorFlags:0,state:`inactive`}):xN({cursorFlags:0,hitRegions:r,state:`hover`}),FN(e.currentTarget);break}}}function zN(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(vN().state){case`hover`:xN({cursorFlags:0,state:`inactive`})}}function BN(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=vN();switch(t.state){case`active`:xN({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(FN(e.currentTarget),t.hitRegions.forEach(e=>{let t=BM(e.group.id,!0);UM(e.group,t)}),e.preventDefault())}}function VN(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=SM(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=SM((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function HN(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=CM({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:SM(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function UN(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function WN({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=SM(e/100*n/t*100);s.set(l.id,r),i+=r;break}case`preserve-relative-size`:default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=SM((r[e]??0)/a*l);else{let e=SM(l/c.length);for(let t of c)u[t]=e}return u}function GN(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var KN=new Map;function qN(e){let t=!0;TM(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=CM({group:e});if(t===0)return;let n=BM(e.id);if(!n)return;let r=wM(e),i=n.defaultLayoutDeferred?VN(r):n.layout,a=lN({layout:WN({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&cN(n.layout,a)&&UN(n.derivedPanelConstraints,r)&&n.groupSize===t)return;UM(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else HN(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{TM(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=CM({group:e}),s=wM(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(GN(e.panels,l)||(l=void 0));let u=lN({layout:e.mutableState.layouts[c]??l??VN(s),panelConstraints:s}),d=e.element.ownerDocument;KN.set(d,(KN.get(d)??0)+1);let f=new Map;return PM(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),UM(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{TM(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,hN)}),KN.get(d)===1&&(d.addEventListener(`dblclick`,dN,!0),d.addEventListener(`pointerdown`,SN,!0),d.addEventListener(`pointerleave`,LN),d.addEventListener(`pointermove`,RN),d.addEventListener(`pointerout`,zN),d.addEventListener(`pointerup`,BN,!0)),function(){t=!1,KN.set(d,Math.max(0,(KN.get(d)??0)-1)),RM(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,hN)}),KN.get(d)||(d.removeEventListener(`dblclick`,dN,!0),d.removeEventListener(`pointerdown`,SN,!0),d.removeEventListener(`pointerleave`,LN),d.removeEventListener(`pointermove`,RN),d.removeEventListener(`pointerout`,zN),d.removeEventListener(`pointerup`,BN,!0)),a.disconnect()}}function JN(){let[e,t]=(0,F.useState)({});return[e,(0,F.useCallback)(()=>t({}),[])]}function YN(e){let t=(0,F.useId)();return`${e??t}`}var XN=typeof window<`u`?F.useLayoutEffect:F.useEffect;function ZN(e){let t=(0,F.useRef)(e);return XN(()=>{t.current=e},[e]),(0,F.useCallback)((...e)=>t.current?.(...e),[t])}function QN(...e){return ZN(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function $N(e){let t=(0,F.useRef)({...e});return XN(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var eP=(0,F.createContext)(null);function tP(e,t){let n=(0,F.useRef)({getLayout:()=>({}),setLayout:CN});(0,F.useImperativeHandle)(t,()=>n.current,[]),XN(()=>{Object.assign(n.current,pN({groupId:e}))})}function nP({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,F.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=ZN(e=>{cN(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=ZN(e=>{cN(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=YN(s),v=(0,F.useRef)(null),[y,b]=JN(),x=(0,F.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=QN(v,a);tP(_,o);let C=ZN((e,t)=>{let r=vN(),i=zM(e),a=BM(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}return{flexGrow:n?.[t]??1}}),w=$N({defaultLayout:n,disableCursor:r}),T=(0,F.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=EM(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=EM(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=zM(_),i=BM(_);r&&i&&UM(r,{...i,derivedPanelConstraints:wM(r)})},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,F.useRef)(null);return XN(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=qN(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=BM(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=HM(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=iN(t.collapsedSize,i[t.panelId]),a=iN(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=vN().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,F.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,I.jsx)(eP.Provider,{value:T,children:(0,I.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}nP.displayName=`Group`;function rP(){let e=(0,F.useContext)(eP);return TM(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function iP(e,t){let{id:n}=rP(),r=(0,F.useRef)({collapse:wN,expand:wN,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:wN});(0,F.useImperativeHandle)(t,()=>r.current,[]),XN(()=>{Object.assign(r.current,uN({groupId:n,panelId:e}))})}function aP({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=YN(c),_=$N({disabled:a}),v=(0,F.useRef)(null),y=QN(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,togglePanelDisabled:w}=rP(),T=d!==null,E=ZN((e,t,n)=>{d?.(e,c,n)});XN(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,F.useEffect)(()=>{w(g,!!a)},[a,g,w]),iP(g,f);let ee=(0,F.useSyncExternalStore)(e=>HM(x,e),()=>JSON.stringify(b(x,g)),()=>JSON.stringify(b(x,g)));return(0,I.jsx)(`div`,{...m,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...oP,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...JSON.parse(ee)},children:(0,I.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}aP.displayName=`Panel`;var oP={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function sP({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=lN({layout:sN({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=lN({layout:sN({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function cP({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=YN(i),c=$N({disabled:n}),[l,u]=(0,F.useState)({}),[d,f]=(0,F.useState)(`inactive`),p=(0,F.useRef)(null),m=QN(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=rP(),b=_===`horizontal`?`vertical`:`horizontal`;XN(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=yN(e=>{f(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=HM(g,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);u(sP({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,F.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,I.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}cP.displayName=`Separator`;function lP({className:e,...t}){return(0,I.jsx)(nP,{"data-slot":`resizable-panel-group`,className:q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function uP({...e}){return(0,I.jsx)(aP,{"data-slot":`resizable-panel`,...e})}function dP({withHandle:e,className:t,...n}){return(0,I.jsx)(cP,{"data-slot":`resizable-handle`,className:q(`bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,I.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,I.jsx)(ha,{className:`size-2.5`})})})}var fP={type:`openai-completions`,base:``,apiKey:``,models:{}};function pP(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft),n=e?.providers??{},r=Object.keys(n),[i,a]=(0,F.useState)(r[0]??null),[o,s]=(0,F.useState)(``),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(``);if(!e)return null;function m(){let e=o.trim().toLowerCase().replace(/[^a-z0-9-]/g,`-`);!e||n[e]||(t(t=>(t.providers[e]={...fP},t)),a(e),s(``),l(!1))}function h(e,n){t(t=>(t.providers[e]=n,t))}function g(e){t(t=>(delete t.providers[e],t)),a(r.find(t=>t!==e)??null)}function _(){if(!i||!n[i])return;let e=f.trim().toLowerCase().replace(/[^a-z0-9-]/g,`-`);!e||n[e]||(t(t=>(t.providers[e]=structuredClone(t.providers[i]),t)),a(e),p(``),d(!1))}return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-6 lg:overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`shrink-0`,children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Providers`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`管理上游 API 服务商配置`})]}),(0,I.jsxs)(lP,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,I.jsx)(uP,{defaultSize:`280px`,minSize:`180px`,maxSize:`50%`,className:`min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex h-full min-w-0 min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,I.jsx)(fE,{className:`min-h-0 min-w-0 flex-1 **:data-[slot=scroll-area-viewport]:min-w-0 **:data-[slot=scroll-area-viewport]:overflow-x-hidden [&_[data-slot=scroll-area-viewport]>div]:block! [&_[data-slot=scroll-area-viewport]>div]:min-w-0 [&_[data-slot=scroll-area-viewport]>div]:w-full`,children:(0,I.jsx)(`div`,{className:`w-full min-w-0 space-y-2 pr-2`,children:r.map(e=>{let t=n[e],r=Object.keys(t.models).length;return(0,I.jsxs)(`button`,{type:`button`,className:`w-full min-w-0 overflow-hidden text-left rounded-lg border p-3 transition-colors hover:bg-accent cursor-pointer ${i===e?`border-primary bg-accent`:`border-border`}`,onClick:()=>a(e),children:[(0,I.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(ka,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate font-medium text-sm`,children:e})]}),(0,I.jsxs)(`div`,{className:`mt-1.5 ml-6 flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(X,{variant:`outline`,className:`min-w-0 max-w-full overflow-hidden text-xs`,children:(0,I.jsx)(`span`,{className:`block min-w-0 truncate`,children:t.type})}),(0,I.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap text-xs text-muted-foreground`,children:[r,` 个模型`]})]})]},e)})})}),(0,I.jsx)(`div`,{className:`shrink-0 pr-2`,children:(0,I.jsxs)(rE,{open:c,onOpenChange:l,children:[(0,I.jsx)(iE,{asChild:!0,children:(0,I.jsxs)(J,{variant:`outline`,className:`w-full`,children:[(0,I.jsx)(Sa,{className:`h-4 w-4 mr-1`}),`添加 Provider`]})}),(0,I.jsxs)(sE,{children:[(0,I.jsxs)(cE,{children:[(0,I.jsx)(uE,{children:`添加 Provider`}),(0,I.jsx)(dE,{children:`输入新 Provider 的名称(kebab-case 格式)`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Aj,{htmlFor:`new-provider-name`,children:`名称`}),(0,I.jsx)(kj,{id:`new-provider-name`,value:o,onChange:e=>s(e.target.value),placeholder:`my-provider`,className:`font-mono`,onKeyDown:e=>e.key===`Enter`&&m()})]}),(0,I.jsx)(lE,{children:(0,I.jsx)(J,{onClick:m,disabled:!o.trim(),children:`创建`})})]})]})})]})}),(0,I.jsx)(dP,{withHandle:!0,className:`bg-transparent transition-colors duration-200 hover:bg-border focus-visible:bg-border active:bg-border [&>div]:opacity-0 [&>div]:transition-opacity [&>div]:duration-200 hover:[&>div]:opacity-100 focus-visible:[&>div]:opacity-100 active:[&>div]:opacity-100`}),(0,I.jsx)(uP,{minSize:`400px`,children:(0,I.jsx)(`div`,{className:`flex h-full flex-col min-h-0 pl-2 pb-3 lg:pb-0`,children:(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background flex flex-col min-h-0 h-full`,children:[(0,I.jsx)(`div`,{className:`border-b px-3 py-3 shrink-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold truncate`,children:i?`${i}`:`选择一个 Provider`}),i&&n[i]&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,I.jsxs)(rE,{open:u,onOpenChange:d,children:[(0,I.jsx)(iE,{asChild:!0,children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`复制此 Provider`,children:(0,I.jsx)(oa,{className:`h-4 w-4`})})}),(0,I.jsxs)(sE,{children:[(0,I.jsxs)(cE,{children:[(0,I.jsx)(uE,{children:`复制 Provider`}),(0,I.jsx)(dE,{children:`输入新 Provider 的名称(kebab-case 格式)`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Aj,{htmlFor:`copy-provider-name`,children:`名称`}),(0,I.jsx)(kj,{id:`copy-provider-name`,value:f,onChange:e=>p(e.target.value),placeholder:`my-provider-copy`,className:`font-mono`,onKeyDown:e=>e.key===`Enter`&&_()})]}),(0,I.jsx)(lE,{children:(0,I.jsx)(J,{onClick:_,disabled:!f.trim(),children:`复制`})})]})]}),(0,I.jsxs)(aM,{children:[(0,I.jsx)(oM,{asChild:!0,children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,"aria-label":`删除此 Provider`,children:(0,I.jsx)(Aa,{className:`h-4 w-4`})})}),(0,I.jsxs)(lM,{children:[(0,I.jsxs)(uM,{children:[(0,I.jsx)(fM,{children:`确认删除`}),(0,I.jsxs)(pM,{children:[`确定要删除 Provider「`,i,`」吗?引用此 Provider 的路由规则将失效。`]})]}),(0,I.jsxs)(dM,{children:[(0,I.jsx)(hM,{children:`取消`}),(0,I.jsx)(mM,{onClick:()=>g(i),children:`删除`})]})]})]})]})]})}),(0,I.jsx)(fE,{className:`min-h-0 flex-1`,children:(0,I.jsx)(`div`,{className:`px-3 py-3`,children:i&&n[i]?(0,I.jsx)(iM,{name:i,config:n[i],isNew:!1,onChange:e=>h(i,e)},i):(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm py-8 text-center`,children:r.length===0?`暂无 Provider,点击左侧「添加 Provider」按钮创建`:`请从左侧列表中选择一个 Provider`})})})]})})})]})]})}var mP={"openai-completions":`OpenAI Completions`,"openai-responses":`OpenAI Responses`,"anthropic-messages":`Anthropic Messages`};function hP({modelMap:e,providers:t,onChange:n}){let r=Object.entries(e),i=r.filter(([e])=>e!==`*`),a=r.find(([e])=>e===`*`);function o(t){if(t===`*`)return;let r={...e};delete r[t],n(r)}function s(t,r){if(r===t)return;let i={};for(let[n,a]of Object.entries(e))i[n===t?r:n]=a;n(i)}function c(t,r,i){n({...e,[t]:{...e[t],[r]:i}})}function l(e){let n=t[e];return n?Object.keys(n.models):[]}return(0,I.jsxs)(`div`,{className:`relative space-y-3`,children:[(0,I.jsx)(`div`,{className:`absolute left-0 top-0 bottom-6 w-px bg-border`}),(0,I.jsxs)(`div`,{className:`ml-5 flex items-center gap-1.5 px-2 text-xs font-medium text-muted-foreground translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(`span`,{className:`w-[200px] min-w-[120px]`,children:`请求模型`}),(0,I.jsx)(`span`,{className:`w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:`路由目标`}),(0,I.jsx)(`span`,{className:`w-8 shrink-0`})]}),i.length>0&&(0,I.jsx)(`div`,{className:`space-y-1.5 translate-x-[-0.5px] translate-y-[-1px]`,children:i.map(([e,n])=>(0,I.jsxs)(`div`,{className:`relative pl-5`,children:[(0,I.jsx)(gP,{}),(0,I.jsx)(_P,{ruleKey:e,target:n,isWildcard:!1,providers:t,getModelsForProvider:l,onKeyCommit:t=>s(e,t),onTargetChange:(t,n)=>c(e,t,n),onRemove:()=>o(e)})]},e))}),a&&i.length>0&&(0,I.jsxs)(`div`,{className:`relative ml-5 translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,I.jsx)(`div`,{className:`w-full border-t border-dashed`})}),(0,I.jsx)(`div`,{className:`relative flex justify-center`,children:(0,I.jsx)(`span`,{className:`bg-background px-2 text-[11px] text-muted-foreground`,children:`兜底规则 — 未匹配的请求将路由至此`})})]}),a&&(0,I.jsxs)(`div`,{className:`relative pl-5 translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(gP,{}),(0,I.jsx)(_P,{ruleKey:a[0],target:a[1],isWildcard:!0,providers:t,getModelsForProvider:l,onKeyCommit:()=>{},onTargetChange:(e,t)=>c(`*`,e,t),onRemove:()=>{}})]})]})}function gP(){return(0,I.jsx)(`svg`,{className:`pointer-events-none absolute left-0 top-1/2 -translate-y-1/2 text-border`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M1 0A10 10 0 0 0 11 10H20`,className:`stroke-current`,strokeWidth:`1`,strokeLinecap:`round`})})}function _P({ruleKey:e,target:t,isWildcard:n,providers:r,getModelsForProvider:i,onKeyCommit:a,onTargetChange:o,onRemove:s}){let[c,l]=(0,F.useState)(e);(0,F.useEffect)(()=>{l(e)},[e]);function u(){c!==e&&a(c)}let d=i(t.provider),f=Object.entries(r).reduce((e,[t,n])=>(e[n.type].push(t),e),{"openai-completions":[],"openai-responses":[],"anthropic-messages":[]});return(0,I.jsxs)(`div`,{className:n?`grid grid-cols-[minmax(120px,200px)_20px_1fr_32px] items-center gap-x-1.5 rounded-lg border border-dashed bg-muted/30 p-2 transition-colors`:`grid grid-cols-[minmax(120px,200px)_20px_1fr_32px] items-center gap-x-1.5 rounded-lg border border-solid bg-background p-2 transition-colors`,children:[n?(0,I.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 px-1`,children:[(0,I.jsx)(X,{variant:`secondary`,className:`text-xs font-mono`,children:`*`}),(0,I.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`所有`})]}):(0,I.jsx)(kj,{value:c,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`h-7 text-sm font-mono`}),(0,I.jsx)(Zi,{className:`h-3.5 w-3.5 text-muted-foreground mx-auto`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,I.jsxs)(jj,{value:t.provider,onValueChange:e=>o(`provider`,e),children:[(0,I.jsx)(Pj,{className:`h-7 text-sm w-[320px] shrink-0`,children:(0,I.jsx)(Nj,{placeholder:`Provider`})}),(0,I.jsx)(Fj,{children:Object.keys(mP).map(e=>{let t=f[e];return t.length===0?null:(0,I.jsxs)(Mj,{children:[(0,I.jsx)(Ij,{children:mP[e]}),t.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]},e)})})]}),(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs shrink-0`,children:`/`}),d.length>0?(0,I.jsxs)(jj,{value:t.model,onValueChange:e=>o(`model`,e),children:[(0,I.jsx)(Pj,{className:`h-7 text-sm flex-1 min-w-0`,children:(0,I.jsx)(Nj,{placeholder:`模型`})}),(0,I.jsx)(Fj,{children:d.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))})]}):(0,I.jsx)(kj,{value:t.model,onChange:e=>o(`model`,e.target.value),className:`h-7 text-sm font-mono flex-1 min-w-0`,placeholder:`模型名称`})]}),(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 text-destructive hover:text-destructive`,disabled:n,onClick:s,children:(0,I.jsx)(Aa,{className:`h-3 w-3`})})]})}var vP=[`openai-completions`,`openai-responses`,`anthropic-messages`];function yP(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft),n=Object.keys(e?.routes??{}),[r,i]=(0,F.useState)(``),a=vP.filter(e=>!n.includes(e));if(!e)return null;let o=e;function s(){if(!r)return;let e=Object.keys(o.providers)[0]??``,n=e?Object.keys(o.providers[e]?.models??{})[0]??``:``;t(t=>(t.routes[r]={"*":{provider:e,model:n}},t)),i(``)}function c(e){t(t=>(delete t.routes[e],t))}function l(e,n){t(t=>(t.routes[e]=n,t))}function u(e){let n=Object.keys(o.providers)[0]??``,r=n?Object.keys(o.providers[n]?.models??{})[0]??``:``;t(t=>{let i=t.routes[e]??{};return t.routes[e]={...i,[`alias-${Date.now()}`]:{provider:n,model:r}},t})}return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`路由`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`管理协议入口与模型路由映射`})]}),n.length===0?(0,I.jsx)(`div`,{className:`rounded-lg border bg-background py-12 text-center text-muted-foreground`,children:`暂无路由配置,请先添加一个协议入口`}):(0,I.jsx)(`div`,{className:`space-y-6`,children:n.map(t=>{let n=e.routes[t],r=Object.keys(n).length;return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{className:`rounded-lg border bg-card text-card-foreground px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:t}),(0,I.jsxs)(X,{variant:`secondary`,className:`text-xs`,children:[r,` 个规则`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs`,onClick:()=>u(t),children:[(0,I.jsx)(Sa,{className:`mr-1 h-3.5 w-3.5`}),`添加规则`]}),(0,I.jsxs)(aM,{children:[(0,I.jsx)(oM,{asChild:!0,children:(0,I.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-destructive hover:text-destructive`,children:(0,I.jsx)(Aa,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(lM,{children:[(0,I.jsxs)(uM,{children:[(0,I.jsx)(fM,{children:`确认删除`}),(0,I.jsxs)(pM,{children:[`确定要删除协议入口「`,t,`」及其所有路由规则吗?`]})]}),(0,I.jsxs)(dM,{children:[(0,I.jsx)(hM,{children:`取消`}),(0,I.jsx)(mM,{onClick:()=>c(t),children:`删除`})]})]})]})]})]})}),(0,I.jsxs)(`div`,{className:`relative mt-3 ml-3`,children:[(0,I.jsx)(`div`,{className:`absolute left-0 -top-3 h-3 w-px bg-border`}),(0,I.jsx)(hP,{routeType:t,modelMap:e.routes[t],providers:e.providers,onChange:e=>l(t,e)})]})]},t)})}),a.length>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(jj,{value:r,onValueChange:i,children:[(0,I.jsx)(Pj,{className:`w-[240px]`,children:(0,I.jsx)(Nj,{placeholder:`选择协议类型...`})}),(0,I.jsx)(Fj,{children:a.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))})]}),(0,I.jsxs)(J,{onClick:s,disabled:!r,children:[(0,I.jsx)(Sa,{className:`h-4 w-4 mr-1`}),`添加协议入口`]})]})]})}var bP={window:`24h`,from:``,to:``,user:``,session:``,q:``};const xP=Ev((e,t)=>({filters:{...bP},summary:null,users:[],meta:null,from:``,to:``,loading:!1,error:null,setFilter:(t,n)=>{e(e=>({filters:{...e.filters,[t]:n}}))},fetchData:async()=>{e({loading:!0,error:null});try{let n=t(),r=await Wv({window:n.filters.window,from:n.filters.from||void 0,to:n.filters.to||void 0,user:n.filters.user||void 0,session:n.filters.session||void 0,q:n.filters.q||void 0});e({summary:r.summary,users:r.users,meta:r.meta,from:r.from,to:r.to,loading:!1,error:null})}catch(t){e({loading:!1,error:t instanceof Error?t.message:`用户会话查询失败`})}},resetFilters:async()=>{e({filters:{...bP}}),await t().fetchData()}}));function SP(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}T${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function CP(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString()}function wP(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function TP(e){return e.length===0?`-`:e.slice(0,3).map(e=>`${e.key}(${e.count})`).join(`, `)}function EP(e,t=6){return e.length<=t*2+3?e:`${e.slice(0,t)}...${e.slice(-t)}`}function DP(){let e=Sr(),t=xP(e=>e.filters),n=xP(e=>e.summary),r=xP(e=>e.users),i=xP(e=>e.meta),a=xP(e=>e.from),o=xP(e=>e.to),s=xP(e=>e.loading),c=xP(e=>e.error),l=xP(e=>e.setFilter),u=xP(e=>e.fetchData),d=xP(e=>e.resetFilters),[f,p]=(0,F.useState)({});(0,F.useEffect)(()=>{u()},[u]);let m=r.length>0,h=(0,F.useMemo)(()=>({users:n?.uniqueUsers??0,sessions:n?.uniqueSessions??0,requests:n?.totalRequests??0,metadataRequests:n?.metadataRequests??0}),[n]);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`用户会话`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`解析日志 metadata 中的 user ↔ session 映射,查看活跃度并跳转日志检索`})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`检索条件`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`支持时间窗、范围、用户/会话精确筛选与关键词检索`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`时间窗口`}),(0,I.jsxs)(jj,{value:t.window,onValueChange:e=>l(`window`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`1h`,children:`最近 1 小时`}),(0,I.jsx)(Lj,{value:`6h`,children:`最近 6 小时`}),(0,I.jsx)(Lj,{value:`24h`,children:`最近 24 小时`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-from`,children:`起始时间`}),(0,I.jsx)(kj,{id:`sessions-from`,type:`datetime-local`,className:`h-8`,value:SP(t.from),onChange:e=>l(`from`,CP(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-to`,children:`结束时间`}),(0,I.jsx)(kj,{id:`sessions-to`,type:`datetime-local`,className:`h-8`,value:SP(t.to),onChange:e=>l(`to`,CP(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-q`,children:`关键词`}),(0,I.jsx)(kj,{id:`sessions-q`,className:`h-8`,value:t.q,onChange:e=>l(`q`,e.target.value),placeholder:`user/session/model/provider`})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-user`,children:`用户标识`}),(0,I.jsx)(kj,{id:`sessions-user`,className:`h-8`,value:t.user,onChange:e=>l(`user`,e.target.value),placeholder:`userKey 或 raw user_id`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-session`,children:`会话 ID`}),(0,I.jsx)(kj,{id:`sessions-session`,className:`h-8`,value:t.session,onChange:e=>l(`session`,e.target.value),placeholder:`sessionId`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(J,{size:`sm`,onClick:()=>void u(),disabled:s,children:[(0,I.jsx)(Oa,{className:`h-3.5 w-3.5`}),`查询`]}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void d(),disabled:s,children:`重置`}),a&&o?(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`生效范围:`,wP(a),` - `,wP(o)]}):null]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,I.jsx)(OP,{title:`用户数`,value:h.users}),(0,I.jsx)(OP,{title:`会话数`,value:h.sessions}),(0,I.jsx)(OP,{title:`请求数`,value:h.requests}),(0,I.jsx)(OP,{title:`含 metadata 请求`,value:h.metadataRequests})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`用户与会话`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`文件 ${i.scannedFiles} · 行 ${i.scannedLines} · 解析异常 ${i.parseErrors}${i.truncated?` · 已截断`:``}`:`等待查询`})]}),(0,I.jsx)(`div`,{className:`px-3 py-3`,children:c?(0,I.jsx)(EO,{className:`min-h-[160px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`用户会话查询失败`}),(0,I.jsx)(jO,{children:c})]})}):s?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`})]}):m?(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:(0,I.jsxs)(UO,{children:[(0,I.jsx)(WO,{className:`w-[46px]`}),(0,I.jsx)(WO,{children:`用户`}),(0,I.jsx)(WO,{children:`请求数`}),(0,I.jsx)(WO,{children:`会话数`}),(0,I.jsx)(WO,{children:`首次活跃`}),(0,I.jsx)(WO,{children:`最近活跃`}),(0,I.jsx)(WO,{children:`模型摘要`}),(0,I.jsx)(WO,{children:`Provider`}),(0,I.jsx)(WO,{children:`RouteType`}),(0,I.jsx)(WO,{className:`sticky right-0 z-10 bg-background text-right`,children:`操作`})]})}),(0,I.jsx)(VO,{children:r.map(t=>{let n=f[t.userKey]??!0;return(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(UO,{children:[(0,I.jsx)(GO,{children:(0,I.jsx)(J,{size:`icon-xs`,variant:`ghost`,onClick:()=>p(e=>({...e,[t.userKey]:!n})),children:n?(0,I.jsx)(ta,{className:`h-3.5 w-3.5`}):(0,I.jsx)(na,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(GO,{className:`font-mono text-xs`,title:t.userKey,children:EP(t.userKey,10)}),(0,I.jsx)(GO,{children:t.requestCount}),(0,I.jsx)(GO,{children:t.sessionCount}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(t.firstSeenAt)}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(t.lastSeenAt)}),(0,I.jsx)(GO,{className:`max-w-[260px] truncate text-xs`,title:TP(t.models),children:TP(t.models)}),(0,I.jsx)(GO,{children:(0,I.jsx)(X,{variant:`outline`,className:`text-xs`,children:t.providers.length})}),(0,I.jsx)(GO,{children:(0,I.jsx)(X,{variant:`outline`,className:`text-xs`,children:t.routeTypes.length})}),(0,I.jsx)(GO,{className:`sticky right-0 z-10 bg-background text-right`,children:(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/logs`,search:{user:t.userKey,session:void 0}}),children:`查看日志`})})]},t.userKey),n?t.sessions.map(n=>(0,I.jsxs)(UO,{className:`bg-muted/20`,children:[(0,I.jsx)(GO,{}),(0,I.jsx)(GO,{className:`text-muted-foreground text-xs`,children:`↳ 会话`}),(0,I.jsx)(GO,{children:n.requestCount}),(0,I.jsx)(GO,{className:`text-xs text-muted-foreground`,children:n.sessionId}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(n.firstSeenAt)}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(n.lastSeenAt)}),(0,I.jsx)(GO,{className:`max-w-[260px] truncate text-xs`,title:TP(n.models),children:TP(n.models)}),(0,I.jsxs)(GO,{className:`text-xs text-muted-foreground`,colSpan:2,children:[`最近 requestId: `,EP(n.latestRequestId,8)]}),(0,I.jsx)(GO,{className:`sticky right-0 z-10 bg-background text-right`,children:(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/logs`,search:{user:t.userKey,session:n.sessionId}}),children:`查看日志`})})]},`${t.userKey}-${n.sessionId}`)):null]},t.userKey)})})]})}):(0,I.jsx)(EO,{className:`min-h-[220px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`暂无可用用户会话`}),(0,I.jsx)(jO,{children:`请确认 bodyPolicy 不为 off,并调整筛选条件后重试`})]})})})]})]})}function OP({title:e,value:t}){return(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background px-3 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,I.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:t})]})}var kP=Vr({component:xO}),AP=zr({getParentRoute:()=>kP,path:`/`,component:()=>(0,I.jsx)(Cr,{to:`/dashboard`,replace:!0})}),jP=zr({getParentRoute:()=>kP,path:`/dashboard`,component:$O}),MP=zr({getParentRoute:()=>kP,path:`/providers`,component:pP}),NP=zr({getParentRoute:()=>kP,path:`/routes`,component:yP}),PP=zr({getParentRoute:()=>kP,path:`/logs`,validateSearch:e=>({user:typeof e.user==`string`?e.user:void 0,session:typeof e.session==`string`?e.session:void 0}),component:Xj}),FP=zr({getParentRoute:()=>kP,path:`/sessions`,component:DP}),IP=zr({getParentRoute:()=>kP,path:`/logs/$id`,component:Zk}),LP=zr({getParentRoute:()=>kP,path:`/logs-settings`,component:$j});const RP=ai({routeTree:kP.addChildren([AP,jP,MP,NP,PP,FP,IP,LP]),basepath:`/admin`,defaultPreload:`intent`});(0,li.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(ci,{router:RP})}));
|
|
190
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function $(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function lA(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:Q(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),$(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function uA(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:Q(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],$(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:Q(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},$(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var dA=`debugHeaders`;function fA(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var pA={createTable:e=>{e.getHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return mA(t,[...a,...s,...o],e)},$(e.options,dA,`getHeaderGroups`)),e.getCenterHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),mA(t,n,e,`center`)),$(e.options,dA,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>mA(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),$(e.options,dA,`getLeftHeaderGroups`)),e.getRightHeaderGroups=Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>mA(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),$(e.options,dA,`getRightHeaderGroups`)),e.getFooterGroups=Q(()=>[e.getHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getFooterGroups`)),e.getLeftFooterGroups=Q(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getLeftFooterGroups`)),e.getCenterFooterGroups=Q(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getCenterFooterGroups`)),e.getRightFooterGroups=Q(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),$(e.options,dA,`getRightFooterGroups`)),e.getFlatHeaders=Q(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getFlatHeaders`)),e.getLeftFlatHeaders=Q(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=Q(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getCenterFlatHeaders`)),e.getRightFlatHeaders=Q(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),$(e.options,dA,`getRightFlatHeaders`)),e.getCenterLeafHeaders=Q(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=Q(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getLeftLeafHeaders`)),e.getRightLeafHeaders=Q(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),$(e.options,dA,`getRightLeafHeaders`)),e.getLeafHeaders=Q(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),$(e.options,dA,`getLeafHeaders`))}};function mA(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=fA(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>fA(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var hA=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>cA(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:Q(()=>[e.getAllLeafColumns()],t=>t.map(t=>lA(e,s,t,t.id)),$(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:Q(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),$(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},gA={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},_A=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};_A.autoRemove=e=>DA(e);var vA=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};vA.autoRemove=e=>DA(e);var yA=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};yA.autoRemove=e=>DA(e);var bA=(e,t,n)=>e.getValue(t)?.includes(n);bA.autoRemove=e=>DA(e);var xA=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});xA.autoRemove=e=>DA(e)||!(e!=null&&e.length);var SA=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));SA.autoRemove=e=>DA(e)||!(e!=null&&e.length);var CA=(e,t,n)=>e.getValue(t)===n;CA.autoRemove=e=>DA(e);var wA=(e,t,n)=>e.getValue(t)==n;wA.autoRemove=e=>DA(e);var TA=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};TA.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},TA.autoRemove=e=>DA(e)||DA(e[0])&&DA(e[1]);var EA={includesString:_A,includesStringSensitive:vA,equalsString:yA,arrIncludes:bA,arrIncludesAll:xA,arrIncludesSome:SA,equals:CA,weakEquals:wA,inNumberRange:TA};function DA(e){return e==null||e===``}var OA={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:aA(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?EA.includesString:typeof n==`number`?EA.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?EA.equals:Array.isArray(n)?EA.arrIncludes:EA.weakEquals},e.getFilterFn=()=>oA(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??EA[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=iA(n,i?i.value:void 0);if(kA(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>iA(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&kA(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function kA(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var AA={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!sA(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},jA={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:aA(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return AA.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return AA.extent},e.getAggregationFn=()=>{if(!e)throw Error();return oA(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??AA[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function MA(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var NA={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:aA(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=Q(e=>[WA(t,e)],t=>t.findIndex(t=>t.id===e.id),$(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>WA(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=WA(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=Q(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return MA(i,t,n)},$(e.options,`debugTable`,`_getOrderColumnsFn`))}},PA=()=>({left:[],right:[]}),FA={getInitialState:e=>({columnPinning:PA(),...e}),getDefaultOptions:e=>({onColumnPinningChange:aA(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},$(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),$(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),$(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?PA():e.initialState?.columnPinning??PA()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),$(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),$(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},$(e.options,`debugColumns`,`getCenterLeafColumns`))}};function IA(e){return e||(typeof document<`u`?document:null)}var LA={size:150,minSize:20,maxSize:2**53-1},RA=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),zA={getDefaultColumnDef:()=>LA,getInitialState:e=>({columnSizing:{},columnSizingInfo:RA(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:aA(`columnSizing`,e),onColumnSizingInfoChange:aA(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??LA.minSize,n??e.columnDef.size??LA.size),e.columnDef.maxSize??LA.maxSize)},e.getStart=Q(e=>[e,WA(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),$(t.options,`debugColumns`,`getStart`)),e.getAfter=Q(e=>[e,WA(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),$(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),HA(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=HA(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=IA(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=VA()?{passive:!1}:!1;HA(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?RA():e.initialState.columnSizingInfo??RA())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},BA=null;function VA(){if(typeof BA==`boolean`)return BA;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return BA=e,BA}function HA(e){return e.type===`touchstart`}var UA={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:aA(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=Q(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),$(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=Q(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],$(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>Q(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),$(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function WA(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var GA={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},KA={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:aA(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>EA.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return oA(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??EA[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},qA={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:aA(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},JA=0,YA=10,XA=()=>({pageIndex:JA,pageSize:YA}),ZA={getInitialState:e=>({...e,pagination:{...XA(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:aA(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>iA(t,e)),e.resetPagination=t=>{e.setPagination(t?XA():e.initialState.pagination??XA())},e.setPageIndex=t=>{e.setPagination(n=>{let r=iA(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?JA:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??JA)},e.resetPageSize=t=>{var n;e.setPageSize(t?YA:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??YA)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,iA(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=iA(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=Q(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},$(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},QA=()=>({top:[],bottom:[]}),$A={getInitialState:e=>({rowPinning:QA(),...e}),getDefaultOptions:e=>({onRowPinningChange:aA(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?QA():e.initialState?.rowPinning??QA()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),$(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),$(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=Q(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},$(e.options,`debugRows`,`getCenterRows`))}},ej={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:aA(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{tj(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=Q(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?nj(e,n):{rows:[],flatRows:[],rowsById:{}},$(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return tj(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return rj(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return ij(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return ij(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},tj=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>tj(e,t.id,n,r,i))};function nj(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=rj(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function rj(e,t){return t[e.id]??!1}function ij(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(rj(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=ij(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var aj=/([0-9]+)/gm,oj=(e,t,n)=>mj(pj(e.getValue(n)).toLowerCase(),pj(t.getValue(n)).toLowerCase()),sj=(e,t,n)=>mj(pj(e.getValue(n)),pj(t.getValue(n))),cj=(e,t,n)=>fj(pj(e.getValue(n)).toLowerCase(),pj(t.getValue(n)).toLowerCase()),lj=(e,t,n)=>fj(pj(e.getValue(n)),pj(t.getValue(n))),uj=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},dj=(e,t,n)=>fj(e.getValue(n),t.getValue(n));function fj(e,t){return e===t?0:e>t?1:-1}function pj(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function mj(e,t){let n=e.split(aj).filter(Boolean),r=t.split(aj).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var hj={alphanumeric:oj,alphanumericCaseSensitive:sj,text:cj,textCaseSensitive:lj,datetime:uj,basic:dj},gj=[pA,UA,NA,FA,gA,OA,GA,KA,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:aA(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return hj.datetime;if(typeof n==`string`&&(r=!0,n.split(aj).length>1))return hj.alphanumeric}return r?hj.text:hj.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return oA(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??hj[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},jA,qA,ZA,$A,ej,zA];function _j(e){let t=[...gj,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(iA(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:Q(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),$(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:Q(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=uA(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},$(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:Q(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),$(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:Q(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),$(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:Q(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),$(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function vj(){return e=>Q(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=hA(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},$(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function yj(e,t){return e?bj(e)?F.createElement(e,t):e:null}function bj(e){return xj(e)||typeof e==`function`||Sj(e)}function xj(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function Sj(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function Cj(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=F.useState(()=>({current:_j(t)})),[r,i]=F.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}function wj({level:e}){return e===`error`?(0,I.jsx)(X,{variant:`destructive`,children:`error`}):(0,I.jsx)(X,{variant:`outline`,children:`info`})}function Tj({statusClass:e}){return e===`2xx`?(0,I.jsx)(X,{variant:`outline`,children:`2xx`}):e===`4xx`?(0,I.jsx)(X,{variant:`secondary`,children:`4xx`}):e===`5xx`?(0,I.jsx)(X,{variant:`destructive`,children:`5xx`}):(0,I.jsx)(X,{variant:`secondary`,children:`network`})}function Ej(e,t){return[{accessorKey:`ts`,header:()=>(0,I.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-1`,onClick:()=>e(t===`time_desc`?`time_asc`:`time_desc`),children:[`时间`,(0,I.jsx)(Qi,{className:`h-3.5 w-3.5`})]}),cell:({row:e})=>{let t=e.original.ts;return(0,I.jsx)(`div`,{className:`text-xs tabular-nums`,children:new Date(t).toLocaleString()})}},{accessorKey:`level`,header:`级别`,cell:({row:e})=>(0,I.jsx)(wj,{level:e.original.level})},{accessorKey:`provider`,header:`Provider`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[140px] truncate text-xs`,title:e.original.provider,children:e.original.provider})},{accessorKey:`routeType`,header:`路由`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[160px] truncate text-xs`,title:e.original.routeType,children:e.original.routeType})},{accessorKey:`modelIn`,header:`模型链路`,cell:({row:e})=>(0,I.jsxs)(`div`,{className:`max-w-[260px] truncate font-mono text-xs`,title:`${e.original.modelIn} -> ${e.original.modelOut}`,children:[e.original.modelIn,` -> `,e.original.modelOut]})},{accessorKey:`message`,header:`消息`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[400px] truncate text-xs`,title:e.original.message,children:e.original.message})},{accessorKey:`latencyMs`,header:`延迟`,cell:({row:e})=>(0,I.jsxs)(`div`,{className:`text-xs tabular-nums`,children:[e.original.latencyMs,` ms`]})},{accessorKey:`statusClass`,header:`状态`,cell:({row:e})=>(0,I.jsx)(Tj,{statusClass:e.original.statusClass})},{accessorKey:`userKey`,header:`用户`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[180px] truncate font-mono text-xs`,title:e.original.userKey??`-`,children:e.original.userKey??`-`})},{accessorKey:`sessionId`,header:`会话`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[220px] truncate font-mono text-xs`,title:e.original.sessionId??`-`,children:e.original.sessionId??`-`})},{accessorKey:`requestId`,header:`Request ID`,cell:({row:e})=>(0,I.jsx)(`div`,{className:`max-w-[220px] truncate font-mono text-xs`,title:e.original.requestId,children:e.original.requestId})}]}function Dj(e){let{data:t,sort:n,onSortChange:r,onRowClick:i}=e,[a,o]=(0,F.useState)({}),s=(0,F.useMemo)(()=>Ej(r,n),[r,n]),c=Cj({data:t,columns:s,getCoreRowModel:vj(),state:{columnVisibility:a},onColumnVisibilityChange:o});return(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:c.getHeaderGroups().map(e=>(0,I.jsx)(UO,{children:e.headers.map(e=>(0,I.jsx)(WO,{children:e.isPlaceholder?null:yj(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,I.jsx)(VO,{children:c.getRowModel().rows?.length?c.getRowModel().rows.map(e=>(0,I.jsx)(Oj,{row:e,onClick:i},e.id)):(0,I.jsx)(UO,{children:(0,I.jsx)(GO,{colSpan:s.length,className:`h-24 text-center text-sm text-muted-foreground`,children:`暂无日志数据`})})})]})})}function Oj({row:e,onClick:t}){return(0,I.jsx)(UO,{className:`cursor-pointer`,onClick:()=>t(e.original),children:e.getVisibleCells().map(e=>(0,I.jsx)(GO,{children:yj(e.column.columnDef.cell,e.getContext())},e.id))})}function kj({className:e,type:t,...n}){return(0,I.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...n})}function Aj({className:e,...t}){return(0,I.jsx)(fp,{"data-slot":`label`,className:q(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function jj({...e}){return(0,I.jsx)(ph,{"data-slot":`select`,...e})}function Mj({...e}){return(0,I.jsx)(bh,{"data-slot":`select-group`,...e})}function Nj({...e}){return(0,I.jsx)(hh,{"data-slot":`select-value`,...e})}function Pj({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(mh,{"data-slot":`select-trigger`,"data-size":t,className:q(`border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,I.jsx)(gh,{asChild:!0,children:(0,I.jsx)(ta,{className:`size-4 opacity-50`})})]})}function Fj({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(_h,{children:(0,I.jsxs)(vh,{"data-slot":`select-content`,className:q(`bg-popover text-popover-foreground 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md`,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,align:r,...i,children:[(0,I.jsx)(Rj,{}),(0,I.jsx)(yh,{className:q(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(zj,{})]})})}function Ij({className:e,...t}){return(0,I.jsx)(xh,{"data-slot":`select-label`,className:q(`text-muted-foreground px-2 py-1.5 text-xs`,e),...t})}function Lj({className:e,children:t,...n}){return(0,I.jsxs)(Sh,{"data-slot":`select-item`,className:q(`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(wh,{children:(0,I.jsx)(ea,{className:`size-4`})})}),(0,I.jsx)(Ch,{children:t})]})}function Rj({className:e,...t}){return(0,I.jsx)(Th,{"data-slot":`select-scroll-up-button`,className:q(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(ra,{className:`size-4`})})}function zj({className:e,...t}){return(0,I.jsx)(Eh,{"data-slot":`select-scroll-down-button`,className:q(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(ta,{className:`size-4`})})}function Bj({className:e,size:t=`default`,...n}){return(0,I.jsx)(Wh,{"data-slot":`switch`,"data-size":t,className:q(`peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6`,e),...n,children:(0,I.jsx)(Gh,{"data-slot":`switch-thumb`,className:q(`bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var Vj={window:`24h`,from:``,to:``,levels:[],provider:``,routeType:``,modelIn:``,modelOut:``,user:``,session:``,statusClass:[],hasError:`all`,q:``},Hj=null,Uj=null;function Wj(e,t){return{window:e.filters.window,from:e.filters.from||void 0,to:e.filters.to||void 0,levels:e.filters.levels,provider:e.filters.provider||void 0,routeType:e.filters.routeType||void 0,modelIn:e.filters.modelIn||void 0,modelOut:e.filters.modelOut||void 0,user:e.filters.user||void 0,session:e.filters.session||void 0,statusClass:e.filters.statusClass,hasError:e.filters.hasError===`all`?void 0:e.filters.hasError===`true`,q:e.filters.q||void 0,sort:e.sort,limit:50,cursor:t??void 0}}function Gj(e,t){let n=new Map;for(let t of e)n.set(t.id,t);for(let e of t)n.set(e.id,e);return Array.from(n.values()).sort((e,t)=>Date.parse(t.ts)-Date.parse(e.ts))}const Kj=Ev((e,t)=>({filters:{...Vj},sort:`time_desc`,items:[],nextCursor:null,hasMore:!1,stats:null,meta:null,loading:!1,loadingMore:!1,error:null,autoRefreshEnabled:!1,refreshIntervalSec:5,savedViews:[],tailEnabled:!1,tailConnected:!1,tailError:null,setFilter:(t,n)=>{e(e=>({filters:{...e.filters,[t]:n}}))},setSort:t=>e({sort:t}),applyFilters:async()=>{await t().fetchFirstPage()},resetFilters:async()=>{e({filters:{...Vj},sort:`time_desc`}),await t().fetchFirstPage()},fetchFirstPage:async()=>{e({loading:!0,error:null});try{let n=await Gv(Wj(t()));e({items:n.items,nextCursor:n.nextCursor,hasMore:n.hasMore,stats:n.stats,meta:n.meta,loading:!1,loadingMore:!1})}catch(t){e({loading:!1,loadingMore:!1,error:t instanceof Error?t.message:`日志查询失败`})}},fetchNextPage:async()=>{let n=t();if(!(!n.nextCursor||n.loadingMore)){e({loadingMore:!0,error:null});try{let t=await Gv(Wj(n,n.nextCursor));e({items:[...n.items,...t.items],nextCursor:t.nextCursor,hasMore:t.hasMore,stats:t.stats,meta:t.meta,loadingMore:!1})}catch(t){e({loadingMore:!1,error:t instanceof Error?t.message:`加载更多日志失败`})}}},setAutoRefreshEnabled:n=>{e({autoRefreshEnabled:n}),n?t().startAutoRefresh():t().stopAutoRefresh()},setRefreshIntervalSec:n=>{e({refreshIntervalSec:Math.max(2,Math.min(60,n))}),t().autoRefreshEnabled&&t().startAutoRefresh()},startAutoRefresh:()=>{Hj&&=(clearInterval(Hj),null);let e=Math.max(2,t().refreshIntervalSec)*1e3;Hj=setInterval(()=>{t().fetchFirstPage()},e)},stopAutoRefresh:()=>{Hj&&=(clearInterval(Hj),null)},setTailEnabled:n=>{e({tailEnabled:n}),n?t().startTail():t().stopTail()},startTail:()=>{Uj&&=(Uj(),null);let n=t();Uj=Jv({window:n.filters.window,levels:n.filters.levels,provider:n.filters.provider||void 0,routeType:n.filters.routeType||void 0,modelIn:n.filters.modelIn||void 0,modelOut:n.filters.modelOut||void 0,user:n.filters.user||void 0,session:n.filters.session||void 0,statusClass:n.filters.statusClass,hasError:n.filters.hasError===`all`?void 0:n.filters.hasError===`true`,q:n.filters.q||void 0,sort:n.sort},{onReady:()=>{e({tailConnected:!0,tailError:null})},onEvents:t=>{e(e=>({tailConnected:!0,tailError:null,items:Gj(e.items,t.items),stats:t.stats,meta:t.meta}))},onError:t=>{e({tailConnected:!1,tailError:t})}})},stopTail:()=>{Uj&&=(Uj(),null),e({tailConnected:!1,tailError:null})},saveCurrentView:n=>{let r=n.trim();if(!r)return;let i=t(),a={id:crypto.randomUUID(),name:r,filters:{...i.filters},sort:i.sort};e(e=>({savedViews:[a,...e.savedViews].slice(0,20)}))},applySavedView:async n=>{let r=t().savedViews.find(e=>e.id===n);r&&(e({filters:{...r.filters},sort:r.sort}),await t().fetchFirstPage())},deleteSavedView:t=>{e(e=>({savedViews:e.savedViews.filter(e=>e.id!==t)}))}}));function qj(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function Jj(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}T${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Yj(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString()}function Xj(){let e=Sr(),t=xr({from:`/logs`}),n=Kj(e=>e.filters),r=Kj(e=>e.sort),i=Kj(e=>e.items),a=Kj(e=>e.hasMore),o=Kj(e=>e.stats),s=Kj(e=>e.meta),c=Kj(e=>e.loading),l=Kj(e=>e.loadingMore),u=Kj(e=>e.error),d=Kj(e=>e.autoRefreshEnabled),f=Kj(e=>e.refreshIntervalSec),p=Kj(e=>e.savedViews),m=Kj(e=>e.tailEnabled),h=Kj(e=>e.tailConnected),g=Kj(e=>e.tailError),_=Kj(e=>e.setFilter),v=Kj(e=>e.setSort),y=Kj(e=>e.applyFilters),b=Kj(e=>e.resetFilters),x=Kj(e=>e.fetchNextPage),S=Kj(e=>e.setAutoRefreshEnabled),C=Kj(e=>e.setRefreshIntervalSec),w=Kj(e=>e.saveCurrentView),T=Kj(e=>e.applySavedView),E=Kj(e=>e.deleteSavedView),ee=Kj(e=>e.setTailEnabled),[D,te]=(0,F.useState)(``);(0,F.useEffect)(()=>{t.user&&_(`user`,t.user),t.session&&_(`session`,t.session),y()},[y,t.user,t.session,_]);let O=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.provider))).sort((e,t)=>e.localeCompare(t)),[i]),ne=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.routeType))).sort((e,t)=>e.localeCompare(t)),[i]),k=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.modelIn).filter(Boolean))).sort((e,t)=>e.localeCompare(t)),[i]),A=(0,F.useMemo)(()=>Array.from(new Set(i.map(e=>e.modelOut).filter(Boolean))).sort((e,t)=>e.localeCompare(t)),[i]);async function re(e){try{qj(await qv({window:n.window,from:n.from||void 0,to:n.to||void 0,levels:n.levels,provider:n.provider||void 0,routeType:n.routeType||void 0,modelIn:n.modelIn||void 0,modelOut:n.modelOut||void 0,user:n.user||void 0,session:n.session||void 0,statusClass:n.statusClass,hasError:n.hasError===`all`?void 0:n.hasError===`true`,q:n.q||void 0,sort:r},e),`logs-export.${e}`),Ei.success(`已导出 ${e.toUpperCase()} 文件`)}catch(e){Ei.error(e instanceof Error?e.message:`导出失败`)}}return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`日志检索`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`多条件过滤、详情定位、导出与实时追踪`})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`检索条件`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`支持窗口、范围、关键词与多维过滤`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`时间窗口`}),(0,I.jsxs)(jj,{value:n.window,onValueChange:e=>_(`window`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`1h`,children:`最近 1 小时`}),(0,I.jsx)(Lj,{value:`6h`,children:`最近 6 小时`}),(0,I.jsx)(Lj,{value:`24h`,children:`最近 24 小时`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`from`,children:`起始时间`}),(0,I.jsx)(kj,{id:`from`,type:`datetime-local`,className:`h-8`,value:Jj(n.from),onChange:e=>_(`from`,Yj(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`to`,children:`结束时间`}),(0,I.jsx)(kj,{id:`to`,type:`datetime-local`,className:`h-8`,value:Jj(n.to),onChange:e=>_(`to`,Yj(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`keyword`,children:`关键词`}),(0,I.jsx)(kj,{id:`keyword`,className:`h-8`,value:n.q,onChange:e=>_(`q`,e.target.value),placeholder:`request id / path / message`})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-6`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`级别`}),(0,I.jsxs)(jj,{value:n.levels.length===0?`all`:n.levels.join(`,`),onValueChange:e=>_(`levels`,e===`all`?[]:e.split(`,`)),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),(0,I.jsx)(Lj,{value:`info`,children:`info`}),(0,I.jsx)(Lj,{value:`error`,children:`error`}),(0,I.jsx)(Lj,{value:`info,error`,children:`info + error`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`Provider`}),(0,I.jsxs)(jj,{value:n.provider||`all`,onValueChange:e=>_(`provider`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),O.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`路由类型`}),(0,I.jsxs)(jj,{value:n.routeType||`all`,onValueChange:e=>_(`routeType`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),ne.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`原始模型`}),(0,I.jsxs)(jj,{value:n.modelIn||`all`,onValueChange:e=>_(`modelIn`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),k.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`路由模型`}),(0,I.jsxs)(jj,{value:n.modelOut||`all`,onValueChange:e=>_(`modelOut`,e===`all`?``:e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),A.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`是否错误`}),(0,I.jsxs)(jj,{value:n.hasError,onValueChange:e=>_(`hasError`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`all`,children:`全部`}),(0,I.jsx)(Lj,{value:`true`,children:`仅错误`}),(0,I.jsx)(Lj,{value:`false`,children:`仅成功`})]})]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`user-key`,children:`用户标识`}),(0,I.jsx)(kj,{id:`user-key`,className:`h-8`,value:n.user,onChange:e=>_(`user`,e.target.value),placeholder:`userKey 或原始 user_id`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`session-id`,children:`会话 ID`}),(0,I.jsx)(kj,{id:`session-id`,className:`h-8`,value:n.session,onChange:e=>_(`session`,e.target.value),placeholder:`sessionId`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(J,{size:`sm`,onClick:()=>void y(),disabled:c,children:`查询`}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:c,children:`重置`}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void re(`csv`),children:[(0,I.jsx)(sa,{className:`h-3.5 w-3.5`}),`导出 CSV`]}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>void re(`json`),children:[(0,I.jsx)(sa,{className:`h-3.5 w-3.5`}),`导出 JSON`]})]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-5`,children:[(0,I.jsx)(Zj,{title:`总条数`,value:o?.total??0}),(0,I.jsx)(Zj,{title:`错误率`,value:`${o?.errorRate??0}%`}),(0,I.jsx)(Zj,{title:`P95`,value:`${o?.p95LatencyMs??0} ms`}),(0,I.jsx)(Zj,{title:`平均延迟`,value:`${o?.avgLatencyMs??0} ms`}),(0,I.jsx)(Zj,{title:`扫描行数`,value:s?.scannedLines??0})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`结果列表`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s?`文件 ${s.scannedFiles} · 行 ${s.scannedLines} · 解析异常 ${s.parseErrors}${s.truncated?` · 已截断`:``}`:`等待查询`})]}),(0,I.jsx)(`div`,{className:`space-y-3 px-3 py-3`,children:u?(0,I.jsx)(EO,{className:`min-h-[160px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`日志检索失败`}),(0,I.jsx)(jO,{children:u})]})}):c?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`})]}):i.length===0?(0,I.jsx)(EO,{className:`min-h-[200px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`没有匹配日志`}),(0,I.jsx)(jO,{children:`请调整筛选条件后重试`})]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Dj,{data:i,sort:r,onSortChange:v,onRowClick:t=>void e({to:`/logs/$id`,params:{id:t.id}})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`已加载 `,i.length,` 条`]}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,disabled:!a||l,onClick:()=>void x(),children:l?`加载中...`:a?`加载更多`:`已到底部`})]})]})})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`增强功能`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`预设视图、自动刷新、实时追踪(可选)`})]}),(0,I.jsxs)(`div`,{className:`space-y-4 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Bj,{checked:d,onCheckedChange:S}),(0,I.jsx)(`span`,{className:`text-sm`,children:`自动刷新`}),(0,I.jsx)(wa,{className:`h-4 w-4 text-muted-foreground`})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Aj,{className:`text-sm`,children:`间隔`}),(0,I.jsxs)(jj,{value:String(f),onValueChange:e=>C(Number.parseInt(e,10)||5),children:[(0,I.jsx)(Pj,{className:`h-8 w-[120px]`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`3`,children:`3 秒`}),(0,I.jsx)(Lj,{value:`5`,children:`5 秒`}),(0,I.jsx)(Lj,{value:`10`,children:`10 秒`}),(0,I.jsx)(Lj,{value:`30`,children:`30 秒`})]})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(Bj,{checked:m,onCheckedChange:ee}),(0,I.jsx)(`span`,{className:`text-sm`,children:`实时追踪`}),(0,I.jsx)(Ca,{className:`h-4 w-4 text-muted-foreground`}),m?(0,I.jsx)(X,{variant:h?`outline`:`secondary`,children:h?`已连接`:`连接中`}):null]})]}),g?(0,I.jsx)(`div`,{className:`text-xs text-destructive`,children:g}):null,(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(kj,{className:`h-8 max-w-sm`,value:D,onChange:e=>te(e.target.value),placeholder:`输入视图名称`}),(0,I.jsxs)(J,{size:`sm`,variant:`outline`,onClick:()=>{D.trim()&&(w(D.trim()),te(``))},children:[(0,I.jsx)(Da,{className:`h-3.5 w-3.5`}),`保存当前筛选`]})]}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:p.length===0?(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`暂无预设视图`}):p.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border px-2 py-1`,children:[(0,I.jsx)(`button`,{type:`button`,className:`text-xs hover:underline`,onClick:()=>void T(e.id),children:e.name}),(0,I.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-destructive`,onClick:()=>E(e.id),children:`删除`})]},e.id))})]})]})]})]})}function Zj({title:e,value:t}){return(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background px-3 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,I.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:t})]})}function Qj(e){return e.log??{}}function $j(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft);if(!e)return null;let n=e.log,r=n?.enabled!==!1&&n!==void 0;function i(e){t(t=>(t.log=e(Qj(t)),t))}return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-6 lg:overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`shrink-0`,children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`日志配置`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`控制请求/响应日志的记录方式与存储策略`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4`,children:[(0,I.jsx)(`div`,{className:`rounded-lg border bg-background`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`启用日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`开启后将记录所有代理请求的元数据`})]}),(0,I.jsx)(Bj,{checked:r,onCheckedChange:e=>{e?i(e=>({...e,enabled:!0})):n&&i(e=>({...e,enabled:!1}))}})]})}),n?(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`通用设置`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`日志目录、Body 记录策略等通用配置`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`Body 记录策略`}),(0,I.jsxs)(jj,{value:n.bodyPolicy??`off`,onValueChange:e=>i(t=>({...t,bodyPolicy:e})),children:[(0,I.jsx)(Pj,{className:`h-8`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`off`,children:`off — 不记录 body(推荐)`}),(0,I.jsx)(Lj,{value:`masked`,children:`masked — 脱敏记录`}),(0,I.jsx)(Lj,{value:`full`,children:`full — 完整记录(仅调试)`})]})]}),n.bodyPolicy===`full`&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`当前为完整记录模式,可能包含敏感信息,建议仅在排障时临时开启。`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`log-basedir`,children:`日志目录`}),(0,I.jsx)(kj,{id:`log-basedir`,value:n.baseDir??``,onChange:e=>i(t=>({...t,baseDir:e.target.value||void 0})),placeholder:`默认: ~/.local-router/logs/`,className:`h-8`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`留空则使用默认路径`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`事件日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`按天分片的 JSONL 格式结构化日志`})]}),(0,I.jsx)(`div`,{className:`px-3 py-3`,children:(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`events-retain`,children:`保留天数`}),(0,I.jsx)(kj,{id:`events-retain`,type:`number`,min:1,value:n.events?.retainDays??14,onChange:e=>i(t=>({...t,events:{...t.events,retainDays:Number.parseInt(e.target.value)||14}})),className:`h-8`})]})})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsx)(`div`,{className:`border-b px-3 py-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`流式日志`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`SSE 原始响应文本`})]}),(0,I.jsx)(Bj,{checked:n.streams?.enabled!==!1,onCheckedChange:e=>i(t=>({...t,streams:{...t.streams,enabled:e}}))})]})}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`streams-retain`,children:`保留天数`}),(0,I.jsx)(kj,{id:`streams-retain`,type:`number`,min:1,value:n.streams?.retainDays??7,onChange:e=>i(t=>({...t,streams:{...t.streams,retainDays:Number.parseInt(e.target.value)||7}})),className:`h-8`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`streams-maxbytes`,children:`单请求最大字节数`}),(0,I.jsx)(kj,{id:`streams-maxbytes`,type:`number`,min:1,value:n.streams?.maxBytesPerRequest??10485760,onChange:e=>i(t=>({...t,streams:{...t.streams,maxBytesPerRequest:Number.parseInt(e.target.value)||10485760}})),className:`h-8`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`默认 10MB (10485760),超出部分将被截断`})]})]})]})]})]}):(0,I.jsx)(`div`,{className:`rounded-lg border bg-background py-12 text-center text-sm text-muted-foreground`,children:`当前未启用日志配置,请先打开上方开关`})]})]})}function eM({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,I.jsx)(Mh,{"data-slot":`separator`,decorative:n,orientation:t,className:q(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function tM({models:e,onChange:t}){let n=Object.entries(e),r=(0,F.useRef)(new Map),i=(0,F.useRef)(0),a=new Set(n.map(([e])=>e));for(let e of r.current.keys())a.has(e)||r.current.delete(e);function o(e){let t=r.current.get(e);if(t)return t;i.current+=1;let n=`model-row-${i.current}`;return r.current.set(e,n),n}function s(){let n=`model-${Date.now()}`;t({...e,[n]:{}})}function c(n){let r={...e};delete r[n],t(r)}function l(n,i){if(i===n)return;let a=r.current.get(n);a&&(r.current.delete(n),r.current.set(i,a));let o={};for(let[t,r]of Object.entries(e))o[t===n?i:t]=r;t(o)}function u(n,r,i){t({...e,[n]:{...e[n],[r]:i}})}return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(Aj,{className:`text-sm font-medium`,children:`模型列表`}),(0,I.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:[(0,I.jsx)(Sa,{className:`h-3.5 w-3.5 mr-1`}),`添加模型`]})]}),n.length===0?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`暂无模型,点击上方按钮添加`}):(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:(0,I.jsxs)(UO,{children:[(0,I.jsx)(WO,{children:`模型ID`}),(0,I.jsx)(WO,{className:`w-24 text-center`,children:`图像输入`}),(0,I.jsx)(WO,{className:`w-24 text-center`,children:`推理输出`}),(0,I.jsx)(WO,{className:`w-16`})]})}),(0,I.jsx)(VO,{children:n.map(([e,t])=>(0,I.jsxs)(UO,{children:[(0,I.jsx)(GO,{children:(0,I.jsx)(kj,{value:e,onChange:t=>l(e,t.target.value),className:`h-8 text-sm`})}),(0,I.jsx)(GO,{className:`text-center`,children:(0,I.jsx)(Bj,{checked:t[`image-input`]??!1,onCheckedChange:t=>u(e,`image-input`,t)})}),(0,I.jsx)(GO,{className:`text-center`,children:(0,I.jsx)(Bj,{checked:t.reasoning??!1,onCheckedChange:t=>u(e,`reasoning`,t)})}),(0,I.jsx)(GO,{children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,onClick:()=>c(e),children:(0,I.jsx)(Aa,{className:`h-3.5 w-3.5`})})})]},o(e)))})]})})]})}var nM=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`}],rM={"openai-completions":`/v1/chat/completions`,"openai-responses":`/v1/responses`,"anthropic-messages":`/v1/messages`};function iM({name:e,config:t,isNew:n,onChange:r}){let[i,a]=(0,F.useState)(!1),o=`${t.base.replace(/\/+$/,``)}${rM[t.type]}`;return(0,I.jsxs)(`div`,{className:`space-y-5`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-name`,children:`Provider 名称`}),(0,I.jsx)(kj,{id:`provider-name`,value:e,disabled:!n,readOnly:!n,className:`font-mono`}),!n&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`名称在创建后不可修改`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`协议类型`}),(0,I.jsxs)(jj,{value:t.type,onValueChange:e=>r({...t,type:e}),children:[(0,I.jsx)(Pj,{children:(0,I.jsx)(Nj,{})}),(0,I.jsx)(Fj,{children:nM.map(e=>(0,I.jsx)(Lj,{value:e.value,children:e.label},e.value))})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-base`,children:`Base URL`}),(0,I.jsx)(kj,{id:`provider-base`,value:t.base,onChange:e=>r({...t,base:e.target.value}),placeholder:`https://api.example.com`}),t.base&&(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[`预览 URL: `,(0,I.jsx)(`span`,{className:`font-mono`,children:o})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-proxy`,children:`Proxy URL(可选)`}),(0,I.jsx)(kj,{id:`provider-proxy`,value:t.proxy??``,onChange:e=>r({...t,proxy:e.target.value}),placeholder:`http://127.0.0.1:7890`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`留空表示直连上游;仅此 provider 生效,不读取环境变量代理。`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`provider-apikey`,children:`API Key`}),(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(kj,{id:`provider-apikey`,type:i?`text`:`password`,value:t.apiKey,onChange:e=>r({...t,apiKey:e.target.value}),className:`pr-10 font-mono`,placeholder:`sk-...`}),(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-full px-3 hover:bg-transparent`,onClick:()=>a(!i),children:i?(0,I.jsx)(ca,{className:`h-4 w-4`}):(0,I.jsx)(la,{className:`h-4 w-4`})})]})]}),(0,I.jsx)(eM,{}),(0,I.jsx)(tM,{models:t.models,onChange:e=>r({...t,models:e})})]})}function aM({...e}){return(0,I.jsx)(Jl,{"data-slot":`alert-dialog`,...e})}function oM({...e}){return(0,I.jsx)(Yl,{"data-slot":`alert-dialog-trigger`,...e})}function sM({...e}){return(0,I.jsx)(Xl,{"data-slot":`alert-dialog-portal`,...e})}function cM({className:e,...t}){return(0,I.jsx)(Zl,{"data-slot":`alert-dialog-overlay`,className:q(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50`,e),...t})}function lM({className:e,size:t=`default`,...n}){return(0,I.jsxs)(sM,{children:[(0,I.jsx)(cM,{}),(0,I.jsx)(Ql,{"data-slot":`alert-dialog-content`,"data-size":t,className:q(`bg-background 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 group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg`,e),...n})]})}function uM({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:q(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function dM({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:q(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function fM({className:e,...t}){return(0,I.jsx)(tu,{"data-slot":`alert-dialog-title`,className:q(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function pM({className:e,...t}){return(0,I.jsx)(nu,{"data-slot":`alert-dialog-description`,className:q(`text-muted-foreground text-sm`,e),...t})}function mM({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,I.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,I.jsx)($l,{"data-slot":`alert-dialog-action`,className:q(e),...r})})}function hM({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,I.jsx)(J,{variant:t,size:n,asChild:!0,children:(0,I.jsx)(eu,{"data-slot":`alert-dialog-cancel`,className:q(e),...r})})}function gM(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function _M(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function vM(e){return e/100*window.innerHeight}function yM(e){return e/100*window.innerWidth}function bM(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function xM({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=bM(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=_M(t,i);break;case`em`:r=gM(t,i);break;case`vh`:r=vM(i);break;case`vw`:r=yM(i);break}return r}function SM(e){return parseFloat(e.toFixed(3))}function CM({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function wM(e){let{panels:t}=e,n=CM({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=SM(xM({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=SM(xM({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=SM(xM({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=SM(xM({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function TM(e,t=`Assertion error`){if(!e)throw Error(t)}function EM(e,t){return Array.from(t).sort(e===`horizontal`?DM:OM)}function DM(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function OM(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function kM(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function AM(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function jM({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=AM(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return TM(i,`No rect found`),i}var MM;function NM(){return MM===void 0&&(MM=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),MM}function PM(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=EM(n,Array.from(t.children).filter(kM).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,jM({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=NM()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:CM({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var FM=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},IM=new Map,LM=new FM;function RM(e){IM=new Map(IM),IM.delete(e)}function zM(e,t){for(let[t]of IM)if(t.id===e)return t}function BM(e,t){for(let[t,n]of IM)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function VM(){return IM}function HM(e,t){return LM.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function UM(e,t){let n=IM.get(e);IM=new Map(IM),IM.set(e,t),LM.emit(`groupChange`,{group:e,prev:n,next:t})}function WM(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=AM(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function GM(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function KM(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:QM(e),b:QM(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();TM(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:ZM(XM(n.a)),b:ZM(XM(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var qM=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function JM(e){let t=getComputedStyle($M(e)??e).display;return t===`flex`||t===`inline-flex`}function YM(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||JM(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||qM.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function XM(e){let t=e.length;for(;t--;){let n=e[t];if(TM(n,`Missing node`),YM(n))return n}return null}function ZM(e){return e&&Number(getComputedStyle(e).zIndex)||0}function QM(e){let t=[];for(;e;)t.push(e),e=$M(e);return t}function $M(e){let{parentNode:t}=e;return GM(t)?t.host:t}function eN(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function tN({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!kM(n)||n.contains(e)||e.contains(n))return!0;if(KM(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(eN(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function nN(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=PM(r),a=WM(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&tN({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function rN(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function iN(e,t,n=0){return Math.abs(SM(e)-SM(t))<=n}function aN(e,t){return iN(e,t)?0:e>t?1:-1}function oN({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(aN(r,c)<0)if(a){let e=(i+c)/2;r=aN(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=SM(r),r}function sN({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(iN(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;TM(u!=null,`Invalid first pivot index`),TM(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];TM(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(TM(n!=null,`Previous layout not found for panel index ${t}`),iN(n,i)){let t=o-n;aN(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];TM(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(TM(n!=null,`Previous layout not found for panel index ${t}`),iN(n,o)){let t=n-i;aN(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];TM(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&aN(i,c)<0)if(e>0){let t=c-o,n=t/2;aN(i+e,c)<0&&(e=aN(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;aN(i-e,c)<0&&(e=aN(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];TM(e!=null,`Previous layout not found for panel index ${r}`);let a=oN({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];TM(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=oN({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!iN(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(rN(c,l))return i;{let t=e<0?d:u,r=s[t];TM(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=oN({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!iN(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];TM(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=oN({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(iN(i,s)||(t-=s-i,l[r]=s),iN(t,0))break;e>0?r--:r++}}}if(!iN(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function cN(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||aN(e[n],t[n])!==0)return!1;return!0}function lN({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!iN(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];TM(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];TM(i!=null,`No layout data found for index ${e}`);let o=r[e];TM(o!=null,`No layout data found for index ${e}`);let s=oN({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!iN(a,0))for(let e=0;e<t.length;e++){let n=r[e];TM(n!=null,`No layout data found for index ${e}`);let i=n+a,o=oN({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,iN(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function uN({groupId:e,panelId:t}){let n=()=>{let t=VM();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=lN({layout:sN({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});cN(l,p)||UM(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&iN(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=SM(e/CM({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function dN(e){e.defaultPrevented||nN(e,VM()).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=uN({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function fN(e){let t=VM();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function pN({groupId:e}){let t=()=>{let t=VM();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=lN({layout:e,panelConstraints:r});return n?o:(cN(o,c)||UM(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function mN(e,t){let n=fN(e),r=BM(n.id,!0),i=n.separators.find(t=>t.element===e);TM(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);TM(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=pN({groupId:n.id}).getLayout(),c=lN({layout:sN({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});cN(s,c)||UM(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function hN(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=fN(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&mN(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&mN(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&mN(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&mN(t,-5);break;case`End`:e.preventDefault(),mN(t,100);break;case`Enter`:{e.preventDefault();let n=fN(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=BM(n.id,!0),o=n.separators.find(e=>e.element===t);TM(o,`Matching separator not found`);let s=a.get(o);TM(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(TM(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];mN(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=fN(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);TM(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),mN(t,-100);break}}var gN={cursorFlags:0,state:`inactive`},_N=new FM;function vN(){return gN}function yN(e){return _N.addListener(`change`,e)}function bN(e){let t=gN,n={...gN};n.cursorFlags=e,gN=n,_N.emit(`change`,{prev:t,next:n})}function xN(e){let t=gN;gN=e,_N.emit(`change`,{prev:t,next:e})}function SN(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=VM(),n=nN(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),xN({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var CN=e=>e,wN=()=>{},TN=1,EN=2,DN=4,ON=8,kN=3,AN=12,jN;function MN(){return jN===void 0&&(jN=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(jN=!0)),jN}function NN({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&MN()){let t=(e&TN)!==0,n=(e&EN)!==0,r=(e&DN)!==0,i=(e&ON)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return MN()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var PN=new WeakMap;function FN(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=PN.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=vN();switch(r.state){case`active`:case`hover`:{let e=NN({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}PN.set(e,{prevStyle:t,styleSheet:n})}function IN({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=sN({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(cN(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?TN:EN;break;case`vertical`:s|=d<0?DN:ON;break}}else UM(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&kN:c|=s&kN,t.movementY===0?c|=o&AN:c|=s&AN,bN(c),FN(e)}function LN(e){let t=VM(),n=vN();switch(n.state){case`active`:IN({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function RN(e){if(e.defaultPrevented)return;let t=vN(),n=VM();switch(t.state){case`active`:if(e.buttons===0){xN({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=BM(e.group.id,!0);UM(e.group,t)});return}IN({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=nN(e,n);r.length===0?t.state!==`inactive`&&xN({cursorFlags:0,state:`inactive`}):xN({cursorFlags:0,hitRegions:r,state:`hover`}),FN(e.currentTarget);break}}}function zN(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(vN().state){case`hover`:xN({cursorFlags:0,state:`inactive`})}}function BN(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=vN();switch(t.state){case`active`:xN({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(FN(e.currentTarget),t.hitRegions.forEach(e=>{let t=BM(e.group.id,!0);UM(e.group,t)}),e.preventDefault())}}function VN(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=SM(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=SM((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function HN(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=CM({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:SM(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function UN(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function WN({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=SM(e/100*n/t*100);s.set(l.id,r),i+=r;break}case`preserve-relative-size`:default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=SM((r[e]??0)/a*l);else{let e=SM(l/c.length);for(let t of c)u[t]=e}return u}function GN(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var KN=new Map;function qN(e){let t=!0;TM(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=CM({group:e});if(t===0)return;let n=BM(e.id);if(!n)return;let r=wM(e),i=n.defaultLayoutDeferred?VN(r):n.layout,a=lN({layout:WN({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&cN(n.layout,a)&&UN(n.derivedPanelConstraints,r)&&n.groupSize===t)return;UM(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else HN(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{TM(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=CM({group:e}),s=wM(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(GN(e.panels,l)||(l=void 0));let u=lN({layout:e.mutableState.layouts[c]??l??VN(s),panelConstraints:s}),d=e.element.ownerDocument;KN.set(d,(KN.get(d)??0)+1);let f=new Map;return PM(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),UM(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{TM(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,hN)}),KN.get(d)===1&&(d.addEventListener(`dblclick`,dN,!0),d.addEventListener(`pointerdown`,SN,!0),d.addEventListener(`pointerleave`,LN),d.addEventListener(`pointermove`,RN),d.addEventListener(`pointerout`,zN),d.addEventListener(`pointerup`,BN,!0)),function(){t=!1,KN.set(d,Math.max(0,(KN.get(d)??0)-1)),RM(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,hN)}),KN.get(d)||(d.removeEventListener(`dblclick`,dN,!0),d.removeEventListener(`pointerdown`,SN,!0),d.removeEventListener(`pointerleave`,LN),d.removeEventListener(`pointermove`,RN),d.removeEventListener(`pointerout`,zN),d.removeEventListener(`pointerup`,BN,!0)),a.disconnect()}}function JN(){let[e,t]=(0,F.useState)({});return[e,(0,F.useCallback)(()=>t({}),[])]}function YN(e){let t=(0,F.useId)();return`${e??t}`}var XN=typeof window<`u`?F.useLayoutEffect:F.useEffect;function ZN(e){let t=(0,F.useRef)(e);return XN(()=>{t.current=e},[e]),(0,F.useCallback)((...e)=>t.current?.(...e),[t])}function QN(...e){return ZN(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function $N(e){let t=(0,F.useRef)({...e});return XN(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var eP=(0,F.createContext)(null);function tP(e,t){let n=(0,F.useRef)({getLayout:()=>({}),setLayout:CN});(0,F.useImperativeHandle)(t,()=>n.current,[]),XN(()=>{Object.assign(n.current,pN({groupId:e}))})}function nP({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,F.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=ZN(e=>{cN(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=ZN(e=>{cN(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=YN(s),v=(0,F.useRef)(null),[y,b]=JN(),x=(0,F.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=QN(v,a);tP(_,o);let C=ZN((e,t)=>{let r=vN(),i=zM(e),a=BM(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}return{flexGrow:n?.[t]??1}}),w=$N({defaultLayout:n,disableCursor:r}),T=(0,F.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=EM(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=EM(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=zM(_),i=BM(_);r&&i&&UM(r,{...i,derivedPanelConstraints:wM(r)})},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,F.useRef)(null);return XN(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=qN(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=BM(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=HM(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=iN(t.collapsedSize,i[t.panelId]),a=iN(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=vN().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,F.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,I.jsx)(eP.Provider,{value:T,children:(0,I.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}nP.displayName=`Group`;function rP(){let e=(0,F.useContext)(eP);return TM(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function iP(e,t){let{id:n}=rP(),r=(0,F.useRef)({collapse:wN,expand:wN,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:wN});(0,F.useImperativeHandle)(t,()=>r.current,[]),XN(()=>{Object.assign(r.current,uN({groupId:n,panelId:e}))})}function aP({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=YN(c),_=$N({disabled:a}),v=(0,F.useRef)(null),y=QN(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,togglePanelDisabled:w}=rP(),T=d!==null,E=ZN((e,t,n)=>{d?.(e,c,n)});XN(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,F.useEffect)(()=>{w(g,!!a)},[a,g,w]),iP(g,f);let ee=(0,F.useSyncExternalStore)(e=>HM(x,e),()=>JSON.stringify(b(x,g)),()=>JSON.stringify(b(x,g)));return(0,I.jsx)(`div`,{...m,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...oP,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...JSON.parse(ee)},children:(0,I.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}aP.displayName=`Panel`;var oP={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function sP({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=lN({layout:sN({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=lN({layout:sN({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function cP({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=YN(i),c=$N({disabled:n}),[l,u]=(0,F.useState)({}),[d,f]=(0,F.useState)(`inactive`),p=(0,F.useRef)(null),m=QN(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=rP(),b=_===`horizontal`?`vertical`:`horizontal`;XN(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=yN(e=>{f(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=HM(g,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);u(sP({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,F.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,I.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}cP.displayName=`Separator`;function lP({className:e,...t}){return(0,I.jsx)(nP,{"data-slot":`resizable-panel-group`,className:q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function uP({...e}){return(0,I.jsx)(aP,{"data-slot":`resizable-panel`,...e})}function dP({withHandle:e,className:t,...n}){return(0,I.jsx)(cP,{"data-slot":`resizable-handle`,className:q(`bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,I.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,I.jsx)(ha,{className:`size-2.5`})})})}var fP={type:`openai-completions`,base:``,apiKey:``,proxy:``,models:{}};function pP(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft),n=e?.providers??{},r=Object.keys(n),[i,a]=(0,F.useState)(r[0]??null),[o,s]=(0,F.useState)(``),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(``);if(!e)return null;function m(){let e=o.trim().toLowerCase().replace(/[^a-z0-9-]/g,`-`);!e||n[e]||(t(t=>(t.providers[e]={...fP},t)),a(e),s(``),l(!1))}function h(e,n){t(t=>(t.providers[e]=n,t))}function g(e){t(t=>(delete t.providers[e],t)),a(r.find(t=>t!==e)??null)}function _(){if(!i||!n[i])return;let e=f.trim().toLowerCase().replace(/[^a-z0-9-]/g,`-`);!e||n[e]||(t(t=>(t.providers[e]=structuredClone(t.providers[i]),t)),a(e),p(``),d(!1))}return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-6 lg:overflow-hidden`,children:[(0,I.jsxs)(`div`,{className:`shrink-0`,children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Providers`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`管理上游 API 服务商配置`})]}),(0,I.jsxs)(lP,{orientation:`horizontal`,className:`min-h-0 flex-1`,children:[(0,I.jsx)(uP,{defaultSize:`280px`,minSize:`180px`,maxSize:`50%`,className:`min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex h-full min-w-0 min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,I.jsx)(fE,{className:`min-h-0 min-w-0 flex-1 **:data-[slot=scroll-area-viewport]:min-w-0 **:data-[slot=scroll-area-viewport]:overflow-x-hidden [&_[data-slot=scroll-area-viewport]>div]:block! [&_[data-slot=scroll-area-viewport]>div]:min-w-0 [&_[data-slot=scroll-area-viewport]>div]:w-full`,children:(0,I.jsx)(`div`,{className:`w-full min-w-0 space-y-2 pr-2`,children:r.map(e=>{let t=n[e],r=Object.keys(t.models).length;return(0,I.jsxs)(`button`,{type:`button`,className:`w-full min-w-0 overflow-hidden text-left rounded-lg border p-3 transition-colors hover:bg-accent cursor-pointer ${i===e?`border-primary bg-accent`:`border-border`}`,onClick:()=>a(e),children:[(0,I.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(ka,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,I.jsx)(`span`,{className:`block min-w-0 flex-1 truncate font-medium text-sm`,children:e})]}),(0,I.jsxs)(`div`,{className:`mt-1.5 ml-6 flex w-full min-w-0 items-center gap-2`,children:[(0,I.jsx)(X,{variant:`outline`,className:`min-w-0 max-w-full overflow-hidden text-xs`,children:(0,I.jsx)(`span`,{className:`block min-w-0 truncate`,children:t.type})}),(0,I.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap text-xs text-muted-foreground`,children:[r,` 个模型`]})]})]},e)})})}),(0,I.jsx)(`div`,{className:`shrink-0 pr-2`,children:(0,I.jsxs)(rE,{open:c,onOpenChange:l,children:[(0,I.jsx)(iE,{asChild:!0,children:(0,I.jsxs)(J,{variant:`outline`,className:`w-full`,children:[(0,I.jsx)(Sa,{className:`h-4 w-4 mr-1`}),`添加 Provider`]})}),(0,I.jsxs)(sE,{children:[(0,I.jsxs)(cE,{children:[(0,I.jsx)(uE,{children:`添加 Provider`}),(0,I.jsx)(dE,{children:`输入新 Provider 的名称(kebab-case 格式)`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Aj,{htmlFor:`new-provider-name`,children:`名称`}),(0,I.jsx)(kj,{id:`new-provider-name`,value:o,onChange:e=>s(e.target.value),placeholder:`my-provider`,className:`font-mono`,onKeyDown:e=>e.key===`Enter`&&m()})]}),(0,I.jsx)(lE,{children:(0,I.jsx)(J,{onClick:m,disabled:!o.trim(),children:`创建`})})]})]})})]})}),(0,I.jsx)(dP,{withHandle:!0,className:`bg-transparent transition-colors duration-200 hover:bg-border focus-visible:bg-border active:bg-border [&>div]:opacity-0 [&>div]:transition-opacity [&>div]:duration-200 hover:[&>div]:opacity-100 focus-visible:[&>div]:opacity-100 active:[&>div]:opacity-100`}),(0,I.jsx)(uP,{minSize:`400px`,children:(0,I.jsx)(`div`,{className:`flex h-full flex-col min-h-0 pl-2 pb-3 lg:pb-0`,children:(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background flex flex-col min-h-0 h-full`,children:[(0,I.jsx)(`div`,{className:`border-b px-3 py-3 shrink-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2 min-w-0`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold truncate`,children:i?`${i}`:`选择一个 Provider`}),i&&n[i]&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,I.jsxs)(rE,{open:u,onOpenChange:d,children:[(0,I.jsx)(iE,{asChild:!0,children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":`复制此 Provider`,children:(0,I.jsx)(oa,{className:`h-4 w-4`})})}),(0,I.jsxs)(sE,{children:[(0,I.jsxs)(cE,{children:[(0,I.jsx)(uE,{children:`复制 Provider`}),(0,I.jsx)(dE,{children:`输入新 Provider 的名称(kebab-case 格式)`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(Aj,{htmlFor:`copy-provider-name`,children:`名称`}),(0,I.jsx)(kj,{id:`copy-provider-name`,value:f,onChange:e=>p(e.target.value),placeholder:`my-provider-copy`,className:`font-mono`,onKeyDown:e=>e.key===`Enter`&&_()})]}),(0,I.jsx)(lE,{children:(0,I.jsx)(J,{onClick:_,disabled:!f.trim(),children:`复制`})})]})]}),(0,I.jsxs)(aM,{children:[(0,I.jsx)(oM,{asChild:!0,children:(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,"aria-label":`删除此 Provider`,children:(0,I.jsx)(Aa,{className:`h-4 w-4`})})}),(0,I.jsxs)(lM,{children:[(0,I.jsxs)(uM,{children:[(0,I.jsx)(fM,{children:`确认删除`}),(0,I.jsxs)(pM,{children:[`确定要删除 Provider「`,i,`」吗?引用此 Provider 的路由规则将失效。`]})]}),(0,I.jsxs)(dM,{children:[(0,I.jsx)(hM,{children:`取消`}),(0,I.jsx)(mM,{onClick:()=>g(i),children:`删除`})]})]})]})]})]})}),(0,I.jsx)(fE,{className:`min-h-0 flex-1`,children:(0,I.jsx)(`div`,{className:`px-3 py-3`,children:i&&n[i]?(0,I.jsx)(iM,{name:i,config:n[i],isNew:!1,onChange:e=>h(i,e)},i):(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm py-8 text-center`,children:r.length===0?`暂无 Provider,点击左侧「添加 Provider」按钮创建`:`请从左侧列表中选择一个 Provider`})})})]})})})]})]})}var mP={"openai-completions":`OpenAI Completions`,"openai-responses":`OpenAI Responses`,"anthropic-messages":`Anthropic Messages`};function hP({modelMap:e,providers:t,onChange:n}){let r=Object.entries(e),i=r.filter(([e])=>e!==`*`),a=r.find(([e])=>e===`*`);function o(t){if(t===`*`)return;let r={...e};delete r[t],n(r)}function s(t,r){if(r===t)return;let i={};for(let[n,a]of Object.entries(e))i[n===t?r:n]=a;n(i)}function c(t,r,i){n({...e,[t]:{...e[t],[r]:i}})}function l(e){let n=t[e];return n?Object.keys(n.models):[]}return(0,I.jsxs)(`div`,{className:`relative space-y-3`,children:[(0,I.jsx)(`div`,{className:`absolute left-0 top-0 bottom-6 w-px bg-border`}),(0,I.jsxs)(`div`,{className:`ml-5 flex items-center gap-1.5 px-2 text-xs font-medium text-muted-foreground translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(`span`,{className:`w-[200px] min-w-[120px]`,children:`请求模型`}),(0,I.jsx)(`span`,{className:`w-5 shrink-0`}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:`路由目标`}),(0,I.jsx)(`span`,{className:`w-8 shrink-0`})]}),i.length>0&&(0,I.jsx)(`div`,{className:`space-y-1.5 translate-x-[-0.5px] translate-y-[-1px]`,children:i.map(([e,n])=>(0,I.jsxs)(`div`,{className:`relative pl-5`,children:[(0,I.jsx)(gP,{}),(0,I.jsx)(_P,{ruleKey:e,target:n,isWildcard:!1,providers:t,getModelsForProvider:l,onKeyCommit:t=>s(e,t),onTargetChange:(t,n)=>c(e,t,n),onRemove:()=>o(e)})]},e))}),a&&i.length>0&&(0,I.jsxs)(`div`,{className:`relative ml-5 translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,I.jsx)(`div`,{className:`w-full border-t border-dashed`})}),(0,I.jsx)(`div`,{className:`relative flex justify-center`,children:(0,I.jsx)(`span`,{className:`bg-background px-2 text-[11px] text-muted-foreground`,children:`兜底规则 — 未匹配的请求将路由至此`})})]}),a&&(0,I.jsxs)(`div`,{className:`relative pl-5 translate-x-[-0.5px] translate-y-[-1px]`,children:[(0,I.jsx)(gP,{}),(0,I.jsx)(_P,{ruleKey:a[0],target:a[1],isWildcard:!0,providers:t,getModelsForProvider:l,onKeyCommit:()=>{},onTargetChange:(e,t)=>c(`*`,e,t),onRemove:()=>{}})]})]})}function gP(){return(0,I.jsx)(`svg`,{className:`pointer-events-none absolute left-0 top-1/2 -translate-y-1/2 text-border`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M1 0A10 10 0 0 0 11 10H20`,className:`stroke-current`,strokeWidth:`1`,strokeLinecap:`round`})})}function _P({ruleKey:e,target:t,isWildcard:n,providers:r,getModelsForProvider:i,onKeyCommit:a,onTargetChange:o,onRemove:s}){let[c,l]=(0,F.useState)(e);(0,F.useEffect)(()=>{l(e)},[e]);function u(){c!==e&&a(c)}let d=i(t.provider),f=Object.entries(r).reduce((e,[t,n])=>(e[n.type].push(t),e),{"openai-completions":[],"openai-responses":[],"anthropic-messages":[]});return(0,I.jsxs)(`div`,{className:n?`grid grid-cols-[minmax(120px,200px)_20px_1fr_32px] items-center gap-x-1.5 rounded-lg border border-dashed bg-muted/30 p-2 transition-colors`:`grid grid-cols-[minmax(120px,200px)_20px_1fr_32px] items-center gap-x-1.5 rounded-lg border border-solid bg-background p-2 transition-colors`,children:[n?(0,I.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 px-1`,children:[(0,I.jsx)(X,{variant:`secondary`,className:`text-xs font-mono`,children:`*`}),(0,I.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`所有`})]}):(0,I.jsx)(kj,{value:c,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`h-7 text-sm font-mono`}),(0,I.jsx)(Zi,{className:`h-3.5 w-3.5 text-muted-foreground mx-auto`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,I.jsxs)(jj,{value:t.provider,onValueChange:e=>o(`provider`,e),children:[(0,I.jsx)(Pj,{className:`h-7 text-sm w-[320px] shrink-0`,children:(0,I.jsx)(Nj,{placeholder:`Provider`})}),(0,I.jsx)(Fj,{children:Object.keys(mP).map(e=>{let t=f[e];return t.length===0?null:(0,I.jsxs)(Mj,{children:[(0,I.jsx)(Ij,{children:mP[e]}),t.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))]},e)})})]}),(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs shrink-0`,children:`/`}),d.length>0?(0,I.jsxs)(jj,{value:t.model,onValueChange:e=>o(`model`,e),children:[(0,I.jsx)(Pj,{className:`h-7 text-sm flex-1 min-w-0`,children:(0,I.jsx)(Nj,{placeholder:`模型`})}),(0,I.jsx)(Fj,{children:d.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))})]}):(0,I.jsx)(kj,{value:t.model,onChange:e=>o(`model`,e.target.value),className:`h-7 text-sm font-mono flex-1 min-w-0`,placeholder:`模型名称`})]}),(0,I.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 text-destructive hover:text-destructive`,disabled:n,onClick:s,children:(0,I.jsx)(Aa,{className:`h-3 w-3`})})]})}var vP=[`openai-completions`,`openai-responses`,`anthropic-messages`];function yP(){let e=Zv(e=>e.draft),t=Zv(e=>e.updateDraft),n=Object.keys(e?.routes??{}),[r,i]=(0,F.useState)(``),a=vP.filter(e=>!n.includes(e));if(!e)return null;let o=e;function s(){if(!r)return;let e=Object.keys(o.providers)[0]??``,n=e?Object.keys(o.providers[e]?.models??{})[0]??``:``;t(t=>(t.routes[r]={"*":{provider:e,model:n}},t)),i(``)}function c(e){t(t=>(delete t.routes[e],t))}function l(e,n){t(t=>(t.routes[e]=n,t))}function u(e){let n=Object.keys(o.providers)[0]??``,r=n?Object.keys(o.providers[n]?.models??{})[0]??``:``;t(t=>{let i=t.routes[e]??{};return t.routes[e]={...i,[`alias-${Date.now()}`]:{provider:n,model:r}},t})}return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`路由`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`管理协议入口与模型路由映射`})]}),n.length===0?(0,I.jsx)(`div`,{className:`rounded-lg border bg-background py-12 text-center text-muted-foreground`,children:`暂无路由配置,请先添加一个协议入口`}):(0,I.jsx)(`div`,{className:`space-y-6`,children:n.map(t=>{let n=e.routes[t],r=Object.keys(n).length;return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`div`,{className:`rounded-lg border bg-card text-card-foreground px-3 py-2`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold`,children:t}),(0,I.jsxs)(X,{variant:`secondary`,className:`text-xs`,children:[r,` 个规则`]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsxs)(J,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs`,onClick:()=>u(t),children:[(0,I.jsx)(Sa,{className:`mr-1 h-3.5 w-3.5`}),`添加规则`]}),(0,I.jsxs)(aM,{children:[(0,I.jsx)(oM,{asChild:!0,children:(0,I.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-destructive hover:text-destructive`,children:(0,I.jsx)(Aa,{className:`h-3.5 w-3.5`})})}),(0,I.jsxs)(lM,{children:[(0,I.jsxs)(uM,{children:[(0,I.jsx)(fM,{children:`确认删除`}),(0,I.jsxs)(pM,{children:[`确定要删除协议入口「`,t,`」及其所有路由规则吗?`]})]}),(0,I.jsxs)(dM,{children:[(0,I.jsx)(hM,{children:`取消`}),(0,I.jsx)(mM,{onClick:()=>c(t),children:`删除`})]})]})]})]})]})}),(0,I.jsxs)(`div`,{className:`relative mt-3 ml-3`,children:[(0,I.jsx)(`div`,{className:`absolute left-0 -top-3 h-3 w-px bg-border`}),(0,I.jsx)(hP,{routeType:t,modelMap:e.routes[t],providers:e.providers,onChange:e=>l(t,e)})]})]},t)})}),a.length>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(jj,{value:r,onValueChange:i,children:[(0,I.jsx)(Pj,{className:`w-[240px]`,children:(0,I.jsx)(Nj,{placeholder:`选择协议类型...`})}),(0,I.jsx)(Fj,{children:a.map(e=>(0,I.jsx)(Lj,{value:e,children:e},e))})]}),(0,I.jsxs)(J,{onClick:s,disabled:!r,children:[(0,I.jsx)(Sa,{className:`h-4 w-4 mr-1`}),`添加协议入口`]})]})]})}var bP={window:`24h`,from:``,to:``,user:``,session:``,q:``};const xP=Ev((e,t)=>({filters:{...bP},summary:null,users:[],meta:null,from:``,to:``,loading:!1,error:null,setFilter:(t,n)=>{e(e=>({filters:{...e.filters,[t]:n}}))},fetchData:async()=>{e({loading:!0,error:null});try{let n=t(),r=await Wv({window:n.filters.window,from:n.filters.from||void 0,to:n.filters.to||void 0,user:n.filters.user||void 0,session:n.filters.session||void 0,q:n.filters.q||void 0});e({summary:r.summary,users:r.users,meta:r.meta,from:r.from,to:r.to,loading:!1,error:null})}catch(t){e({loading:!1,error:t instanceof Error?t.message:`用户会话查询失败`})}},resetFilters:async()=>{e({filters:{...bP}}),await t().fetchData()}}));function SP(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}T${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function CP(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString()}function wP(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function TP(e){return e.length===0?`-`:e.slice(0,3).map(e=>`${e.key}(${e.count})`).join(`, `)}function EP(e,t=6){return e.length<=t*2+3?e:`${e.slice(0,t)}...${e.slice(-t)}`}function DP(){let e=Sr(),t=xP(e=>e.filters),n=xP(e=>e.summary),r=xP(e=>e.users),i=xP(e=>e.meta),a=xP(e=>e.from),o=xP(e=>e.to),s=xP(e=>e.loading),c=xP(e=>e.error),l=xP(e=>e.setFilter),u=xP(e=>e.fetchData),d=xP(e=>e.resetFilters),[f,p]=(0,F.useState)({});(0,F.useEffect)(()=>{u()},[u]);let m=r.length>0,h=(0,F.useMemo)(()=>({users:n?.uniqueUsers??0,sessions:n?.uniqueSessions??0,requests:n?.totalRequests??0,metadataRequests:n?.metadataRequests??0}),[n]);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`用户会话`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`解析日志 metadata 中的 user ↔ session 映射,查看活跃度并跳转日志检索`})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`检索条件`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`支持时间窗、范围、用户/会话精确筛选与关键词检索`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 px-3 py-3`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{children:`时间窗口`}),(0,I.jsxs)(jj,{value:t.window,onValueChange:e=>l(`window`,e),children:[(0,I.jsx)(Pj,{className:`h-8 w-full`,children:(0,I.jsx)(Nj,{})}),(0,I.jsxs)(Fj,{children:[(0,I.jsx)(Lj,{value:`1h`,children:`最近 1 小时`}),(0,I.jsx)(Lj,{value:`6h`,children:`最近 6 小时`}),(0,I.jsx)(Lj,{value:`24h`,children:`最近 24 小时`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-from`,children:`起始时间`}),(0,I.jsx)(kj,{id:`sessions-from`,type:`datetime-local`,className:`h-8`,value:SP(t.from),onChange:e=>l(`from`,CP(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-to`,children:`结束时间`}),(0,I.jsx)(kj,{id:`sessions-to`,type:`datetime-local`,className:`h-8`,value:SP(t.to),onChange:e=>l(`to`,CP(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-q`,children:`关键词`}),(0,I.jsx)(kj,{id:`sessions-q`,className:`h-8`,value:t.q,onChange:e=>l(`q`,e.target.value),placeholder:`user/session/model/provider`})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-user`,children:`用户标识`}),(0,I.jsx)(kj,{id:`sessions-user`,className:`h-8`,value:t.user,onChange:e=>l(`user`,e.target.value),placeholder:`userKey 或 raw user_id`})]}),(0,I.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,I.jsx)(Aj,{htmlFor:`sessions-session`,children:`会话 ID`}),(0,I.jsx)(kj,{id:`sessions-session`,className:`h-8`,value:t.session,onChange:e=>l(`session`,e.target.value),placeholder:`sessionId`})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsxs)(J,{size:`sm`,onClick:()=>void u(),disabled:s,children:[(0,I.jsx)(Oa,{className:`h-3.5 w-3.5`}),`查询`]}),(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void d(),disabled:s,children:`重置`}),a&&o?(0,I.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`生效范围:`,wP(a),` - `,wP(o)]}):null]})]})]}),(0,I.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,I.jsx)(OP,{title:`用户数`,value:h.users}),(0,I.jsx)(OP,{title:`会话数`,value:h.sessions}),(0,I.jsx)(OP,{title:`请求数`,value:h.requests}),(0,I.jsx)(OP,{title:`含 metadata 请求`,value:h.metadataRequests})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background`,children:[(0,I.jsxs)(`div`,{className:`border-b px-3 py-3`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold`,children:`用户与会话`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?`文件 ${i.scannedFiles} · 行 ${i.scannedLines} · 解析异常 ${i.parseErrors}${i.truncated?` · 已截断`:``}`:`等待查询`})]}),(0,I.jsx)(`div`,{className:`px-3 py-3`,children:c?(0,I.jsx)(EO,{className:`min-h-[160px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`用户会话查询失败`}),(0,I.jsx)(jO,{children:c})]})}):s?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`}),(0,I.jsx)(MO,{className:`h-10 w-full`})]}):m?(0,I.jsx)(`div`,{className:`rounded-md border`,children:(0,I.jsxs)(zO,{children:[(0,I.jsx)(BO,{children:(0,I.jsxs)(UO,{children:[(0,I.jsx)(WO,{className:`w-[46px]`}),(0,I.jsx)(WO,{children:`用户`}),(0,I.jsx)(WO,{children:`请求数`}),(0,I.jsx)(WO,{children:`会话数`}),(0,I.jsx)(WO,{children:`首次活跃`}),(0,I.jsx)(WO,{children:`最近活跃`}),(0,I.jsx)(WO,{children:`模型摘要`}),(0,I.jsx)(WO,{children:`Provider`}),(0,I.jsx)(WO,{children:`RouteType`}),(0,I.jsx)(WO,{className:`sticky right-0 z-10 bg-background text-right`,children:`操作`})]})}),(0,I.jsx)(VO,{children:r.map(t=>{let n=f[t.userKey]??!0;return(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(UO,{children:[(0,I.jsx)(GO,{children:(0,I.jsx)(J,{size:`icon-xs`,variant:`ghost`,onClick:()=>p(e=>({...e,[t.userKey]:!n})),children:n?(0,I.jsx)(ta,{className:`h-3.5 w-3.5`}):(0,I.jsx)(na,{className:`h-3.5 w-3.5`})})}),(0,I.jsx)(GO,{className:`font-mono text-xs`,title:t.userKey,children:EP(t.userKey,10)}),(0,I.jsx)(GO,{children:t.requestCount}),(0,I.jsx)(GO,{children:t.sessionCount}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(t.firstSeenAt)}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(t.lastSeenAt)}),(0,I.jsx)(GO,{className:`max-w-[260px] truncate text-xs`,title:TP(t.models),children:TP(t.models)}),(0,I.jsx)(GO,{children:(0,I.jsx)(X,{variant:`outline`,className:`text-xs`,children:t.providers.length})}),(0,I.jsx)(GO,{children:(0,I.jsx)(X,{variant:`outline`,className:`text-xs`,children:t.routeTypes.length})}),(0,I.jsx)(GO,{className:`sticky right-0 z-10 bg-background text-right`,children:(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/logs`,search:{user:t.userKey,session:void 0}}),children:`查看日志`})})]},t.userKey),n?t.sessions.map(n=>(0,I.jsxs)(UO,{className:`bg-muted/20`,children:[(0,I.jsx)(GO,{}),(0,I.jsx)(GO,{className:`text-muted-foreground text-xs`,children:`↳ 会话`}),(0,I.jsx)(GO,{children:n.requestCount}),(0,I.jsx)(GO,{className:`text-xs text-muted-foreground`,children:n.sessionId}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(n.firstSeenAt)}),(0,I.jsx)(GO,{className:`text-xs`,children:wP(n.lastSeenAt)}),(0,I.jsx)(GO,{className:`max-w-[260px] truncate text-xs`,title:TP(n.models),children:TP(n.models)}),(0,I.jsxs)(GO,{className:`text-xs text-muted-foreground`,colSpan:2,children:[`最近 requestId: `,EP(n.latestRequestId,8)]}),(0,I.jsx)(GO,{className:`sticky right-0 z-10 bg-background text-right`,children:(0,I.jsx)(J,{size:`sm`,variant:`outline`,onClick:()=>void e({to:`/logs`,search:{user:t.userKey,session:n.sessionId}}),children:`查看日志`})})]},`${t.userKey}-${n.sessionId}`)):null]},t.userKey)})})]})}):(0,I.jsx)(EO,{className:`min-h-[220px] p-6 md:p-6`,children:(0,I.jsxs)(DO,{children:[(0,I.jsx)(AO,{children:`暂无可用用户会话`}),(0,I.jsx)(jO,{children:`请确认 bodyPolicy 不为 off,并调整筛选条件后重试`})]})})})]})]})}function OP({title:e,value:t}){return(0,I.jsxs)(`div`,{className:`rounded-lg border bg-background px-3 py-3`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:e}),(0,I.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:t})]})}var kP=Vr({component:xO}),AP=zr({getParentRoute:()=>kP,path:`/`,component:()=>(0,I.jsx)(Cr,{to:`/dashboard`,replace:!0})}),jP=zr({getParentRoute:()=>kP,path:`/dashboard`,component:$O}),MP=zr({getParentRoute:()=>kP,path:`/providers`,component:pP}),NP=zr({getParentRoute:()=>kP,path:`/routes`,component:yP}),PP=zr({getParentRoute:()=>kP,path:`/logs`,validateSearch:e=>({user:typeof e.user==`string`?e.user:void 0,session:typeof e.session==`string`?e.session:void 0}),component:Xj}),FP=zr({getParentRoute:()=>kP,path:`/sessions`,component:DP}),IP=zr({getParentRoute:()=>kP,path:`/logs/$id`,component:Zk}),LP=zr({getParentRoute:()=>kP,path:`/logs-settings`,component:$j});const RP=ai({routeTree:kP.addChildren([AP,jP,MP,NP,PP,FP,IP,LP]),basepath:`/admin`,defaultPreload:`intent`});(0,li.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(F.StrictMode,{children:(0,I.jsx)(ci,{router:RP})}));
|
package/dist/web/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="/admin/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/admin/assets/index-BbfScfK-.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/admin/assets/index-D7k-VsmO.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|