@nextclaw/ui 0.13.9 → 0.13.10-beta.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/assets/{api-CIJxdHmy.js → api-CA2udGyv.js} +3 -3
  3. package/dist/assets/app-presenter-provider-B9ChYida.js +3 -0
  4. package/dist/assets/arrow-left-CI0Ocu9p.js +1 -0
  5. package/dist/assets/{channels-list-page-C_Xe0CNX.js → channels-list-page-PrT4a9g4.js} +1 -1
  6. package/dist/assets/{chat-page-CXRtoQR2.js → chat-page-CImtIhmN.js} +1 -1
  7. package/dist/assets/{config-split-page-DBAcw9mJ.js → config-split-page-bO0K6uQv.js} +1 -1
  8. package/dist/assets/{confirm-dialog-DwPTxq8C.js → confirm-dialog-l4FYdzga.js} +1 -1
  9. package/dist/assets/{desktop-update-config-BqABa_1C.js → desktop-update-config-p3rJIgRg.js} +1 -1
  10. package/dist/assets/{dist-BfcibKyv.js → dist-DQoV-62W.js} +1 -1
  11. package/dist/assets/{dist-WjhKB-pc.js → dist-T6rf86Nf.js} +1 -1
  12. package/dist/assets/{doc-browser-8EEDwGCJ.js → doc-browser-CTFB6ACN.js} +1 -1
  13. package/dist/assets/{doc-browser-context-DLJOy6Am.js → doc-browser-context-CP2tI-Br.js} +1 -1
  14. package/dist/assets/doc-browser-yi02ASOL.js +1 -0
  15. package/dist/assets/{ellipsis-H-4aNwgt.js → ellipsis-B7CbNPNr.js} +1 -1
  16. package/dist/assets/{es2015-B5k1IpKX.js → es2015-BSPOGpH4.js} +1 -1
  17. package/dist/assets/{external-link-BN1wd-eI.js → external-link-CefT35zP.js} +1 -1
  18. package/dist/assets/{index-WJt0X9wC.js → index-DFC_DdT1.js} +4 -4
  19. package/dist/assets/{key-round-D-7IaAQS.js → key-round-BpM3GZn4.js} +1 -1
  20. package/dist/assets/{loader-circle-CB38Q7Ws.js → loader-circle-_edjOFsw.js} +1 -1
  21. package/dist/assets/mcp-marketplace-page-DNHSmfDf.js +1 -0
  22. package/dist/assets/{mcp-marketplace-page-ju1KH3TG.js → mcp-marketplace-page-DhqcnhZc.js} +1 -1
  23. package/dist/assets/{model-config-CgS6dp65.js → model-config-C9ydDDFh.js} +1 -1
  24. package/dist/assets/{notice-card-DW9BLKpG.js → notice-card-BfXlhPjX.js} +1 -1
  25. package/dist/assets/play-DD0bg50i.js +1 -0
  26. package/dist/assets/plus-zZ2GC_AJ.js +1 -0
  27. package/dist/assets/{popover-ofN845gZ.js → popover-D_pJfOlM.js} +1 -1
  28. package/dist/assets/{provider-scoped-model-input-DaDqi8Zy.js → provider-scoped-model-input-CkeEyTfO.js} +1 -1
  29. package/dist/assets/{providers-list-CZNQXY4n.js → providers-list-9eOBQFUn.js} +1 -1
  30. package/dist/assets/{react-Bq34NL59.js → react-Bl8iJUcF.js} +1 -1
  31. package/dist/assets/{refresh-cw-DJttSXS8.js → refresh-cw-CqfS1EhK.js} +1 -1
  32. package/dist/assets/remote-fGlxrJI_.js +1 -0
  33. package/dist/assets/rotate-cw-C7EvaSlb.js +1 -0
  34. package/dist/assets/{runtime-config-page-gUjM6Z_A.js → runtime-config-page-B30PC6bx.js} +1 -1
  35. package/dist/assets/{save-DtAFbS7x.js → save-CQERCODg.js} +1 -1
  36. package/dist/assets/search-C0b2yzmt.js +1 -0
  37. package/dist/assets/{search-config-C04PrmHj.js → search-config-RN01uPJQ.js} +1 -1
  38. package/dist/assets/{secrets-config-DvxHdz9h.js → secrets-config-CTZ_TGoA.js} +1 -1
  39. package/dist/assets/{status-dot-D4jbKDLB.js → status-dot-DY0xUUvK.js} +1 -1
  40. package/dist/assets/{tabs-Ca2vw7YQ.js → tabs-C77i1w90.js} +1 -1
  41. package/dist/assets/{tabs-custom-DzGDjYxf.js → tabs-custom-CFpR54-m.js} +1 -1
  42. package/dist/assets/{tag-chip-CW-_pHjH.js → tag-chip-Dnb2VuWh.js} +1 -1
  43. package/dist/assets/{tooltip-Cq2mERPk.js → tooltip-fs7VQG7d.js} +1 -1
  44. package/dist/assets/{trash-2-rumaEu9l.js → trash-2-Bb8mTTLl.js} +1 -1
  45. package/dist/assets/x-BV4iiea8.js +1 -0
  46. package/dist/index.html +24 -24
  47. package/package.json +8 -8
  48. package/src/features/panel-apps/components/panel-app-list-item.test.tsx +4 -0
  49. package/src/features/panel-apps/components/panel-apps-list.tsx +27 -1
  50. package/src/features/panel-apps/hooks/use-panel-apps.ts +10 -0
  51. package/src/features/panel-apps/managers/panel-app-bridge.manager.test.ts +18 -40
  52. package/src/features/panel-apps/managers/panel-app-bridge.manager.ts +24 -36
  53. package/src/features/panel-apps/utils/panel-app-view.utils.test.ts +4 -0
  54. package/src/features/right-panel-resources/utils/right-panel-resource-uri.utils.test.ts +4 -0
  55. package/src/features/service-apps/components/service-apps-panel.tsx +3 -3
  56. package/src/shared/lib/api/index.ts +1 -1
  57. package/src/shared/lib/api/{ncp-session-query-cache.test.ts → ncp-session-query-cache.utils.test.ts} +23 -0
  58. package/src/shared/lib/api/{ncp-session-query-cache.ts → ncp-session-query-cache.utils.ts} +9 -11
  59. package/src/shared/lib/api/types.ts +4 -0
  60. package/src/shared/lib/i18n/runtime/doc-browser-labels.utils.ts +5 -0
  61. package/dist/assets/app-presenter-provider-CKZqZfv5.js +0 -3
  62. package/dist/assets/arrow-left-DHcD-tbC.js +0 -1
  63. package/dist/assets/doc-browser-DlT90zQD.js +0 -1
  64. package/dist/assets/mcp-marketplace-page-CmZwt64F.js +0 -1
  65. package/dist/assets/play-DGpH8jeI.js +0 -1
  66. package/dist/assets/plus-CkcQjwuH.js +0 -1
  67. package/dist/assets/remote-CYmsM9DD.js +0 -1
  68. package/dist/assets/rotate-cw-D_xslHna.js +0 -1
  69. package/dist/assets/search-CNMRwAFx.js +0 -1
  70. package/dist/assets/x-DGqjdMUt.js +0 -1
@@ -5,7 +5,6 @@ import type {
5
5
  PanelAppAgentGenerateObjectResultView,
6
6
  PanelAppAgentSendRequestView,
7
7
  PanelAppAgentSendResultView,
8
- PanelAppBridgeSessionView,
9
8
  PanelAppCapabilityGrantView,
10
9
  ServiceActionGrantView,
11
10
  ServiceActionInvokeResultView,
@@ -18,6 +17,8 @@ import { nextclawClient } from '@/shared/lib/api';
18
17
  type PanelAppBridgeRequest = {
19
18
  type: 'nextclaw:panel-app-service-actions:request';
20
19
  requestId: string;
20
+ appId: string;
21
+ runtimeToken: string;
21
22
  method:
22
23
  | 'agent.generateObject'
23
24
  | 'agent.send'
@@ -32,6 +33,11 @@ type PanelAppBridgeRequest = {
32
33
  };
33
34
  };
34
35
 
36
+ type PanelAppBridgeContext = {
37
+ appId: string;
38
+ token: string;
39
+ };
40
+
35
41
  type PanelAppBridgeResponse =
36
42
  | {
37
43
  type: 'nextclaw:panel-app-service-actions:response';
@@ -51,8 +57,6 @@ type PanelAppBridgeResponse =
51
57
  };
52
58
 
53
59
  export class PanelAppBridgeManager {
54
- private readonly sessions = new Map<string, Promise<PanelAppBridgeSessionView>>();
55
-
56
60
  constructor(private readonly authorizationManager: ServiceActionAuthorizationManager) {}
57
61
 
58
62
  handleIframeMessage = ({ event, iframe, iframeInstanceId, tab }: DocBrowserIframeMessageParams): void => {
@@ -70,7 +74,7 @@ export class PanelAppBridgeManager {
70
74
  request: PanelAppBridgeRequest,
71
75
  ): Promise<void> => {
72
76
  try {
73
- const session = await this.getSession(params);
77
+ const session = this.getBridgeContext(request);
74
78
  const data = await this.dispatchRequest(session, request);
75
79
  this.postResponse(params, {
76
80
  type: 'nextclaw:panel-app-service-actions:response',
@@ -89,7 +93,7 @@ export class PanelAppBridgeManager {
89
93
  };
90
94
 
91
95
  private dispatchRequest = async (
92
- session: PanelAppBridgeSessionView,
96
+ session: PanelAppBridgeContext,
93
97
  request: PanelAppBridgeRequest,
94
98
  ): Promise<
95
99
  | PanelAppAgentGenerateObjectResultView
@@ -124,7 +128,7 @@ export class PanelAppBridgeManager {
124
128
  };
125
129
 
126
130
  private invokeWithAuthorization = async (
127
- session: PanelAppBridgeSessionView,
131
+ session: PanelAppBridgeContext,
128
132
  request: PanelAppBridgeRequest,
129
133
  ): Promise<ServiceActionInvokeResultView> => {
130
134
  const actionId = this.requireActionId(request);
@@ -148,7 +152,7 @@ export class PanelAppBridgeManager {
148
152
  };
149
153
 
150
154
  private sendAgentMessageWithAuthorization = async (
151
- session: PanelAppBridgeSessionView,
155
+ session: PanelAppBridgeContext,
152
156
  request: PanelAppBridgeRequest,
153
157
  ): Promise<PanelAppAgentSendResultView> => {
154
158
  try {
@@ -169,7 +173,7 @@ export class PanelAppBridgeManager {
169
173
  };
170
174
 
171
175
  private generateAgentObjectWithAuthorization = async (
172
- session: PanelAppBridgeSessionView,
176
+ session: PanelAppBridgeContext,
173
177
  request: PanelAppBridgeRequest,
174
178
  ): Promise<PanelAppAgentGenerateObjectResultView> => {
175
179
  try {
@@ -190,11 +194,11 @@ export class PanelAppBridgeManager {
190
194
  };
191
195
 
192
196
  private confirmAndGrantAgentCapability = async (
193
- session: PanelAppBridgeSessionView,
197
+ session: PanelAppBridgeContext,
194
198
  capability: PanelAppAgentCapabilityView,
195
199
  ): Promise<PanelAppCapabilityGrantView> => {
196
200
  const allowed = await this.authorizationManager.requestAuthorization({
197
- panelAppId: session.panelAppId,
201
+ panelAppId: session.appId,
198
202
  actions: [{
199
203
  actionId: capability,
200
204
  actionTitle: capability === 'agent:send' ? 'Send agent message' : 'Generate object',
@@ -217,13 +221,13 @@ export class PanelAppBridgeManager {
217
221
  };
218
222
 
219
223
  private confirmAndGrant = async (
220
- session: PanelAppBridgeSessionView,
224
+ session: PanelAppBridgeContext,
221
225
  actionId: string,
222
226
  input?: Record<string, unknown>,
223
227
  ): Promise<ServiceActionGrantView> => {
224
228
  const actions = await this.listGrantCandidateActions(session, actionId);
225
229
  const allowed = await this.authorizationManager.requestAuthorization({
226
- panelAppId: session.panelAppId,
230
+ panelAppId: session.appId,
227
231
  actions: actions.map((action) => ({
228
232
  actionId: action.id,
229
233
  actionTitle: action.title,
@@ -250,7 +254,7 @@ export class PanelAppBridgeManager {
250
254
  };
251
255
 
252
256
  private listGrantCandidateActions = async (
253
- session: PanelAppBridgeSessionView,
257
+ session: PanelAppBridgeContext,
254
258
  actionId: string,
255
259
  ): Promise<Array<ServiceActionListView['actions'][number]>> => {
256
260
  const actionList = await nextclawClient.serviceApps.listServiceActions({
@@ -294,29 +298,11 @@ export class PanelAppBridgeManager {
294
298
  }
295
299
  };
296
300
 
297
- private getSession = async (
298
- params: DocBrowserIframeMessageParams,
299
- ): Promise<PanelAppBridgeSessionView> => {
300
- const panelAppId = this.readPanelAppId(params.tab.currentUrl);
301
- const key = `${params.iframeInstanceId}:${panelAppId}`;
302
- let session = this.sessions.get(key);
303
- if (!session) {
304
- session = nextclawClient.panelApps.createBridgeSession({
305
- panelAppId,
306
- tabId: params.tab.id,
307
- });
308
- this.sessions.set(key, session);
309
- }
310
- return await session;
311
- };
312
-
313
- private readPanelAppId = (url: string): string => {
314
- const parsed = new URL(url, window.location.origin);
315
- const match = /^\/api\/panel-apps\/([^/]+)\/content$/.exec(parsed.pathname);
316
- if (!match?.[1]) {
317
- throw new Error('Current tab is not a Panel App.');
318
- }
319
- return decodeURIComponent(match[1]);
301
+ private getBridgeContext = (request: PanelAppBridgeRequest): PanelAppBridgeContext => {
302
+ return {
303
+ appId: request.appId,
304
+ token: request.runtimeToken,
305
+ };
320
306
  };
321
307
 
322
308
  private requireActionId = (request: PanelAppBridgeRequest): string => {
@@ -383,6 +369,8 @@ export class PanelAppBridgeManager {
383
369
  return (
384
370
  candidate.type === 'nextclaw:panel-app-service-actions:request' &&
385
371
  typeof candidate.requestId === 'string' &&
372
+ typeof candidate.runtimeToken === 'string' &&
373
+ typeof candidate.appId === 'string' &&
386
374
  (candidate.method === 'invoke' ||
387
375
  candidate.method === 'agent.send' ||
388
376
  candidate.method === 'agent.generateObject' ||
@@ -7,13 +7,17 @@ function createPanelAppEntry(overrides: Partial<PanelAppEntryView> = {}): PanelA
7
7
  const updatedAt = overrides.updatedAt ?? createdAt;
8
8
  return {
9
9
  id: overrides.id ?? overrides.fileName ?? 'demo.panel.html',
10
+ appId: overrides.appId ?? 'demo',
10
11
  fileName: overrides.fileName ?? 'demo.panel.html',
12
+ kind: overrides.kind ?? 'single-file',
11
13
  title: overrides.title ?? 'Demo',
12
14
  contentPath: overrides.contentPath ?? '/api/panel-apps/demo/content',
13
15
  createdAt,
14
16
  updatedAt,
15
17
  sizeBytes: overrides.sizeBytes ?? 12,
16
18
  favorite: overrides.favorite ?? false,
19
+ clientDeclared: overrides.clientDeclared ?? false,
20
+ clientGranted: overrides.clientGranted ?? false,
17
21
  openCount: overrides.openCount ?? 0,
18
22
  ...overrides,
19
23
  };
@@ -4,11 +4,15 @@ import { createPanelAppRightPanelResourceTarget } from '@/features/right-panel-r
4
4
 
5
5
  function createPanelAppEntry(overrides: Partial<PanelAppEntryView> = {}): PanelAppEntryView {
6
6
  return {
7
+ appId: 'demo',
8
+ clientDeclared: false,
9
+ clientGranted: false,
7
10
  contentPath: '/api/panel-apps/demo/content',
8
11
  createdAt: '2026-06-02T00:00:00.000Z',
9
12
  favorite: false,
10
13
  fileName: 'demo.html',
11
14
  id: 'demo',
15
+ kind: 'single-file',
12
16
  openCount: 0,
13
17
  sizeBytes: 1024,
14
18
  title: 'Demo App',
@@ -77,9 +77,9 @@ export function ServiceAppsPanel({
77
77
  );
78
78
  }
79
79
 
80
- const apps = serviceApps.data?.entries ?? [];
81
- const actions = serviceActions.data?.actions ?? [];
82
- const grants = serviceActionGrants.data?.grants ?? [];
80
+ const apps: ServiceAppRecordView[] = serviceApps.data?.entries ?? [];
81
+ const actions: ServiceActionView[] = serviceActions.data?.actions ?? [];
82
+ const grants: ServiceActionGrantView[] = serviceActionGrants.data?.grants ?? [];
83
83
  const discover = (appId: string) => {
84
84
  void discoverServiceAppActions.mutateAsync(appId).then((result) => {
85
85
  setDiscoveredActionsByApp((current) => ({
@@ -11,7 +11,7 @@ export * from './utils/mcp-marketplace.utils';
11
11
  export * from './utils/ncp-attachments.utils';
12
12
  export * from './utils/ncp-session.utils';
13
13
  export * from './ncp-session.types';
14
- export * from './ncp-session-query-cache';
14
+ export * from './ncp-session-query-cache.utils';
15
15
  export * from './raw-client.utils';
16
16
  export * from './utils/remote.utils';
17
17
  export * from './remote.types';
@@ -131,6 +131,29 @@ describe('ncp-session-query-cache', () => {
131
131
  });
132
132
  });
133
133
 
134
+ it('keeps the realtime running overlay when a newer persisted idle summary arrives', () => {
135
+ const current = updateNcpSessionRunStatusList(createSessionsList(), {
136
+ sessionKey: 'session-1',
137
+ status: 'running'
138
+ });
139
+
140
+ const updated = upsertNcpSessionSummaryList(current, {
141
+ sessionId: 'session-1',
142
+ messageCount: 2,
143
+ createdAt: '2026-03-29T08:00:00.000Z',
144
+ updatedAt: '2026-03-29T10:01:00.000Z',
145
+ lastMessageAt: '2026-03-29T10:01:00.000Z',
146
+ status: 'idle',
147
+ metadata: { last_activity_preview: { state: 'running' } }
148
+ });
149
+
150
+ expect(updated?.sessions[0]).toMatchObject({
151
+ sessionId: 'session-1',
152
+ messageCount: 2,
153
+ status: 'running'
154
+ });
155
+ });
156
+
134
157
  it('applies realtime upsert/delete events to every ncp-sessions query cache entry', () => {
135
158
  const queryClient = new QueryClient();
136
159
  queryClient.setQueryData(['ncp-sessions', 200], createSessionsList());
@@ -14,18 +14,11 @@ function shouldReplaceSessionSummary(
14
14
  next: NcpSessionSummaryView
15
15
  ): boolean {
16
16
  const timeOrder = next.updatedAt.localeCompare(current.updatedAt);
17
- if (timeOrder > 0) {
18
- return true;
19
- }
20
- if (timeOrder < 0) {
21
- return false;
22
- }
23
-
24
- if (current.status === next.status) {
25
- return true;
17
+ if (timeOrder !== 0) {
18
+ return timeOrder > 0;
26
19
  }
27
20
 
28
- return next.status === 'idle';
21
+ return current.status === next.status || next.status === 'idle';
29
22
  }
30
23
 
31
24
  export function upsertNcpSessionSummaryList(
@@ -40,7 +33,12 @@ export function upsertNcpSessionSummaryList(
40
33
  const nextSessions =
41
34
  existingIndex >= 0
42
35
  ? current.sessions.map((session, index) =>
43
- index === existingIndex && shouldReplaceSessionSummary(session, summary) ? summary : session
36
+ index === existingIndex && shouldReplaceSessionSummary(session, summary)
37
+ ? {
38
+ ...summary,
39
+ status: session.status === 'running' && summary.status === 'idle' ? 'running' : summary.status
40
+ }
41
+ : session
44
42
  )
45
43
  : [...current.sessions, summary];
46
44
  const sortedSessions = sortSessionSummaries(nextSessions);
@@ -363,7 +363,9 @@ export type ServerPathReadView = { requestedPath: string; resolvedPath: string;
363
363
 
364
364
  export type PanelAppEntryView = {
365
365
  id: string;
366
+ appId: string;
366
367
  fileName: string;
368
+ kind: "single-file" | "folder";
367
369
  title: string;
368
370
  description?: string;
369
371
  icon?: string;
@@ -372,6 +374,8 @@ export type PanelAppEntryView = {
372
374
  updatedAt: string;
373
375
  sizeBytes: number;
374
376
  favorite: boolean;
377
+ clientDeclared: boolean;
378
+ clientGranted: boolean;
375
379
  lastOpenedAt?: string;
376
380
  openCount: number;
377
381
  };
@@ -39,6 +39,11 @@ export const DOC_BROWSER_LABELS = {
39
39
  zh: '将删除这个面板应用文件,删除后不可恢复。',
40
40
  en: 'This will delete the panel app file and cannot be undone.',
41
41
  },
42
+ panelAppsClientGrantTitle: { zh: 'NextClaw Client SDK', en: 'NextClaw Client SDK' },
43
+ panelAppsClientGrantDescription: {
44
+ zh: '允许这个面板应用使用完整 NextClaw Client SDK。',
45
+ en: 'Allow this panel app to use the full NextClaw Client SDK.',
46
+ },
42
47
  panelAppsLastOpened: { zh: '上次打开', en: 'Last opened' },
43
48
  panelAppsUpdated: { zh: '更新于', en: 'Updated' },
44
49
  serviceAppsTitle: { zh: '服务应用', en: 'Service Apps' },
@@ -1,3 +0,0 @@
1
- import{d as e,g as t,i as n,m as r,n as i,o as a,s as o,t as s,y as c}from"./react-Bq34NL59.js";import{At as l,Bt as u,Dt as d,Et as f,Ft as p,Lt as m,Mt as h,Nt as g,Ot as _,Pt as v,Qt as y,Vt as b,a as ee,c as te,ct as x,i as ne,jt as re,kt as ie,l as ae,o as oe,pt as se,r as ce,s as le,u as ue,wt as S,zt as C}from"./api-CIJxdHmy.js";import{c as w}from"./dist-WjhKB-pc.js";import{a as de,i as fe,n as pe,o as me,r as he,s as ge,t as _e}from"./confirm-dialog-DwPTxq8C.js";import{t as ve}from"./arrow-left-DHcD-tbC.js";import{n as ye,t as be}from"./loader-circle-CB38Q7Ws.js";import{i as xe,n as Se,r as Ce,t as we,u as Te}from"./tooltip-Cq2mERPk.js";import{t as Ee}from"./key-round-D-7IaAQS.js";import{t as De}from"./plus-CkcQjwuH.js";import{t as Oe}from"./refresh-cw-DJttSXS8.js";import{t as ke}from"./trash-2-rumaEu9l.js";import{t as Ae}from"./x-DGqjdMUt.js";import{t as T}from"./notice-card-DW9BLKpG.js";import{t as je}from"./status-dot-D4jbKDLB.js";import{n as Me,r as Ne,t as Pe}from"./popover-ofN845gZ.js";import{i as E,r as Fe,t as Ie}from"./tabs-Ca2vw7YQ.js";import{a as D,c as Le,f as Re,g as ze,h as O,i as Be,l as Ve,m as He,n as Ue,o as We,p as Ge,r as Ke,s as qe,u as Je}from"./doc-browser-context-DLJOy6Am.js";var Ye=`modulepreload`,Xe=function(e){return`/`+e},Ze={},Qe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Xe(t,n),t in Ze)return;Ze[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Ye,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},k=c(t(),1),$e=`popstate`;function et(e={}){let{initialEntries:t=[`/`],initialIndex:n,v5Compat:r=!1}=e,i;i=t.map((e,t)=>u(e,typeof e==`string`?null:e.state,t===0?`default`:void 0));let a=c(n??i.length-1),o=`POP`,s=null;function c(e){return Math.min(Math.max(e,0),i.length-1)}function l(){return i[a]}function u(e,t=null,n){let r=it(i?l().pathname:`/`,e,t,n);return j(r.pathname.charAt(0)===`/`,`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function d(e){return typeof e==`string`?e:M(e)}return{get index(){return a},get action(){return o},get location(){return l()},createHref:d,createURL(e){return new URL(d(e),`http://localhost`)},encodeLocation(e){let t=typeof e==`string`?N(e):e;return{pathname:t.pathname||``,search:t.search||``,hash:t.hash||``}},push(e,t){o=`PUSH`;let n=u(e,t);a+=1,i.splice(a,i.length,n),r&&s&&s({action:o,location:n,delta:1})},replace(e,t){o=`REPLACE`;let n=u(e,t);i[a]=n,r&&s&&s({action:o,location:n,delta:0})},go(e){o=`POP`;let t=c(a+e),n=i[t];a=t,s&&s({action:o,location:n,delta:e})},listen(e){return s=e,()=>{s=null}}}}function tt(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return it(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:M(t)}return at(t,n,null,e)}function A(e,t){if(e===!1||e==null)throw Error(t)}function j(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function nt(){return Math.random().toString(36).substring(2,10)}function rt(e,t){return{usr:e.state,key:e.key,idx:t}}function it(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?N(t):t,state:n,key:t&&t.key||r||nt()}}function M({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function N(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function at(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=it(h.location,e,t);n&&n(r,e),l=u()+1;let d=rt(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=it(h.location,e,t);n&&n(r,e),l=u();let i=rt(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return ot(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener($e,d),c=e,()=>{i.removeEventListener($e,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function ot(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),A(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:M(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function st(e,t,n=`/`){return ct(e,t,n,!1)}function ct(e,t,n,r){let i=P((typeof t==`string`?N(t):t).pathname||`/`,n);if(i==null)return null;let a=ut(e);ft(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=Tt(i);o=St(a[e],t,r)}return o}function lt(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function ut(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;A(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=F([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(A(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),ut(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:bt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of dt(e.path))a(e,t,!0,n)}),t}function dt(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=dt(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ft(e){e.sort((e,t)=>e.score===t.score?xt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var pt=/^:[\w-]+$/,mt=3,ht=2,gt=1,_t=10,vt=-2,yt=e=>e===`*`;function bt(e,t){let n=e.split(`/`),r=n.length;return n.some(yt)&&(r+=vt),t&&(r+=ht),n.filter(e=>!yt(e)).reduce((e,t)=>e+(pt.test(t)?mt:t===``?gt:_t),r)}function xt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function St(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=Ct({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=Ct({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:F([a,u.pathname]),pathnameBase:Nt(F([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=F([a,u.pathnameBase]))}return o}function Ct(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=wt(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function wt(e,t=!1,n=!0){j(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Tt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return j(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function P(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var Et=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Dt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?N(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Ot(n.substring(1),`/`):Ot(n,t)):a=t,{pathname:a,search:Pt(r),hash:Ft(i)}}function Ot(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function kt(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function At(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function jt(e){let t=At(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Mt(e,t,n,r=!1){let i;typeof e==`string`?i=N(e):(i={...e},A(!i.pathname||!i.pathname.includes(`?`),kt(`?`,`pathname`,`search`,i)),A(!i.pathname||!i.pathname.includes(`#`),kt(`#`,`pathname`,`hash`,i)),A(!i.search||!i.search.includes(`#`),kt(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Dt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var F=e=>e.join(`/`).replace(/\/\/+/g,`/`),Nt=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Pt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ft=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,It=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Lt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Rt(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var zt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Bt(e,t){let n=e;if(typeof n!=`string`||!Et.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(zt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=P(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{j(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Vt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Vt);var Ht=[`GET`,...Vt];new Set(Ht);var I=k.createContext(null);I.displayName=`DataRouter`;var Ut=k.createContext(null);Ut.displayName=`DataRouterState`;var Wt=k.createContext(!1),Gt=k.createContext({isTransitioning:!1});Gt.displayName=`ViewTransition`;var Kt=k.createContext(new Map);Kt.displayName=`Fetchers`;var qt=k.createContext(null);qt.displayName=`Await`;var L=k.createContext(null);L.displayName=`Navigation`;var Jt=k.createContext(null);Jt.displayName=`Location`;var R=k.createContext({outlet:null,matches:[],isDataRoute:!1});R.displayName=`Route`;var Yt=k.createContext(null);Yt.displayName=`RouteError`;var Xt=`REACT_ROUTER_ERROR`,Zt=`REDIRECT`,Qt=`ROUTE_ERROR_RESPONSE`;function $t(e){if(e.startsWith(`${Xt}:${Zt}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function en(e){if(e.startsWith(`${Xt}:${Qt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new It(t.status,t.statusText,t.data)}catch{}}function tn(e,{relative:t}={}){A(z(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=k.useContext(L),{hash:i,pathname:a,search:o}=cn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:F([n,a])),r.createHref({pathname:s,search:o,hash:i})}function z(){return k.useContext(Jt)!=null}function B(){return A(z(),`useLocation() may be used only in the context of a <Router> component.`),k.useContext(Jt).location}var nn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function rn(e){k.useContext(L).static||k.useLayoutEffect(e)}function an(){let{isDataRoute:e}=k.useContext(R);return e?Dn():on()}function on(){A(z(),`useNavigate() may be used only in the context of a <Router> component.`);let e=k.useContext(I),{basename:t,navigator:n}=k.useContext(L),{matches:r}=k.useContext(R),{pathname:i}=B(),a=JSON.stringify(jt(r)),o=k.useRef(!1);return rn(()=>{o.current=!0}),k.useCallback((r,s={})=>{if(j(o.current,nn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Mt(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:F([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}k.createContext(null);function sn(){let{matches:e}=k.useContext(R),t=e[e.length-1];return t?t.params:{}}function cn(e,{relative:t}={}){let{matches:n}=k.useContext(R),{pathname:r}=B(),i=JSON.stringify(jt(n));return k.useMemo(()=>Mt(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function ln(e,t){return un(e,t)}function un(e,t,n,r,i){A(z(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=k.useContext(L),{matches:o}=k.useContext(R),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;kn(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
-
3
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let f=B(),p;if(t){let e=typeof t==`string`?N(t):t;A(u===`/`||e.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),p=e}else p=f;let m=p.pathname||`/`,h=m;if(u!==`/`){let e=u.replace(/^\//,``).split(`/`);h=`/`+m.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let g=st(e,{pathname:h});j(d||g!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),j(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=_n(g&&g.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:F([u,a.encodeLocation?a.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?u:F([u,a.encodeLocation?a.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),o,n,r,i);return t&&_?k.createElement(Jt.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...p},navigationType:`POP`}},_):_}function dn(){let e=En(),t=Lt(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=k.createElement(k.Fragment,null,k.createElement(`p`,null,`💿 Hey developer 👋`),k.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,k.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,k.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),k.createElement(k.Fragment,null,k.createElement(`h2`,null,`Unexpected Application Error!`),k.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?k.createElement(`pre`,{style:i},n):null,o)}var fn=k.createElement(dn,null),pn=class extends k.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=en(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:k.createElement(R.Provider,{value:this.props.routeContext},k.createElement(Yt.Provider,{value:e,children:this.props.component}));return this.context?k.createElement(hn,{error:e},t):t}};pn.contextType=Wt;var mn=new WeakMap;function hn({children:e,error:t}){let{basename:n}=k.useContext(L);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=$t(t.digest);if(e){let r=mn.get(t);if(r)throw r;let i=Bt(e.location,n);if(zt&&!mn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw mn.set(t,n),n}return k.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function gn({routeContext:e,match:t,children:n}){let r=k.useContext(I);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),k.createElement(R.Provider,{value:e},n)}function _n(e,t=[],n=null,r=null,i=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);A(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n)for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){s=!0,a=c>=0?a.slice(0,c+1):[a[0]];break}}}let l=n&&r?(e,t)=>{r(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Rt(n.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,i)=>{let u,d=!1,f=null,p=null;n&&(u=o&&r.route.id?o[r.route.id]:void 0,f=r.route.errorElement||fn,s&&(c<0&&i===0?(kn(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):c===i&&(d=!0,p=r.route.hydrateFallbackElement||null)));let m=t.concat(a.slice(0,i+1)),h=()=>{let t;return t=u?f:d?p:r.route.Component?k.createElement(r.route.Component,null):r.route.element?r.route.element:e,k.createElement(gn,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?k.createElement(pn,{location:n.location,revalidation:n.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function vn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yn(e){let t=k.useContext(I);return A(t,vn(e)),t}function bn(e){let t=k.useContext(Ut);return A(t,vn(e)),t}function xn(e){let t=k.useContext(R);return A(t,vn(e)),t}function Sn(e){let t=xn(e),n=t.matches[t.matches.length-1];return A(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Cn(){return Sn(`useRouteId`)}function wn(){return bn(`useNavigation`).navigation}function Tn(){let{matches:e,loaderData:t}=bn(`useMatches`);return k.useMemo(()=>e.map(e=>lt(e,t)),[e,t])}function En(){let e=k.useContext(Yt),t=bn(`useRouteError`),n=Sn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Dn(){let{router:e}=yn(`useNavigate`),t=Sn(`useNavigate`),n=k.useRef(!1);return rn(()=>{n.current=!0}),k.useCallback(async(r,i={})=>{j(n.current,nn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var On={};function kn(e,t,n){!t&&!On[e]&&(On[e]=!0,j(!1,n))}k.useOptimistic,k.memo(An);function An({routes:e,future:t,state:n,onError:r}){return un(e,void 0,n,r,t)}function jn({basename:e,children:t,initialEntries:n,initialIndex:r,unstable_useTransitions:i}){let a=k.useRef();a.current??=et({initialEntries:n,initialIndex:r,v5Compat:!0});let o=a.current,[s,c]=k.useState({action:o.action,location:o.location}),l=k.useCallback(e=>{i===!1?c(e):k.startTransition(()=>c(e))},[i]);return k.useLayoutEffect(()=>o.listen(l),[o,l]),k.createElement(Pn,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,unstable_useTransitions:i})}function Mn({to:e,replace:t,state:n,relative:r}){A(z(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=k.useContext(L);j(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=k.useContext(R),{pathname:o}=B(),s=an(),c=Mt(e,jt(a),o,r===`path`),l=JSON.stringify(c);return k.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Nn(e){A(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Pn({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){A(!z(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=k.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=N(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`}=n,m=k.useMemo(()=>{let e=P(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p},navigationType:r}},[s,l,u,d,f,p,r]);return j(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:k.createElement(L.Provider,{value:c},k.createElement(Jt.Provider,{children:t,value:m}))}function Fn({children:e,location:t}){return ln(In(e),t)}k.Component;function In(e,t=[]){let n=[];return k.Children.forEach(e,(e,r)=>{if(!k.isValidElement(e))return;let i=[...t,r];if(e.type===k.Fragment){n.push.apply(n,In(e.props.children,i));return}A(e.type===Nn,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),A(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=In(e.props.children,i)),n.push(a)}),n}var Ln=`get`,Rn=`application/x-www-form-urlencoded`;function zn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Bn(e){return zn(e)&&e.tagName.toLowerCase()===`button`}function Vn(e){return zn(e)&&e.tagName.toLowerCase()===`form`}function Hn(e){return zn(e)&&e.tagName.toLowerCase()===`input`}function Un(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Wn(e,t){return e.button===0&&(!t||t===`_self`)&&!Un(e)}var Gn=null;function Kn(){if(Gn===null)try{new FormData(document.createElement(`form`),0),Gn=!1}catch{Gn=!0}return Gn}var qn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Jn(e){return e!=null&&!qn.has(e)?(j(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Rn}"`),null):e}function Yn(e,t){let n,r,i,a,o;if(Vn(e)){let o=e.getAttribute(`action`);r=o?P(o,t):null,n=e.getAttribute(`method`)||Ln,i=Jn(e.getAttribute(`enctype`))||Rn,a=new FormData(e)}else if(Bn(e)||Hn(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?P(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Ln,i=Jn(e.getAttribute(`formenctype`))||Jn(o.getAttribute(`enctype`))||Rn,a=new FormData(o,e),!Kn()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(zn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Ln,r=null,i=Rn,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Xn={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Zn=/[&><\u2028\u2029]/g;function Qn(e){return e.replace(Zn,e=>Xn[e])}function $n(e,t){if(e===!1||e==null)throw Error(t)}function er(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&P(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function tr(e,t){if(e.id in t)return t[e.id];try{let n=await Qe(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function nr(e){return e!=null&&typeof e.page==`string`}function rr(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function ir(e,t,n){return lr((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await tr(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(rr).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function ar(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function or(e,t,{includeHydrateFallback:n}={}){return sr(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function sr(e){return[...new Set(e)]}function cr(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function lr(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!nr(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(cr(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function ur(){let e=k.useContext(I);return $n(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function dr(){let e=k.useContext(Ut);return $n(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var fr=k.createContext(void 0);fr.displayName=`FrameworkContext`;function pr(){let e=k.useContext(fr);return $n(e,`You must render this element inside a <HydratedRouter> element`),e}function mr(e,t){let n=k.useContext(fr),[r,i]=k.useState(!1),[a,o]=k.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=k.useRef(null);k.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),k.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:hr(s,p),onBlur:hr(c,m),onMouseEnter:hr(l,p),onMouseLeave:hr(u,m),onTouchStart:hr(d,p)}]:[a,f,{}]:[!1,f,{}]}function hr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function gr({page:e,...t}){let{router:n}=ur(),r=k.useMemo(()=>st(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?k.createElement(vr,{page:e,matches:r,...t}):null}function _r(e){let{manifest:t,routeModules:n}=pr(),[r,i]=k.useState([]);return k.useEffect(()=>{let r=!1;return ir(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function vr({page:e,matches:t,...n}){let r=B(),{future:i,manifest:a,routeModules:o}=pr(),{basename:s}=ur(),{loaderData:c,matches:l}=dr(),u=k.useMemo(()=>ar(e,t,l,a,r,`data`),[e,t,l,a,r]),d=k.useMemo(()=>ar(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=k.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=er(e,s,i.unstable_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.unstable_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=k.useMemo(()=>or(d,a),[d,a]),m=_r(d);return k.createElement(k.Fragment,null,f.map(e=>k.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>k.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>k.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function yr(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}k.Component;var br=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{br&&(window.__reactRouterVersion=`7.13.0`)}catch{}function xr({basename:e,children:t,unstable_useTransitions:n,window:r}){let i=k.useRef();i.current??=tt({window:r,v5Compat:!0});let a=i.current,[o,s]=k.useState({action:a.action,location:a.location}),c=k.useCallback(e=>{n===!1?s(e):k.startTransition(()=>s(e))},[n]);return k.useLayoutEffect(()=>a.listen(c),[a,c]),k.createElement(Pn,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}function Sr({basename:e,children:t,history:n,unstable_useTransitions:r}){let[i,a]=k.useState({action:n.action,location:n.location}),o=k.useCallback(e=>{r===!1?a(e):k.startTransition(()=>a(e))},[r]);return k.useLayoutEffect(()=>n.listen(o),[n,o]),k.createElement(Pn,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,unstable_useTransitions:r})}Sr.displayName=`unstable_HistoryRouter`;var Cr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wr=k.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u,unstable_defaultShouldRevalidate:d,...f},p){let{basename:m,unstable_useTransitions:h}=k.useContext(L),g=typeof c==`string`&&Cr.test(c),_=Bt(c,m);c=_.to;let v=tn(c,{relative:r}),[y,b,ee]=mr(n,f),te=jr(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h});function x(t){e&&e(t),t.defaultPrevented||te(t)}let ne=k.createElement(`a`,{...f,...ee,href:_.absoluteURL||v,onClick:_.isExternal||i?e:x,ref:yr(p,b),target:s,"data-discover":!g&&t===`render`?`true`:void 0});return y&&!g?k.createElement(k.Fragment,null,ne,k.createElement(gr,{page:v})):ne});wr.displayName=`Link`;var Tr=k.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=cn(a,{relative:c.relative}),d=B(),f=k.useContext(Ut),{navigator:p,basename:m}=k.useContext(L),h=f!=null&&Vr(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=P(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,ee=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),te={isActive:b,isPending:ee,isTransitioning:h},x=b?e:void 0,ne;ne=typeof n==`function`?n(te):[n,b?`active`:null,ee?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let re=typeof i==`function`?i(te):i;return k.createElement(wr,{...c,"aria-current":x,className:ne,ref:l,style:re,to:a,viewTransition:o},typeof s==`function`?s(te):s)});Tr.displayName=`NavLink`;var Er=k.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Ln,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m)=>{let{unstable_useTransitions:h}=k.useContext(L),g=Pr(),_=Fr(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&Cr.test(s);return k.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f});h&&n!==!1?k.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Er.displayName=`Form`;function Dr({getKey:e,storageKey:t,...n}){let r=k.useContext(fr),{basename:i}=k.useContext(L),a=B(),o=Tn();zr({getKey:e,storageKey:t});let s=k.useMemo(()=>{if(!r||!e)return null;let t=Rr(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return k.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${Qn(JSON.stringify(t||Ir))}, ${Qn(JSON.stringify(s))})`}})}Dr.displayName=`ScrollRestoration`;function Or(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kr(e){let t=k.useContext(I);return A(t,Or(e)),t}function Ar(e){let t=k.useContext(Ut);return A(t,Or(e)),t}function jr(e,{target:t,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let l=an(),u=B(),d=cn(e,{relative:a});return k.useCallback(f=>{if(Wn(f,t)){f.preventDefault();let t=n===void 0?M(u)===M(d):n,p=()=>l(e,{replace:t,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:s});c?k.startTransition(()=>p()):p()}},[u,l,d,n,r,t,e,i,a,o,s,c])}var Mr=0,Nr=()=>`__${String(++Mr)}__`;function Pr(){let{router:e}=kr(`useSubmit`),{basename:t}=k.useContext(L),n=Cn(),r=e.fetch,i=e.navigate;return k.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Yn(e,t);a.navigate===!1?await r(a.fetcherKey||Nr(),n,a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Fr(e,{relative:t}={}){let{basename:n}=k.useContext(L),r=k.useContext(R);A(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...cn(e||`.`,{relative:t})},o=B();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:F([n,a.pathname])),M(a)}var Ir=`react-router-scroll-positions`,Lr={};function Rr(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:P(e.pathname,n)||e.pathname},t)),i??=e.key,i}function zr({getKey:e,storageKey:t}={}){let{router:n}=kr(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Ar(`useScrollRestoration`),{basename:a}=k.useContext(L),o=B(),s=Tn(),c=wn();k.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Br(k.useCallback(()=>{if(c.state===`idle`){let t=Rr(o,s,a,e);Lr[t]=window.scrollY}try{sessionStorage.setItem(t||Ir,JSON.stringify(Lr))}catch(e){j(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(k.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Ir);e&&(Lr=JSON.parse(e))}catch{}},[t]),k.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Lr,()=>window.scrollY,e?(t,n)=>Rr(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),k.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{j(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Br(e,t){let{capture:n}=t||{};k.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Vr(e,{relative:t}={}){let n=k.useContext(Gt);A(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=kr(`useViewTransitionState`),i=cn(e,{relative:t});if(!n.isTransitioning)return!1;let a=P(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=P(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ct(i.pathname,o)!=null||Ct(i.pathname,a)!=null}var Hr=w(`AppWindow`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Ur=w(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),Wr=w(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Gr=w(`CircleDashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),Kr=w(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),qr=w(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),Jr=w(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Yr=w(`Grid3x3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Xr=w(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),Zr=w(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),Qr=w(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),$r=w(`RefreshCcw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),ei=w(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),ti=w(`ShieldAlert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ni=w(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ri=w(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),ii=w(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),ai=w(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),oi=w(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),si=w(`Wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`,key:`cbrjhi`}]]);function ci(){return b({queryKey:ui,queryFn:ee,staleTime:5e3,refetchOnWindowFocus:!0})}var V=r();function H(e){let{label:t,muted:n,value:r}=e;return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,V.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function li(){let e=$o(),t=ci(),r=t.data,a=G(e=>e.actionLabel),o=(0,k.useMemo)(()=>xi(r),[r]),s=!!a,c=r?.runtime?.deviceName?.trim()||r?.settings.deviceName?.trim()||n(`remoteDeviceNameAuto`),u=!!(r?.account.loggedIn&&hi(r)),{hero:m,issueHint:g}=o;return(0,k.useEffect)(()=>{e.remoteAccessManager.syncStatus(r)},[e,r]),t.isLoading&&!r?(0,V.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`remoteLoading`)}):(0,V.jsxs)(h,{className:`space-y-6`,children:[(0,V.jsx)(re,{title:n(`remotePageTitle`),description:n(`remotePageDescription`)}),(0,V.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,V.jsxs)(f,{children:[(0,V.jsxs)(ie,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,V.jsx)(l,{children:m.title}),(0,V.jsx)(je,{status:m.badgeStatus,label:m.badgeLabel})]}),(0,V.jsx)(_,{children:m.description})]}),(0,V.jsxs)(d,{className:`space-y-5`,children:[(0,V.jsxs)(T,{tone:`neutral`,children:[(0,V.jsx)(H,{label:n(`remoteSignedInAccount`),value:r?.account.email}),(0,V.jsx)(H,{label:n(`remoteDeviceName`),value:c}),(0,V.jsx)(H,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,V.jsx)(H,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[o.primaryAction?(0,V.jsxs)(p,{onClick:()=>{if(o.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(r);return}if(o.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(r);return}e.remoteAccessManager.enableRemoteAccess(r)},disabled:s,children:[o.primaryAction.showRefreshIcon?(0,V.jsx)($r,{className:`mr-2 h-4 w-4`}):null,a||o.primaryAction.label]}):null,(0,V.jsxs)(p,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:s||!u,children:[(0,V.jsx)(ri,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),r?.settings.enabled?(0,V.jsx)(p,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(r),disabled:s,children:n(`remoteDisable`)}):null]}),o.shouldShowIssueHint&&g?(0,V.jsx)(T,{tone:`warning`,title:g.title,description:g.body}):null,(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteOpenWebHint`)})]})]}),(0,V.jsxs)(f,{children:[(0,V.jsxs)(ie,{children:[(0,V.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Xr,{className:`h-4 w-4 text-primary`}),n(`remoteDeviceSectionTitle`)]}),(0,V.jsx)(_,{children:n(`remoteDeviceSectionDescription`)})]}),(0,V.jsxs)(d,{className:`space-y-5`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(je,{status:r?.account.loggedIn?`ready`:`inactive`,label:r?.account.loggedIn?n(`remoteAccountConnected`):n(`remoteAccountNotConnected`)}),(0,V.jsx)(je,{status:r?.settings.enabled?`active`:`inactive`,label:r?.settings.enabled?n(`remoteEnabled`):n(`remoteStateDisabled`)}),(0,V.jsx)(je,{status:r?.service.running?`active`:`inactive`,label:r?.service.running?n(`remoteServiceRunning`):n(`remoteServiceStopped`)})]}),(0,V.jsxs)(T,{tone:`neutral`,children:[(0,V.jsx)(H,{label:n(`remoteDeviceName`),value:c}),(0,V.jsx)(H,{label:n(`remoteConnectionStatus`),value:m.badgeLabel}),(0,V.jsx)(H,{label:n(`remoteLastConnectedAt`),value:r?.runtime?.lastConnectedAt?i(r.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,V.jsx)(T,{tone:`neutral`,borderStyle:`dashed`,description:r?.account.loggedIn?n(`remoteOpenWebHint`):n(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var ui=[`remote-status`],di=`https://platform.nextclaw.io`,fi=`https://nextclaw-platform-console.pages.dev`,U=async()=>await m.fetchQuery({queryKey:ui,queryFn:ee,staleTime:5e3}),W=async()=>(await m.invalidateQueries({queryKey:ui}),await U()),pi=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function mi(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return di;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return fi}var hi=e=>mi(e?.account.apiBase)||mi(e?.settings.platformApiBase)||mi(e?.platformBase)||mi(e?.account.platformBase)||void 0,G=s(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),gi=class{constructor(e){this.params=e,this.syncStatus=e=>{if(!e)return;let t=G.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{G.getState().setEnabled(e)},this.setDeviceName=e=>{G.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{G.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{G.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await W(),n=G.getState(),r=await this.ensureRemoteAccount(t,n.platformApiBase);await this.applyEnabledState(!0,r)},this.disableRemoteAccess=async e=>{let t=e??await W();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let t=e??await W(),r=(await this.ensureRemoteAccount(t)).service.running?`restart`:`start`;await this.runManagedAction({actionLabel:n(r===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await ce(r);let e=await W();this.hydrateDraftFromStatus(e)},successMessage:n(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await W(),n=await this.params.accountManager.startBrowserSignInAndWait({status:t,apiBase:G.getState().platformApiBase});await this.repairRemoteAccess(n)},this.saveAdvancedSettings=async e=>{let t=e??await W(),r=G.getState();await this.runManagedAction({actionLabel:n(`remoteActionSavingAdvanced`),job:async()=>{await ue({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await W();this.hydrateDraftFromStatus(e)},successMessage:t.settings.enabled===r.enabled?n(`remoteSettingsSaved`):n(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:n(`remoteDoctorRunning`),job:async()=>{let e=await ne();G.getState().setDoctor(e)},successMessage:n(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,n(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,n(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,n(`remoteActionStopping`))},this.applyEnabledState=async(e,t)=>{let r=G.getState();await this.runManagedAction({actionLabel:n(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await ue({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let n=await W();this.hydrateDraftFromStatus(n),e?await ce(n.service.running?`restart`:`start`):t.service.running&&await ce(`restart`);let i=await W();this.hydrateDraftFromStatus(i)},successMessage:n(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.ensureRemoteAccount=async(e,t)=>e.account.loggedIn?e:await this.params.accountManager.ensureSignedIn({apiBase:t,status:e}),this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await ce(e),n=await W();this.hydrateDraftFromStatus(n),C.success(t.message)}})},this.hydrateDraftFromStatus=e=>{G.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{let{actionLabel:t,job:r,successMessage:i}=e;G.getState().beginAction(t);try{await r(),i&&C.success(i)}catch(e){let t=e instanceof Error?e.message:n(`error`);throw C.error(t),e}finally{G.getState().finishAction()}}}},_i=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function vi(e){return e?.runtime?.lastError?.trim()||``}function yi(e){let t=n(`remoteStatusIssueDetailGeneric`),r=vi(e);return r?`${t} (${r})`:t}function bi(e){if(!e?.settings.enabled)return!1;let t=vi(e);return _i.some(e=>e.test(t))}function xi(e){return bi(e)?{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateReauthorizationRequired`),title:n(`remoteStatusReauthorizationTitle`),description:n(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:n(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:n(`statusReady`),title:n(`remoteStatusReadyTitle`),description:n(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:n(`connecting`),title:n(`remoteStatusConnectingTitle`),description:n(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteStateDisconnected`),title:n(`remoteStatusIssueTitle`),description:n(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:yi(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:n(`remoteServiceStopped`),title:n(`remoteStatusNeedsServiceTitle`),description:n(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:n(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:n(`remoteStatusRecoveryTitle`),body:n(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:n(`statusInactive`),title:n(`remoteStatusNeedsEnable`),description:n(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:n(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:n(`statusSetup`),title:n(`remoteStatusNeedsSignIn`),description:n(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:n(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var K=s(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function Si({label:e,value:t}){return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,V.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function Ci(e){let{email:t,username:r,role:i,canSubmitUsername:a,savingUsername:o,usernameDraft:s,onUsernameDraftChange:c,onSubmitUsername:l,onOpenDeviceList:u,onLogout:d}=e;return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(T,{tone:`success`,title:n(`accountPanelSignedInTitle`),description:n(`accountPanelSignedInDescription`)}),(0,V.jsxs)(T,{tone:`neutral`,children:[(0,V.jsx)(Si,{label:n(`remoteAccountEmail`),value:t}),(0,V.jsx)(Si,{label:n(`remoteAccountUsername`),value:r}),(0,V.jsx)(Si,{label:n(`remoteAccountRole`),value:i})]}),r?(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:n(`remoteAccountUsernameLockedHelp`)}):(0,V.jsxs)(T,{tone:`warning`,title:n(`remoteAccountUsernameRequiredTitle`),description:n(`remoteAccountUsernameRequiredDescription`),children:[(0,V.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,V.jsx)(g,{htmlFor:`account-panel-username`,children:n(`remoteAccountUsername`)}),(0,V.jsx)(v,{id:`account-panel-username`,value:s,onChange:e=>c(e.target.value),placeholder:n(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,V.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,V.jsx)(p,{disabled:!a,onClick:()=>void l(),children:n(o?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,V.jsxs)(p,{onClick:()=>void u(),children:[(0,V.jsx)(ri,{className:`mr-2 h-4 w-4`}),n(`remoteOpenDeviceList`)]}),(0,V.jsxs)(p,{variant:`outline`,onClick:()=>void d(),children:[(0,V.jsx)(Zr,{className:`mr-2 h-4 w-4`}),n(`remoteLogout`)]})]})]})}function wi(e){let{authSessionId:t,authExpiresAt:r,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(T,{tone:`neutral`,title:n(`accountPanelSignedOutTitle`),description:n(`accountPanelSignedOutDescription`),children:t?(0,V.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,V.jsx)(Si,{label:n(`remoteBrowserAuthSession`),value:t}),(0,V.jsx)(Si,{label:n(`remoteBrowserAuthExpiresAt`),value:r?i(r):`-`})]}):null}),a?(0,V.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,V.jsx)(p,{onClick:()=>void s(),children:n(t?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,V.jsx)(p,{variant:`outline`,onClick:c,children:n(`remoteBrowserAuthResume`)}):null]})]})}function Ti(){let e=$o(),t=ci(),r=K(e=>e.panelOpen),i=K(e=>e.authSessionId),a=K(e=>e.authVerificationUri),o=K(e=>e.authExpiresAt),s=K(e=>e.authStatusMessage),c=t.data,[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(!1);(0,k.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,V.jsx)(pe,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,V.jsxs)(he,{className:`max-w-xl`,children:[(0,V.jsxs)(me,{children:[(0,V.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Ee,{className:`h-5 w-5 text-primary`}),n(`accountPanelTitle`)]}),(0,V.jsx)(fe,{children:n(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,V.jsx)(Ci,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,V.jsx)(wi,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function Ei({username:e}){let t=se(),[r,i]=(0,k.useState)(e??``),[a,o]=(0,k.useState)(``),s=r.trim().length>0&&a.length>0&&!t.isPending;return(0,V.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,V.jsxs)(f,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,V.jsxs)(ie,{children:[(0,V.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:n(`authBrand`)}),(0,V.jsx)(l,{className:`text-2xl`,children:n(`authLoginTitle`)}),(0,V.jsx)(_,{children:n(`authLoginDescription`)})]}),(0,V.jsx)(d,{children:(0,V.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),s&&t.mutate({username:r.trim(),password:a})},children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authUsername`)}),(0,V.jsx)(v,{value:r,onChange:e=>i(e.target.value),placeholder:n(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:n(`authPassword`)}),(0,V.jsx)(v,{type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:n(`authPasswordPlaceholder`)})]}),(0,V.jsx)(p,{type:`submit`,className:`w-full`,disabled:!s,children:t.isPending?n(`authLoggingIn`):n(`authLoginAction`)})]})})]})})}var Di=class{constructor(){this.authPollTimerId=null,this.browserSignInCompletion=null,this.openAccountPanel=()=>{K.getState().openPanel()},this.closeAccountPanel=()=>{K.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),this.resolveBrowserSignIn(e),K.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=e?.status??await U();return t.account.loggedIn?t:(this.openAccountPanel(),await this.startBrowserSignInAndWait({apiBase:e?.apiBase,status:t}))},this.startBrowserSignInAndWait=async e=>{let t=this.createBrowserSignInCompletion();return await this.startBrowserSignIn(e),await t},this.startBrowserSignIn=async e=>{try{let t=e?.apiBase,r=await te({apiBase:pi(e?.status??await U(),t)});K.getState().beginBrowserAuth({sessionId:r.sessionId,verificationUri:r.verificationUri,expiresAt:r.expiresAt,intervalMs:r.intervalMs,statusMessage:n(`remoteBrowserAuthWaiting`)}),window.open(r.verificationUri,`_blank`,`noopener,noreferrer`)||K.getState().setAuthStatusMessage(n(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let t=e instanceof Error?e.message:n(`remoteBrowserAuthStartFailed`);this.rejectBrowserSignIn(e),C.error(`${n(`remoteBrowserAuthStartFailed`)}: ${t}`)}},this.resumeBrowserSignIn=()=>{let e=K.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await oe(),this.rejectBrowserSignIn(Error(`Signed out before browser sign-in completed.`)),K.getState().clearBrowserAuth(),await W(),C.success(n(`remoteLogoutSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteLogoutFailed`);C.error(`${n(`remoteLogoutFailed`)}: ${t}`)}},this.updateUsername=async e=>{try{await ae({username:e.trim()}),await W(),C.success(n(`remoteAccountUsernameSetSuccess`))}catch(e){let t=e instanceof Error?e.message:n(`remoteAccountUsernameSetFailed`);C.error(`${n(`remoteAccountUsernameSetFailed`)}: ${t}`)}},this.openNextClawWeb=async(e=`/`)=>{let t=hi(await U());if(!t){C.error(n(`remoteOpenWebUnavailable`));return}let r=new URL(e,`${t.replace(/\/+$/,``)}/`).toString();window.open(r,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=K.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=K.getState();if(e.authSessionId)try{let t=await U(),r=await le({sessionId:e.authSessionId,apiBase:pi(t)});if(r.status===`pending`){K.getState().updateBrowserAuth({statusMessage:n(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),this.rejectBrowserSignIn(Error(r.message||n(`remoteBrowserAuthExpired`))),K.getState().clearBrowserAuth(),C.error(r.message||n(`remoteBrowserAuthExpired`));return}K.getState().setAuthStatusMessage(n(`remoteBrowserAuthCompleted`));let i=await W();this.clearPollTimer(),this.resolveBrowserSignIn(i),K.getState().clearBrowserAuth(),C.success(n(`remoteLoginSuccess`))}catch(e){this.clearPollTimer(),this.rejectBrowserSignIn(e),K.getState().clearBrowserAuth();let t=e instanceof Error?e.message:n(`remoteBrowserAuthPollFailed`);C.error(`${n(`remoteBrowserAuthPollFailed`)}: ${t}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.createBrowserSignInCompletion=()=>(this.rejectBrowserSignIn(Error(`Browser sign-in was replaced by a newer request.`)),new Promise((e,t)=>{this.browserSignInCompletion={resolve:e,reject:t}})),this.resolveBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.resolve(e))},this.rejectBrowserSignIn=e=>{let t=this.browserSignInCompletion;t&&(this.browserSignInCompletion=null,t.reject(e instanceof Error?e:Error(String(e))))},this.getBrowserAuthSummary=()=>{let e=K.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?i(e.authExpiresAt):`-`}}}};function Oi({deletePending:e,entry:t,favoritePending:r,onDelete:i,onOpen:a,onToggleFavorite:o}){let[s,c]=(0,k.useState)(!1),[l,u]=(0,k.useState)(!1),d=t.favorite?n(`panelAppsUnfavorite`):n(`panelAppsFavorite`),f=t.lastOpenedAt?`${n(`panelAppsLastOpened`)} ${Ai(t.lastOpenedAt)}`:`${n(`panelAppsUpdated`)} ${Ai(t.updatedAt)}`,p=e=>{e.stopPropagation(),o()},m=()=>{c(!1),u(!0)};return(0,V.jsxs)(`div`,{className:`group w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2.5 py-2.5 transition-colors hover:border-amber-200 hover:bg-amber-50/50`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:a,className:`min-w-0 flex-1 text-left`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-amber-50 text-base text-amber-700`,children:(0,V.jsx)(ji,{icon:t.icon,title:t.title})}),(0,V.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-sm font-medium text-gray-900`,children:t.title})]}),t.description?(0,V.jsx)(`span`,{className:`mt-1.5 block truncate text-xs leading-5 text-gray-600`,children:t.description}):null,(0,V.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] leading-4 text-gray-400`,children:f})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:p,disabled:r,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-amber-500 disabled:opacity-50`,title:d,"aria-label":d,children:(0,V.jsx)(ii,{className:t.favorite?`h-4 w-4 fill-amber-400 text-amber-500`:`h-4 w-4`})}),(0,V.jsxs)(Pe,{open:s,onOpenChange:c,children:[(0,V.jsx)(Ne,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-400 transition-colors hover:bg-white hover:text-gray-700`,"aria-label":n(`panelAppsMoreActions`),disabled:e,children:(0,V.jsx)(Jr,{className:`h-4 w-4`})})}),(0,V.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,V.jsx)(ki,{destructive:!0,disabled:e,icon:ke,label:n(`panelAppsDelete`),onClick:m})})]})]})]}),(0,V.jsx)(_e,{open:l,onOpenChange:u,title:n(`panelAppsDeleteConfirmTitle`),description:`${n(`panelAppsDeleteConfirmDescription`)} ${t.fileName}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:i,onCancel:()=>void 0})]})}function ki({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,V.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,V.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,V.jsx)(`span`,{children:i})]})}function Ai(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=o(a()),r=new Date;return t.toDateString()===r.toDateString()?new Intl.DateTimeFormat(n,{hour:`2-digit`,minute:`2-digit`}).format(t):t.getFullYear()===r.getFullYear()?new Intl.DateTimeFormat(n,{month:`numeric`,day:`numeric`}).format(t):new Intl.DateTimeFormat(n,{year:`2-digit`,month:`numeric`,day:`numeric`}).format(t)}function ji({icon:e,title:t}){return e?Mi(e)?(0,V.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,className:`h-5 w-5 rounded-sm object-contain`,title:t}):(0,V.jsx)(`span`,{className:`max-w-6 truncate text-center leading-none`,children:e}):(0,V.jsx)(Hr,{className:`h-4 w-4`})}function Mi(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}var Ni=[`panel-apps`];function Pi(){return b({queryKey:Ni,queryFn:()=>x.panelApps.listPanelApps(),staleTime:0})}function Fi(){let e=y();return u({mutationFn:({id:e,preferences:t})=>x.panelApps.updatePanelAppPreferences(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:Ni})}})}function Ii(){let e=y();return u({mutationFn:e=>x.panelApps.recordPanelAppOpened(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ni})}})}function Li(){let e=y();return u({mutationFn:e=>x.panelApps.deletePanelApp(e),onSuccess:()=>{e.invalidateQueries({queryKey:Ni})}})}function Ri(e,t){return t===`favorites`?zi(e.filter(e=>e.favorite),`smart`):zi(t===`recent-open`?e.filter(e=>e.lastOpenedAt):e,t)}function zi(e,t){return[...e].sort((e,n)=>Bi(e,n,t))}function Bi(e,t,n){return n===`recent-open`?Wi(e.lastOpenedAt,t.lastOpenedAt)||Vi(e,t):n===`updated`?Wi(e.updatedAt,t.updatedAt)||Vi(e,t):n===`name`?Vi(e,t):Hi(e,t)||Number(t.favorite)-Number(e.favorite)||Vi(e,t)}function Vi(e,t){return e.title.localeCompare(t.title)}function Hi(e,t){return Ui(t)-Ui(e)}function Ui(e){return Math.max(new Date(e.lastOpenedAt??0).getTime(),new Date(e.createdAt).getTime(),new Date(e.updatedAt).getTime())}function Wi(e,t){return new Date(t??0).getTime()-new Date(e??0).getTime()}function Gi({headerContent:e,onOpenPanelApp:t}){let r=Pi(),i=Li(),a=Fi(),o=Ii(),[s,c]=(0,k.useState)(`smart`),l=(0,k.useMemo)(()=>Ri(r.data?.entries??[],s),[r.data?.entries,s]),u=async e=>{try{t(await o.mutateAsync(e.id))}catch{t(e)}},d=e=>{a.mutate({id:e.id,preferences:{favorite:!e.favorite}})},f=e=>{i.mutate(e.id)};return r.isLoading?(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`panelAppsLoading`)}):r.isError?(0,V.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:r.error instanceof Error?r.error.message:n(`panelAppsLoadFailed`)}):(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e??(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`panelAppsTitle`)}),r.data?.panelsPath?(0,V.jsx)(Ce,{delayDuration:250,children:(0,V.jsxs)(we,{children:[(0,V.jsx)(xe,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700`,"aria-label":n(`panelAppsTitle`),children:(0,V.jsx)(Kr,{className:`h-3.5 w-3.5`})})}),(0,V.jsx)(Se,{side:`bottom`,className:`max-w-[320px] break-all font-mono text-xs`,children:r.data.panelsPath})]})}):null]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void r.refetch(),className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefresh`),"aria-label":n(`panelAppsRefresh`),children:(0,V.jsx)(Oe,{className:`h-3.5 w-3.5`})})]}),(0,V.jsx)(`div`,{className:`border-b border-gray-100 px-3 py-2`,children:(0,V.jsx)(Ie,{value:s,onValueChange:e=>c(e),children:(0,V.jsxs)(Fe,{className:`grid h-auto w-full grid-cols-5 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,V.jsx)(E,{value:`smart`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortSmart`)}),(0,V.jsx)(E,{value:`favorites`,className:`px-2 py-1 text-xs`,children:n(`panelAppsFavorites`)}),(0,V.jsx)(E,{value:`recent-open`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortRecentOpen`)}),(0,V.jsx)(E,{value:`updated`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortUpdated`)}),(0,V.jsx)(E,{value:`name`,className:`px-2 py-1 text-xs`,children:n(`panelAppsSortName`)})]})})}),l.length===0?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`panelAppsEmpty`)}):(0,V.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,V.jsx)(`div`,{className:`space-y-1.5`,children:l.map(e=>(0,V.jsx)(Oi,{entry:e,deletePending:i.isPending,favoritePending:a.isPending,onDelete:()=>f(e),onOpen:()=>void u(e),onToggleFavorite:()=>d(e)},e.id))})})]})}var Ki=class{constructor(e){this.authorizationManager=e,this.sessions=new Map,this.handleIframeMessage=({event:e,iframe:t,iframeInstanceId:n,tab:r})=>{this.isBridgeRequest(e.data)&&(!t?.contentWindow||e.source!==t.contentWindow||this.handleBridgeRequest({event:e,iframe:t,iframeInstanceId:n,tab:r},e.data))},this.handleBridgeRequest=async(e,t)=>{try{let n=await this.getSession(e),r=await this.dispatchRequest(n,t);this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!0,data:r})}catch(n){this.postResponse(e,{type:`nextclaw:panel-app-service-actions:response`,requestId:t.requestId,ok:!1,error:this.toBridgeError(n)})}},this.dispatchRequest=async(e,t)=>{switch(t.method){case`list`:return await x.serviceApps.listServiceActions({bridgeSessionToken:e.token});case`requestGrant`:return await this.confirmAndGrant(e,this.requireActionId(t));case`revokeGrant`:return await x.serviceApps.revokeServiceAction(this.requireActionId(t),{bridgeSessionToken:e.token});case`invoke`:return await this.invokeWithAuthorization(e,t);case`agent.send`:return await this.sendAgentMessageWithAuthorization(e,t);case`agent.generateObject`:return await this.generateAgentObjectWithAuthorization(e,t);default:throw Error(`Unsupported panel bridge method: ${String(t.method)}`)}},this.invokeWithAuthorization=async(e,t)=>{let n=this.requireActionId(t);try{return await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}catch(r){if(!(r instanceof S)||r.code!==`AUTHORIZATION_REQUIRED`)throw r;return await this.confirmAndGrant(e,n,this.readOptionalRecord(t.payload?.input)),await x.serviceApps.invokeServiceAction(n,this.readOptionalRecord(t.payload?.input),{bridgeSessionToken:e.token})}},this.sendAgentMessageWithAuthorization=async(e,t)=>{try{return await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:send`),await x.panelApps.sendAgentMessage(this.readAgentSendRequest(t),{bridgeSessionToken:e.token})}},this.generateAgentObjectWithAuthorization=async(e,t)=>{try{return await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}catch(n){if(!(n instanceof S)||n.code!==`AUTHORIZATION_REQUIRED`)throw n;return await this.confirmAndGrantAgentCapability(e,`agent:generateObject`),await x.panelApps.generateAgentObject(this.readGenerateObjectRequest(t),{bridgeSessionToken:e.token})}},this.confirmAndGrantAgentCapability=async(e,t)=>{if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actions:[{actionId:t,actionTitle:t===`agent:send`?`Send agent message`:`Generate object`,actionDescription:t===`agent:send`?`Send a message to a NextClaw Agent session.`:`Send context to a NextClaw Agent session and receive a structured object.`,risk:`write`}]}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});return await x.panelApps.grantAgentCapability(t,{bridgeSessionToken:e.token})},this.confirmAndGrant=async(e,t,n)=>{let r=await this.listGrantCandidateActions(e,t);if(!await this.authorizationManager.requestAuthorization({panelAppId:e.panelAppId,actions:r.map(e=>({actionId:e.id,actionTitle:e.title,actionDescription:e.description,risk:e.risk})),inputPreview:this.createInputPreview(n)}))throw new S({code:`AUTHORIZATION_REJECTED`,message:`Permission rejected for ${t}.`});let i=await x.serviceApps.grantServiceActions(r.map(e=>e.id),{bridgeSessionToken:e.token}),a=i.grants.find(e=>e.actionId===t)??i.grants[0];if(!a)throw Error(`No permission grant returned for ${t}.`);return a},this.listGrantCandidateActions=async(e,t)=>{let n=await x.serviceApps.listServiceActions({bridgeSessionToken:e.token}),r=n.actions.find(e=>e.id===t);if(r&&r.grantState!==`not-granted`)return[r];let i=n.actions.filter(e=>e.grantState===`not-granted`),a=[...i.filter(e=>e.id===t),...i.filter(e=>e.id!==t)];return a.length>0?a:[{appId:r?.appId??t.split(`.`)[0]??t,description:r?.description,id:t,name:r?.name??t,risk:r?.risk??`dangerous`,title:r?.title}]},this.createInputPreview=e=>{if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e,null,2);return t.length>500?`${t.slice(0,500)}...`:t}catch{return`[unserializable input]`}},this.getSession=async e=>{let t=this.readPanelAppId(e.tab.currentUrl),n=`${e.iframeInstanceId}:${t}`,r=this.sessions.get(n);return r||(r=x.panelApps.createBridgeSession({panelAppId:t,tabId:e.tab.id}),this.sessions.set(n,r)),await r},this.readPanelAppId=e=>{let t=new URL(e,window.location.origin),n=/^\/api\/panel-apps\/([^/]+)\/content$/.exec(t.pathname);if(!n?.[1])throw Error(`Current tab is not a Panel App.`);return decodeURIComponent(n[1])},this.requireActionId=e=>{let t=e.payload?.actionId?.trim();if(!t)throw Error(`Panel bridge actionId is required.`);return t},this.readOptionalRecord=e=>{if(e!==void 0)return this.requireRecord(e,`input`)},this.readAgentSendRequest=e=>({payload:this.requireRecord(e.payload?.request,`agent.send request`)}),this.readGenerateObjectRequest=e=>({input:this.requireRecord(e.payload?.input,`generateObject input`)}),this.requireRecord=(e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} is required.`);return e},this.postResponse=(e,t)=>{e.iframe?.contentWindow?.postMessage(t,`*`)},this.toBridgeError=e=>e instanceof S?{code:e.code,message:e.message,details:e.details}:{message:e instanceof Error?e.message:String(e)},this.isBridgeRequest=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`nextclaw:panel-app-service-actions:request`&&typeof t.requestId==`string`&&(t.method===`invoke`||t.method===`agent.send`||t.method===`agent.generateObject`||t.method===`list`||t.method===`requestGrant`||t.method===`revokeGrant`)}}};function qi(){return`service-action-auth-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var Ji=s((e,t)=>({pending:null,requestAuthorization:async n=>await new Promise(r=>{t().pending?.resolve(!1),e({pending:{id:qi(),...n,resolve:r}})}),resolveAuthorization:n=>{let{pending:r}=t();r&&(r.resolve(n),e({pending:null}))}}));function Yi(){let e=Ji(e=>e.pending),t=Ji(e=>e.resolveAuthorization);return(0,V.jsx)(pe,{open:!!e,onOpenChange:e=>{e||t(!1)},children:(0,V.jsxs)(he,{className:`[&>:last-child]:hidden`,children:[(0,V.jsxs)(me,{children:[(0,V.jsxs)(ge,{className:`flex items-center gap-2`,children:[(0,V.jsx)(ti,{className:`h-4 w-4 text-amber-600`}),n(`serviceActionAuthorizationTitle`)]}),(0,V.jsx)(fe,{children:n(`serviceActionAuthorizationDescription`)})]}),e?(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-gray-100 bg-gray-50 p-3 text-sm`,children:[(0,V.jsx)(Zi,{label:n(`serviceActionAuthorizationSource`),value:e.panelAppId}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:n(`serviceActionAuthorizationActions`)}),(0,V.jsx)(`div`,{className:`max-h-64 space-y-2 overflow-auto`,children:e.actions.map(e=>(0,V.jsx)(Xi,{action:e},e.actionId))})]}),e.inputPreview?(0,V.jsx)(Zi,{label:n(`serviceActionAuthorizationInput`),value:e.inputPreview}):null]}):null,(0,V.jsxs)(de,{className:`gap-2 sm:gap-0`,children:[(0,V.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:n(`serviceActionAuthorizationReject`)}),(0,V.jsx)(p,{type:`button`,onClick:()=>t(!0),children:n(`serviceActionAuthorizationAllow`)})]})]})})}function Xi({action:e}){return(0,V.jsxs)(`div`,{className:`space-y-1 rounded border border-gray-200 bg-white px-3 py-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`min-w-0 break-words text-xs font-medium text-gray-900`,children:e.actionTitle??e.actionId}),(0,V.jsx)(`div`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700`,children:e.risk??`dangerous`})]}),(0,V.jsx)(`div`,{className:`break-words text-[11px] text-gray-500`,children:e.actionId}),e.actionDescription?(0,V.jsx)(`div`,{className:`break-words text-xs text-gray-600`,children:e.actionDescription}):null]})}function Zi({label:e,value:t}){return(0,V.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-3`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500`,children:e}),(0,V.jsx)(`div`,{className:`min-w-0 break-words text-xs text-gray-900`,children:t})]})}var Qi=class{constructor(){this.requestAuthorization=async e=>await Ji.getState().requestAuthorization(e)}},$i=[`service-apps`],ea=[`service-actions`],ta=[`service-action-grants`];function na(){return b({queryKey:$i,queryFn:()=>x.serviceApps.listServiceApps()})}function ra(){return b({queryKey:ea,queryFn:()=>x.serviceApps.listServiceActions()})}function ia(){return b({queryKey:ta,queryFn:()=>x.serviceApps.listServiceActionGrants()})}function aa(){let e=y();return u({mutationFn:e=>x.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea})])}})}function oa(){let e=y();return u({mutationFn:e=>x.serviceApps.deleteServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:$i}),e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function sa(){let e=y();return u({mutationFn:e=>x.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:$i})}})}function ca(){let e=y();return u({mutationFn:e=>x.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:ea}),e.invalidateQueries({queryKey:ta})])}})}function la({headerContent:e}){let t=na(),r=ra(),i=ia(),a=oa(),o=aa(),s=sa(),c=ca(),[l,u]=(0,k.useState)({}),d=()=>{t.refetch(),r.refetch(),i.refetch()};if(t.isLoading||r.isLoading||i.isLoading)return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:n(`serviceAppsLoading`)});if(t.isError||r.isError||i.isError){let e=t.error??r.error??i.error;return(0,V.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:n(`serviceAppsLoadFailed`)})}let f=t.data?.entries??[],p=r.data?.actions??[],m=i.data?.grants??[],h=e=>{s.mutateAsync(e).then(t=>{u(n=>({...n,[e]:t.actions}))})};return(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-white`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3`,children:[(0,V.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:e??(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(ei,{className:`h-4 w-4 text-primary`}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:n(`serviceAppsTitle`)})]})}),(0,V.jsx)(Ce,{delayDuration:250,children:(0,V.jsx)(pa,{icon:Oe,label:n(`serviceAppsRefresh`),onClick:d})})]}),f.length===0?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-gray-500`,children:n(`serviceAppsEmpty`)}):(0,V.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3`,children:(0,V.jsx)(`div`,{className:`space-y-3`,children:f.map(e=>(0,V.jsx)(ua,{app:e,actions:l[e.id]??p.filter(t=>t.appId===e.id),grants:m,deletePending:a.isPending,isDiscovering:s.isPending,onDiscover:h,onDelete:e=>void a.mutate(e),onRestart:e=>void o.mutate(e),onRevoke:e=>void c.mutate({actionId:e.actionId,caller:e.caller})},e.id))})})]})}function ua({app:e,actions:t,grants:r,deletePending:i,isDiscovering:a,onDiscover:o,onDelete:s,onRestart:c,onRevoke:l}){let[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(!1),m=e.status!==`starting`&&e.status!==`stopped`,h=e.status===`running`||e.status===`failed`,g=()=>{d(!1),p(!0)};return(0,V.jsx)(Ce,{delayDuration:250,children:(0,V.jsxs)(`section`,{className:`rounded-lg border border-gray-200 bg-white p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.title}),(0,V.jsx)(da,{status:e.status})]}),e.description?(0,V.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-gray-500`,children:e.description}):null,e.lastError?(0,V.jsx)(`div`,{className:`mt-2 rounded bg-rose-50 px-2 py-1 text-xs text-rose-700`,children:e.lastError}):null]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(pa,{disabled:a||!m,icon:Qr,label:n(`serviceAppsDiscoverActions`),tooltip:n(`serviceAppsDiscoverActionsHint`),onClick:()=>o(e.id)}),(0,V.jsx)(pa,{disabled:!h,icon:oi,label:n(`serviceAppsDisconnectRuntime`),tooltip:n(`serviceAppsDisconnectRuntimeHint`),onClick:()=>c(e.id)}),(0,V.jsxs)(Pe,{open:u,onOpenChange:d,children:[(0,V.jsxs)(we,{children:[(0,V.jsx)(xe,{asChild:!0,children:(0,V.jsx)(Ne,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50`,"aria-label":n(`serviceAppsMoreActions`),disabled:i,children:(0,V.jsx)(Jr,{className:`h-3.5 w-3.5`})})})}),(0,V.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n(`serviceAppsMoreActions`)})]}),(0,V.jsx)(Me,{align:`end`,className:`w-48 rounded-xl p-1.5`,children:(0,V.jsx)(ma,{destructive:!0,disabled:i,icon:ke,label:n(`serviceAppsDelete`),onClick:g})})]})]})]}),(0,V.jsx)(ha,{app:e}),(0,V.jsx)(`div`,{className:`mt-3 space-y-1`,children:t.map(e=>(0,V.jsx)(_a,{action:e,grants:r.filter(t=>t.actionId===e.id),onRevoke:l},e.id))}),(0,V.jsx)(_e,{open:f,onOpenChange:p,title:n(`serviceAppsDeleteConfirmTitle`),description:`${n(`serviceAppsDeleteConfirmDescription`)} ${e.title}`,confirmLabel:n(`delete`),variant:`destructive`,onConfirm:()=>s(e.id),onCancel:()=>void 0})]})})}function da({status:t}){let n=fa(t),r=n.icon;return(0,V.jsxs)(we,{children:[(0,V.jsx)(xe,{asChild:!0,children:(0,V.jsxs)(`span`,{className:e(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium`,n.className),"aria-label":n.label,children:[(0,V.jsx)(r,{className:e(`h-3 w-3`,n.iconClassName)}),(0,V.jsx)(`span`,{children:n.label})]})}),(0,V.jsx)(Se,{side:`bottom`,className:`text-xs`,children:n.tooltip})]})}function fa(e){switch(e){case`running`:return{className:`bg-emerald-50 text-emerald-700`,icon:Wr,label:n(`serviceAppsStatus_running`),tooltip:n(`serviceAppsStatusHint_running`)};case`starting`:return{className:`bg-blue-50 text-blue-700`,icon:be,iconClassName:`animate-spin`,label:n(`serviceAppsStatus_starting`),tooltip:n(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`bg-rose-50 text-rose-700`,icon:ai,label:n(`serviceAppsStatus_failed`),tooltip:n(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`bg-gray-100 text-gray-600`,icon:qr,label:n(`serviceAppsStatus_stopped`),tooltip:n(`serviceAppsStatusHint_stopped`)};default:return{className:`bg-slate-100 text-slate-600`,icon:Gr,label:n(`serviceAppsStatus_idle`),tooltip:n(`serviceAppsStatusHint_idle`)}}}function pa({disabled:e=!1,icon:t,label:n,tooltip:r=n,onClick:i}){return(0,V.jsxs)(we,{children:[(0,V.jsx)(xe,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,onClick:i,disabled:e,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:text-gray-300 disabled:opacity-60 disabled:hover:bg-transparent`,"aria-label":n,children:(0,V.jsx)(t,{className:`h-3.5 w-3.5`})})}),(0,V.jsx)(Se,{side:`bottom`,className:`max-w-56 text-xs`,children:r})]})}function ma({destructive:t=!1,disabled:n=!1,icon:r,label:i,onClick:a}){return(0,V.jsxs)(`button`,{type:`button`,className:e(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,t?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),disabled:n,onClick:a,children:[(0,V.jsx)(r,{className:`h-4 w-4 shrink-0`}),(0,V.jsx)(`span`,{children:i})]})}function ha({app:e}){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `),r=[{label:n(`serviceAppsCommand`),value:t},{label:n(`serviceAppsCwd`),value:e.cwd},{label:n(`serviceAppsManifest`),value:e.manifestPath},{label:n(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:n(`serviceAppsLastReady`),value:e.lastReadyAt},{label:n(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value);return r.length===0?null:(0,V.jsx)(`dl`,{className:`mt-3 grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 border-t border-gray-100 pt-2 text-[11px]`,children:r.map(e=>(0,V.jsx)(ga,{label:e.label,value:e.value},e.label))})}function ga({label:e,value:t}){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`text-gray-400`,children:e}),(0,V.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-gray-500`,title:t,children:t})]})}function _a({action:e,grants:t,onRevoke:r}){return(0,V.jsxs)(`div`,{className:`rounded bg-gray-50 px-2 py-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(si,{className:`h-3.5 w-3.5 shrink-0 text-gray-400`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate text-xs font-medium text-gray-800`,children:e.title??e.name}),e.description?(0,V.jsx)(`div`,{className:`truncate text-[11px] text-gray-500`,children:e.description}):null]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,V.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:n(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,V.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-gray-600`,children:e.risk})]})]}),t.map(e=>(0,V.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2 pl-5`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-gray-500`,children:[(0,V.jsx)(ni,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,V.jsxs)(`span`,{className:`truncate`,children:[n(`serviceAppsGrantedTo`),` `,e.caller.appId]})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`rounded-md p-1 text-gray-400 transition-colors hover:bg-white hover:text-rose-600`,title:n(`serviceAppsRevokeGrant`),"aria-label":n(`serviceAppsRevokeGrant`),children:(0,V.jsx)(ke,{className:`h-3 w-3`})})]},`${e.caller.surface}:${e.caller.appId}:${e.actionId}`))]})}function va({activeTab:e,onActiveTabChange:t,onOpenPanelApp:r}){let i=(0,V.jsx)(Ie,{value:e,onValueChange:e=>t(e),children:(0,V.jsxs)(Fe,{className:`grid h-auto w-[min(340px,100%)] grid-cols-2 rounded-lg bg-gray-100/70 p-0.5`,children:[(0,V.jsxs)(E,{value:`panel-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,V.jsx)(Hr,{className:`h-3.5 w-3.5`}),n(`panelAppsTitle`)]}),(0,V.jsxs)(E,{value:`service-apps`,className:`gap-1.5 px-2 py-1.5 text-xs`,children:[(0,V.jsx)(ei,{className:`h-3.5 w-3.5`}),n(`serviceAppsTitle`)]})]})});return(0,V.jsx)(`div`,{className:`h-full min-h-0 bg-white`,children:e===`panel-apps`?(0,V.jsx)(Gi,{headerContent:i,onOpenPanelApp:r}):(0,V.jsx)(la,{headerContent:i})})}function ya({onOpenApps:e,onRefresh:t}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2 bg-white border-b border-gray-100 shrink-0`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,children:[(0,V.jsx)(ve,{className:`h-3.5 w-3.5`}),n(`appsTitle`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md p-1.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-800`,title:n(`panelAppsRefreshCurrent`),"aria-label":n(`panelAppsRefreshCurrent`),children:(0,V.jsx)(Oe,{className:`h-3.5 w-3.5`})})]})}function ba(e){return e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0)}function q(e){let t=e.trim();try{let e=new URL(t);return{authority:e.hostname,pathSegments:ba(e.pathname),pathname:e.pathname,raw:t,scheme:e.protocol.replace(/:$/,``).toLowerCase(),searchParams:e.searchParams}}catch{return{authority:``,pathSegments:ba(t),pathname:t,raw:t,scheme:``,searchParams:new URLSearchParams}}}var xa=class{constructor(e,t){this.routeDefinitions=e,this.options=t,this.resolve=e=>{let t=q(e);return this.findDefinition(t).resolve(t)},this.normalize=e=>this.options.getNormalizedUri(this.resolve(e)),this.areEquivalent=(e,t)=>this.findDefinition(q(e)).areEquivalent?.(e,t)??this.normalize(e)===this.normalize(t),this.findDefinition=e=>{let t=this.routeDefinitions.find(t=>t.match(e));if(!t)throw Error(`Unsupported resource URI: ${e.raw}`);return t}}},Sa=`home`,Ca=`nextclaw://new-tab`,wa=`apps`,J=`nextclaw://apps`,Ta=`${J}?tab=service-apps`,Ea=`panel-app`,Da=`panel-apps`;function Oa(e){return e===`panel-apps`||e===`service-apps`}function ka(e=Da){return e===Da?J:Ta}function Aa(e){try{let t=new URL(e).searchParams.get(`tab`);return Oa(t)?t:Da}catch{return Da}}function ja(e){return ka(Aa(e))}function Ma(e){return`nextclaw://panel-app/${encodeURIComponent(e)}`}function Na(e){return e.startsWith(`data:image/`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)}function Pa(e){let t=e.icon?.trim();if(t)return Na(t)?{type:`url`,url:t}:{type:`text`,value:t}}function Fa(e){return{dedupeKey:`panel-app:${e.id}`,dockIcon:Pa(e),historyPolicy:`managed`,kind:Ea,resourceUri:Ma(e.id),title:e.title,url:e.contentPath}}function Ia(e,t){return e===t||e.startsWith(`${t}?`)||e.startsWith(`${t}/`)}function La(e){let t=e.pathSegments.join(`/`);return ze(t?`/${t}`:`/`,`docs`)}function Ra(e){let t=e.filter(e=>e.trim().length>0).map(e=>encodeURIComponent(decodeURIComponent(e))).join(`/`);return t?`nextclaw://docs/${t}`:`nextclaw://docs`}function za(e){let t=O(e),n=t.startsWith(`/`)?t:(()=>{try{return new URL(e).pathname}catch{return``}})();return n?Ra(n.split(`/`)):`nextclaw://docs`}function Y(e){if(e.scheme===`nextclaw`&&e.authority===`panel-app`)return e.pathSegments[0]??``;let[t,n,r,i]=e.pathSegments;return t===`api`&&n===`panel-apps`&&r!==void 0&&r.length>0&&i===`content`?r:``}function Ba(e){return Y(e).length>0}function Va(e){let t=Y(e);return t?`/api/panel-apps/${encodeURIComponent(decodeURIComponent(t))}/content`:`nextclaw://panel-app`}function Ha(e){let t=Y(e);return t?`nextclaw://panel-app/${encodeURIComponent(decodeURIComponent(t))}`:`nextclaw://panel-app`}function Ua(e,t){let n=q(e),r=q(t),i=Y(n),a=Y(r);return i.length>0&&a.length>0?decodeURIComponent(i)===decodeURIComponent(a):e===t}var X=[{defaultUrl:()=>Ca,id:`home`,kind:Sa,match:e=>e.raw===Ca,resolve:()=>({historyPolicy:`managed`,kind:Sa,resourceUri:Ca,title:n(`docBrowserHomeTitle`),url:Ca}),areEquivalent:(e,t)=>e===t},{defaultUrl:Re,id:`docs-url`,kind:`docs`,match:e=>He(e.raw),resolve:e=>{let t=ze(e.raw,`docs`);return{historyPolicy:`managed`,kind:`docs`,resourceUri:za(t),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>O(e)===O(t)},{defaultUrl:Re,id:`nextclaw-docs`,kind:`docs`,match:e=>e.scheme===`nextclaw`&&e.authority===`docs`,resolve:e=>{let t=La(e);return{historyPolicy:`managed`,kind:`docs`,resourceUri:Ra(e.pathSegments),title:n(`docBrowserHelp`),url:t}},areEquivalent:(e,t)=>O(e)===O(t)},{defaultUrl:()=>J,id:`apps`,kind:wa,match:e=>Ia(e.raw,J),resolve:e=>{let t=ja(e.raw);return{dedupeKey:`apps`,historyPolicy:`managed`,kind:wa,resourceUri:t,title:n(t===`nextclaw://apps`?`appsTitle`:`serviceAppsTitle`),url:t}},areEquivalent:(e,t)=>ja(e)===ja(t)},{defaultUrl:()=>`nextclaw://panel-app`,id:`panel-app`,kind:Ea,match:e=>e.scheme===`nextclaw`&&e.authority===`panel-app`||Ba(e),resolve:e=>{let t=Va(e),r=Y(e);return{dedupeKey:r?`panel-app:${decodeURIComponent(r)}`:void 0,historyPolicy:`managed`,kind:Ea,resourceUri:Ha(e),title:n(`panelAppsTitle`),url:t}},areEquivalent:Ua},{defaultUrl:()=>`about:blank`,id:`content`,kind:`content`,match:()=>!0,resolve:e=>({historyPolicy:`managed`,kind:`content`,resourceUri:e.raw||`about:blank`,title:Ge(e.raw,`content`,`Detail`),url:e.raw||`about:blank`}),areEquivalent:(e,t)=>e===t}],Wa=X.map(e=>({areEquivalent:e.areEquivalent,id:e.id,match:e.match,resolve:e.resolve}));function Ga(){return[{id:`apps`,label:n(`appsTitle`),target:{type:`right-panel-resource`,uri:J}},{id:`service-apps`,label:n(`serviceAppsTitle`),target:{type:`right-panel-resource`,uri:Ta}},{id:`docs`,label:n(`docBrowserHelp`),target:{options:{newTab:!0},type:`right-panel-resource`,uri:Re()}},{id:`skill-marketplace`,label:n(`marketplaceSkillsPageTitle`),target:{path:`/marketplace/skills`,type:`app-route`}}]}var Ka={apps:{accentClassName:`bg-emerald-50 text-emerald-700`,hoverAccentClassName:`group-hover:bg-emerald-100`,icon:(0,V.jsx)(Te,{className:`h-5 w-5`})},"service-apps":{accentClassName:`bg-sky-50 text-sky-700`,hoverAccentClassName:`group-hover:bg-sky-100`,icon:(0,V.jsx)(Yr,{className:`h-5 w-5`})},docs:{accentClassName:`bg-amber-50 text-amber-700`,hoverAccentClassName:`group-hover:bg-amber-100`,icon:(0,V.jsx)(ye,{className:`h-5 w-5`})},"skill-marketplace":{accentClassName:`bg-rose-50 text-rose-700`,hoverAccentClassName:`group-hover:bg-rose-100`,icon:(0,V.jsx)(Ur,{className:`h-5 w-5`})}};function qa(e){return Ka[e.id]??{accentClassName:`bg-gray-50 text-gray-700`,hoverAccentClassName:`group-hover:bg-gray-100`,icon:(0,V.jsx)(Te,{className:`h-5 w-5`})}}function Ja({open:t}){let n=an(),r=Ga(),i=e=>{if(e.type===`app-route`){n(e.path);return}t(e.uri,e.options)};return(0,V.jsx)(`div`,{className:`h-full overflow-auto bg-background px-4 py-5`,children:(0,V.jsx)(`div`,{className:`mx-auto w-full max-w-[520px]`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fit,minmax(76px,1fr))] gap-x-2 gap-y-4`,children:r.map(t=>{let n=qa(t);return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(t.target),className:`group flex min-h-[68px] flex-col items-center gap-1.5 rounded-md px-1.5 py-1.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,V.jsx)(`span`,{className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-md transition-colors`,n.accentClassName,n.hoverAccentClassName),children:n.icon}),(0,V.jsx)(`span`,{className:`line-clamp-2 min-w-0 max-w-full text-xs font-medium leading-snug text-gray-700 transition-colors group-hover:text-gray-900`,children:t.label})]},t.id)})})})})}function Ya(e){return e&&He(e)?`docs`:`content`}var Xa=class{constructor(){this.resourceUriResolver=new xa(Wa,{getNormalizedUri:e=>e.resourceUri??e.url}),this.resolve=e=>this.resourceUriResolver.resolve(e),this.normalize=e=>this.resourceUriResolver.normalize(e),this.areEquivalent=(e,t)=>this.resourceUriResolver.areEquivalent(e,t),this.resolveOpenTarget=e=>{let{activeTab:t,kind:n,url:r}=e,i=this.resolveRouteDefinition(r,n,t),a=r?.trim()||(!n&&t&&t.kind!==`docs`?t.currentUrl:i.defaultUrl());return i.resolve(q(a))},this.areUrlsEquivalent=(e,t,n,r)=>n===r?this.resolveRouteDefinition(e,n).areEquivalent?.(e,t)??this.areEquivalent(e,t):!1,this.usesManagedHistory=e=>this.resolveRouteDefinition(e.currentUrl,e.kind).resolve(q(e.currentUrl)).historyPolicy===`managed`,this.resolveRouteDefinition=(e,t,n)=>{let r=t??(e?void 0:n?.kind),i=r?X.find(e=>e.kind===r):void 0;if(i)return i;let a=e?q(e):null,o=a?X.find(e=>e.match(a)):void 0;if(o)return o;let s=t??n?.kind??Ya(e);return X.find(e=>e.kind===s)??X[X.length-1]}}},Za=wa,Qa=Ea,$a=`panel-apps`,eo=[`allow-scripts`,`allow-forms`,`allow-modals`,`allow-popups`,`allow-popups-to-escape-sandbox`,`allow-downloads`,`allow-pointer-lock`,`allow-presentation`].join(` `);function to(e){return e===`panel-apps`||e===`service-apps`}function no(e=$a){return e===$a?J:Ta}function ro(e){try{let t=new URL(e).searchParams.get(`tab`);return to(t)?t:$a}catch{return $a}}function io(e){e.open(no(),{kind:Za,title:n(`appsTitle`),dedupeKey:`apps`})}var ao={[Sa]:{getTitle:()=>n(`docBrowserHomeTitle`),renderContent:({open:e})=>(0,V.jsx)(Ja,{open:e})},[Za]:{getTitle:()=>n(`appsTitle`),renderIcon:()=>(0,V.jsx)(Te,{className:`w-4 h-4 text-primary shrink-0`}),renderContent:({currentUrl:e,open:t,openTarget:r})=>(0,V.jsx)(va,{activeTab:ro(e),onActiveTabChange:e=>t(no(e),{activate:!1,kind:Za,title:n(`appsTitle`),dedupeKey:`apps`}),onOpenPanelApp:e=>r(Fa(e))})},[Qa]:{getIframeSandbox:()=>eo,getTitle:e=>e.title||n(`panelAppsTitle`),onIframeMessage:e=>Xo().panelAppBridgeManager.handleIframeMessage(e),renderIcon:()=>(0,V.jsx)(Hr,{className:`w-4 h-4 text-primary shrink-0`}),renderToolbar:({open:e,refreshIframe:t})=>(0,V.jsx)(ya,{onOpenApps:()=>io({open:e}),onRefresh:t})}},oo=`nextclaw://docs`;function so(){return[{builtIn:!0,icon:{type:`builtin`,name:`apps`},id:`apps`,label:n(`appsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:J}},{builtIn:!0,icon:{type:`builtin`,name:`service-apps`},id:`service-apps`,label:n(`serviceAppsTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ta}},{builtIn:!0,icon:{type:`builtin`,name:`docs`},id:`docs`,label:n(`docBrowserHelp`),removable:!1,target:{type:`right-panel-resource`,uri:oo}},{builtIn:!0,icon:{type:`builtin`,name:`new-tab`},id:`new-tab`,label:n(`docBrowserHomeTitle`),removable:!1,target:{type:`right-panel-resource`,uri:Ca}}]}var co=[`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`];function lo(e){return!!e&&typeof e==`object`}function uo(e){return co.includes(e)}function fo(e){return!lo(e)||typeof e.type!=`string`?null:e.type===`builtin`&&uo(e.name)?{type:`builtin`,name:e.name}:e.type===`url`&&typeof e.url==`string`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e.type===`text`&&typeof e.value==`string`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function po(e){if(!lo(e)||typeof e.id!=`string`||e.id.trim().length===0||typeof e.label!=`string`||e.label.trim().length===0||typeof e.createdAt!=`string`||e.createdAt.trim().length===0||!lo(e.target)||e.target.type!==`right-panel-resource`||typeof e.target.uri!=`string`||e.target.uri.trim().length===0)return null;let t=fo(e.icon);return t?{createdAt:e.createdAt,icon:t,id:e.id.trim(),label:e.label.trim(),target:{type:`right-panel-resource`,uri:e.target.uri.trim()}}:null}function mo(e){if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let n=po(e);n&&t.set(n.id,n)}),Array.from(t.values())}function ho(e,t){return{createdAt:t,icon:e.icon,id:e.id,label:e.label,target:e.target}}function go(e){return{builtIn:!1,icon:e.icon,id:e.id,label:e.label,removable:!0,target:e.target}}function _o(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(e.map(e=>e.target.uri)),i=t.filter(e=>!n.has(e.id)&&!r.has(e.target.uri)).map(go);return[...e,...i]}var vo=`nextclaw.side-dock.state`,yo=1;function bo(e){return!!e&&typeof e==`object`}var xo=s()(Le(e=>({pinnedItems:[],setPinnedItems:t=>e({pinnedItems:mo(t)})}),{name:vo,version:yo,storage:qe(()=>window.localStorage),partialize:e=>({pinnedItems:e.pinnedItems}),merge:(e,t)=>{let n=bo(e)?mo(e.pinnedItems):[];return{...t,pinnedItems:n}}})),So={apps:Te,docs:ye,"new-tab":De,"panel-app":Hr,"service-apps":Hr};function Co({icon:e}){if(e.type===`url`)return(0,V.jsx)(`img`,{src:e.url,alt:``,className:`h-5 w-5 rounded object-cover`});if(e.type===`text`)return(0,V.jsx)(`span`,{className:`max-w-7 truncate text-center text-[13px] font-semibold leading-none`,"aria-hidden":`true`,children:e.value});let t=So[e.name];return(0,V.jsx)(t,{className:`h-5 w-5`,"aria-hidden":`true`})}function wo({active:t,item:r,onOpen:i,onUnpin:a}){let{label:o}=r;return(0,V.jsxs)(we,{children:[(0,V.jsxs)(`div`,{className:`group relative`,children:[(0,V.jsx)(xe,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-label":o,title:o,"data-side-dock-item-id":r.id,onClick:()=>i(r),className:e(`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors`,`hover:bg-primary/10 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?`bg-primary/10 text-primary`:`bg-transparent`),children:(0,V.jsx)(Co,{icon:r.icon})})}),r.removable?(0,V.jsx)(`button`,{type:`button`,"aria-label":n(`sideDockUnpinItem`),title:n(`sideDockUnpinItem`),onClick:e=>{e.stopPropagation(),a(r)},className:`absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full bg-background text-muted-foreground shadow-sm ring-1 ring-border/70 transition-colors hover:bg-muted hover:text-foreground group-hover:flex focus-visible:flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,V.jsx)(Ae,{className:`h-3 w-3`,"aria-hidden":`true`})}):null]}),(0,V.jsx)(Se,{side:`left`,children:o})]})}function Z(e){return e?.trim()??``}function To(e,t,n,r=!1){if(!t||!n)return!1;let i=Z(e.target.uri),a=Z(n.resourceUri);return a&&a===i||Z(n.currentUrl)===i?!0:r?!1:e.id===`docs`&&n.kind===`docs`}function Eo(e,t){if(!t)return!1;let n=Z(t.resourceUri),r=Z(t.currentUrl);return e.some(e=>{let t=Z(e.target.uri);return t===n||t===r})}function Do({manager:e}){let t=xo(e=>e.pinnedItems),{currentTab:n,isOpen:r}=Ue(),i=_o(so(),t),a=Eo(i,n);return(0,V.jsx)(Ce,{delayDuration:250,children:(0,V.jsx)(`aside`,{"data-testid":`side-dock`,className:`z-30 flex h-full w-14 shrink-0 flex-col items-center gap-1 border-l border-border/60 bg-background/95 px-2 py-3`,children:i.map(t=>(0,V.jsx)(wo,{active:To(t,r,n,a),item:t,onOpen:e.openItem,onUnpin:t=>e.unpinItem(t.id)},t.id))})})}var Oo=`pinned`,ko=new Set([`apps`,`docs`,`new-tab`,`panel-app`,`service-apps`]);function Q(e){return e.trim()}function Ao(e){let t=0;return Array.from(Q(e)).forEach(e=>{t=t*31+e.charCodeAt(0)>>>0}),`${Oo}-${Q(e).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()||`resource`}-${t.toString(36)}`}function jo(e){return e?.type===`builtin`&&ko.has(e.name)?{type:`builtin`,name:e.name}:e?.type===`url`&&e.url.trim().length>0?{type:`url`,url:e.url.trim()}:e?.type===`text`&&e.value.trim().length>0?{type:`text`,value:e.value.trim()}:null}function Mo(e){return e.kind===`docs`?`docs`:e.kind===`home`?`new-tab`:e.kind===`apps`?e.resourceUri?.includes(`service-apps`)?`service-apps`:`apps`:e.kind===`panel-app`?`panel-app`:`apps`}var No=class{constructor(e){this.docBrowserManager=e,this.getItems=()=>_o(so(),xo.getState().pinnedItems),this.openItem=e=>{e.target.type===`right-panel-resource`&&this.docBrowserManager.open(e.target.uri,{dockIcon:e.icon,title:e.label})},this.getDockState=e=>{let t=this.getTabResourceUri(e);if(!t)return{canDock:!1,isDocked:!1,removable:!1};let n=this.findItemByUri(t);return{canDock:!0,isDocked:!!n,removable:n?.removable===!0}},this.pinTab=(e,t=new Date().toISOString())=>{let n=this.getTabResourceUri(e);!e||!n||this.findItemByUri(n)||this.pinItem({builtIn:!1,icon:jo(e.dockIcon)??{type:`builtin`,name:Mo(e)},id:Ao(n),label:e.title.trim()||n,removable:!0,target:{type:`right-panel-resource`,uri:n}},t)},this.unpinTab=e=>{let t=this.getTabResourceUri(e),n=t?this.findItemByUri(t):void 0;n?.removable&&this.unpinItem(n.id)},this.pinItem=(e,t=new Date().toISOString())=>{if(!e.removable)return;let n=Q(e.target.uri);this.setPinnedItems(r=>r.some(t=>t.id===e.id||Q(t.target.uri)===n)?r:[...r,ho({...e,target:{...e.target,uri:n}},t)])},this.unpinItem=e=>{this.setPinnedItems(t=>t.filter(t=>t.id!==e))},this.reorderPinnedItems=e=>{this.setPinnedItems(t=>{let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e)).filter(e=>e!==void 0),i=new Set(r.map(e=>e.id)),a=t.filter(e=>!i.has(e.id));return[...r,...a]})},this.setPinnedItems=e=>{let{pinnedItems:t,setPinnedItems:n}=xo.getState();n(e(t))},this.getTabResourceUri=e=>{let t=e?.resourceUri??e?.currentUrl,n=t?Q(t):``;return n.length>0?n:null},this.findItemByUri=e=>{let t=Q(e);return this.getItems().find(e=>Q(e.target.uri)===t)}}},Po=new class{constructor(){this.resolveOpenTarget=e=>{let{activeTab:t,kind:r,url:i}=e,a=r??(i?void 0:t?.kind)??(i&&He(i)?`docs`:`home`),o=i?.trim()||(!r&&t&&t.kind!==`docs`?t.currentUrl:a===`home`?`nextclaw://new-tab`:a===`docs`?Re():`about:blank`),s=a===`docs`?ze(o,`docs`):o;return{historyPolicy:`managed`,kind:a,title:a===`home`?n(`docBrowserHomeTitle`):Ge(s,a,a===`docs`?n(`docBrowserHelp`):`Detail`),url:s}},this.areUrlsEquivalent=(e,t,n,r)=>n===r?n===`docs`?O(e)===O(t):e===t:!1,this.usesManagedHistory=e=>e.currentUrl!==Ve}};function Fo(e,t,n){return{...e,tabs:e.tabs.map(e=>e.id===t?n(e):e)}}function Io(e,t){return Fo(e,e.activeTabId,t)}function Lo(e,t){let n=[...e.history.slice(0,e.historyIndex+1),t];return{history:n,historyIndex:n.length-1}}function Ro(e,t,n){let r=t.resourceUri??t.url,i=n.resourceUri??n.url;return t.tabId===n.tabId&&t.kind===n.kind&&e.areUrlsEquivalent(r,i,t.kind,n.kind)}function zo(e,t){return{kind:t.kind,resourceUri:t.resourceUri??t.url,tabId:e,url:t.url}}function $(e,t,n){let r=t.activeHistory[t.activeHistoryIndex];if(r&&Ro(e,r,n))return t;let i=[...t.activeHistory.slice(0,t.activeHistoryIndex+1),n];return{...t,activeHistory:i,activeHistoryIndex:i.length-1}}function Bo(e,t,n){for(let r=t.history.length-1;r>=0;--r)if(e.areUrlsEquivalent(t.history[r],n,t.kind,t.kind))return r;return-1}function Vo(e,t,n){let r=t.tabs.find(e=>e.id===n.tabId);if(!r)return t;let i=n.resourceUri??n.url,a=e.resolveOpenTarget({activeTab:r,kind:n.kind,url:i}),o=Bo(e,r,a.url),s=n.resourceUri!==void 0&&n.resourceUri===r.resourceUri;return Fo({...t,activeTabId:r.id,isOpen:!0},r.id,e=>({...e,currentUrl:a.url,dedupeKey:a.dedupeKey,dockIcon:a.dockIcon??e.dockIcon,historyIndex:o>=0?o:e.historyIndex,kind:a.kind,resourceUri:a.resourceUri??a.url,title:s?e.title:a.title}))}function Ho(e,t,n,r,i){let a={...t,title:r?.title||n.title||t.title,kind:n.kind,resourceUri:n.resourceUri??n.url,dockIcon:r?.dockIcon??n.dockIcon,dedupeKey:i};return e.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?a:{...a,currentUrl:n.url,...Lo(t,n.url),navVersion:t.navVersion+1}}function Uo(e,t){return!e.isOpen&&e.tabs.length===1&&t?.kind===`home`&&t.currentUrl===`nextclaw://new-tab`}function Wo(e,t,n,r){let{activate:i,dedupeKey:a,newTab:o,title:s}=r??{},c=a?.trim()||n.dedupeKey,l=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0],u=c?t.tabs.find(e=>e.dedupeKey===c):void 0;if(u){let a=Fo(t,u.id,t=>Ho(e,t,n,r,c)),o=i!==!1,s=o?u.id:t.activeTabId,l={...a,activeTabId:s,isOpen:!0};return o||u.id===t.activeTabId?$(e,l,zo(u.id,n)):l}if(o||c||!l||l.kind!==n.kind){let i=We(n.url,n.kind,s??n.title,c,n.resourceUri??n.url,r?.dockIcon??n.dockIcon);return Uo(t,l)?{...t,isOpen:!0,tabs:[i],activeTabId:i.id,activeHistory:[D(i)],activeHistoryIndex:0}:$(e,{...t,isOpen:!0,tabs:[...t.tabs,i],activeTabId:i.id},D(i))}return $(e,{...Io(t,t=>Ho(e,t,n,r,c)),isOpen:!0},zo(t.activeTabId,n))}function Go(e,t,n,r){let i=t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[0];return Wo(e,t,e.resolveOpenTarget({activeTab:i,kind:r?.kind,url:n}),r)}var Ko=class{constructor(e=Po){this.routeResolver=e,this.setSnapshot=e=>{Ke.getState().setSnapshot(e)},this.open=(e,t)=>{this.setSnapshot(n=>Go(this.routeResolver,n,e,t))},this.openTarget=(e,t)=>{this.setSnapshot(n=>Wo(this.routeResolver,n,e,{...t,dedupeKey:t?.dedupeKey??e.dedupeKey,kind:t?.kind??e.kind,title:t?.title??e.title}))},this.openNewTab=()=>{this.open(void 0,{kind:Je,newTab:!0})},this.close=()=>{this.setSnapshot(e=>({...e,isOpen:!1}))},this.toggleMode=()=>{this.setSnapshot(e=>({...e,mode:e.mode===`floating`?`docked`:`floating`}))},this.navigate=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=We(Re(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id,isOpen:!0}}let n=Io(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Lo(t,n.url),kind:n.kind,navVersion:t.navVersion+1,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.syncUrl=e=>{this.setSnapshot(t=>{if(!t.tabs.length){let e=We(Re(),`docs`,`Docs`);return{...t,tabs:[e],activeTabId:e.id}}let n=Io(t,t=>{if(!this.routeResolver.usesManagedHistory(t))return t;let n=this.routeResolver.resolveOpenTarget({activeTab:t,kind:t.kind,url:e});return this.routeResolver.areUrlsEquivalent(t.currentUrl,n.url,t.kind,n.kind)?t:{...t,currentUrl:n.url,dedupeKey:n.dedupeKey,dockIcon:n.dockIcon,...Lo(t,n.url),kind:n.kind,resourceUri:n.resourceUri??n.url,title:n.title}}),r=n.tabs.find(e=>e.id===n.activeTabId);return r?$(this.routeResolver,n,D(r)):n})},this.goBack=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex<=0)return e;let t=e.activeHistoryIndex-1,n=e.activeHistory[t];return n?Vo(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.goForward=()=>{this.setSnapshot(e=>{if(e.activeHistoryIndex>=e.activeHistory.length-1)return e;let t=e.activeHistoryIndex+1,n=e.activeHistory[t];return n?Vo(this.routeResolver,{...e,activeHistoryIndex:t},n):e})},this.closeTab=e=>{this.setSnapshot(t=>{if(t.tabs.length<=1)return{...Be(),isOpen:!1};let n=t.tabs.findIndex(t=>t.id===e);if(n<0)return t;let r=t.tabs.filter(t=>t.id!==e),i=t.activeTabId===e?r[Math.max(0,n-1)]?.id??r[0].id:t.activeTabId,a={...t,tabs:r,activeTabId:i},o=a.activeHistory.filter(t=>t.tabId!==e),s=a.activeHistory.slice(0,a.activeHistoryIndex+1).filter(t=>t.tabId!==e),c=r.find(e=>e.id===i)??r[0],l={...a,activeHistory:o.length>0?o:[D(c)],activeHistoryIndex:Math.min(Math.max(0,s.length-1),Math.max(0,o.length-1))};return t.activeTabId===e?$(this.routeResolver,l,D(c)):l})},this.setActiveTab=e=>{this.setSnapshot(t=>{if(!t.tabs.some(t=>t.id===e))return t;let n=t.tabs.find(t=>t.id===e);return n?$(this.routeResolver,{...t,activeTabId:e,isOpen:!0},D(n)):t})}}},qo=class{constructor(){this.accountManager=new Di,this.rightPanelResourceRouteResolver=new Xa,this.docBrowserManager=new Ko(this.rightPanelResourceRouteResolver),this.sideDockManager=new No(this.docBrowserManager),this.serviceActionAuthorizationManager=new Qi,this.panelAppBridgeManager=new Ki(this.serviceActionAuthorizationManager),this.remoteAccessManager=new gi({accountManager:this.accountManager})}},Jo=null;function Yo(){return Jo??=new qo,Jo}function Xo(){return Yo()}var Zo=(0,k.createContext)(null);function Qo({children:e}){let t=(0,k.useMemo)(()=>Yo(),[]);return(0,V.jsx)(Zo.Provider,{value:t,children:e})}function $o(){let e=(0,k.useContext)(Zo);if(!e)throw Error(`useAppPresenter must be used inside AppPresenterProvider`);return e}export{wr as A,ai as C,Wr as D,Jr as E,Fn as F,B as I,an as L,Tr as M,Mn as N,Ur as O,Nn as P,sn as R,si as S,$r as T,W as _,xo as a,li as b,Yi as c,xi as d,bi as f,U as g,ui as h,Do as i,jn as j,xr as k,Ei as l,G as m,$o as n,ao as o,gi as p,Xo as r,io as s,Qo as t,Ti as u,pi as v,ni as w,ci as x,hi as y,Qe as z};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-WjhKB-pc.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -1 +0,0 @@
1
- import{t as e}from"./doc-browser-8EEDwGCJ.js";export{e as DocBrowser};
@@ -1 +0,0 @@
1
- import{t as e}from"./mcp-marketplace-page-ju1KH3TG.js";export{e as McpMarketplacePage};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-WjhKB-pc.js";var t=e(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]);export{t};
@@ -1 +0,0 @@
1
- import{c as e}from"./dist-WjhKB-pc.js";var t=e(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};