om-memory-system 4.16.1 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/opencode/tui-status.js +2 -1
- package/dist/adapters/pi/extension.js +3 -2
- package/dist/cli/profile-cleanup-categories-command.js +1 -2
- package/dist/importer/import-sources.js +2 -0
- package/dist/services/api-handlers.js +2 -2
- package/dist/services/status-glyphs.d.ts +19 -0
- package/dist/services/status-glyphs.js +21 -0
- package/dist/services/user-profile/category-cleanup-store.d.ts +11 -0
- package/dist/services/user-profile/category-cleanup-store.js +57 -1
- package/dist/services/user-profile/category-cleanup.d.ts +16 -7
- package/dist/services/user-profile/category-cleanup.js +94 -31
- package/dist/web/assets/{index-B46sRbG_.js → index-CIODmA62.js} +1 -1
- package/dist/web/index.html +1 -1
- package/opencode/tui.tsx +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ommsStatusLabel } from "../../services/status-glyphs.js";
|
|
1
2
|
import { availableUpdate, latestNpmVersion } from "../../services/update-check.js";
|
|
2
3
|
export function tuiStatusText(state) {
|
|
3
|
-
const web = state.web === "offline" ? "
|
|
4
|
+
const web = ommsStatusLabel(state.web === "offline" ? "web app off" : state.web);
|
|
4
5
|
return state.update ? `${web} · ${state.update} available` : web;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
@@ -13,6 +13,7 @@ import { registerPiHistoryImportCommand } from "./import-command.js";
|
|
|
13
13
|
import { performPiProfileLearning } from "./profile.js";
|
|
14
14
|
import { buildRetrievalSection, retrievalWrapperBytes, wrapRetrievalSection, } from "../../core/retrieval.js";
|
|
15
15
|
import { DEFAULT_RETRIEVAL_MAX_TOKENS, tokensToByteCeiling } from "../../core/context-budget.js";
|
|
16
|
+
import { ommsStatusLabel } from "../../services/status-glyphs.js";
|
|
16
17
|
const GLOBAL_PLUGIN_WARMUP_KEY = Symbol.for("omms.plugin.warmedup");
|
|
17
18
|
const GLOBAL_PI_BACKFILL_KEY = Symbol.for("omms.pi.backfill.scheduled");
|
|
18
19
|
const OMMS_STATUS_KEY = "omms";
|
|
@@ -79,13 +80,13 @@ export default function ommsPiExtension(pi) {
|
|
|
79
80
|
const startStatus = (ctx, status) => {
|
|
80
81
|
const version = ++statusVersion;
|
|
81
82
|
if (ctx.hasUI)
|
|
82
|
-
ctx.ui.setStatus(OMMS_STATUS_KEY,
|
|
83
|
+
ctx.ui.setStatus(OMMS_STATUS_KEY, ommsStatusLabel(status));
|
|
83
84
|
return version;
|
|
84
85
|
};
|
|
85
86
|
const finishStatus = (ctx, version, status) => {
|
|
86
87
|
if (version !== statusVersion || !ctx.hasUI)
|
|
87
88
|
return;
|
|
88
|
-
ctx.ui.setStatus(OMMS_STATUS_KEY,
|
|
89
|
+
ctx.ui.setStatus(OMMS_STATUS_KEY, ommsStatusLabel(status));
|
|
89
90
|
};
|
|
90
91
|
const clearStatus = (ctx) => {
|
|
91
92
|
statusVersion++;
|
|
@@ -71,14 +71,13 @@ export async function runProfileCleanupCategoriesCommand(argv, print = console.l
|
|
|
71
71
|
return 0;
|
|
72
72
|
}
|
|
73
73
|
const result = await cleanup.applyCategoryCleanup(userId, {
|
|
74
|
-
version: preview.version,
|
|
75
74
|
groups: preview.groups.map((group) => ({
|
|
76
75
|
labels: group.labels.map((entry) => entry.label),
|
|
77
76
|
name: group.name,
|
|
78
77
|
})),
|
|
79
78
|
}, deps);
|
|
80
79
|
if (!result.ok)
|
|
81
|
-
throw new Error(`Cleanup not applied (${result.error}). Run the
|
|
80
|
+
throw new Error(`Cleanup not applied (${result.error}). Run the command again.`);
|
|
82
81
|
print(`Renamed ${result.renamed} items.`);
|
|
83
82
|
return 0;
|
|
84
83
|
}
|
|
@@ -84,6 +84,8 @@ function isSqliteFile(path) {
|
|
|
84
84
|
export function defaultClaudeSourcePath(claudeConfigDir) {
|
|
85
85
|
return claudeProjectsRoot(claudeConfigDir);
|
|
86
86
|
}
|
|
87
|
+
// One of about 29 host-name branches outside src/adapters/. A host registry would replace
|
|
88
|
+
// them. Read "Host parity" in AGENTS.md before you add a fourth host.
|
|
87
89
|
export function defaultImportSourcePath(host, claudeConfigDir) {
|
|
88
90
|
if (host === "pi")
|
|
89
91
|
return DEFAULT_PI_SESSION_ROOT;
|
|
@@ -1108,14 +1108,14 @@ export async function handleCategoryCleanupApply(userId, body, deps) {
|
|
|
1108
1108
|
const { applyCategoryCleanup } = await import("./user-profile/category-cleanup.js");
|
|
1109
1109
|
const { clearCategoryCleanupJob } = await import("./user-profile/category-cleanup-job.js");
|
|
1110
1110
|
const user = await categoryCleanupUser(userId);
|
|
1111
|
-
const result = await applyCategoryCleanup(user, {
|
|
1111
|
+
const result = await applyCategoryCleanup(user, { groups: body?.groups }, deps);
|
|
1112
1112
|
if (result.ok) {
|
|
1113
1113
|
// The finished preview no longer matches the profile.
|
|
1114
1114
|
clearCategoryCleanupJob(user);
|
|
1115
1115
|
return { success: true, data: { renamed: result.renamed } };
|
|
1116
1116
|
}
|
|
1117
1117
|
const messages = {
|
|
1118
|
-
stale: "Profile
|
|
1118
|
+
stale: "Profile saved at the same moment. Try Apply again.",
|
|
1119
1119
|
no_profile: "No profile found to clean up",
|
|
1120
1120
|
invalid: "Each group needs at least two labels and a name.",
|
|
1121
1121
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footer label for the Pi and OpenCode adapters. Claude Code cannot import
|
|
3
|
+
* from `src/`, so `hooks/omms-status-glyphs.js` holds a twin of this file and
|
|
4
|
+
* `tests/status-glyph-parity.test.ts` keeps the two equal.
|
|
5
|
+
*
|
|
6
|
+
* Each glyph is a one-column text symbol. Never append U+FE0F: it asks the
|
|
7
|
+
* terminal for a two-column colour emoji.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STATUS_GLYPHS: {
|
|
10
|
+
readonly warming: "⧖";
|
|
11
|
+
readonly connected: "✔";
|
|
12
|
+
readonly recalling: "↻";
|
|
13
|
+
readonly capturing: "✎";
|
|
14
|
+
readonly error: "✘";
|
|
15
|
+
};
|
|
16
|
+
export type StatusGlyphState = keyof typeof STATUS_GLYPHS;
|
|
17
|
+
/** States that need an action keep their words after the error glyph. */
|
|
18
|
+
export type StatusWordState = "web app off" | "not installed";
|
|
19
|
+
export declare function ommsStatusLabel(state: StatusGlyphState | StatusWordState): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footer label for the Pi and OpenCode adapters. Claude Code cannot import
|
|
3
|
+
* from `src/`, so `hooks/omms-status-glyphs.js` holds a twin of this file and
|
|
4
|
+
* `tests/status-glyph-parity.test.ts` keeps the two equal.
|
|
5
|
+
*
|
|
6
|
+
* Each glyph is a one-column text symbol. Never append U+FE0F: it asks the
|
|
7
|
+
* terminal for a two-column colour emoji.
|
|
8
|
+
*/
|
|
9
|
+
export const STATUS_GLYPHS = {
|
|
10
|
+
warming: "⧖",
|
|
11
|
+
connected: "✔",
|
|
12
|
+
recalling: "↻",
|
|
13
|
+
capturing: "✎",
|
|
14
|
+
error: "✘",
|
|
15
|
+
};
|
|
16
|
+
export function ommsStatusLabel(state) {
|
|
17
|
+
if (state === "web app off" || state === "not installed") {
|
|
18
|
+
return `omms: ${STATUS_GLYPHS.error} ${state}`;
|
|
19
|
+
}
|
|
20
|
+
return `omms: ${STATUS_GLYPHS[state]}`;
|
|
21
|
+
}
|
|
@@ -6,3 +6,14 @@ export declare function latestOpenCleanup(profileId: string): Promise<{
|
|
|
6
6
|
renames: CategoryRename[];
|
|
7
7
|
} | null>;
|
|
8
8
|
export declare function markCleanupUndone(id: number): Promise<void>;
|
|
9
|
+
/** What the profile model answered for one group: the labels it kept and the name it proposed. */
|
|
10
|
+
export interface SavedVerdict {
|
|
11
|
+
keep: string[];
|
|
12
|
+
name: string | null;
|
|
13
|
+
}
|
|
14
|
+
export declare const VERDICT_MAX_AGE_MS: number;
|
|
15
|
+
/** Saves the answers by group id. Only category names are stored, never descriptions. */
|
|
16
|
+
export declare function saveVerdicts(profileId: string, verdicts: Map<string, SavedVerdict>, now?: number): Promise<void>;
|
|
17
|
+
export declare function loadVerdicts(profileId: string): Promise<Map<string, SavedVerdict>>;
|
|
18
|
+
/** Deletes the profile's answers that are too old or belong to a group that no longer exists. */
|
|
19
|
+
export declare function pruneVerdicts(profileId: string, currentGroupIds: Iterable<string>, maxAgeMs?: number, now?: number): Promise<void>;
|
|
@@ -2,7 +2,10 @@ import { join } from "node:path";
|
|
|
2
2
|
import { CONFIG } from "../../config.js";
|
|
3
3
|
import { tursoConnectionManager } from "../turso/connection-manager.js";
|
|
4
4
|
import { USER_PROFILES_DB_NAME } from "./user-profile-manager.js";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Undo records for category cleanups (the profile changelog keeps too few entries for undo)
|
|
7
|
+
* and the profile model's saved verdicts per group, so a new preview asks only about new groups.
|
|
8
|
+
*/
|
|
6
9
|
async function connection() {
|
|
7
10
|
const db = await tursoConnectionManager.getConnection(join(CONFIG.storagePath || "", USER_PROFILES_DB_NAME));
|
|
8
11
|
await db.execute(`CREATE TABLE IF NOT EXISTS profile_category_cleanups (
|
|
@@ -11,6 +14,14 @@ async function connection() {
|
|
|
11
14
|
created_at INTEGER NOT NULL,
|
|
12
15
|
renames TEXT NOT NULL,
|
|
13
16
|
undone_at INTEGER
|
|
17
|
+
)`);
|
|
18
|
+
await db.execute(`CREATE TABLE IF NOT EXISTS profile_category_verdicts (
|
|
19
|
+
profile_id TEXT NOT NULL,
|
|
20
|
+
group_id TEXT NOT NULL,
|
|
21
|
+
keep TEXT NOT NULL,
|
|
22
|
+
name TEXT,
|
|
23
|
+
created_at INTEGER NOT NULL,
|
|
24
|
+
PRIMARY KEY (profile_id, group_id)
|
|
14
25
|
)`);
|
|
15
26
|
return db;
|
|
16
27
|
}
|
|
@@ -33,3 +44,48 @@ export async function markCleanupUndone(id) {
|
|
|
33
44
|
id,
|
|
34
45
|
]);
|
|
35
46
|
}
|
|
47
|
+
export const VERDICT_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
48
|
+
const DELETE_CHUNK = 200;
|
|
49
|
+
/** Saves the answers by group id. Only category names are stored, never descriptions. */
|
|
50
|
+
export async function saveVerdicts(profileId, verdicts, now = Date.now()) {
|
|
51
|
+
const db = await connection();
|
|
52
|
+
for (const [groupId, verdict] of verdicts) {
|
|
53
|
+
await db.execute("INSERT OR REPLACE INTO profile_category_verdicts (profile_id, group_id, keep, name, created_at) VALUES (?, ?, ?, ?, ?)", [profileId, groupId, JSON.stringify(verdict.keep), verdict.name, now]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function loadVerdicts(profileId) {
|
|
57
|
+
const db = await connection();
|
|
58
|
+
const rows = await db.all("SELECT group_id, keep, name FROM profile_category_verdicts WHERE profile_id = ?", [profileId]);
|
|
59
|
+
const verdicts = new Map();
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
let keep;
|
|
62
|
+
try {
|
|
63
|
+
keep = JSON.parse(String(row.keep));
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// A row that is not a list of names is skipped, so its group is asked again.
|
|
69
|
+
if (!Array.isArray(keep))
|
|
70
|
+
continue;
|
|
71
|
+
verdicts.set(String(row.group_id), {
|
|
72
|
+
keep: keep.filter((label) => typeof label === "string"),
|
|
73
|
+
name: row.name == null ? null : String(row.name),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return verdicts;
|
|
77
|
+
}
|
|
78
|
+
/** Deletes the profile's answers that are too old or belong to a group that no longer exists. */
|
|
79
|
+
export async function pruneVerdicts(profileId, currentGroupIds, maxAgeMs = VERDICT_MAX_AGE_MS, now = Date.now()) {
|
|
80
|
+
const db = await connection();
|
|
81
|
+
await db.execute("DELETE FROM profile_category_verdicts WHERE profile_id = ? AND created_at < ?", [profileId, now - maxAgeMs]);
|
|
82
|
+
const current = new Set(currentGroupIds);
|
|
83
|
+
const rows = await db.all("SELECT group_id FROM profile_category_verdicts WHERE profile_id = ?", [
|
|
84
|
+
profileId,
|
|
85
|
+
]);
|
|
86
|
+
const gone = rows.map((row) => String(row.group_id)).filter((id) => !current.has(id));
|
|
87
|
+
for (let start = 0; start < gone.length; start += DELETE_CHUNK) {
|
|
88
|
+
const chunk = gone.slice(start, start + DELETE_CHUNK);
|
|
89
|
+
await db.execute(`DELETE FROM profile_category_verdicts WHERE profile_id = ? AND group_id IN (${chunk.map(() => "?").join(",")})`, [profileId, ...chunk]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CategoryGroup } from "./category-groups.js";
|
|
2
|
+
import { type SavedVerdict } from "./category-cleanup-store.js";
|
|
2
3
|
import type { UserProfileManager } from "./user-profile-manager.js";
|
|
3
4
|
export declare const GROUPS_PER_MODEL_CALL = 20;
|
|
4
5
|
export declare const MAX_EXAMPLES_PER_LABEL = 3;
|
|
@@ -16,14 +17,20 @@ export interface NamedGroup extends CategoryGroup {
|
|
|
16
17
|
/** False when the model did not check this group and the most used label was chosen. */
|
|
17
18
|
checked: boolean;
|
|
18
19
|
}
|
|
20
|
+
/** The model's saved answers by group id, and where to save new ones. */
|
|
21
|
+
export interface VerdictCache {
|
|
22
|
+
saved: Map<string, SavedVerdict>;
|
|
23
|
+
save: (verdicts: Map<string, SavedVerdict>) => Promise<void>;
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
* The profile model checks each group in batches: it removes names that do not belong
|
|
21
|
-
* and proposes one name. A
|
|
22
|
-
*
|
|
27
|
+
* and proposes one name. A group with a saved answer skips the model. A failed batch, a
|
|
28
|
+
* missing reply, or no model falls back to the most used label, marks the group unchecked
|
|
29
|
+
* and saves nothing, so a later preview retries it. The log holds counts and codes only.
|
|
23
30
|
*/
|
|
24
31
|
export declare function checkAndNameGroups(groups: CategoryGroup[], examples: Map<string, string[]>, model: CleanupModel | null,
|
|
25
|
-
/** Called with batches
|
|
26
|
-
onProgress?: (done: number, total: number) => void): Promise<NamedGroup[]>;
|
|
32
|
+
/** Called with batches to run and the total, before the first batch and after each one. */
|
|
33
|
+
onProgress?: (done: number, total: number) => void, cache?: VerdictCache): Promise<NamedGroup[]>;
|
|
27
34
|
/** The host model when one is registered, else the external API, else none. */
|
|
28
35
|
export declare function resolveCleanupModel(): Promise<CleanupModel | null>;
|
|
29
36
|
export interface CleanupDeps {
|
|
@@ -38,7 +45,6 @@ export interface CleanupDeps {
|
|
|
38
45
|
}
|
|
39
46
|
export interface CategoryCleanupPreview {
|
|
40
47
|
profileId: string;
|
|
41
|
-
version: number;
|
|
42
48
|
/** Distinct categories now, and if every group were accepted. */
|
|
43
49
|
before: number;
|
|
44
50
|
after: number;
|
|
@@ -65,9 +71,12 @@ export type UndoResult = {
|
|
|
65
71
|
};
|
|
66
72
|
/** Builds the groups for review. Changes nothing in the stored profile. */
|
|
67
73
|
export declare function previewCategoryCleanup(userId: string, deps?: CleanupDeps): Promise<CategoryCleanupPreview | null>;
|
|
68
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Renames the categories of the accepted groups on the profile as stored now. Learning may
|
|
76
|
+
* have saved newer versions since the preview; the rename goes by label, so that is safe.
|
|
77
|
+
* It refuses only when a save lands between the read and the write below.
|
|
78
|
+
*/
|
|
69
79
|
export declare function applyCategoryCleanup(userId: string, input: {
|
|
70
|
-
version: number;
|
|
71
80
|
groups: AcceptedGroup[];
|
|
72
81
|
}, deps?: CleanupDeps): Promise<ApplyResult>;
|
|
73
82
|
/** Restores the categories of the newest cleanup that is not undone yet. */
|
|
@@ -9,7 +9,7 @@ import { applySafeExtraParams } from "../ai/providers/base-provider.js";
|
|
|
9
9
|
import { completeStructured, resolveHostProfileModel } from "./profile-model.js";
|
|
10
10
|
import { CATEGORY_GROUP_THRESHOLD, collectCategoryLabels, groupCategoryLabels, groupId, recordRenames, restoreRenames, } from "./category-groups.js";
|
|
11
11
|
import { canonicaliseCategories, categoryKey, tidyCategory } from "./profile-category.js";
|
|
12
|
-
import { latestOpenCleanup, markCleanupUndone, recordCleanup } from "./category-cleanup-store.js";
|
|
12
|
+
import { latestOpenCleanup, loadVerdicts, markCleanupUndone, pruneVerdicts, recordCleanup, saveVerdicts, } from "./category-cleanup-store.js";
|
|
13
13
|
export const GROUPS_PER_MODEL_CALL = 20;
|
|
14
14
|
export const MAX_EXAMPLES_PER_LABEL = 3;
|
|
15
15
|
/**
|
|
@@ -83,23 +83,43 @@ function applyReply(group, answer) {
|
|
|
83
83
|
: labels[0].label;
|
|
84
84
|
return { id: groupId(labels), labels, name, checked: true };
|
|
85
85
|
}
|
|
86
|
+
function verdictOf(answer) {
|
|
87
|
+
if (!answer || !Array.isArray(answer.keep))
|
|
88
|
+
return null;
|
|
89
|
+
return {
|
|
90
|
+
keep: answer.keep.filter((name) => typeof name === "string"),
|
|
91
|
+
name: typeof answer.name === "string" ? answer.name : null,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
86
94
|
/**
|
|
87
95
|
* The profile model checks each group in batches: it removes names that do not belong
|
|
88
|
-
* and proposes one name. A
|
|
89
|
-
*
|
|
96
|
+
* and proposes one name. A group with a saved answer skips the model. A failed batch, a
|
|
97
|
+
* missing reply, or no model falls back to the most used label, marks the group unchecked
|
|
98
|
+
* and saves nothing, so a later preview retries it. The log holds counts and codes only.
|
|
90
99
|
*/
|
|
91
100
|
export async function checkAndNameGroups(groups, examples, model,
|
|
92
|
-
/** Called with batches
|
|
93
|
-
onProgress) {
|
|
101
|
+
/** Called with batches to run and the total, before the first batch and after each one. */
|
|
102
|
+
onProgress, cache) {
|
|
103
|
+
const named = new Map();
|
|
104
|
+
const pending = [];
|
|
105
|
+
for (const group of groups) {
|
|
106
|
+
const saved = cache?.saved.get(group.id);
|
|
107
|
+
if (saved)
|
|
108
|
+
named.set(group.id, applyReply(group, saved));
|
|
109
|
+
else
|
|
110
|
+
pending.push(group);
|
|
111
|
+
}
|
|
94
112
|
const batches = [];
|
|
95
|
-
for (let start = 0; start <
|
|
96
|
-
batches.push(
|
|
113
|
+
for (let start = 0; start < pending.length; start += GROUPS_PER_MODEL_CALL) {
|
|
114
|
+
batches.push(pending.slice(start, start + GROUPS_PER_MODEL_CALL));
|
|
97
115
|
}
|
|
98
116
|
let failedBatches = 0;
|
|
99
|
-
let dropped = 0;
|
|
100
117
|
const checkBatch = async (batch) => {
|
|
101
|
-
if (!model)
|
|
102
|
-
|
|
118
|
+
if (!model) {
|
|
119
|
+
for (const group of batch)
|
|
120
|
+
named.set(group.id, fallback(group));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
103
123
|
let replies;
|
|
104
124
|
try {
|
|
105
125
|
replies = readReply(await model(SYSTEM_PROMPT, buildPrompt(batch, examples)));
|
|
@@ -110,34 +130,50 @@ onProgress) {
|
|
|
110
130
|
groups: batch.length,
|
|
111
131
|
code: error instanceof Error ? error.name : "unknown",
|
|
112
132
|
});
|
|
113
|
-
|
|
133
|
+
for (const group of batch)
|
|
134
|
+
named.set(group.id, fallback(group));
|
|
135
|
+
return;
|
|
114
136
|
}
|
|
115
|
-
const
|
|
137
|
+
const verdicts = new Map();
|
|
116
138
|
for (const group of batch) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
const answer = replies.get(group.id);
|
|
140
|
+
named.set(group.id, applyReply(group, answer));
|
|
141
|
+
const verdict = verdictOf(answer);
|
|
142
|
+
if (verdict)
|
|
143
|
+
verdicts.set(group.id, verdict);
|
|
144
|
+
}
|
|
145
|
+
if (cache && verdicts.size > 0) {
|
|
146
|
+
try {
|
|
147
|
+
await cache.save(verdicts);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
log("category cleanup: verdict save failed", {
|
|
151
|
+
groups: verdicts.size,
|
|
152
|
+
code: error instanceof Error ? error.name : "unknown",
|
|
153
|
+
});
|
|
154
|
+
}
|
|
122
155
|
}
|
|
123
|
-
return results;
|
|
124
156
|
};
|
|
125
157
|
// One call at a time: a provider that refuses parallel calls still finishes (TDR-044).
|
|
126
|
-
const named = [];
|
|
127
158
|
onProgress?.(0, batches.length);
|
|
128
159
|
for (const [index, batch] of batches.entries()) {
|
|
129
|
-
|
|
160
|
+
await checkBatch(batch);
|
|
130
161
|
onProgress?.(index + 1, batches.length);
|
|
131
162
|
}
|
|
163
|
+
const result = groups
|
|
164
|
+
.map((group) => named.get(group.id))
|
|
165
|
+
.filter((group) => !!group);
|
|
132
166
|
log("category cleanup: groups checked", {
|
|
133
167
|
groups: groups.length,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
168
|
+
reused: groups.length - pending.length,
|
|
169
|
+
sent: pending.length,
|
|
170
|
+
named: result.length,
|
|
171
|
+
dropped: groups.length - result.length,
|
|
172
|
+
unchecked: result.filter((group) => !group.checked).length,
|
|
137
173
|
failedBatches,
|
|
138
174
|
model: model ? "available" : "none",
|
|
139
175
|
});
|
|
140
|
-
return
|
|
176
|
+
return result;
|
|
141
177
|
}
|
|
142
178
|
/** The host model when one is registered, else the external API, else none. */
|
|
143
179
|
export async function resolveCleanupModel() {
|
|
@@ -219,28 +255,53 @@ function countAfter(labels, groups) {
|
|
|
219
255
|
}
|
|
220
256
|
return new Set(labels.map((entry) => categoryKey(rename.get(entry.label) ?? entry.label))).size;
|
|
221
257
|
}
|
|
258
|
+
/** Opens the saved model answers for the groups; without the store the preview just asks the model. */
|
|
259
|
+
async function openVerdictCache(profileId, groupIds) {
|
|
260
|
+
try {
|
|
261
|
+
await pruneVerdicts(profileId, groupIds);
|
|
262
|
+
return {
|
|
263
|
+
saved: await loadVerdicts(profileId),
|
|
264
|
+
save: (verdicts) => saveVerdicts(profileId, verdicts),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
log("category cleanup: verdict store unavailable", {
|
|
269
|
+
code: error instanceof Error ? error.name : "unknown",
|
|
270
|
+
});
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
222
274
|
/** Builds the groups for review. Changes nothing in the stored profile. */
|
|
223
275
|
export async function previewCategoryCleanup(userId, deps = {}) {
|
|
224
276
|
const manager = await managerOf(deps);
|
|
225
277
|
const profile = await manager.getActiveProfile(userId);
|
|
226
278
|
if (!profile)
|
|
227
279
|
return null;
|
|
280
|
+
const started = Date.now();
|
|
228
281
|
const data = readProfile(profile.profileData);
|
|
229
282
|
const labels = collectCategoryLabels(data);
|
|
230
283
|
const embed = deps.embed ?? (await defaultEmbed());
|
|
231
284
|
const vectors = [];
|
|
232
285
|
for (const entry of labels)
|
|
233
286
|
vectors.push({ ...entry, vector: await embed(entry.label) });
|
|
287
|
+
const embedded = Date.now();
|
|
234
288
|
const groups = groupCategoryLabels(vectors, deps.threshold ?? CATEGORY_GROUP_THRESHOLD);
|
|
289
|
+
const grouped = Date.now();
|
|
290
|
+
const cache = await openVerdictCache(profile.id, groups.map((group) => group.id));
|
|
235
291
|
const model = deps.model === undefined ? await resolveCleanupModel() : deps.model;
|
|
236
|
-
const named = await checkAndNameGroups(groups, examplesByLabel(data), model, deps.onProgress);
|
|
292
|
+
const named = await checkAndNameGroups(groups, examplesByLabel(data), model, deps.onProgress, cache);
|
|
293
|
+
const reused = groups.filter((group) => cache?.saved.has(group.id)).length;
|
|
237
294
|
log("category cleanup: preview built", {
|
|
238
295
|
labels: labels.length,
|
|
239
296
|
groups: named.length,
|
|
297
|
+
reusedGroups: reused,
|
|
298
|
+
sentGroups: groups.length - reused,
|
|
299
|
+
embedMs: embedded - started,
|
|
300
|
+
groupMs: grouped - embedded,
|
|
301
|
+
checkMs: Date.now() - grouped,
|
|
240
302
|
});
|
|
241
303
|
return {
|
|
242
304
|
profileId: profile.id,
|
|
243
|
-
version: profile.version,
|
|
244
305
|
before: labels.length,
|
|
245
306
|
after: countAfter(labels, named),
|
|
246
307
|
groups: named,
|
|
@@ -255,16 +316,18 @@ function validGroups(groups) {
|
|
|
255
316
|
typeof group.name === "string" &&
|
|
256
317
|
group.name.trim().length > 0));
|
|
257
318
|
}
|
|
258
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Renames the categories of the accepted groups on the profile as stored now. Learning may
|
|
321
|
+
* have saved newer versions since the preview; the rename goes by label, so that is safe.
|
|
322
|
+
* It refuses only when a save lands between the read and the write below.
|
|
323
|
+
*/
|
|
259
324
|
export async function applyCategoryCleanup(userId, input, deps = {}) {
|
|
260
|
-
if (!
|
|
325
|
+
if (!validGroups(input?.groups))
|
|
261
326
|
return { ok: false, error: "invalid" };
|
|
262
327
|
const manager = await managerOf(deps);
|
|
263
328
|
const profile = await manager.getActiveProfile(userId);
|
|
264
329
|
if (!profile)
|
|
265
330
|
return { ok: false, error: "no_profile" };
|
|
266
|
-
if (profile.version !== input.version)
|
|
267
|
-
return { ok: false, error: "stale" };
|
|
268
331
|
const data = readProfile(profile.profileData);
|
|
269
332
|
const rename = new Map();
|
|
270
333
|
for (const group of input.groups) {
|
|
@@ -281,7 +344,7 @@ export async function applyCategoryCleanup(userId, input, deps = {}) {
|
|
|
281
344
|
if (renames.length === 0)
|
|
282
345
|
return { ok: true, renamed: 0 };
|
|
283
346
|
const summary = `Category cleanup: ${renames.length} items renamed in ${input.groups.length} groups`;
|
|
284
|
-
if (!(await manager.updateProfile(profile.id, next, 0, summary,
|
|
347
|
+
if (!(await manager.updateProfile(profile.id, next, 0, summary, profile.version))) {
|
|
285
348
|
return { ok: false, error: "stale" };
|
|
286
349
|
}
|
|
287
350
|
await recordCleanup(profile.id, renames);
|
|
@@ -52,7 +52,7 @@ Error generating stack: `+e.message+`
|
|
|
52
52
|
`||e===`\r`||e===` `||e===`\b`||e===`\f`}function yc(e,t){let n=e.charCodeAt(t);return n===Ys||n===Xs||n===Zs||n===Qs}function bc(e,t){let n=e.charCodeAt(t);return n===Ys||n===Zs||n===Qs}function xc(e,t){let n=e.charCodeAt(t);return n===$s||n===ec||n>=tc&&n<=nc||n===rc||n===ic||n===ac||n===oc}function Sc(e){return Cc(e)||Tc(e)}function Cc(e){return e===`"`||e===`“`||e===`”`}function wc(e){return e===`"`}function Tc(e){return e===`'`||e===`‘`||e===`’`||e==="`"||e===`´`}function Ec(e){return e===`'`}function Dc(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=e.lastIndexOf(t);return r===-1?e:e.substring(0,r)+(n?``:e.substring(r+1))}function Oc(e,t){let n=e.length;if(!yc(e,n-1))return e+t;for(;yc(e,n-1);)n--;return e.substring(0,n)+t+e.substring(n)}function kc(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Ac(e){return/[,\n][ \t\r]*$/.test(e)}var jc={""":`"`,"&":`&`,"<":`<`,">":`>`,"'":`'`};function Mc(e){if(e.charAt(0)!==`&`)return null;let t=e.indexOf(`;`);if(t===-1)return null;let n=e.substring(0,t+1),r=jc[n];if(r!==void 0)return{char:r,length:n.length};if(e.charAt(1)===`#`){let r=e.substring(2,t),i=r.charAt(0)===`x`||r.charAt(0)===`X`,a=i?r.substring(1):r;if(a.length>0){let e=Number.parseInt(a,i?16:10);if(!Number.isNaN(e)&&e>=0&&e<=1114111)return{char:String.fromCodePoint(e),length:n.length}}}return null}function Nc(e){return e!==null&&e.char===`"`}function Pc(e){return e!==null&&e.char===`'`}function Fc(e,t){let n=0;for(let r=0;r<e.length;r++)e.charAt(r)===t&&n++;return n}function Ic(e,t){switch(t){case`)`:return Fc(e,`(`)>Fc(e,`)`);case`]`:return Fc(e,`[`)>Fc(e,`]`);case`}`:return Fc(e,`{`)>Fc(e,`}`);default:return!1}}var Lc={"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`},Rc={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
|
|
53
53
|
`,r:`\r`,t:` `};function zc(e){let t=0,n=``;c(["```","[```","{```"]),i()||ee(),c(["```","```]","```}"]);let r=u(`,`);for(r&&a(),gc(e[t])&&Ac(n)?(r||(n=Oc(n,`,`)),g()):r&&(n=Dc(n,`,`));e[t]===`}`||e[t]===`]`;)t++,a();if(t>=e.length)return n;O();function i(){a();let e=m()||h()||_()||y()||b()||S(!1)||C();return a(),e}function a(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=t,r=o(e);do r=s(),r&&=o(e);while(r);return t>n}function o(r){let i=r?yc:bc,a=``;for(;;)if(i(e,t))a+=e[t],t++;else if(xc(e,t))a+=` `,t++;else break;return a.length>0&&(n+=a,!0)}function s(){if(e[t]===`/`&&e[t+1]===`*`){for(;t<e.length&&!Bc(e,t);)t++;return t+=2,!0}if(e[t]===`/`&&e[t+1]===`/`){for(;t<e.length&&e[t]!==`
|
|
54
54
|
`;)t++;return!0}return!1}function c(n){if(l(n)){if(dc(e[t]))for(;t<e.length&&fc(e[t]);)t++;return a(),!0}return!1}function l(n){o(!0);for(let r of n){let n=t+r.length;if(e.slice(t,n)===r)return t=n,!0}return!1}function u(r){return e[t]===r&&(n+=e[t],t++,!0)}function d(n){return e[t]===n&&(t++,!0)}function f(){return d(`\\`)}function p(){return a(),e[t]===`.`&&e[t+1]===`.`&&e[t+2]===`.`&&(t+=3,a(),d(`,`),!0)}function m(){if(e[t]===`{`){n+=`{`,t++,a(),d(`,`)&&a();let r=!0;for(;t<e.length&&e[t]!==`}`;){let o;if(r?o=!0:(o=u(`,`),o||(n=Oc(n,`,`)),a()),p(),!(_()||S(!0))){e[t]===`}`||e[t]===`{`||e[t]===`]`||e[t]===`[`||e[t]===void 0?r||(n=Dc(n,`,`)):te();break}a();let s=u(`:`),c=t>=e.length;s||(gc(e[t])||c?n=Oc(n,`:`):k()),i()||(s||c?n+=`null`:k()),r=!1}return e[t]===`}`?(n+=`}`,t++):n=Oc(n,`}`),!0}return!1}function h(){if(e[t]===`[`){n+=`[`,t++,a(),d(`,`)&&a();let r=!0;for(;t<e.length&&e[t]!==`]`;){if(r||u(`,`)||(n=Oc(n,`,`)),p(),!i()){r||(n=Dc(n,`,`));break}r=!1}return e[t]===`]`?(n+=`]`,t++):n=Oc(n,`]`),!0}return!1}function g(){let e=!0,t=!0;for(;t;)e?e=!1:u(`,`)||(n=Oc(n,`,`)),t=i();t||(n=Dc(n,`,`)),n=`[\n${n}\n]`}function _(){let r=arguments.length>0&&arguments[0]!==void 0&&arguments[0],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,o=e[t]===`\\`;o&&(t++,Sc(e[t])||O());let s=e[t]===`&`?Mc(e.slice(t,t+12)):null,c=Nc(s)||Pc(s);if(Sc(e[t])||c){let l=wc(e[t])?wc:Ec(e[t])?Ec:Tc(e[t])?Tc:Cc,u=t,d=n.length,p=`"`;for(t+=c&&s?s.length:1;;){if(t>=e.length){let i=w(t-1);return!r&&uc(e.charAt(i))?(t=u,n=n.substring(0,d),_(!0)):(p=Oc(p,`"`),n+=p,!0)}if(t===i)return p=Oc(p,`"`),n+=p,!0;let m=c&&e[t]===`&`?Mc(e.slice(t,t+12)):null;if(m&&s?m.char===s.char:l(e[t])){let i=t,o=p.length;if(p+=`"`,t+=m?m.length:1,n+=p,a(!1),r||t>=e.length||uc(e[t])&&!Ic(p,e[t])||Sc(e[t])&&!T(t)||cc(e[t]))return v(),!0;e[t]===`\\`&&O();let s=w(i-1),c=e.charAt(s);if(c===`,`)return t=u,n=n.substring(0,d),_(!1,s);if(uc(c))return t=u,n=n.substring(0,d),_(!0);n=n.substring(0,d),t=i+(m?m.length:1),p=`${p.substring(0,o)}\\${p.substring(o)}`}else if(r&&hc(e[t])){if(e[t-1]===`:`&&pc.test(e.substring(u+1,t+2)))for(;t<e.length&&mc.test(e[t]);)p+=e[t],t++;return p=Oc(p,`"`),n+=p,v(),!0}else if(m){let e=m.char;e===`"`?p+=`\\"`:vc(e)?p+=Lc[e]:p+=e,t+=m.length}else if(e[t]===`\\`){let n=e.charAt(t+1);if(Rc[n]!==void 0)p+=e.slice(t,t+2),t+=2;else if(n===`u`){let n=2;for(;n<6&&sc(e[t+n]);)n++;n===6?(p+=e.slice(t,t+6),t+=6):t+n>=e.length?t=e.length:ne()}else n===`
|
|
55
|
-
`?(p+=`\\n`,t+=2):(p+=n,t+=2)}else{let n=e.charAt(t);n===`"`&&e[t-1]!==`\\`?(p+=`\\${n}`,t++):vc(n)?(p+=Lc[n],t++):(lc(n)||D(n),p+=n,t++)}o&&f()}}return!1}function v(){let r=!1;for(a();e[t]===`+`;){r=!0,t++,a(),n=Dc(n,`"`,!0);let e=n.length;n=_()?kc(n,e,1):Oc(n,`"`)}return r}function y(){let r=t,i=``,a=!1;for(e[t]===`-`&&(i+=e[t],t++,!cc(e[t])&&E()&&(i+=`0`)),e[t]===`0`&&cc(e[t+1])&&(a=!0);cc(e[t]);)i+=e[t],t++;if(e[t]===`.`)for((i===``||i===`-`)&&(i+=`0`),i+=e[t],t++,cc(e[t])||(i+=`0`);cc(e[t]);)i+=e[t],t++;if(t>r){if(e[t]===`e`||e[t]===`E`)for(i===`-`&&(a=!0),i+=e[t],t++,(e[t]===`-`||e[t]===`+`)&&(i+=e[t],t++),cc(e[t])||(i+=`0`);cc(e[t]);)i+=e[t],t++;return E()?(n+=a?`"${e.substring(r,t)}"`:i,!0):(t=r,!1)}return!1}function b(){return x(`true`,`true`)||x(`false`,`false`)||x(`null`,`null`)||x(`True`,`true`)||x(`False`,`false`)||x(`None`,`null`)}function x(r,i){return e.slice(t,t+r.length)===r&&!fc(e[t+r.length])&&(n+=i,t+=r.length,!0)}function S(r){let a=t;if(dc(e[t])){for(;t<e.length&&fc(e[t]);)t++;let n=t;for(;yc(e,n);)n++;if(e[n]===`(`)return t=n+1,i(),e[t]===`)`&&(t++,e[t]===`;`&&t++),!0}for(;t<e.length&&!hc(e[t])&&!Sc(e[t])&&(!r||e[t]!==`:`);)t++;if(e[t-1]===`:`&&pc.test(e.substring(a,t+2)))for(;t<e.length&&mc.test(e[t]);)t++;if(t>a){for(;yc(e,t-1)&&t>0;)t--;let r=e.slice(a,t);return n+=r===`undefined`?`null`:JSON.stringify(r),e[t]===`"`&&t++,!0}}function C(){if(e[t]===`/`){let r=t;for(t++;t<e.length&&(e[t]!==`/`||e[t-1]===`\\`);)t++;return t++,n+=JSON.stringify(e.substring(r,t)),!0}}function w(t){let n=t;for(;n>0&&yc(e,n);)n--;return n}function T(t){let n=t+1;for(;n<e.length&&yc(e,n);)n++;return n>=e.length||uc(e[n])}function E(){return t>=e.length||uc(e[t])||yc(e,t)}function D(e){throw new Js(`Invalid character ${JSON.stringify(e)}`,t)}function O(){throw new Js(`Unexpected character ${JSON.stringify(e[t])}`,t)}function ee(){throw new Js(`Unexpected end of json string`,e.length)}function te(){throw new Js(`Object key expected`,t)}function k(){throw new Js(`Colon expected`,t)}function ne(){throw new Js(`Invalid unicode character "${e.slice(t,t+6)}"`,t)}}function Bc(e,t){return e[t]===`*`&&e[t+1]===`/`}function Vc(e){if(!e)return[];let t=e,n=null;for(;typeof t==`string`&&t!==n;){n=t;try{t=JSON.parse(zc(t))}catch{break}}if(!Array.isArray(t))return[];let r=[],i=e=>{Array.isArray(e)?e.forEach(i):e&&typeof e==`object`&&r.push(e)};return i(t),r}function Hc(e,t){if(!t||!e.includes(`_`))return null;let[n,r]=e.split(`_`),i=parseInt(r,10);return Number.isNaN(i)?null:n===`pref`?t.preferences?.[i]?.description??null:n===`pat`?t.patterns?.[i]?.description??null:n===`wf`?t.workflows?.[i]?.description??null:null}function Uc(e,t){if(!t||!e.includes(`_`))return null;let[n,r]=e.split(`_`),i=parseInt(r,10);return Number.isNaN(i)||n!==`wf`?null:t.workflows?.[i]?.steps||null}function Wc(e){return e>=80?`high`:e>=60?`medium`:e>=40?`low`:`poor`}var Gc={high:`border-green-600/40 bg-green-500/15 text-green-700 dark:text-green-400`,medium:`border-blue-600/40 bg-blue-500/15 text-blue-700 dark:text-blue-400`,low:`border-orange-600/40 bg-orange-500/15 text-orange-700 dark:text-orange-400`,poor:`border-red-600/40 bg-red-500/15 text-red-700 dark:text-red-400`};function Kc(e,t){return e.length>t?e.substring(0,t)+`...`:e}function qc({open:e=!1,profile:t=null,onOpenChange:n,onApplied:r}){let{t:i}=yr(),[a,o]=(0,_.useState)(`select`),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(new Set),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(new Set),[h,g]=(0,_.useState)(new Set),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=(0,_.useRef)(!1),C=(0,_.useMemo)(()=>{let e={};for(let t of s){let n=t.category||`(none)`;e[n]||(e[n]={pref:[],pat:[],wf:[]}),e[n][t._type].push(t)}return e},[s]),w=(0,_.useMemo)(()=>Object.keys(C).sort(),[C]),T=l.size,E=p.size+h.size,D=(d?.changes.merged?.length||0)+(d?.changes.removed?.length||0);function O(){let e=t?.profileData;if(!e){V.error(`No profile data loaded`),ee(!1);return}let n=(e.preferences||[]).map((e,t)=>({...e,_id:`pref_${t}`,_type:`pref`})),r=(e.patterns||[]).map((e,t)=>({...e,_id:`pat_${t}`,_type:`pat`})),i=(e.workflows||[]).map((e,t)=>({...e,_id:`wf_${t}`,_type:`wf`})),a=[...n,...r,...i];c(a),u(new Set(a.filter(e=>(e.frequency||0)<=3).map(e=>e._id))),o(`select`),f(null),y(!1)}(0,_.useEffect)(()=>{e&&!S.current?O():!e&&S.current&&(o(`select`),f(null),x(!1)),S.current=e},[e]);function ee(e){n?.(e)}function te(e,t){u(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function ne(){u(new Set(s.map(e=>e._id)))}function re(){u(new Set)}function ie(){u(new Set(s.filter(e=>(e.frequency||0)<=3).map(e=>e._id)))}function A(){let e=new Set;for(let t of Object.keys(C)){let n=[...C[t].pref,...C[t].pat,...C[t].wf];if(n.length>=3)for(let t of n)e.add(t._id)}u(e)}async function M(){let e=[...l];if(e.length===0){V.warning(`No items selected`);return}o(`loading`);let n=await Xn(`/api/user-profile/ai-cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({includeIds:e,profileVersion:t?.version}),timeout:18e4});if(!n.success||!n.data){o(`select`),V.error(n.error||i(`toast-ai-cleanup-failed`));return}f(n.data),m(new Set((n.data.changes.merged||[]).map((e,t)=>t))),g(new Set((n.data.changes.removed||[]).map((e,t)=>t))),o(`diff`)}function se(e){if(!e.includes(`_`))return`?`;let t=e.split(`_`)[0];return t===`pref`?i(`profile-type-pref`)||`Pref`:t===`pat`?i(`profile-type-pat`)||`Pat`:t===`wf`?i(`profile-type-wf`)||`Wf`:`?`}function ce(e,t){m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function N(e,t){g(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function le(){m(new Set((d?.changes.merged||[]).map((e,t)=>t))),g(new Set((d?.changes.removed||[]).map((e,t)=>t)))}function ue(){m(new Set),g(new Set)}async function de(){if(!d||E===0)return;x(!0);let e=[...p].map(e=>d?.changes.merged?.[e]?.ids).filter(e=>!!e),t=[...h].map(e=>d?.changes.removed?.[e]?.id).filter(e=>!!e),n=await Xn(`/api/user-profile/ai-cleanup/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:d.new,acceptedMerged:e,acceptedRemoved:t})});x(!1),n.success?(V.success(i(`toast-ai-cleanup-success`)),ee(!1),r?.()):V.error(n.error||i(`toast-cleanup-apply-failed`))}return(0,B.jsx)(Bs,{open:e,onOpenChange:ee,children:(0,B.jsxs)(Us,{className:`grid! sm:max-w-2xl max-h-[90vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden gap-4`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:i(`label-ai-cleanup-title`)})}),a===`loading`?(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-muted-foreground`,children:[(0,B.jsx)(pe,{className:`size-6 animate-spin`}),(0,B.jsx)(`span`,{className:`text-sm`,children:i(`label-ai-cleanup-loading`)})]}):a===`select`?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-subsection-title font-semibold`,children:i(`label-ai-cleanup-select`)}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:ne,children:i(`label-ai-cleanup-select-all`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:re,children:i(`label-ai-cleanup-deselect-all`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:ie,children:i(`label-ai-cleanup-select-low`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:A,children:i(`label-ai-cleanup-select-same-cat`)})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto pr-1`,children:w.map(e=>{let t=[...C[e].pref,...C[e].pat,...C[e].wf];return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs rounded-full bg-muted px-2 py-0.5`,children:e}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t.length,` items`]})]}),t.map(e=>{let t=l.has(e._id);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 px-2 py-1.5 text-sm cursor-pointer hover:bg-muted/40`,role:`checkbox`,"aria-checked":t,tabIndex:0,onClick:()=>te(e._id,!t),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),te(e._id,!t))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:t,tabIndex:-1})}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground w-4`,children:e._type===`pref`?`P`:e._type===`pat`?`T`:`W`}),(0,B.jsx)(`span`,{className:`flex-1 truncate`,children:(e.description||``).substring(0,80)}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground shrink-0`,children:[(0,B.jsx)(Ne,{className:`size-3`}),e.frequency||0,e.confidence==null?``:` | ${Math.round(e.confidence*100)}%`]})]},e._id)})]},e)})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`label-ai-cleanup-selected`,{count:T})}),(0,B.jsx)(U,{onClick:M,children:i(`label-ai-cleanup-analyze`)})]})]}):a===`diff`&&d?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`label-ai-cleanup-changes-selected`,{selected:E,total:D})}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:le,children:i(`label-ai-cleanup-select-all`)}),(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:ue,children:i(`label-ai-cleanup-deselect-all`)})]})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto pr-1`,children:[(d.changes.merged||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-subsection-title font-semibold`,children:[(0,B.jsx)(P,{className:`size-3.5`}),i(`label-ai-cleanup-merged-header`,{count:d.changes.merged?.length||0})]}),(d.changes.merged||[]).map((e,t)=>{let n=e.ids.slice(1),r=e.result||``,a=Uc(e.ids[0],d.old),o=p.has(t);return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm cursor-pointer`,role:`checkbox`,"aria-checked":o,tabIndex:0,onClick:()=>ce(t,!o),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(t,!o))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:o,tabIndex:-1})}),(0,B.jsx)(`span`,{children:i(`label-ai-cleanup-merge-check`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_auto_1fr] items-start text-sm`,children:[(0,B.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=Hc(e,d.old),n=Uc(e,d.old);return t?(0,B.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 space-y-1`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-[10px] rounded bg-muted px-1.5 py-0.5`,children:se(e)}),` `,Kc(t,80)]}),n?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:n.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<n.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null]},e):null})}),(0,B.jsx)(`div`,{className:`text-muted-foreground self-center grid place-items-center`,children:(0,B.jsx)(j,{className:`size-4`})}),(0,B.jsxs)(`div`,{className:`rounded-lg bg-primary/10 p-2 space-y-1`,children:[(0,B.jsx)(`div`,{children:Kc(r,120)}),a?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:a.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<a.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null]})]})]},t)})]}):null,(d.changes.removed||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-subsection-title font-semibold`,children:[(0,B.jsx)(Pe,{className:`size-3.5`}),i(`label-ai-cleanup-removed-header`,{count:d.changes.removed?.length||0})]}),(d.changes.removed||[]).map((e,t)=>{let n=Hc(e.id,d.old),r=Uc(e.id,d.old),a=h.has(t);return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm cursor-pointer`,role:`checkbox`,"aria-checked":a,tabIndex:0,onClick:()=>N(t,!a),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),N(t,!a))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:a,tabIndex:-1})}),(0,B.jsx)(`span`,{children:i(`label-ai-cleanup-remove-check`)})]}),(0,B.jsx)(`div`,{className:`text-sm`,children:n||e.id}),r?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:r.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<r.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null,(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.reason})]},t)})]}):null,(d.changes.kept||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-sm font-medium`,onClick:()=>y(e=>!e),children:[i(`label-ai-cleanup-kept`),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,d.changes.kept?.length||0,`)`]}),v?(0,B.jsx)(oe,{className:`size-3.5`}):(0,B.jsx)(ae,{className:`size-3.5`})]}),v?(0,B.jsx)(`div`,{className:`space-y-1`,children:(d.changes.kept||[]).map((e,t)=>(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground rounded bg-muted/40 px-2 py-1`,children:e},t))}):null]}):null]})]}):null,(0,B.jsxs)(Gs,{children:[(0,B.jsx)(U,{variant:`secondary`,onClick:()=>ee(!1),children:i(`btn-cancel`)}),a===`diff`?(0,B.jsx)(U,{disabled:E===0||b,onClick:de,children:E>0?`${i(`label-ai-cleanup-apply`)} (${E})`:i(`label-ai-cleanup-apply`)||`Apply`}):null]})]})})}function Jc(e){let t=0;for(let n of e.trim().toLowerCase())t=t*31+n.codePointAt(0)|0;return Math.abs(t)%360}function Yc({keyword:e,active:t=!1,title:n,onClick:r,"aria-describedby":i,"aria-label":a}){let o=Jc(e);return(0,B.jsx)(`button`,{type:`button`,title:n,"aria-describedby":i,"aria-label":a,"aria-pressed":t,onClick:()=>r?.(e),className:z(`inline-flex min-h-6 max-w-full cursor-pointer items-center rounded-[7px] border px-2 text-xs break-words transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,`[color:oklch(0.42_0.13_var(--keyword-hue))] dark:[color:oklch(0.8_0.13_var(--keyword-hue))]`,t&&`ring-2 ring-offset-1 ring-offset-background`),style:{backgroundColor:`oklch(0.72 0.14 ${o} / 0.18)`,borderColor:`oklch(0.72 0.14 ${o} / 0.45)`,"--keyword-hue":String(o),"--tw-ring-color":`oklch(0.72 0.14 ${o} / 0.7)`},children:e})}var Xc=Gr(`h-5 gap-1 rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap transition-colors focus-visible:ring-[3px] [&>svg]:pointer-events-none`,{variants:{variant:{default:`bg-primary/10 border-primary/25 text-primary-label [a]:hover:bg-primary/16`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 border-destructive/25 [a]:hover:bg-destructive/16 text-destructive-label`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function Zc({className:e,variant:t,asChild:n=!1,...r}){return(0,B.jsx)(n?Ar:`span`,{"data-slot":`badge`,className:z(Xc({variant:t}),e),...r})}function Qc({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:z(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-selection selection:text-foreground flex h-9 w-full min-w-0 rounded-[10px] border bg-card px-2.5 py-1 text-ui transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-ui file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`aria-invalid:ring-destructive aria-invalid:ring-1 aria-invalid:border-destructive`,e),...n})}var $c=3e3;function el({label:e,count:t}){return(0,B.jsxs)(Zc,{variant:`outline`,className:`bg-transparent border-current [color:oklch(0.42_0.13_var(--category-hue))] dark:[color:oklch(0.8_0.13_var(--category-hue))]`,style:{"--category-hue":String(Jc(e))},children:[(0,B.jsx)(`bdi`,{children:e}),(0,B.jsx)(`span`,{className:`ms-1 font-mono opacity-70`,children:t})]})}function tl({open:e=!1,onOpenChange:t,onApplied:n}){let{t:r}=yr(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),g=(0,_.useRef)(!1),v=(0,_.useRef)(0);(0,_.useEffect)(()=>{e&&!g.current&&b(!1),e||v.current++,g.current=e},[e]);function y(e){a(e),s(new Set(e.groups.map((e,t)=>t))),l(e.groups.map(e=>e.name))}async function b(e){let t=++v.current;a(null),p(null),h(null);let n=null;if(!e){let e=await Xn(`/api/user-profile/category-cleanup`);n=e.success?e.data??null:null}if(!n||n.status.state===`failed`){let e=await Xn(`/api/user-profile/category-cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!e.success||!e.data){h(e.error||r(`toast-category-cleanup-failed`));return}n=e.data}for(;t===v.current;){let e=n.status;if(e.state===`done`)return y(e.preview);if(e.state===`failed`)return h(e.error);p(e.state===`checking`?{done:e.done,total:e.total}:null),await new Promise(e=>setTimeout(e,$c));let t=await Xn(`/api/user-profile/category-cleanup`);if(!t.success||!t.data)return h(t.error||r(`toast-category-cleanup-failed`));n=t.data}}function x(e){s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let S=i?i.before-i.groups.reduce((e,t,n)=>e+(o.has(n)?t.labels.length-1:0),0):0,C=[...o].every(e=>(c[e]??``).trim().length>0);async function w(){if(!i||o.size===0||!C)return;d(!0);let e=[...o].map(e=>({labels:i.groups[e].labels.map(e=>e.label),name:c[e].trim()})),a=await Xn(`/api/user-profile/category-cleanup/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:i.version,groups:e})});if(d(!1),!a.success||!a.data){V.error(a.error||r(`toast-category-cleanup-failed`));return}V.success(r(`toast-category-cleanup-applied`,{count:a.data.renamed})),t?.(!1),n?.()}async function T(){d(!0);let e=await Xn(`/api/user-profile/category-cleanup/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(d(!1),!e.success||!e.data){V.info(e.error||r(`toast-category-cleanup-failed`));return}V.success(r(`toast-category-cleanup-undone`,e.data)),t?.(!1),n?.()}return(0,B.jsx)(Bs,{open:e,onOpenChange:t,children:(0,B.jsxs)(Us,{className:`grid! sm:max-w-2xl max-h-[90vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden gap-4`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:r(`label-category-cleanup-title`)})}),m?(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-destructive`,children:m}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>void b(!0),children:r(`btn-category-cleanup-rebuild`)})]}):i?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:r(`label-category-cleanup-counts`,{before:i.before,after:S})}),(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:()=>void b(!0),children:r(`btn-category-cleanup-rebuild`)})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`label-category-cleanup-note`)}),i.groups.length===0?(0,B.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r(`label-category-cleanup-empty`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`label-category-cleanup-selected`,{selected:o.size,total:i.groups.length})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pe-1`,children:i.groups.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)($i,{checked:o.has(t),onCheckedChange:()=>x(t),"aria-label":r(`label-category-cleanup-accept`)}),(0,B.jsx)(Qc,{dir:`auto`,className:`h-8 min-w-0 flex-1 sm:max-w-64`,value:c[t]??``,"aria-label":r(`label-category-cleanup-name`),disabled:!o.has(t),onChange:e=>l(n=>n.map((n,r)=>r===t?e.target.value:n))}),e.checked?null:(0,B.jsx)(`span`,{className:`basis-full text-xs text-muted-foreground sm:basis-auto`,children:r(`label-category-cleanup-unchecked`)})]}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.labels.map(e=>(0,B.jsx)(el,{label:e.label,count:e.count},e.label))})]},e.id))})]})]}):(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-center text-muted-foreground`,children:[(0,B.jsx)(pe,{className:`size-6 animate-spin`}),(0,B.jsx)(`span`,{className:`text-sm`,children:f?r(`label-category-cleanup-progress`,f):r(`label-category-cleanup-loading`)}),(0,B.jsx)(`span`,{className:`text-xs`,children:r(`label-category-cleanup-background`)})]}),(0,B.jsxs)(Gs,{className:`gap-2 sm:justify-between`,children:[(0,B.jsxs)(U,{variant:`secondary`,size:`sm`,disabled:u,onClick:()=>void T(),children:[(0,B.jsx)(Le,{className:`size-3.5`}),r(`btn-category-cleanup-undo`)]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>t?.(!1),children:r(`btn-cancel`)}),(0,B.jsx)(U,{size:`sm`,disabled:u||!i||o.size===0||!C,onClick:()=>void w(),children:r(`btn-category-cleanup-apply`)})]})]})]})})}function nl({className:e,...t}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:z(`size-4 shrink-0`,e),...t,children:(0,B.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}var rl=15e3,il=5e3,al=500,ol=3e4,sl=2e3,cl=42e4,ll=new Set([`idle`,`installing`,`restarting`,`failed`]);function ul(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.state!=`string`||!ll.has(t.state)))return{available:typeof t.available==`string`?t.available:null,state:t.state,code:typeof t.code==`string`?t.code:null,canInstall:t.canInstall===!0}}var dl=()=>({"x-omms-token":window.__OMMS_TOKEN__??``});async function fl(){try{let e=await fetch(`/api/web/status`,{headers:dl(),signal:AbortSignal.timeout(il)});if(!e.ok)return null;let t=await e.json();if(typeof t.version!=`string`||typeof t.canControl!=`boolean`)return null;let n=ul(t.update);return{version:t.version,canControl:t.canControl,...typeof t.instance==`string`?{instance:t.instance}:{},...n?{update:n}:{}}}catch{return null}}async function pl(e){try{return(await fetch(`/api/web/${e}`,{method:`POST`,headers:{...dl(),"Content-Type":`application/json`},body:`{}`,signal:AbortSignal.timeout(il)})).status===202}catch{return!1}}async function ml(e,t={}){let n=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),r;for(let t=0;;t+=al){if(r=await fl(),r&&r.instance!==e)return`restarted`;if(t>=ol)break;await n(al)}return r?`unchanged`:`down`}async function hl(){try{return(await fetch(`/api/web/update`,{method:`POST`,headers:{...dl(),"Content-Type":`application/json`},body:`{}`,signal:AbortSignal.timeout(il)})).status===202}catch{return!1}}async function gl(e,t={}){let n=t.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let t=0;t<=cl;t+=sl){let t=await fl();if(t&&t.instance!==e)return{kind:`restarted`};if(t?.update?.state===`failed`)return{kind:`failed`,code:t.update.code??`unknown`};await n(sl)}return{kind:`timeout`}}var _l={ok:!0,status:null},vl=new Set,yl=null,bl=0,xl=0;async function Sl(){let e=++bl,t=await fl();if(!(e<xl)){xl=e,_l=t?{ok:!0,status:t}:{..._l,ok:!1};for(let e of vl)e(_l)}}function Cl(e){return vl.add(e),e(_l),Sl(),yl??=setInterval(()=>void Sl(),rl),()=>{vl.delete(e),vl.size===0&&yl!==null&&(clearInterval(yl),yl=null)}}var wl=()=>_l;function Tl(){return(0,_.useSyncExternalStore)(Cl,wl,wl)}var El=`om-memory-system web`;function Dl(){let{t:e}=yr(),{ok:t,status:n}=Tl(),r=n?.canControl??!1,i=n?.instance??null,[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(`idle`),[l,u]=(0,_.useState)(``);async function d(e){if(s!==`idle`)return;if(c(`working`),u(``),!await pl(e)){c(`idle`),u(`power-request-failed`);return}if(o(!1),e===`stop`){c(`stopped`);return}c(`restarting`);let t=await ml(i);if(t===`restarted`){window.location.reload();return}if(t===`unchanged`){u(`power-restart-failed`),c(`idle`),o(!0);return}u(`power-restart-timeout`),c(`stopped`)}return!r&&s===`idle`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,"data-power":t?`on`:`off`,className:`inline-flex min-h-11 min-w-11 md:min-h-8 md:min-w-7 items-center justify-center self-stretch border-s border-sidebar-border px-1.5 text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,onClick:()=>{u(``),o(!0)},"aria-label":e(`power-button`),title:e(`power-button`),children:(0,B.jsx)(Te,{className:z(`size-4`,t&&`text-emerald-500`)})}),(0,B.jsx)(Bs,{open:a,onOpenChange:e=>s===`idle`&&o(e),children:(0,B.jsxs)(Us,{showCloseButton:!1,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:e(`power-dialog-title`)})}),(0,B.jsx)(`p`,{children:e(`power-dialog-body`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`power-note`)}),l?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:e(l)}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,B.jsx)(U,{variant:`ghost`,disabled:s!==`idle`,onClick:()=>o(!1),children:e(`power-cancel`)}),(0,B.jsx)(U,{variant:`destructive`,disabled:s!==`idle`,onClick:()=>void d(`stop`),children:e(`power-stop`)}),(0,B.jsx)(U,{autoFocus:!0,disabled:s!==`idle`,onClick:()=>void d(`restart`),children:e(`power-restart`)})]})]})}),s===`restarting`||s===`stopped`?(0,B.jsx)(`div`,{role:`alert`,className:`fixed inset-0 z-[60] flex flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:s===`restarting`?(0,B.jsx)(`p`,{children:e(`power-restarting`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h2`,{className:`text-section-title font-semibold`,children:e(`power-stopped-title`)}),l?(0,B.jsx)(`p`,{children:e(l)}):null,(0,B.jsx)(`p`,{children:e(`power-stopped-command`)}),(0,B.jsx)(`code`,{className:`rounded-md bg-muted px-2 py-1`,children:El}),(0,B.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e(`power-note`)})]})}):null]})}function Ol({brand:e,className:t}){let{status:n}=Tl();return(0,B.jsxs)(`span`,{className:z(`flex min-w-0 items-baseline gap-1.5`,t),children:[(0,B.jsx)(`span`,{className:`truncate text-ui font-medium tracking-wide text-brand-label`,children:e}),n?(0,B.jsxs)(`span`,{className:`shrink-0 text-xs text-foreground`,"data-testid":`sidebar-version`,children:[`v`,n.version]}):null]})}var kl=[{label:`update-host-claude`,command:`claude plugin update omms@omms`},{label:`update-host-opencode`,command:`opencode plugin update om-memory-system`},{label:`update-host-pi`,command:`pi update npm:om-memory-system`},{label:`update-host-global`,command:`npm i -g om-memory-system@latest && om-memory-system web install`}],Al={row:`mb-2 flex min-h-11 w-full rounded-lg border border-sidebar-border/80 bg-card/70 px-2`,inline:`inline-flex min-h-8 self-stretch border-s border-sidebar-border px-2`,icon:`inline-flex min-h-8 min-w-7 self-stretch px-1.5 py-1.5`};function jl(){let{ok:e,status:t}=Tl(),n=t?.update;return!t?.canControl||!n?.available?null:{ok:e,status:t,update:n,available:n.available}}function Ml({variant:e=`row`,className:t,onOpen:n}){let{t:r}=yr(),i=jl();return i?.ok?(0,B.jsx)(`button`,{type:`button`,"data-update":i.available,"data-variant":e,className:z(`items-center justify-center text-xs font-medium text-brand-label transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,Al[e],t),onClick:n,"aria-label":r(`update-button`,{version:i.available}),title:r(`update-button`,{version:i.available}),children:e===`icon`?(0,B.jsx)(M,{className:`size-4`}):r(`update-label`)}):null}function Nl({open:e,onOpenChange:t}){let{t:n}=yr(),r=jl(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null);if(!r)return null;let{status:u,update:d,available:f}=r,p=d.state===`failed`?d.code:null,m=i||d.state===`installing`||d.state===`restarting`;async function h(){if(m)return;if(a(!0),s(``),!await hl()){a(!1),s(n(`update-request-failed`));return}let e=await gl(u?.instance??null);if(e.kind===`restarted`){window.location.reload();return}a(!1),s(e.kind===`failed`?n(`update-failed`,{code:e.code}):n(`update-timeout`))}function g(e){navigator.clipboard?.writeText(e),l(e)}let v=o||(p?n(`update-failed`,{code:p}):``);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Bs,{open:e,onOpenChange:e=>!m&&t(e),children:(0,B.jsxs)(Us,{showCloseButton:!1,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:n(`update-dialog-title`)})}),(0,B.jsx)(`p`,{children:n(`update-versions`,{running:u.version,available:f})}),(0,B.jsx)(`p`,{className:`text-sm`,children:n(`update-hosts-intro`)}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-2`,children:kl.map(({label:e,command:t})=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(e)}),(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 text-xs`,children:t}),(0,B.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>g(t),"aria-label":`${n(`update-copy`)}: ${t}`,children:[(0,B.jsx)(ce,{className:`size-3.5`}),n(c===t?`update-copied`:`update-copy`)]})]})]},t))}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`update-hosts-note`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d.canInstall?n(`update-install-note`):n(`update-cannot-install`)}),m?(0,B.jsx)(`p`,{role:`status`,className:`text-sm`,children:n(`update-installing`)}):null,v&&!m?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,B.jsx)(U,{variant:`ghost`,disabled:m,onClick:()=>t(!1),children:n(`update-close`)}),(0,B.jsx)(U,{autoFocus:!0,disabled:m||!d.canInstall,onClick:()=>void h(),children:n(`update-install`)})]})]})})})}var Pl=Object.defineProperty,Fl=(e,t)=>Pl(e,`name`,{value:t,configurable:!0}),Il=`horizontal`,Ll=[`horizontal`,`vertical`],Rl=_.forwardRef(Fl(function(e,t){let{decorative:n,orientation:r=Il,...i}=e,a=zl(r)?r:Il,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,B.jsx)(Ni.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function zl(e){return Ll.includes(e)}Fl(zl,`isValidOrientation`);var Bl=Rl;function K({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Bl,{"data-slot":`separator`,decorative:n,orientation:t,className:z(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var q=[{id:`memory-section-import`,title:`Import chat history`},{id:`memory-section-auto-import`,title:`Automatic import`},{id:`memory-section-profile`,title:`Profile learning`},{id:`memory-section-limits`,title:`Memory limits`},{id:`memory-section-project-folders`,title:`Resolve missing project folders`}],Vl={"settings-section-import":`memory-section-import`,"settings-section-auto-import":`memory-section-auto-import`,"settings-section-profile":`memory-section-profile`,"settings-section-memory":`memory-section-limits`,"settings-section-directory-maps":`memory-section-project-folders`};function Hl(e,t){if(e!==`/settings`)return null;let n=t.replace(/^#/,``);return Vl[n]?`#${Vl[n]}`:/^directory-maps-(pi|opencode|claude-code)$/.test(n)?t:null}function Ul(e,t){let n=e.startsWith(`#`)?e.slice(1):``;if(!/^(settings|memory)-section-[a-z0-9-]+$/.test(n))return!1;let r=t.getElementById(n);return r?(r.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1}function Wl(e){if(typeof document>`u`||typeof requestAnimationFrame>`u`)return;let t=e.replace(/^#/,``);if(!/^(?:(?:settings|memory)-section-[a-z0-9-]+|directory-maps-(?:pi|opencode|claude-code)|profile-(?:preferences|patterns|workflows))$/.test(t))return;let n=0,r=()=>{let e=document.getElementById(t);if(!e){n++<50&&requestAnimationFrame(r);return}if(t.startsWith(`directory-maps-`)){let t=e.parentElement;t&&(t.open=!0),e.focus({preventScroll:!0})}e.scrollIntoView({behavior:`smooth`,block:`start`})};requestAnimationFrame(r)}var J={home:`/`,project:`/project-memories`,profile:`/user-profile`,settings:`/settings`,memory:`/memory`};function Gl(e){let t=e.replace(/\/+$/,``)||`/`;return t.startsWith(`/`)?t:`/${t}`}function Kl(e){let t=Gl(e);return t===J.memory?`memory`:t===J.settings?`settings`:t===J.profile?`profile`:`project`}function ql(e){let t=Gl(e);return t===J.home||t===J.project||t===J.profile||t===J.settings||t===J.memory}function Jl(e){let t=Gl(e);return t===J.home?J.project:ql(t)?t:J.project}function Yl(e,t=``){let n=Hl(Gl(e),t);return n?`${J.memory}${n}`:`${Jl(e)}${t}`}var Xl=typeof window<`u`?Yl(window.location.pathname,window.location.hash):J.project,Zl=new Set;function Ql(){for(let e of Zl)e()}function $l(e){Xl!==e&&(Xl=e,Ql())}function eu(e){return Zl.add(e),()=>{Zl.delete(e)}}function tu(){return Xl}function nu(){return J.project}function ru(e,t=!1){let[n,r=``]=e.split(/(?=#)/),i=Yl(n,r),a=Hl(Gl(n),r);`${Gl(window.location.pathname)}${window.location.hash}`!==i&&(t||a?window.history.replaceState({},``,i):window.history.pushState({},``,i)),$l(i),(r||a)&&Wl(a??r)}function iu(){let e=()=>{let e=`${Gl(window.location.pathname)}${window.location.hash}`,t=Yl(window.location.pathname,window.location.hash);e!==t&&window.history.replaceState({},``,t),$l(t),window.location.hash&&Wl(window.location.hash)};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function au(){return(0,_.useSyncExternalStore)(eu,tu,nu)}function ou(){return Kl(au().split(`#`)[0])}var su=`omms-theme`,cu=`opencode-mem-theme`;function lu(){if(typeof window>`u`)return`dark`;let e=Zn(su,cu);return e===`light`||e===`dark`?e:`dark`}var uu=lu(),du=new Set;function fu(){for(let e of du)e()}function pu(e){uu=e,typeof document<`u`&&(document.documentElement.classList.toggle(`dark`,e===`dark`),Qn(su,e)),fu()}function mu(e){return du.add(e),()=>{du.delete(e)}}function hu(){return uu}function gu(){return`dark`}function _u(e){pu(e)}function vu(){let e=uu===`dark`?`light`:`dark`;return _u(e),e}function yu(){pu(lu())}function bu(){return(0,_.useSyncExternalStore)(mu,hu,gu)}typeof document<`u`&&pu(uu);var xu=[{code:`en`,label:`English (EN)`},{code:`zh`,label:`中文 (ZH)`},{code:`ar`,label:`العربية (AR)`}],Su=`omms-sidebar-collapsed`,Cu=`omms-sidebar-settings-open`,wu=`omms-sidebar-memory-open`,Tu=`inline-flex min-h-11 min-w-11 md:min-h-8 md:min-w-7 items-center justify-center text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`;function Eu(){try{let e=localStorage.getItem(Cu);return e===null?null:e===`1`}catch{return null}}function Du(){try{return localStorage.getItem(Su)===`1`}catch{return!1}}function Ou({open:e=!1,currentView:t,brand:n,projectLabel:r,profileLabel:i,profileSections:a,settingsSections:o=[],memoryLabel:s=`Memory`,memorySections:c=[],langLabel:l,languageLabel:u,themeLabel:d,settingsLabel:f,closeLabel:p,collapseLabel:m,expandLabel:h,onOpenChange:g,onLanguageSelect:v}){let y=bu()===`dark`,[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),[E,D]=(0,_.useState)(Du),O=e=>E?e:``,[ee,te]=(0,_.useState)(()=>Eu()??t===`settings`),[k,ne]=(0,_.useState)(()=>{try{let e=localStorage.getItem(wu);return e===null?t===`memory`:e===`1`}catch{return t===`memory`}});function ie(){let e=!k;ne(e);try{localStorage.setItem(wu,e?`1`:`0`)}catch{}}function ae(){let e=!ee;te(e);try{localStorage.setItem(Cu,e?`1`:`0`)}catch{}}function A(){let e=!E;D(e);try{localStorage.setItem(Su,e?`1`:`0`)}catch{}}(0,_.useEffect)(()=>{if(!b)return;w.current?.querySelector(`[aria-checked=true]`)?.focus();function e(e){w.current?.contains(e.target)||x(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[b]);function oe(e){if(e.key===`Escape`&&(e.preventDefault(),x(!1),T.current?.focus()),![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Array.from(w.current?.querySelectorAll(`[role=menuitemradio]`)??[]),n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}function M(e){g?.(e)}function se(e,t){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),ru(t),M(!1))}function ce(e,t,n=`profile`){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),ru(`${J[n]}#${t}`),M(!1))}function P(e){return z(`flex w-full min-w-0 min-h-11 md:min-h-9 items-center gap-2 rounded-[10px] px-3 py-2 text-ui transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,O(`md:justify-center md:px-0`),e?`bg-sidebar-accent text-sidebar-accent-foreground`:`text-sidebar-foreground hover:bg-interactive-hover active:bg-interactive-active`)}return(0,B.jsxs)(B.Fragment,{children:[e?(0,B.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-black/50 md:hidden`,"aria-label":p,onClick:()=>M(!1)}):null,(0,B.jsxs)(`aside`,{className:z(`inset-y-0 start-0 z-50 flex h-svh w-64 shrink-0 flex-col border-e border-sidebar-border bg-sidebar text-sidebar-foreground transition-[transform,width] duration-200`,O(`md:w-14`),`fixed md:sticky md:top-0 md:translate-x-0!`,e?`translate-x-0`:`max-md:-translate-x-full max-md:rtl:translate-x-full`),children:[(0,B.jsxs)(`div`,{className:z(`flex items-center gap-2 px-4 py-4`,O(`md:flex-col md:px-2`)),children:[(0,B.jsxs)(`a`,{href:J.home,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg transition-colors hover:opacity-90`,onClick:e=>se(e,J.home),children:[(0,B.jsx)(`img`,{src:`/omms-icon.svg`,alt:``,width:20,height:20,className:`size-5 shrink-0 rounded-sm`}),(0,B.jsx)(Ol,{brand:n,className:O(`md:hidden`)})]}),(0,B.jsx)(U,{variant:`ghost`,size:`icon-sm`,className:`hidden shrink-0 text-muted-foreground hover:text-primary md:inline-flex`,onClick:A,"aria-label":E?h:m,"aria-expanded":!E,title:E?h:m,children:E?(0,B.jsx)(ye,{className:`size-4 rtl:-scale-x-100`}):(0,B.jsx)(ve,{className:`size-4 rtl:-scale-x-100`})}),(0,B.jsx)(U,{variant:`ghost`,size:`icon-sm`,className:`md:hidden min-h-11 min-w-11 shrink-0`,onClick:()=>M(!1),"aria-label":p,children:(0,B.jsx)(Ve,{className:`size-4`})})]}),(0,B.jsx)(K,{className:`bg-sidebar-border`}),(0,B.jsxs)(`nav`,{className:z(`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-3`,O(`md:px-2`)),"aria-label":`Main`,children:[(0,B.jsxs)(`a`,{href:J.project,className:P(t===`project`),"aria-current":t===`project`?`page`:void 0,title:E?r:void 0,onClick:e=>se(e,J.project),children:[(0,B.jsx)(N,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start`,O(`md:sr-only`)),children:r})]}),(0,B.jsxs)(`a`,{href:J.profile,className:P(t===`profile`),"aria-current":t===`profile`?`page`:void 0,title:E?i:void 0,onClick:e=>se(e,J.profile),children:[(0,B.jsx)(ze,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start`,O(`md:sr-only`)),children:i})]}),(0,B.jsx)(`ul`,{className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:a.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.profile}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,onClick:t=>ce(t,e.id),children:e.label})},e.id))}),(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`a`,{href:J.memory,className:P(t===`memory`),"aria-current":t===`memory`?`page`:void 0,title:E?s:void 0,onClick:e=>se(e,J.memory),children:[(0,B.jsx)(re,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start uppercase`,O(`md:sr-only`)),children:s})]}),c.length>0?(0,B.jsx)(`button`,{type:`button`,className:z(`inline-flex min-h-11 min-w-11 md:min-h-7 md:min-w-7 shrink-0 items-center justify-center rounded-lg p-1.5 text-muted-foreground hover:bg-interactive-hover focus-visible:outline-2 focus-visible:outline-ring`,O(`md:hidden`)),onClick:ie,"aria-expanded":k,"aria-controls":`sidebar-memory-tree`,"aria-label":s,title:s,children:(0,B.jsx)(j,{className:z(`size-4 transition-transform rtl:-scale-x-100`,k&&`rotate-90 rtl:rotate-90`)})}):null]}),k&&c.length>0?(0,B.jsx)(`ul`,{id:`sidebar-memory-tree`,className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:c.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.memory}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground hover:bg-interactive-hover focus-visible:outline-2 focus-visible:outline-ring`,onClick:t=>ce(t,e.id,`memory`),children:e.label})},e.id))}):null,(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`a`,{href:J.settings,className:P(t===`settings`),"aria-current":t===`settings`?`page`:void 0,title:E?f:void 0,onClick:e=>se(e,J.settings),children:[(0,B.jsx)(ke,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start uppercase`,O(`md:sr-only`)),children:f})]}),o.length>0?(0,B.jsx)(`button`,{type:`button`,className:z(`inline-flex min-h-11 min-w-11 md:min-h-7 md:min-w-7 shrink-0 items-center justify-center rounded-lg p-1.5 text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,O(`md:hidden`)),onClick:ae,"aria-expanded":ee,"aria-controls":`sidebar-settings-tree`,"aria-label":f,title:f,children:(0,B.jsx)(j,{className:z(`size-4 transition-transform rtl:-scale-x-100`,ee&&`rotate-90 rtl:rotate-90`)})}):null]}),ee&&o.length>0?(0,B.jsx)(`ul`,{id:`sidebar-settings-tree`,className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:o.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.settings}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,onClick:t=>ce(t,e.id,`settings`),children:e.label})},e.id))}):null]}),(0,B.jsxs)(`div`,{className:z(`mt-auto p-3`,O(`md:px-2`)),children:[(0,B.jsx)(Ml,{variant:`row`,className:`md:hidden`,onOpen:()=>C(!0)}),(0,B.jsxs)(`div`,{className:z(`flex w-fit items-center rounded-lg border border-sidebar-border/80 bg-card/70`,O(`md:mx-auto md:flex-col md:[&>*]:justify-center md:[&>*]:py-1.5 md:[&>*+*]:border-s-0 md:[&>*+*]:border-t md:[&>*]:rounded-none`)),children:[(0,B.jsxs)(`div`,{ref:w,className:`relative flex self-stretch`,onBlur:e=>{w.current?.contains(e.relatedTarget)||x(!1)},children:[(0,B.jsx)(`button`,{ref:T,type:`button`,className:`${Tu} rounded-s-lg px-1.5 py-1.5 text-ui`,onClick:()=>x(e=>!e),"aria-label":`${u}: ${l}`,"aria-haspopup":`menu`,"aria-expanded":b,"aria-controls":`sidebar-language-menu`,title:u,children:(0,B.jsx)(`span`,{className:`text-xs tabular-nums`,children:l})}),b?(0,B.jsx)(`div`,{id:`sidebar-language-menu`,role:`menu`,"aria-label":u,onKeyDown:oe,className:`absolute bottom-full start-0 z-10 mb-2 w-44 max-h-[60vh] overflow-y-auto rounded-lg border border-sidebar-border bg-card p-1 shadow-lg`,children:xu.map(({code:e,label:t})=>(0,B.jsx)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":l.toLowerCase()===e,className:`flex min-h-11 md:min-h-9 w-full items-center rounded-md px-2.5 py-2 text-start text-ui text-card-foreground aria-checked:bg-selection hover:bg-interactive-hover focus-visible:bg-selection focus-visible:outline-2 focus-visible:outline-ring`,onClick:()=>{v?.(e),x(!1),T.current?.focus()},children:t},e))}):null]}),(0,B.jsx)(`button`,{type:`button`,className:`${Tu} self-stretch border-s border-sidebar-border px-1.5`,onClick:()=>vu(),"aria-label":d,title:d,children:y?(0,B.jsx)(ge,{className:`size-4 rounded-md p-0.5`}):(0,B.jsx)(je,{className:`size-4 rounded-md p-0.5`})}),(0,B.jsx)(`a`,{href:J.settings,className:`${Tu} self-stretch border-s border-sidebar-border px-1.5`,onClick:e=>se(e,J.settings),"aria-label":f,title:f,"aria-current":t===`settings`?`page`:void 0,children:(0,B.jsx)(ke,{className:`size-4`})}),(0,B.jsx)(Dl,{}),(0,B.jsx)(`a`,{href:`https://github.com/cmdaltctr/omms`,target:`_blank`,rel:`noopener noreferrer`,className:`${Tu} self-stretch rounded-e-lg border-s border-sidebar-border px-1.5`,title:`GitHub`,"aria-label":`GitHub`,children:(0,B.jsx)(nl,{className:`size-4`})}),(0,B.jsx)(Ml,{onOpen:()=>C(!0),variant:E?`icon`:`inline`,className:z(`max-md:hidden`,E?`md:border-t md:border-sidebar-border`:`rounded-e-lg`)})]}),(0,B.jsx)(Nl,{open:S,onOpenChange:C})]})]})]})}var ku=Object.defineProperty,Au=_.forwardRef(((e,t)=>ku(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,B.jsx)(Ni.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`));function ju({className:e,...t}){return(0,B.jsx)(Au,{"data-slot":`label`,className:z(`flex items-center gap-2 text-ui leading-normal select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Mu({className:e,...t}){return(0,B.jsx)(`textarea`,{"data-slot":`textarea`,dir:`auto`,className:z(`border-input placeholder:text-muted-foreground selection:bg-selection selection:text-foreground flex field-sizing-content min-h-16 w-full min-w-0 rounded-[10px] border bg-card px-2.5 py-2 text-ui [unicode-bidi:plaintext] transition-colors duration-150 outline-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`aria-invalid:ring-destructive aria-invalid:ring-1 aria-invalid:border-destructive`,e),...t})}function Nu({open:e=!1,content:t=``,onOpenChange:n,onSave:r}){let{t:i}=yr(),[a,o]=(0,_.useState)(``);(0,_.useEffect)(()=>{e&&o(t)},[e,t]);function s(e){n?.(e)}function c(e){e.preventDefault();let t=a.trim();t&&r?.(t)}return(0,B.jsx)(Bs,{open:e,onOpenChange:s,children:(0,B.jsxs)(Us,{className:`sm:max-w-lg`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:i(`modal-edit-title`)})}),(0,B.jsxs)(`form`,{className:`space-y-4`,onSubmit:c,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(ju,{htmlFor:`edit-content`,children:i(`label-content`)}),(0,B.jsx)(Mu,{id:`edit-content`,rows:6,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,B.jsxs)(Gs,{children:[(0,B.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>s(!1),children:i(`btn-cancel`)}),(0,B.jsx)(U,{type:`submit`,children:i(`btn-save`)})]})]})]})})}function Pu({children:e,maxHeight:t,fade:n=`var(--card)`}){let{t:r}=yr(),i=(0,_.useId)(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>l(e.offsetHeight>t);if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t]);let u=c&&!o;return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{id:i,className:`relative overflow-hidden`,style:u?{maxHeight:t}:void 0,"data-collapsed":u?`true`:void 0,children:[(0,B.jsx)(`div`,{ref:a,children:e}),u?(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-12`,style:{background:`linear-gradient(to top, ${n}, transparent)`}}):null]}),c?(0,B.jsxs)(U,{variant:`ghost`,size:`xs`,"aria-expanded":o,"aria-controls":i,onClick:()=>s(e=>!e),children:[o?(0,B.jsx)(oe,{}):(0,B.jsx)(ae,{}),r(o?`btn-see-less`:`btn-see-more`)]}):null]})}var Fu=8;function Iu({content:e,children:t,className:n}){let r=_.useId(),i=_.useRef(null),[a,o]=_.useState(0),s=_.isValidElement(t)?_.cloneElement(t,{"aria-describedby":r}):t,c=()=>{let e=i.current;if(!e)return;let t=e.parentElement.getBoundingClientRect(),n=e.offsetWidth/2,r=t.left+t.width/2,a=document.documentElement.clientWidth,s=Fu+n,c=a-Fu-n;o(Math.min(Math.max(r,s),c)-r)};return(0,B.jsxs)(`span`,{className:z(`group/tooltip relative inline-flex`,n),onPointerEnter:c,onFocus:c,children:[s,(0,B.jsxs)(`span`,{ref:i,id:r,role:`tooltip`,style:{transform:`translateX(calc(-50% + ${a}px))`},className:`pointer-events-none absolute bottom-full left-1/2 z-30 mb-2 w-max max-w-[min(24rem,calc(100vw-1rem))] rounded-md border border-border bg-card px-2 py-1 text-xs whitespace-normal text-card-foreground opacity-0 shadow-sm transition-opacity duration-150 ease-in group-focus-within/tooltip:opacity-100 group-hover/tooltip:opacity-100`,children:[e,(0,B.jsx)(`span`,{"aria-hidden":`true`,style:{left:`calc(50% - ${a}px)`},className:`absolute top-full -mt-1 size-2 -translate-x-1/2 rotate-45 border-e border-b border-border bg-card`})]})]})}function Lu({type:e}){let{t}=yr();return(0,B.jsx)(Iu,{content:t(`tooltip-memory-type`),className:`min-w-0 max-w-full`,children:(0,B.jsx)(Zc,{variant:`outline`,"data-memory-type":e,tabIndex:0,className:`h-auto min-h-5 max-w-full shrink break-all whitespace-normal bg-transparent border-current [color:oklch(0.42_0.13_var(--memory-type-hue))] dark:[color:oklch(0.8_0.13_var(--memory-type-hue))]`,style:{"--memory-type-hue":String(Jc(e))},children:e})})}var Ru=/<pasted_content\b[^>]*>([\s\S]*?)<\/pasted_content[^>]*>|```[^\n]*\n([\s\S]*?)```/g;function zu(e){return e.replace(/^\n+|\n+$/g,``)}function Bu(e){let t=[],n=e=>{let n=zu(e);n.trim()&&t.push({kind:`text`,text:n})},r=0;for(let i of e.matchAll(Ru)){n(e.slice(r,i.index));let a=i[1]!==void 0;t.push({kind:a?`pasted`:`code`,text:zu(a?i[1]:i[2])}),r=i.index+i[0].length}return n(e.slice(r)),t}function Vu(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g))r.index>n&&t.push({code:!1,text:e.slice(n,r.index)}),t.push({code:!0,text:r[1]}),n=r.index+r[0].length;return n<e.length&&t.push({code:!1,text:e.slice(n)}),t}function Hu({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background/60`,children:[e?(0,B.jsx)(`div`,{className:`border-b border-border px-3 py-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}):null,(0,B.jsx)(`pre`,{dir:`ltr`,className:`overflow-x-auto p-3 font-mono text-code leading-relaxed whitespace-pre-wrap break-words`,children:t})]})}function Uu({content:e}){let{t}=yr();return(0,B.jsx)(`div`,{className:`space-y-3`,children:Bu(e).map((e,n)=>e.kind===`pasted`?(0,B.jsx)(Hu,{label:t(`label-pasted-content`),children:e.text},n):e.kind===`code`?(0,B.jsx)(Hu,{children:e.text},n):(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:Vu(e.text).map((e,t)=>e.code?(0,B.jsx)(`code`,{className:`inline-code`,children:e.text},t):(0,B.jsx)(_.Fragment,{children:e.text},t))},n))})}function Wu(e){let t=new Date(e),n=mr(),r=n===`zh`?`zh-CN`:n===`ar`?`ar-SA`:`en-US`;return t.toLocaleString(r,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Gu(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ku(e){if(Array.isArray(e))return e}function qu(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ju(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
55
|
+
`?(p+=`\\n`,t+=2):(p+=n,t+=2)}else{let n=e.charAt(t);n===`"`&&e[t-1]!==`\\`?(p+=`\\${n}`,t++):vc(n)?(p+=Lc[n],t++):(lc(n)||D(n),p+=n,t++)}o&&f()}}return!1}function v(){let r=!1;for(a();e[t]===`+`;){r=!0,t++,a(),n=Dc(n,`"`,!0);let e=n.length;n=_()?kc(n,e,1):Oc(n,`"`)}return r}function y(){let r=t,i=``,a=!1;for(e[t]===`-`&&(i+=e[t],t++,!cc(e[t])&&E()&&(i+=`0`)),e[t]===`0`&&cc(e[t+1])&&(a=!0);cc(e[t]);)i+=e[t],t++;if(e[t]===`.`)for((i===``||i===`-`)&&(i+=`0`),i+=e[t],t++,cc(e[t])||(i+=`0`);cc(e[t]);)i+=e[t],t++;if(t>r){if(e[t]===`e`||e[t]===`E`)for(i===`-`&&(a=!0),i+=e[t],t++,(e[t]===`-`||e[t]===`+`)&&(i+=e[t],t++),cc(e[t])||(i+=`0`);cc(e[t]);)i+=e[t],t++;return E()?(n+=a?`"${e.substring(r,t)}"`:i,!0):(t=r,!1)}return!1}function b(){return x(`true`,`true`)||x(`false`,`false`)||x(`null`,`null`)||x(`True`,`true`)||x(`False`,`false`)||x(`None`,`null`)}function x(r,i){return e.slice(t,t+r.length)===r&&!fc(e[t+r.length])&&(n+=i,t+=r.length,!0)}function S(r){let a=t;if(dc(e[t])){for(;t<e.length&&fc(e[t]);)t++;let n=t;for(;yc(e,n);)n++;if(e[n]===`(`)return t=n+1,i(),e[t]===`)`&&(t++,e[t]===`;`&&t++),!0}for(;t<e.length&&!hc(e[t])&&!Sc(e[t])&&(!r||e[t]!==`:`);)t++;if(e[t-1]===`:`&&pc.test(e.substring(a,t+2)))for(;t<e.length&&mc.test(e[t]);)t++;if(t>a){for(;yc(e,t-1)&&t>0;)t--;let r=e.slice(a,t);return n+=r===`undefined`?`null`:JSON.stringify(r),e[t]===`"`&&t++,!0}}function C(){if(e[t]===`/`){let r=t;for(t++;t<e.length&&(e[t]!==`/`||e[t-1]===`\\`);)t++;return t++,n+=JSON.stringify(e.substring(r,t)),!0}}function w(t){let n=t;for(;n>0&&yc(e,n);)n--;return n}function T(t){let n=t+1;for(;n<e.length&&yc(e,n);)n++;return n>=e.length||uc(e[n])}function E(){return t>=e.length||uc(e[t])||yc(e,t)}function D(e){throw new Js(`Invalid character ${JSON.stringify(e)}`,t)}function O(){throw new Js(`Unexpected character ${JSON.stringify(e[t])}`,t)}function ee(){throw new Js(`Unexpected end of json string`,e.length)}function te(){throw new Js(`Object key expected`,t)}function k(){throw new Js(`Colon expected`,t)}function ne(){throw new Js(`Invalid unicode character "${e.slice(t,t+6)}"`,t)}}function Bc(e,t){return e[t]===`*`&&e[t+1]===`/`}function Vc(e){if(!e)return[];let t=e,n=null;for(;typeof t==`string`&&t!==n;){n=t;try{t=JSON.parse(zc(t))}catch{break}}if(!Array.isArray(t))return[];let r=[],i=e=>{Array.isArray(e)?e.forEach(i):e&&typeof e==`object`&&r.push(e)};return i(t),r}function Hc(e,t){if(!t||!e.includes(`_`))return null;let[n,r]=e.split(`_`),i=parseInt(r,10);return Number.isNaN(i)?null:n===`pref`?t.preferences?.[i]?.description??null:n===`pat`?t.patterns?.[i]?.description??null:n===`wf`?t.workflows?.[i]?.description??null:null}function Uc(e,t){if(!t||!e.includes(`_`))return null;let[n,r]=e.split(`_`),i=parseInt(r,10);return Number.isNaN(i)||n!==`wf`?null:t.workflows?.[i]?.steps||null}function Wc(e){return e>=80?`high`:e>=60?`medium`:e>=40?`low`:`poor`}var Gc={high:`border-green-600/40 bg-green-500/15 text-green-700 dark:text-green-400`,medium:`border-blue-600/40 bg-blue-500/15 text-blue-700 dark:text-blue-400`,low:`border-orange-600/40 bg-orange-500/15 text-orange-700 dark:text-orange-400`,poor:`border-red-600/40 bg-red-500/15 text-red-700 dark:text-red-400`};function Kc(e,t){return e.length>t?e.substring(0,t)+`...`:e}function qc({open:e=!1,profile:t=null,onOpenChange:n,onApplied:r}){let{t:i}=yr(),[a,o]=(0,_.useState)(`select`),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(new Set),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(new Set),[h,g]=(0,_.useState)(new Set),[v,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(!1),S=(0,_.useRef)(!1),C=(0,_.useMemo)(()=>{let e={};for(let t of s){let n=t.category||`(none)`;e[n]||(e[n]={pref:[],pat:[],wf:[]}),e[n][t._type].push(t)}return e},[s]),w=(0,_.useMemo)(()=>Object.keys(C).sort(),[C]),T=l.size,E=p.size+h.size,D=(d?.changes.merged?.length||0)+(d?.changes.removed?.length||0);function O(){let e=t?.profileData;if(!e){V.error(`No profile data loaded`),ee(!1);return}let n=(e.preferences||[]).map((e,t)=>({...e,_id:`pref_${t}`,_type:`pref`})),r=(e.patterns||[]).map((e,t)=>({...e,_id:`pat_${t}`,_type:`pat`})),i=(e.workflows||[]).map((e,t)=>({...e,_id:`wf_${t}`,_type:`wf`})),a=[...n,...r,...i];c(a),u(new Set(a.filter(e=>(e.frequency||0)<=3).map(e=>e._id))),o(`select`),f(null),y(!1)}(0,_.useEffect)(()=>{e&&!S.current?O():!e&&S.current&&(o(`select`),f(null),x(!1)),S.current=e},[e]);function ee(e){n?.(e)}function te(e,t){u(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function ne(){u(new Set(s.map(e=>e._id)))}function re(){u(new Set)}function ie(){u(new Set(s.filter(e=>(e.frequency||0)<=3).map(e=>e._id)))}function A(){let e=new Set;for(let t of Object.keys(C)){let n=[...C[t].pref,...C[t].pat,...C[t].wf];if(n.length>=3)for(let t of n)e.add(t._id)}u(e)}async function M(){let e=[...l];if(e.length===0){V.warning(`No items selected`);return}o(`loading`);let n=await Xn(`/api/user-profile/ai-cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({includeIds:e,profileVersion:t?.version}),timeout:18e4});if(!n.success||!n.data){o(`select`),V.error(n.error||i(`toast-ai-cleanup-failed`));return}f(n.data),m(new Set((n.data.changes.merged||[]).map((e,t)=>t))),g(new Set((n.data.changes.removed||[]).map((e,t)=>t))),o(`diff`)}function se(e){if(!e.includes(`_`))return`?`;let t=e.split(`_`)[0];return t===`pref`?i(`profile-type-pref`)||`Pref`:t===`pat`?i(`profile-type-pat`)||`Pat`:t===`wf`?i(`profile-type-wf`)||`Wf`:`?`}function ce(e,t){m(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function N(e,t){g(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function le(){m(new Set((d?.changes.merged||[]).map((e,t)=>t))),g(new Set((d?.changes.removed||[]).map((e,t)=>t)))}function ue(){m(new Set),g(new Set)}async function de(){if(!d||E===0)return;x(!0);let e=[...p].map(e=>d?.changes.merged?.[e]?.ids).filter(e=>!!e),t=[...h].map(e=>d?.changes.removed?.[e]?.id).filter(e=>!!e),n=await Xn(`/api/user-profile/ai-cleanup/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:d.new,acceptedMerged:e,acceptedRemoved:t})});x(!1),n.success?(V.success(i(`toast-ai-cleanup-success`)),ee(!1),r?.()):V.error(n.error||i(`toast-cleanup-apply-failed`))}return(0,B.jsx)(Bs,{open:e,onOpenChange:ee,children:(0,B.jsxs)(Us,{className:`grid! sm:max-w-2xl max-h-[90vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden gap-4`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:i(`label-ai-cleanup-title`)})}),a===`loading`?(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-muted-foreground`,children:[(0,B.jsx)(pe,{className:`size-6 animate-spin`}),(0,B.jsx)(`span`,{className:`text-sm`,children:i(`label-ai-cleanup-loading`)})]}):a===`select`?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`h3`,{className:`text-subsection-title font-semibold`,children:i(`label-ai-cleanup-select`)}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:ne,children:i(`label-ai-cleanup-select-all`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:re,children:i(`label-ai-cleanup-deselect-all`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:ie,children:i(`label-ai-cleanup-select-low`)}),(0,B.jsx)(U,{variant:`secondary`,size:`xs`,onClick:A,children:i(`label-ai-cleanup-select-same-cat`)})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto pr-1`,children:w.map(e=>{let t=[...C[e].pref,...C[e].pat,...C[e].wf];return(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs rounded-full bg-muted px-2 py-0.5`,children:e}),(0,B.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t.length,` items`]})]}),t.map(e=>{let t=l.has(e._id);return(0,B.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 px-2 py-1.5 text-sm cursor-pointer hover:bg-muted/40`,role:`checkbox`,"aria-checked":t,tabIndex:0,onClick:()=>te(e._id,!t),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),te(e._id,!t))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:t,tabIndex:-1})}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground w-4`,children:e._type===`pref`?`P`:e._type===`pat`?`T`:`W`}),(0,B.jsx)(`span`,{className:`flex-1 truncate`,children:(e.description||``).substring(0,80)}),(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground shrink-0`,children:[(0,B.jsx)(Ne,{className:`size-3`}),e.frequency||0,e.confidence==null?``:` | ${Math.round(e.confidence*100)}%`]})]},e._id)})]},e)})}),(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`label-ai-cleanup-selected`,{count:T})}),(0,B.jsx)(U,{onClick:M,children:i(`label-ai-cleanup-analyze`)})]})]}):a===`diff`&&d?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`label-ai-cleanup-changes-selected`,{selected:E,total:D})}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:le,children:i(`label-ai-cleanup-select-all`)}),(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:ue,children:i(`label-ai-cleanup-deselect-all`)})]})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto pr-1`,children:[(d.changes.merged||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-subsection-title font-semibold`,children:[(0,B.jsx)(P,{className:`size-3.5`}),i(`label-ai-cleanup-merged-header`,{count:d.changes.merged?.length||0})]}),(d.changes.merged||[]).map((e,t)=>{let n=e.ids.slice(1),r=e.result||``,a=Uc(e.ids[0],d.old),o=p.has(t);return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm cursor-pointer`,role:`checkbox`,"aria-checked":o,tabIndex:0,onClick:()=>ce(t,!o),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(t,!o))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:o,tabIndex:-1})}),(0,B.jsx)(`span`,{children:i(`label-ai-cleanup-merge-check`)})]}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_auto_1fr] items-start text-sm`,children:[(0,B.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=Hc(e,d.old),n=Uc(e,d.old);return t?(0,B.jsxs)(`div`,{className:`rounded-lg bg-muted/50 p-2 space-y-1`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`text-[10px] rounded bg-muted px-1.5 py-0.5`,children:se(e)}),` `,Kc(t,80)]}),n?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:n.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<n.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null]},e):null})}),(0,B.jsx)(`div`,{className:`text-muted-foreground self-center grid place-items-center`,children:(0,B.jsx)(j,{className:`size-4`})}),(0,B.jsxs)(`div`,{className:`rounded-lg bg-primary/10 p-2 space-y-1`,children:[(0,B.jsx)(`div`,{children:Kc(r,120)}),a?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:a.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<a.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null]})]})]},t)})]}):null,(d.changes.removed||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-subsection-title font-semibold`,children:[(0,B.jsx)(Pe,{className:`size-3.5`}),i(`label-ai-cleanup-removed-header`,{count:d.changes.removed?.length||0})]}),(d.changes.removed||[]).map((e,t)=>{let n=Hc(e.id,d.old),r=Uc(e.id,d.old),a=h.has(t);return(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm cursor-pointer`,role:`checkbox`,"aria-checked":a,tabIndex:0,onClick:()=>N(t,!a),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),N(t,!a))},children:[(0,B.jsx)(`span`,{className:`pointer-events-none inline-flex`,children:(0,B.jsx)($i,{checked:a,tabIndex:-1})}),(0,B.jsx)(`span`,{children:i(`label-ai-cleanup-remove-check`)})]}),(0,B.jsx)(`div`,{className:`text-sm`,children:n||e.id}),r?.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1 text-xs text-muted-foreground`,children:r.map((e,t)=>(0,B.jsxs)(`span`,{className:`contents`,children:[(0,B.jsxs)(`span`,{children:[t+1,`. `,e]}),t<r.length-1?(0,B.jsx)(k,{className:`size-3 inline`}):null]},t))}):null,(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.reason})]},t)})]}):null,(d.changes.kept||[]).length>0?(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-sm font-medium`,onClick:()=>y(e=>!e),children:[i(`label-ai-cleanup-kept`),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,d.changes.kept?.length||0,`)`]}),v?(0,B.jsx)(oe,{className:`size-3.5`}):(0,B.jsx)(ae,{className:`size-3.5`})]}),v?(0,B.jsx)(`div`,{className:`space-y-1`,children:(d.changes.kept||[]).map((e,t)=>(0,B.jsx)(`div`,{className:`text-xs text-muted-foreground rounded bg-muted/40 px-2 py-1`,children:e},t))}):null]}):null]})]}):null,(0,B.jsxs)(Gs,{children:[(0,B.jsx)(U,{variant:`secondary`,onClick:()=>ee(!1),children:i(`btn-cancel`)}),a===`diff`?(0,B.jsx)(U,{disabled:E===0||b,onClick:de,children:E>0?`${i(`label-ai-cleanup-apply`)} (${E})`:i(`label-ai-cleanup-apply`)||`Apply`}):null]})]})})}function Jc(e){let t=0;for(let n of e.trim().toLowerCase())t=t*31+n.codePointAt(0)|0;return Math.abs(t)%360}function Yc({keyword:e,active:t=!1,title:n,onClick:r,"aria-describedby":i,"aria-label":a}){let o=Jc(e);return(0,B.jsx)(`button`,{type:`button`,title:n,"aria-describedby":i,"aria-label":a,"aria-pressed":t,onClick:()=>r?.(e),className:z(`inline-flex min-h-6 max-w-full cursor-pointer items-center rounded-[7px] border px-2 text-xs break-words transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,`[color:oklch(0.42_0.13_var(--keyword-hue))] dark:[color:oklch(0.8_0.13_var(--keyword-hue))]`,t&&`ring-2 ring-offset-1 ring-offset-background`),style:{backgroundColor:`oklch(0.72 0.14 ${o} / 0.18)`,borderColor:`oklch(0.72 0.14 ${o} / 0.45)`,"--keyword-hue":String(o),"--tw-ring-color":`oklch(0.72 0.14 ${o} / 0.7)`},children:e})}var Xc=Gr(`h-5 gap-1 rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap transition-colors focus-visible:ring-[3px] [&>svg]:pointer-events-none`,{variants:{variant:{default:`bg-primary/10 border-primary/25 text-primary-label [a]:hover:bg-primary/16`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 border-destructive/25 [a]:hover:bg-destructive/16 text-destructive-label`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function Zc({className:e,variant:t,asChild:n=!1,...r}){return(0,B.jsx)(n?Ar:`span`,{"data-slot":`badge`,className:z(Xc({variant:t}),e),...r})}function Qc({className:e,type:t,...n}){return(0,B.jsx)(`input`,{type:t,"data-slot":`input`,className:z(`border-input file:text-foreground placeholder:text-muted-foreground selection:bg-selection selection:text-foreground flex h-9 w-full min-w-0 rounded-[10px] border bg-card px-2.5 py-1 text-ui transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-ui file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`aria-invalid:ring-destructive aria-invalid:ring-1 aria-invalid:border-destructive`,e),...n})}var $c=3e3;function el({label:e,count:t}){return(0,B.jsxs)(Zc,{variant:`outline`,className:`bg-transparent border-current [color:oklch(0.42_0.13_var(--category-hue))] dark:[color:oklch(0.8_0.13_var(--category-hue))]`,style:{"--category-hue":String(Jc(e))},children:[(0,B.jsx)(`bdi`,{children:e}),(0,B.jsx)(`span`,{className:`ms-1 font-mono opacity-70`,children:t})]})}function tl({open:e=!1,onOpenChange:t,onApplied:n}){let{t:r}=yr(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)([]),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),g=(0,_.useRef)(!1),v=(0,_.useRef)(0);(0,_.useEffect)(()=>{e&&!g.current&&b(!1),e||v.current++,g.current=e},[e]);function y(e){a(e),s(new Set(e.groups.map((e,t)=>t))),l(e.groups.map(e=>e.name))}async function b(e){let t=++v.current;a(null),p(null),h(null);let n=null;if(!e){let e=await Xn(`/api/user-profile/category-cleanup`);n=e.success?e.data??null:null}if(!n||n.status.state===`failed`){let e=await Xn(`/api/user-profile/category-cleanup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!e.success||!e.data){h(e.error||r(`toast-category-cleanup-failed`));return}n=e.data}for(;t===v.current;){let e=n.status;if(e.state===`done`)return y(e.preview);if(e.state===`failed`)return h(e.error);p(e.state===`checking`&&e.total>0?{done:e.done,total:e.total}:null),await new Promise(e=>setTimeout(e,$c));let t=await Xn(`/api/user-profile/category-cleanup`);if(!t.success||!t.data)return h(t.error||r(`toast-category-cleanup-failed`));n=t.data}}function x(e){s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let S=i?i.before-i.groups.reduce((e,t,n)=>e+(o.has(n)?t.labels.length-1:0),0):0,C=[...o].every(e=>(c[e]??``).trim().length>0);async function w(){if(!i||o.size===0||!C)return;d(!0);let e=[...o].map(e=>({labels:i.groups[e].labels.map(e=>e.label),name:c[e].trim()})),a=await Xn(`/api/user-profile/category-cleanup/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groups:e})});if(d(!1),!a.success||!a.data){V.error(a.error||r(`toast-category-cleanup-failed`));return}V.success(r(`toast-category-cleanup-applied`,{count:a.data.renamed})),t?.(!1),n?.()}async function T(){d(!0);let e=await Xn(`/api/user-profile/category-cleanup/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(d(!1),!e.success||!e.data){V.info(e.error||r(`toast-category-cleanup-failed`));return}V.success(r(`toast-category-cleanup-undone`,e.data)),t?.(!1),n?.()}return(0,B.jsx)(Bs,{open:e,onOpenChange:t,children:(0,B.jsxs)(Us,{className:`grid! sm:max-w-2xl max-h-[90vh] grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden gap-4`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:r(`label-category-cleanup-title`)})}),m?(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-destructive`,children:m}),(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>void b(!0),children:r(`btn-category-cleanup-rebuild`)})]}):i?(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3 overflow-hidden`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,B.jsx)(`p`,{className:`text-sm`,children:r(`label-category-cleanup-counts`,{before:i.before,after:S})}),(0,B.jsx)(U,{variant:`link`,size:`xs`,onClick:()=>void b(!0),children:r(`btn-category-cleanup-rebuild`)})]}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`label-category-cleanup-note`)}),i.groups.length===0?(0,B.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r(`label-category-cleanup-empty`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`label-category-cleanup-selected`,{selected:o.size,total:i.groups.length})}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto pe-1`,children:i.groups.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)($i,{checked:o.has(t),onCheckedChange:()=>x(t),"aria-label":r(`label-category-cleanup-accept`)}),(0,B.jsx)(Qc,{dir:`auto`,className:`h-8 min-w-0 flex-1 sm:max-w-64`,value:c[t]??``,"aria-label":r(`label-category-cleanup-name`),disabled:!o.has(t),onChange:e=>l(n=>n.map((n,r)=>r===t?e.target.value:n))}),e.checked?null:(0,B.jsx)(`span`,{className:`basis-full text-xs text-muted-foreground sm:basis-auto`,children:r(`label-category-cleanup-unchecked`)})]}),(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.labels.map(e=>(0,B.jsx)(el,{label:e.label,count:e.count},e.label))})]},e.id))})]})]}):(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-center text-muted-foreground`,children:[(0,B.jsx)(pe,{className:`size-6 animate-spin`}),(0,B.jsx)(`span`,{className:`text-sm`,children:f?r(`label-category-cleanup-progress`,f):r(`label-category-cleanup-loading`)}),(0,B.jsx)(`span`,{className:`text-xs`,children:r(`label-category-cleanup-background`)})]}),(0,B.jsxs)(Gs,{className:`gap-2 sm:justify-between`,children:[(0,B.jsxs)(U,{variant:`secondary`,size:`sm`,disabled:u,onClick:()=>void T(),children:[(0,B.jsx)(Le,{className:`size-3.5`}),r(`btn-category-cleanup-undo`)]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>t?.(!1),children:r(`btn-cancel`)}),(0,B.jsx)(U,{size:`sm`,disabled:u||!i||o.size===0||!C,onClick:()=>void w(),children:r(`btn-category-cleanup-apply`)})]})]})]})})}function nl({className:e,...t}){return(0,B.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:z(`size-4 shrink-0`,e),...t,children:(0,B.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}var rl=15e3,il=5e3,al=500,ol=3e4,sl=2e3,cl=42e4,ll=new Set([`idle`,`installing`,`restarting`,`failed`]);function ul(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.state!=`string`||!ll.has(t.state)))return{available:typeof t.available==`string`?t.available:null,state:t.state,code:typeof t.code==`string`?t.code:null,canInstall:t.canInstall===!0}}var dl=()=>({"x-omms-token":window.__OMMS_TOKEN__??``});async function fl(){try{let e=await fetch(`/api/web/status`,{headers:dl(),signal:AbortSignal.timeout(il)});if(!e.ok)return null;let t=await e.json();if(typeof t.version!=`string`||typeof t.canControl!=`boolean`)return null;let n=ul(t.update);return{version:t.version,canControl:t.canControl,...typeof t.instance==`string`?{instance:t.instance}:{},...n?{update:n}:{}}}catch{return null}}async function pl(e){try{return(await fetch(`/api/web/${e}`,{method:`POST`,headers:{...dl(),"Content-Type":`application/json`},body:`{}`,signal:AbortSignal.timeout(il)})).status===202}catch{return!1}}async function ml(e,t={}){let n=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),r;for(let t=0;;t+=al){if(r=await fl(),r&&r.instance!==e)return`restarted`;if(t>=ol)break;await n(al)}return r?`unchanged`:`down`}async function hl(){try{return(await fetch(`/api/web/update`,{method:`POST`,headers:{...dl(),"Content-Type":`application/json`},body:`{}`,signal:AbortSignal.timeout(il)})).status===202}catch{return!1}}async function gl(e,t={}){let n=t.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let t=0;t<=cl;t+=sl){let t=await fl();if(t&&t.instance!==e)return{kind:`restarted`};if(t?.update?.state===`failed`)return{kind:`failed`,code:t.update.code??`unknown`};await n(sl)}return{kind:`timeout`}}var _l={ok:!0,status:null},vl=new Set,yl=null,bl=0,xl=0;async function Sl(){let e=++bl,t=await fl();if(!(e<xl)){xl=e,_l=t?{ok:!0,status:t}:{..._l,ok:!1};for(let e of vl)e(_l)}}function Cl(e){return vl.add(e),e(_l),Sl(),yl??=setInterval(()=>void Sl(),rl),()=>{vl.delete(e),vl.size===0&&yl!==null&&(clearInterval(yl),yl=null)}}var wl=()=>_l;function Tl(){return(0,_.useSyncExternalStore)(Cl,wl,wl)}var El=`om-memory-system web`;function Dl(){let{t:e}=yr(),{ok:t,status:n}=Tl(),r=n?.canControl??!1,i=n?.instance??null,[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(`idle`),[l,u]=(0,_.useState)(``);async function d(e){if(s!==`idle`)return;if(c(`working`),u(``),!await pl(e)){c(`idle`),u(`power-request-failed`);return}if(o(!1),e===`stop`){c(`stopped`);return}c(`restarting`);let t=await ml(i);if(t===`restarted`){window.location.reload();return}if(t===`unchanged`){u(`power-restart-failed`),c(`idle`),o(!0);return}u(`power-restart-timeout`),c(`stopped`)}return!r&&s===`idle`?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,"data-power":t?`on`:`off`,className:`inline-flex min-h-11 min-w-11 md:min-h-8 md:min-w-7 items-center justify-center self-stretch border-s border-sidebar-border px-1.5 text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,onClick:()=>{u(``),o(!0)},"aria-label":e(`power-button`),title:e(`power-button`),children:(0,B.jsx)(Te,{className:z(`size-4`,t&&`text-emerald-500`)})}),(0,B.jsx)(Bs,{open:a,onOpenChange:e=>s===`idle`&&o(e),children:(0,B.jsxs)(Us,{showCloseButton:!1,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:e(`power-dialog-title`)})}),(0,B.jsx)(`p`,{children:e(`power-dialog-body`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`power-note`)}),l?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:e(l)}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,B.jsx)(U,{variant:`ghost`,disabled:s!==`idle`,onClick:()=>o(!1),children:e(`power-cancel`)}),(0,B.jsx)(U,{variant:`destructive`,disabled:s!==`idle`,onClick:()=>void d(`stop`),children:e(`power-stop`)}),(0,B.jsx)(U,{autoFocus:!0,disabled:s!==`idle`,onClick:()=>void d(`restart`),children:e(`power-restart`)})]})]})}),s===`restarting`||s===`stopped`?(0,B.jsx)(`div`,{role:`alert`,className:`fixed inset-0 z-[60] flex flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:s===`restarting`?(0,B.jsx)(`p`,{children:e(`power-restarting`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h2`,{className:`text-section-title font-semibold`,children:e(`power-stopped-title`)}),l?(0,B.jsx)(`p`,{children:e(l)}):null,(0,B.jsx)(`p`,{children:e(`power-stopped-command`)}),(0,B.jsx)(`code`,{className:`rounded-md bg-muted px-2 py-1`,children:El}),(0,B.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e(`power-note`)})]})}):null]})}function Ol({brand:e,className:t}){let{status:n}=Tl();return(0,B.jsxs)(`span`,{className:z(`flex min-w-0 items-baseline gap-1.5`,t),children:[(0,B.jsx)(`span`,{className:`truncate text-ui font-medium tracking-wide text-brand-label`,children:e}),n?(0,B.jsxs)(`span`,{className:`shrink-0 text-xs text-foreground`,"data-testid":`sidebar-version`,children:[`v`,n.version]}):null]})}var kl=[{label:`update-host-claude`,command:`claude plugin update omms@omms`},{label:`update-host-opencode`,command:`opencode plugin update om-memory-system`},{label:`update-host-pi`,command:`pi update npm:om-memory-system`},{label:`update-host-global`,command:`npm i -g om-memory-system@latest && om-memory-system web install`}],Al={row:`mb-2 flex min-h-11 w-full rounded-lg border border-sidebar-border/80 bg-card/70 px-2`,inline:`inline-flex min-h-8 self-stretch border-s border-sidebar-border px-2`,icon:`inline-flex min-h-8 min-w-7 self-stretch px-1.5 py-1.5`};function jl(){let{ok:e,status:t}=Tl(),n=t?.update;return!t?.canControl||!n?.available?null:{ok:e,status:t,update:n,available:n.available}}function Ml({variant:e=`row`,className:t,onOpen:n}){let{t:r}=yr(),i=jl();return i?.ok?(0,B.jsx)(`button`,{type:`button`,"data-update":i.available,"data-variant":e,className:z(`items-center justify-center text-xs font-medium text-brand-label transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,Al[e],t),onClick:n,"aria-label":r(`update-button`,{version:i.available}),title:r(`update-button`,{version:i.available}),children:e===`icon`?(0,B.jsx)(M,{className:`size-4`}):r(`update-label`)}):null}function Nl({open:e,onOpenChange:t}){let{t:n}=yr(),r=jl(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null);if(!r)return null;let{status:u,update:d,available:f}=r,p=d.state===`failed`?d.code:null,m=i||d.state===`installing`||d.state===`restarting`;async function h(){if(m)return;if(a(!0),s(``),!await hl()){a(!1),s(n(`update-request-failed`));return}let e=await gl(u?.instance??null);if(e.kind===`restarted`){window.location.reload();return}a(!1),s(e.kind===`failed`?n(`update-failed`,{code:e.code}):n(`update-timeout`))}function g(e){navigator.clipboard?.writeText(e),l(e)}let v=o||(p?n(`update-failed`,{code:p}):``);return(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Bs,{open:e,onOpenChange:e=>!m&&t(e),children:(0,B.jsxs)(Us,{showCloseButton:!1,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:n(`update-dialog-title`)})}),(0,B.jsx)(`p`,{children:n(`update-versions`,{running:u.version,available:f})}),(0,B.jsx)(`p`,{className:`text-sm`,children:n(`update-hosts-intro`)}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-2`,children:kl.map(({label:e,command:t})=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(e)}),(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md bg-muted px-2 py-1 text-xs`,children:t}),(0,B.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>g(t),"aria-label":`${n(`update-copy`)}: ${t}`,children:[(0,B.jsx)(ce,{className:`size-3.5`}),n(c===t?`update-copied`:`update-copy`)]})]})]},t))}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`update-hosts-note`)}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d.canInstall?n(`update-install-note`):n(`update-cannot-install`)}),m?(0,B.jsx)(`p`,{role:`status`,className:`text-sm`,children:n(`update-installing`)}):null,v&&!m?(0,B.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:v}):null,(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,B.jsx)(U,{variant:`ghost`,disabled:m,onClick:()=>t(!1),children:n(`update-close`)}),(0,B.jsx)(U,{autoFocus:!0,disabled:m||!d.canInstall,onClick:()=>void h(),children:n(`update-install`)})]})]})})})}var Pl=Object.defineProperty,Fl=(e,t)=>Pl(e,`name`,{value:t,configurable:!0}),Il=`horizontal`,Ll=[`horizontal`,`vertical`],Rl=_.forwardRef(Fl(function(e,t){let{decorative:n,orientation:r=Il,...i}=e,a=zl(r)?r:Il,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,B.jsx)(Ni.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function zl(e){return Ll.includes(e)}Fl(zl,`isValidOrientation`);var Bl=Rl;function K({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,B.jsx)(Bl,{"data-slot":`separator`,decorative:n,orientation:t,className:z(`bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var q=[{id:`memory-section-import`,title:`Import chat history`},{id:`memory-section-auto-import`,title:`Automatic import`},{id:`memory-section-profile`,title:`Profile learning`},{id:`memory-section-limits`,title:`Memory limits`},{id:`memory-section-project-folders`,title:`Resolve missing project folders`}],Vl={"settings-section-import":`memory-section-import`,"settings-section-auto-import":`memory-section-auto-import`,"settings-section-profile":`memory-section-profile`,"settings-section-memory":`memory-section-limits`,"settings-section-directory-maps":`memory-section-project-folders`};function Hl(e,t){if(e!==`/settings`)return null;let n=t.replace(/^#/,``);return Vl[n]?`#${Vl[n]}`:/^directory-maps-(pi|opencode|claude-code)$/.test(n)?t:null}function Ul(e,t){let n=e.startsWith(`#`)?e.slice(1):``;if(!/^(settings|memory)-section-[a-z0-9-]+$/.test(n))return!1;let r=t.getElementById(n);return r?(r.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1}function Wl(e){if(typeof document>`u`||typeof requestAnimationFrame>`u`)return;let t=e.replace(/^#/,``);if(!/^(?:(?:settings|memory)-section-[a-z0-9-]+|directory-maps-(?:pi|opencode|claude-code)|profile-(?:preferences|patterns|workflows))$/.test(t))return;let n=0,r=()=>{let e=document.getElementById(t);if(!e){n++<50&&requestAnimationFrame(r);return}if(t.startsWith(`directory-maps-`)){let t=e.parentElement;t&&(t.open=!0),e.focus({preventScroll:!0})}e.scrollIntoView({behavior:`smooth`,block:`start`})};requestAnimationFrame(r)}var J={home:`/`,project:`/project-memories`,profile:`/user-profile`,settings:`/settings`,memory:`/memory`};function Gl(e){let t=e.replace(/\/+$/,``)||`/`;return t.startsWith(`/`)?t:`/${t}`}function Kl(e){let t=Gl(e);return t===J.memory?`memory`:t===J.settings?`settings`:t===J.profile?`profile`:`project`}function ql(e){let t=Gl(e);return t===J.home||t===J.project||t===J.profile||t===J.settings||t===J.memory}function Jl(e){let t=Gl(e);return t===J.home?J.project:ql(t)?t:J.project}function Yl(e,t=``){let n=Hl(Gl(e),t);return n?`${J.memory}${n}`:`${Jl(e)}${t}`}var Xl=typeof window<`u`?Yl(window.location.pathname,window.location.hash):J.project,Zl=new Set;function Ql(){for(let e of Zl)e()}function $l(e){Xl!==e&&(Xl=e,Ql())}function eu(e){return Zl.add(e),()=>{Zl.delete(e)}}function tu(){return Xl}function nu(){return J.project}function ru(e,t=!1){let[n,r=``]=e.split(/(?=#)/),i=Yl(n,r),a=Hl(Gl(n),r);`${Gl(window.location.pathname)}${window.location.hash}`!==i&&(t||a?window.history.replaceState({},``,i):window.history.pushState({},``,i)),$l(i),(r||a)&&Wl(a??r)}function iu(){let e=()=>{let e=`${Gl(window.location.pathname)}${window.location.hash}`,t=Yl(window.location.pathname,window.location.hash);e!==t&&window.history.replaceState({},``,t),$l(t),window.location.hash&&Wl(window.location.hash)};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function au(){return(0,_.useSyncExternalStore)(eu,tu,nu)}function ou(){return Kl(au().split(`#`)[0])}var su=`omms-theme`,cu=`opencode-mem-theme`;function lu(){if(typeof window>`u`)return`dark`;let e=Zn(su,cu);return e===`light`||e===`dark`?e:`dark`}var uu=lu(),du=new Set;function fu(){for(let e of du)e()}function pu(e){uu=e,typeof document<`u`&&(document.documentElement.classList.toggle(`dark`,e===`dark`),Qn(su,e)),fu()}function mu(e){return du.add(e),()=>{du.delete(e)}}function hu(){return uu}function gu(){return`dark`}function _u(e){pu(e)}function vu(){let e=uu===`dark`?`light`:`dark`;return _u(e),e}function yu(){pu(lu())}function bu(){return(0,_.useSyncExternalStore)(mu,hu,gu)}typeof document<`u`&&pu(uu);var xu=[{code:`en`,label:`English (EN)`},{code:`zh`,label:`中文 (ZH)`},{code:`ar`,label:`العربية (AR)`}],Su=`omms-sidebar-collapsed`,Cu=`omms-sidebar-settings-open`,wu=`omms-sidebar-memory-open`,Tu=`inline-flex min-h-11 min-w-11 md:min-h-8 md:min-w-7 items-center justify-center text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`;function Eu(){try{let e=localStorage.getItem(Cu);return e===null?null:e===`1`}catch{return null}}function Du(){try{return localStorage.getItem(Su)===`1`}catch{return!1}}function Ou({open:e=!1,currentView:t,brand:n,projectLabel:r,profileLabel:i,profileSections:a,settingsSections:o=[],memoryLabel:s=`Memory`,memorySections:c=[],langLabel:l,languageLabel:u,themeLabel:d,settingsLabel:f,closeLabel:p,collapseLabel:m,expandLabel:h,onOpenChange:g,onLanguageSelect:v}){let y=bu()===`dark`,[b,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),[E,D]=(0,_.useState)(Du),O=e=>E?e:``,[ee,te]=(0,_.useState)(()=>Eu()??t===`settings`),[k,ne]=(0,_.useState)(()=>{try{let e=localStorage.getItem(wu);return e===null?t===`memory`:e===`1`}catch{return t===`memory`}});function ie(){let e=!k;ne(e);try{localStorage.setItem(wu,e?`1`:`0`)}catch{}}function ae(){let e=!ee;te(e);try{localStorage.setItem(Cu,e?`1`:`0`)}catch{}}function A(){let e=!E;D(e);try{localStorage.setItem(Su,e?`1`:`0`)}catch{}}(0,_.useEffect)(()=>{if(!b)return;w.current?.querySelector(`[aria-checked=true]`)?.focus();function e(e){w.current?.contains(e.target)||x(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[b]);function oe(e){if(e.key===`Escape`&&(e.preventDefault(),x(!1),T.current?.focus()),![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Array.from(w.current?.querySelectorAll(`[role=menuitemradio]`)??[]),n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}function M(e){g?.(e)}function se(e,t){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),ru(t),M(!1))}function ce(e,t,n=`profile`){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),ru(`${J[n]}#${t}`),M(!1))}function P(e){return z(`flex w-full min-w-0 min-h-11 md:min-h-9 items-center gap-2 rounded-[10px] px-3 py-2 text-ui transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,O(`md:justify-center md:px-0`),e?`bg-sidebar-accent text-sidebar-accent-foreground`:`text-sidebar-foreground hover:bg-interactive-hover active:bg-interactive-active`)}return(0,B.jsxs)(B.Fragment,{children:[e?(0,B.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-black/50 md:hidden`,"aria-label":p,onClick:()=>M(!1)}):null,(0,B.jsxs)(`aside`,{className:z(`inset-y-0 start-0 z-50 flex h-svh w-64 shrink-0 flex-col border-e border-sidebar-border bg-sidebar text-sidebar-foreground transition-[transform,width] duration-200`,O(`md:w-14`),`fixed md:sticky md:top-0 md:translate-x-0!`,e?`translate-x-0`:`max-md:-translate-x-full max-md:rtl:translate-x-full`),children:[(0,B.jsxs)(`div`,{className:z(`flex items-center gap-2 px-4 py-4`,O(`md:flex-col md:px-2`)),children:[(0,B.jsxs)(`a`,{href:J.home,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg transition-colors hover:opacity-90`,onClick:e=>se(e,J.home),children:[(0,B.jsx)(`img`,{src:`/omms-icon.svg`,alt:``,width:20,height:20,className:`size-5 shrink-0 rounded-sm`}),(0,B.jsx)(Ol,{brand:n,className:O(`md:hidden`)})]}),(0,B.jsx)(U,{variant:`ghost`,size:`icon-sm`,className:`hidden shrink-0 text-muted-foreground hover:text-primary md:inline-flex`,onClick:A,"aria-label":E?h:m,"aria-expanded":!E,title:E?h:m,children:E?(0,B.jsx)(ye,{className:`size-4 rtl:-scale-x-100`}):(0,B.jsx)(ve,{className:`size-4 rtl:-scale-x-100`})}),(0,B.jsx)(U,{variant:`ghost`,size:`icon-sm`,className:`md:hidden min-h-11 min-w-11 shrink-0`,onClick:()=>M(!1),"aria-label":p,children:(0,B.jsx)(Ve,{className:`size-4`})})]}),(0,B.jsx)(K,{className:`bg-sidebar-border`}),(0,B.jsxs)(`nav`,{className:z(`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-3`,O(`md:px-2`)),"aria-label":`Main`,children:[(0,B.jsxs)(`a`,{href:J.project,className:P(t===`project`),"aria-current":t===`project`?`page`:void 0,title:E?r:void 0,onClick:e=>se(e,J.project),children:[(0,B.jsx)(N,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start`,O(`md:sr-only`)),children:r})]}),(0,B.jsxs)(`a`,{href:J.profile,className:P(t===`profile`),"aria-current":t===`profile`?`page`:void 0,title:E?i:void 0,onClick:e=>se(e,J.profile),children:[(0,B.jsx)(ze,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start`,O(`md:sr-only`)),children:i})]}),(0,B.jsx)(`ul`,{className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:a.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.profile}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,onClick:t=>ce(t,e.id),children:e.label})},e.id))}),(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`a`,{href:J.memory,className:P(t===`memory`),"aria-current":t===`memory`?`page`:void 0,title:E?s:void 0,onClick:e=>se(e,J.memory),children:[(0,B.jsx)(re,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start uppercase`,O(`md:sr-only`)),children:s})]}),c.length>0?(0,B.jsx)(`button`,{type:`button`,className:z(`inline-flex min-h-11 min-w-11 md:min-h-7 md:min-w-7 shrink-0 items-center justify-center rounded-lg p-1.5 text-muted-foreground hover:bg-interactive-hover focus-visible:outline-2 focus-visible:outline-ring`,O(`md:hidden`)),onClick:ie,"aria-expanded":k,"aria-controls":`sidebar-memory-tree`,"aria-label":s,title:s,children:(0,B.jsx)(j,{className:z(`size-4 transition-transform rtl:-scale-x-100`,k&&`rotate-90 rtl:rotate-90`)})}):null]}),k&&c.length>0?(0,B.jsx)(`ul`,{id:`sidebar-memory-tree`,className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:c.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.memory}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground hover:bg-interactive-hover focus-visible:outline-2 focus-visible:outline-ring`,onClick:t=>ce(t,e.id,`memory`),children:e.label})},e.id))}):null,(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`a`,{href:J.settings,className:P(t===`settings`),"aria-current":t===`settings`?`page`:void 0,title:E?f:void 0,onClick:e=>se(e,J.settings),children:[(0,B.jsx)(ke,{className:`size-4 shrink-0`}),(0,B.jsx)(`span`,{className:z(`min-w-0 break-words text-start uppercase`,O(`md:sr-only`)),children:f})]}),o.length>0?(0,B.jsx)(`button`,{type:`button`,className:z(`inline-flex min-h-11 min-w-11 md:min-h-7 md:min-w-7 shrink-0 items-center justify-center rounded-lg p-1.5 text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,O(`md:hidden`)),onClick:ae,"aria-expanded":ee,"aria-controls":`sidebar-settings-tree`,"aria-label":f,title:f,children:(0,B.jsx)(j,{className:z(`size-4 transition-transform rtl:-scale-x-100`,ee&&`rotate-90 rtl:rotate-90`)})}):null]}),ee&&o.length>0?(0,B.jsx)(`ul`,{id:`sidebar-settings-tree`,className:z(`ms-5 space-y-0.5 border-s border-sidebar-border ps-2`,O(`md:hidden`)),children:o.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsx)(`a`,{href:`${J.settings}#${e.id}`,className:`flex min-h-11 md:min-h-7 items-center break-words rounded-lg px-2.5 py-1 text-xs text-muted-foreground transition-colors duration-150 hover:bg-interactive-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,onClick:t=>ce(t,e.id,`settings`),children:e.label})},e.id))}):null]}),(0,B.jsxs)(`div`,{className:z(`mt-auto p-3`,O(`md:px-2`)),children:[(0,B.jsx)(Ml,{variant:`row`,className:`md:hidden`,onOpen:()=>C(!0)}),(0,B.jsxs)(`div`,{className:z(`flex w-fit items-center rounded-lg border border-sidebar-border/80 bg-card/70`,O(`md:mx-auto md:flex-col md:[&>*]:justify-center md:[&>*]:py-1.5 md:[&>*+*]:border-s-0 md:[&>*+*]:border-t md:[&>*]:rounded-none`)),children:[(0,B.jsxs)(`div`,{ref:w,className:`relative flex self-stretch`,onBlur:e=>{w.current?.contains(e.relatedTarget)||x(!1)},children:[(0,B.jsx)(`button`,{ref:T,type:`button`,className:`${Tu} rounded-s-lg px-1.5 py-1.5 text-ui`,onClick:()=>x(e=>!e),"aria-label":`${u}: ${l}`,"aria-haspopup":`menu`,"aria-expanded":b,"aria-controls":`sidebar-language-menu`,title:u,children:(0,B.jsx)(`span`,{className:`text-xs tabular-nums`,children:l})}),b?(0,B.jsx)(`div`,{id:`sidebar-language-menu`,role:`menu`,"aria-label":u,onKeyDown:oe,className:`absolute bottom-full start-0 z-10 mb-2 w-44 max-h-[60vh] overflow-y-auto rounded-lg border border-sidebar-border bg-card p-1 shadow-lg`,children:xu.map(({code:e,label:t})=>(0,B.jsx)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":l.toLowerCase()===e,className:`flex min-h-11 md:min-h-9 w-full items-center rounded-md px-2.5 py-2 text-start text-ui text-card-foreground aria-checked:bg-selection hover:bg-interactive-hover focus-visible:bg-selection focus-visible:outline-2 focus-visible:outline-ring`,onClick:()=>{v?.(e),x(!1),T.current?.focus()},children:t},e))}):null]}),(0,B.jsx)(`button`,{type:`button`,className:`${Tu} self-stretch border-s border-sidebar-border px-1.5`,onClick:()=>vu(),"aria-label":d,title:d,children:y?(0,B.jsx)(ge,{className:`size-4 rounded-md p-0.5`}):(0,B.jsx)(je,{className:`size-4 rounded-md p-0.5`})}),(0,B.jsx)(`a`,{href:J.settings,className:`${Tu} self-stretch border-s border-sidebar-border px-1.5`,onClick:e=>se(e,J.settings),"aria-label":f,title:f,"aria-current":t===`settings`?`page`:void 0,children:(0,B.jsx)(ke,{className:`size-4`})}),(0,B.jsx)(Dl,{}),(0,B.jsx)(`a`,{href:`https://github.com/cmdaltctr/omms`,target:`_blank`,rel:`noopener noreferrer`,className:`${Tu} self-stretch rounded-e-lg border-s border-sidebar-border px-1.5`,title:`GitHub`,"aria-label":`GitHub`,children:(0,B.jsx)(nl,{className:`size-4`})}),(0,B.jsx)(Ml,{onOpen:()=>C(!0),variant:E?`icon`:`inline`,className:z(`max-md:hidden`,E?`md:border-t md:border-sidebar-border`:`rounded-e-lg`)})]}),(0,B.jsx)(Nl,{open:S,onOpenChange:C})]})]})]})}var ku=Object.defineProperty,Au=_.forwardRef(((e,t)=>ku(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,B.jsx)(Ni.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`));function ju({className:e,...t}){return(0,B.jsx)(Au,{"data-slot":`label`,className:z(`flex items-center gap-2 text-ui leading-normal select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Mu({className:e,...t}){return(0,B.jsx)(`textarea`,{"data-slot":`textarea`,dir:`auto`,className:z(`border-input placeholder:text-muted-foreground selection:bg-selection selection:text-foreground flex field-sizing-content min-h-16 w-full min-w-0 rounded-[10px] border bg-card px-2.5 py-2 text-ui [unicode-bidi:plaintext] transition-colors duration-150 outline-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`aria-invalid:ring-destructive aria-invalid:ring-1 aria-invalid:border-destructive`,e),...t})}function Nu({open:e=!1,content:t=``,onOpenChange:n,onSave:r}){let{t:i}=yr(),[a,o]=(0,_.useState)(``);(0,_.useEffect)(()=>{e&&o(t)},[e,t]);function s(e){n?.(e)}function c(e){e.preventDefault();let t=a.trim();t&&r?.(t)}return(0,B.jsx)(Bs,{open:e,onOpenChange:s,children:(0,B.jsxs)(Us,{className:`sm:max-w-lg`,children:[(0,B.jsx)(Ws,{children:(0,B.jsx)(Ks,{children:i(`modal-edit-title`)})}),(0,B.jsxs)(`form`,{className:`space-y-4`,onSubmit:c,children:[(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(ju,{htmlFor:`edit-content`,children:i(`label-content`)}),(0,B.jsx)(Mu,{id:`edit-content`,rows:6,value:a,onChange:e=>o(e.target.value),required:!0})]}),(0,B.jsxs)(Gs,{children:[(0,B.jsx)(U,{type:`button`,variant:`secondary`,onClick:()=>s(!1),children:i(`btn-cancel`)}),(0,B.jsx)(U,{type:`submit`,children:i(`btn-save`)})]})]})]})})}function Pu({children:e,maxHeight:t,fade:n=`var(--card)`}){let{t:r}=yr(),i=(0,_.useId)(),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>l(e.offsetHeight>t);if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t]);let u=c&&!o;return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{id:i,className:`relative overflow-hidden`,style:u?{maxHeight:t}:void 0,"data-collapsed":u?`true`:void 0,children:[(0,B.jsx)(`div`,{ref:a,children:e}),u?(0,B.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-x-0 bottom-0 h-12`,style:{background:`linear-gradient(to top, ${n}, transparent)`}}):null]}),c?(0,B.jsxs)(U,{variant:`ghost`,size:`xs`,"aria-expanded":o,"aria-controls":i,onClick:()=>s(e=>!e),children:[o?(0,B.jsx)(oe,{}):(0,B.jsx)(ae,{}),r(o?`btn-see-less`:`btn-see-more`)]}):null]})}var Fu=8;function Iu({content:e,children:t,className:n}){let r=_.useId(),i=_.useRef(null),[a,o]=_.useState(0),s=_.isValidElement(t)?_.cloneElement(t,{"aria-describedby":r}):t,c=()=>{let e=i.current;if(!e)return;let t=e.parentElement.getBoundingClientRect(),n=e.offsetWidth/2,r=t.left+t.width/2,a=document.documentElement.clientWidth,s=Fu+n,c=a-Fu-n;o(Math.min(Math.max(r,s),c)-r)};return(0,B.jsxs)(`span`,{className:z(`group/tooltip relative inline-flex`,n),onPointerEnter:c,onFocus:c,children:[s,(0,B.jsxs)(`span`,{ref:i,id:r,role:`tooltip`,style:{transform:`translateX(calc(-50% + ${a}px))`},className:`pointer-events-none absolute bottom-full left-1/2 z-30 mb-2 w-max max-w-[min(24rem,calc(100vw-1rem))] rounded-md border border-border bg-card px-2 py-1 text-xs whitespace-normal text-card-foreground opacity-0 shadow-sm transition-opacity duration-150 ease-in group-focus-within/tooltip:opacity-100 group-hover/tooltip:opacity-100`,children:[e,(0,B.jsx)(`span`,{"aria-hidden":`true`,style:{left:`calc(50% - ${a}px)`},className:`absolute top-full -mt-1 size-2 -translate-x-1/2 rotate-45 border-e border-b border-border bg-card`})]})]})}function Lu({type:e}){let{t}=yr();return(0,B.jsx)(Iu,{content:t(`tooltip-memory-type`),className:`min-w-0 max-w-full`,children:(0,B.jsx)(Zc,{variant:`outline`,"data-memory-type":e,tabIndex:0,className:`h-auto min-h-5 max-w-full shrink break-all whitespace-normal bg-transparent border-current [color:oklch(0.42_0.13_var(--memory-type-hue))] dark:[color:oklch(0.8_0.13_var(--memory-type-hue))]`,style:{"--memory-type-hue":String(Jc(e))},children:e})})}var Ru=/<pasted_content\b[^>]*>([\s\S]*?)<\/pasted_content[^>]*>|```[^\n]*\n([\s\S]*?)```/g;function zu(e){return e.replace(/^\n+|\n+$/g,``)}function Bu(e){let t=[],n=e=>{let n=zu(e);n.trim()&&t.push({kind:`text`,text:n})},r=0;for(let i of e.matchAll(Ru)){n(e.slice(r,i.index));let a=i[1]!==void 0;t.push({kind:a?`pasted`:`code`,text:zu(a?i[1]:i[2])}),r=i.index+i[0].length}return n(e.slice(r)),t}function Vu(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g))r.index>n&&t.push({code:!1,text:e.slice(n,r.index)}),t.push({code:!0,text:r[1]}),n=r.index+r[0].length;return n<e.length&&t.push({code:!1,text:e.slice(n)}),t}function Hu({label:e,children:t}){return(0,B.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background/60`,children:[e?(0,B.jsx)(`div`,{className:`border-b border-border px-3 py-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}):null,(0,B.jsx)(`pre`,{dir:`ltr`,className:`overflow-x-auto p-3 font-mono text-code leading-relaxed whitespace-pre-wrap break-words`,children:t})]})}function Uu({content:e}){let{t}=yr();return(0,B.jsx)(`div`,{className:`space-y-3`,children:Bu(e).map((e,n)=>e.kind===`pasted`?(0,B.jsx)(Hu,{label:t(`label-pasted-content`),children:e.text},n):e.kind===`code`?(0,B.jsx)(Hu,{children:e.text},n):(0,B.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:Vu(e.text).map((e,t)=>e.code?(0,B.jsx)(`code`,{className:`inline-code`,children:e.text},t):(0,B.jsx)(_.Fragment,{children:e.text},t))},n))})}function Wu(e){let t=new Date(e),n=mr(),r=n===`zh`?`zh-CN`:n===`ar`?`ar-SA`:`en-US`;return t.toLocaleString(r,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Gu(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ku(e){if(Array.isArray(e))return e}function qu(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ju(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
56
56
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yu(e,t){return Ku(e)||qu(e,t)||Xu(e,t)||Ju()}function Xu(e,t){if(e){if(typeof e==`string`)return Gu(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Gu(e,t):void 0}}var Zu=Object.entries,Qu=Object.setPrototypeOf,$u=Object.isFrozen,ed=Object.getPrototypeOf,td=Object.getOwnPropertyDescriptor,nd=Object.freeze,rd=Object.seal,id=Object.create,ad=typeof Reflect<`u`&&Reflect,od=ad.apply,sd=ad.construct;nd||=function(e){return e},rd||=function(e){return e},od||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},sd||=function(e){return new e(...[...arguments].slice(1))};var cd=Dd(Array.prototype.forEach),ld=Dd(Array.prototype.lastIndexOf),ud=Dd(Array.prototype.pop),dd=Dd(Array.prototype.push),fd=Dd(Array.prototype.splice),pd=Array.isArray,md=Dd(String.prototype.toLowerCase),hd=Dd(String.prototype.toString),gd=Dd(String.prototype.match),_d=Dd(String.prototype.replace),vd=Dd(String.prototype.indexOf),yd=Dd(String.prototype.trim),bd=Dd(Number.prototype.toString),xd=Dd(Boolean.prototype.toString),Sd=typeof BigInt>`u`?null:Dd(BigInt.prototype.toString),Y=typeof Symbol>`u`?null:Dd(Symbol.prototype.toString),Cd=Dd(Object.prototype.hasOwnProperty),wd=Dd(Object.prototype.toString),Td=Dd(RegExp.prototype.test),Ed=Od(TypeError);function Dd(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return od(e,t,n)}}function Od(e){return function(){return sd(e,[...arguments])}}function X(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:md;if(Qu&&Qu(e,null),!pd(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&($u(t)||(t[r]=e),i=e)}e[i]=!0}return e}function kd(e){for(let t=0;t<e.length;t++)Cd(e,t)||(e[t]=null);return e}function Ad(e){let t=id(null);for(let r of Zu(e)){var n=Yu(r,2);let i=n[0],a=n[1];Cd(e,i)&&(t[i]=pd(a)?kd(a):a&&typeof a==`object`&&a.constructor===Object?Ad(a):a)}return t}function jd(e){switch(typeof e){case`string`:return e;case`number`:return bd(e);case`boolean`:return xd(e);case`bigint`:return Sd?Sd(e):`0`;case`symbol`:return Y?Y(e):`Symbol()`;case`undefined`:return wd(e);case`function`:case`object`:{if(e===null)return wd(e);let t=e,n=Md(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:wd(e)}return wd(e)}default:return wd(e)}}function Md(e,t){for(;e!==null;){let n=td(e,t);if(n){if(n.get)return Dd(n.get);if(typeof n.value==`function`)return Dd(n.value)}e=ed(e)}function n(){return null}return n}function Nd(e){try{return Td(e,``),!0}catch{return!1}}var Pd=nd(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Fd=nd(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Id=nd([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Ld=nd([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Rd=nd(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),zd=nd([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Bd=nd([`#text`]),Vd=nd(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Hd=nd(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ud=nd(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Wd=nd([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Gd=rd(/{{[\w\W]*|^[\w\W]*}}/g),Kd=rd(/<%[\w\W]*|^[\w\W]*%>/g),qd=rd(/\${[\w\W]*/g),Jd=rd(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yd=rd(/^aria-[\-\w]+$/),Xd=rd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zd=rd(/^(?:\w+script|data):/i),Qd=rd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$d=rd(/^html$/i),ef=rd(/^[a-z][.\w]*(-[.\w]+)+$/i),tf=rd(/<[/\w!]/g),nf=rd(/<[/\w]/g),rf=rd(/<\/no(script|embed|frames)/i),af=rd(/\/>/i),of={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},sf=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],cf=nd(X({},sf)),lf=function(){let e={};return cd(sf,t=>{e[t]=rd(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),nd(e)}(),uf=function(){return typeof window>`u`?null:window},df=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},ff=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},pf=function(e,t,n,r){return Cd(e,t)&&pd(e[t])?X(r.base?Ad(r.base):{},e[t],r.transform):n},mf=function(e,t,n){let r=Cd(e,t)?e[t]:void 0;return r&&typeof r==`object`?Ad(r):n()};function hf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uf(),t=e=>hf(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==of.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Md(d,`cloneNode`),p=Md(d,`remove`),m=Md(d,`nextSibling`),h=Md(d,`childNodes`),g=Md(d,`parentNode`),_=Md(d,`shadowRoot`),v=Md(d,`attributes`),y=o&&o.prototype?Md(o.prototype,`nodeType`):null,b=o&&o.prototype?Md(o.prototype,`nodeName`):null,x=o&&o.prototype?Md(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},C=function(e){return b?b(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,T=``,E,D=!1,O=0,ee=function(){if(O>0)throw Ed(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},te=function(e){ee(),O++;try{return w.createHTML(e)}finally{O--}},k=function(e){ee(),O++;try{return w.createScriptURL(e)}finally{O--}},ne=function(){return D||=(E=df(u,i),!0),E},re=n,ie=re.implementation,ae=re.createNodeIterator,A=re.createDocumentFragment,j=re.getElementsByTagName,oe=r.importNode,M=ff();t.isSupported=typeof Zu==`function`&&typeof g==`function`&&ie&&ie.createHTMLDocument!==void 0;let se=Gd,ce=Kd,N=qd,P=Jd,le=Yd,ue=Zd,de=Qd,fe=ef,pe=Xd,me=null,he=X({},[...Pd,...Fd,...Id,...Rd,...Bd]),ge=null,_e=X({},[...Vd,...Hd,...Ud,...Wd]),ve=Object.seal(id(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ye=null,be=null,xe=Object.seal(id(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,Ce=!0,we=!1,Te=!0,Ee=!1,De=!0,Oe=!1,ke=!1,Ae=null,je=null,Me=!1,Ne=!1,Pe=!1,Fe=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve={},He=null,Ue=X({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),We=null,Ge=X({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ke=null,qe=X({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Je=`http://www.w3.org/1998/Math/MathML`,Ye=`http://www.w3.org/2000/svg`,Xe=`http://www.w3.org/1999/xhtml`,Ze=Xe,Qe=!1,$e=null,et=X({},[Je,Ye,Xe],hd),tt=nd([`mi`,`mo`,`mn`,`ms`,`mtext`]),nt=X({},tt),rt=nd([`annotation-xml`]),it=X({},rt),at=X({},[`title`,`style`,`font`,`a`,`script`]),ot=null,st=[`application/xhtml+xml`,`text/html`],ct=null,lt=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(lt&<===e)return;(!e||typeof e!=`object`)&&(e={}),e=Ad(e),ot=st.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ct=ot===`application/xhtml+xml`?hd:md,me=pf(e,`ALLOWED_TAGS`,he,{transform:ct}),ge=pf(e,`ALLOWED_ATTR`,_e,{transform:ct}),$e=pf(e,`ALLOWED_NAMESPACES`,et,{transform:hd}),Ke=pf(e,`ADD_URI_SAFE_ATTR`,qe,{transform:ct,base:qe}),We=pf(e,`ADD_DATA_URI_TAGS`,Ge,{transform:ct,base:Ge}),He=pf(e,`FORBID_CONTENTS`,Ue,{transform:ct}),ye=pf(e,`FORBID_TAGS`,Ad({}),{transform:ct}),be=pf(e,`FORBID_ATTR`,Ad({}),{transform:ct}),Ve=Cd(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Ad(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,Ce=e.ALLOW_DATA_ATTR!==!1,we=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Te=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ee=e.SAFE_FOR_TEMPLATES||!1,De=e.SAFE_FOR_XML!==!1,Oe=e.WHOLE_DOCUMENT||!1,Ne=e.RETURN_DOM||!1,Pe=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,pe=Nd(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Xd,Ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Xe,nt=mf(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>X({},tt)),it=mf(e,`HTML_INTEGRATION_POINTS`,()=>X({},rt));let t=mf(e,`CUSTOM_ELEMENT_HANDLING`,()=>id(null));if(ve=id(null),Cd(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(ve.tagNameCheck=t.tagNameCheck),Cd(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(ve.attributeNameCheck=t.attributeNameCheck),Cd(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ve.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),rd(ve),Ee&&(Ce=!1),Pe&&(Ne=!0),Ve&&(me=X({},Bd),ge=id(null),Ve.html===!0&&(X(me,Pd),X(ge,Vd)),Ve.svg===!0&&(X(me,Fd),X(ge,Hd),X(ge,Wd)),Ve.svgFilters===!0&&(X(me,Id),X(ge,Hd),X(ge,Wd)),Ve.mathMl===!0&&(X(me,Rd),X(ge,Ud),X(ge,Wd))),xe.tagCheck=null,xe.attributeCheck=null,Cd(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?xe.tagCheck=e.ADD_TAGS:pd(e.ADD_TAGS)&&(me===he&&(me=Ad(me)),X(me,e.ADD_TAGS,ct))),Cd(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?xe.attributeCheck=e.ADD_ATTR:pd(e.ADD_ATTR)&&(ge===_e&&(ge=Ad(ge)),X(ge,e.ADD_ATTR,ct))),Cd(e,`ADD_FORBID_CONTENTS`)&&pd(e.ADD_FORBID_CONTENTS)&&(He===Ue&&(He=Ad(He)),X(He,e.ADD_FORBID_CONTENTS,ct)),ze&&(me[`#text`]=!0),Oe&&X(me,[`html`,`head`,`body`]),me.table&&(X(me,[`tbody`]),delete ye.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ed(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ed(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{T=te(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,T=``):(w===void 0&&(w=ne()),w&&typeof T==`string`&&(T=te(``)));nd&&nd(e),lt=e},pt=X({},[...Fd,...Id,...Ld]),mt=X({},[...Rd,...zd]),ht=function(e,t,n){return t.namespaceURI===Xe?e===`svg`:t.namespaceURI===Je?e===`svg`&&(n===`annotation-xml`||nt[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Xe?e===`math`:t.namespaceURI===Ye?e===`math`&&it[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===Ye&&!it[n]||t.namespaceURI===Je&&!nt[n]?!1:!mt[e]&&(at[e]||!pt[e])},vt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Ze,tagName:`template`});let n=md(e.tagName),r=md(t.tagName);return $e[e.namespaceURI]?e.namespaceURI===Ye?ht(n,t,r):e.namespaceURI===Je?gt(n,t,r):e.namespaceURI===Xe?_t(n,t,r):!!(ot===`application/xhtml+xml`&&$e[e.namespaceURI]):!1},yt=function(e){dd(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Ed(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},bt=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},xt=function(e){Ct(e);let t=h(e);if(t){let e=[];cd(t,t=>{dd(e,t)}),cd(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&bt(e,r,i)}},St=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}dd(t.removed,{attribute:r||null,from:n});try{r?n.removeAttributeNode(r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ne||Pe)try{yt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},F=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||ge[ct(i)]||bt(e,r,i)}},Ct=function(e){let t=[e];for(;t.length>0;){let e=t.pop();S(e)===of.element&&F(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},wt=function(e,t){return De?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Tt=function(e){if(!De)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=S(e);if(n===of.processingInstruction||n===of.comment&&Td(nf,e.data)){try{p(e)}catch{}continue}if(n===of.element){let t=e,n=ct(C(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&wt(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Et=function(e){let t=null,r=null;if(Me)e=`<remove></remove>`+e;else{let t=gd(e,/^[\r\n\t ]+/);r=t&&t[0]}ot===`application/xhtml+xml`&&Ze===Xe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?te(e):e;if(Ze===Xe)try{t=new l().parseFromString(i,ot)}catch{}if(!t||!t.documentElement){t=ie.createDocument(Ze,`template`,null);try{t.documentElement.innerHTML=Qe?T:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ze===Xe?j.call(t,Oe?`html`:`body`)[0]:Oe?t.documentElement:a},Dt=function(e){let t=x?x(e):e.ownerDocument;return ae.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ot=function(e){return e=_d(e,se,` `),e=_d(e,ce,` `),e=_d(e,N,` `),e},kt=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=ae.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Ot(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&cd(i,e=>{jt(e.content)&&kt(e.content)})},At=function(e){let t=b?b(e):null;return typeof t!=`string`||ct(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},jt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===of.documentFragment}catch{return!1}},I=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Mt(e,n,r){e.length!==0&&cd(e,e=>{e.call(t,n,r,lt)})}let Nt=function(e,t){return!!(De&&e.hasChildNodes()&&!I(e.firstElementChild)&&Td(tf,e.textContent)&&Td(tf,e.innerHTML)||De&&e.namespaceURI===Xe&&cf[t]&&(I(e.firstElementChild)||typeof e.textContent==`string`&&Td(lf[t],e.textContent))||e.nodeType===of.processingInstruction||De&&e.nodeType===of.comment&&Td(nf,e.data))},Pt=function(e,t){return e instanceof RegExp?Td(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Ft=function(e,t,n){if(!ye[t]&&Vt(t)&&Pt(ve.tagNameCheck,t))return!1;if(ze&&!He[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return yt(e),!0},It=function(e,t,n,r){return e.length===0?t:t===n||t===r?Ad(t):t},Lt=function(e,t){return e===t||g(e)!==null?!1:(Be&&Ct(e),!0)},Rt=function(e,n){if(Mt(M.beforeSanitizeElements,e,null),Lt(e,n))return!0;if(At(e))return yt(e),!0;let r=ct(C(e));if(me=It(M.uponSanitizeElement,me,he,Ae),Mt(M.uponSanitizeElement,e,{tagName:r,allowedTags:me}),Lt(e,n))return!0;if(Nt(e,r))return yt(e),!0;if(ye[r]||!(xe.tagCheck instanceof Function&&xe.tagCheck(r))&&!me[r]){let t=Ft(e,r,n);return t===!1&&Mt(M.afterSanitizeElements,e,null),t}if(S(e)===of.element&&!vt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Td(rf,e.innerHTML))return yt(e),!0;if(Ee&&e.nodeType===of.text){let n=Ot(e.textContent);e.textContent!==n&&(dd(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Mt(M.afterSanitizeElements,e,null),!1},zt=function(e,t,r){if(be[t]||wt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=ge[t]||xe.attributeCheck instanceof Function&&xe.attributeCheck(t,e);return Ce&&Td(P,t)||Se&&Td(le,t)?!0:i?Ke[t]||Td(pe,_d(r,de,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&vd(r,`data:`)===0&&We[e]||we&&!Td(ue,_d(r,de,``))?!0:!r:Vt(e)&&Pt(ve.tagNameCheck,e)&&Pt(ve.attributeNameCheck,t,e)||t===`is`&&ve.allowCustomizedBuiltInElements&&Pt(ve.tagNameCheck,r)},Bt=X({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Vt=function(e){return!Bt[md(e)]&&Td(fe,e)},Ht=function(e,t,n,r){if(w&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return te(r);case`TrustedScriptURL`:return k(r)}return r},L=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),At(e)?yt(e):ud(t.removed)}catch{St(n,e)}},Ut=function(e){Mt(M.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||At(e))return;ge=It(M.uponSanitizeAttribute,ge,_e,je);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ge,forceKeepAttr:void 0},r=t.length,i=ct(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=ct(o),u=c,d=o===`value`?u:yd(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Mt(M.uponSanitizeAttribute,e,n),d=n.attrValue,Le&&(l===`id`||l===`name`)&&vd(d,Re)!==0&&(St(o,e,a),d=Re+d),De&&Td(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){St(o,e,a);continue}if(l===`attributename`&&gd(d,`href`)){St(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){St(o,e,a);continue}if(!Te&&Td(af,d)){St(o,e,a);continue}if(Ee&&(d=Ot(d)),!zt(i,l,d)){St(o,e,a);continue}d=Ht(i,l,s,d),d!==u&&L(e,o,s,d)}}Mt(M.afterSanitizeAttributes,e,null)},Wt=function(e){let t=null,n=Dt(e);for(Mt(M.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Mt(M.uponSanitizeShadowNode,t,null),Rt(t,e),Ut(t),jt(t.content)&&Wt(t.content),S(t)===of.element){let e=_(t);jt(e)&&(Gt(e),Wt(e))}Mt(M.afterSanitizeShadowDOM,e,null)},Gt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Wt(e.shadow);continue}let n=e.node,r=S(n)===of.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&ct(e)===`template`){let e=n.content;jt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);jt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Qe=!e,Qe&&(e=`<!-->`),typeof e!=`string`&&!I(e)&&(e=jd(e),typeof e!=`string`))throw Ed(`dirty is not a string, aborting`);if(!t.isSupported)return e;ke?(me=Ae,ge=je):ft(n),(M.uponSanitizeElement.length>0||M.uponSanitizeAttribute.length>0)&&(me=Ad(me)),M.uponSanitizeAttribute.length>0&&(ge=Ad(ge)),t.removed=[];let c=Be&&typeof e!=`string`&&I(e);if(c){Tt(e);let t=C(e);if(typeof t==`string`){let n=ct(t);if(!me[n]||ye[n])throw xt(e),Ed(`root node is forbidden and cannot be sanitized in-place`)}if(At(e))throw xt(e),Ed(`root node is clobbered and cannot be sanitized in-place`);try{Gt(e)}catch(t){throw xt(e),t}}else if(I(e))i=Et(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===of.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Gt(a);else{if(!Ne&&!Ee&&!Oe&&e.indexOf(`<`)===-1)return w&&Fe?te(e):e;if(i=Et(e),!i)return Ne?null:Fe?T:``}i&&Me&&yt(i.firstChild);let l=c?e:i;try{let e=Dt(l);for(;o=e.nextNode();)Rt(o,l),Ut(o),jt(o.content)&&Wt(o.content)}catch(n){throw c&&(xt(e),cd(t.removed,e=>{e.element&&Ct(e.element)})),n}if(c)return cd(t.removed,e=>{e.element&&Ct(e.element)}),Ee&&kt(e),e;if(Ne){if(Ee&&kt(i),Pe)for(s=A.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ge.shadowroot||ge.shadowrootmode)&&(s=oe.call(r,s,!0)),s}let u=Oe?i.outerHTML:i.innerHTML;return Oe&&me[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Td($d,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
57
57
|
`+u),Ee&&(u=Ot(u)),w&&Fe?te(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),ke=!0,Ae=me,je=ge},t.clearConfig=function(){lt=null,ke=!1,Ae=null,je=null,w=E,T=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=ct(e),i=ct(t);return zt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&Cd(M,e)&&dd(M[e],t)},t.removeHook=function(e,t){if(Cd(M,e)){if(t!==void 0){let n=ld(M[e],t);return n===-1?void 0:fd(M[e],n,1)[0]}return ud(M[e])}},t.removeHooks=function(e){Cd(M,e)&&(M[e]=[])},t.removeAllHooks=function(){M=ff()},t}var gf=hf();function _f(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var vf=_f();function yf(e){vf=e}var bf={exec:()=>null};function xf(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Cf.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Sf=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Cf={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:xf(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:xf(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:xf(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:xf(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:xf(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:xf(e=>RegExp(`^ {0,${e}}>`))},wf=/^(?:[ \t]*(?:\n|$))+/,Tf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ef=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Df=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Of=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,kf=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Af=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,jf=Z(Af).replace(/bull/g,kf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Mf=Z(Af).replace(/bull/g,kf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Nf=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Pf=/^[^\n]+/,Ff=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,If=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Ff).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Lf=Z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,kf).getRegex(),Rf=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,zf=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Bf=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,zf).replace(`tag`,Rf).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vf=e=>Z(Nf).replace(`hr`,Df).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Rf).getRegex(),Hf=Vf(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Uf=Vf(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Wf={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Uf).getRegex(),code:Tf,def:If,fences:Ef,heading:Of,hr:Df,html:Bf,lheading:jf,list:Lf,newline:wf,paragraph:Hf,table:bf,text:Pf},Gf=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Df).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Rf).getRegex(),Kf={...Wf,lheading:Mf,table:Gf,paragraph:Z(Nf).replace(`hr`,Df).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Gf).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Rf).getRegex()},qf={...Wf,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,zf).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:bf,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(Nf).replace(`hr`,Df).replace(`heading`,` *#{1,6} *[^
|
|
58
58
|
]`).replace(`lheading`,jf).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Jf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Yf=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Xf=/^( {2,}|\\)\n(?!\s*$)/,Zf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Qf=/[\p{P}\p{S}]/u,$f=/[\s\p{P}\p{S}]/u,ep=/[^\s\p{P}\p{S}]/u,tp=Z(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,$f).getRegex(),np=/[\p{Pi}\p{Ps}"']/u,rp=/(?!~)[\p{P}\p{S}]/u,ip=/(?!~)[\s\p{P}\p{S}]/u,ap=/(?:[^\s\p{P}\p{S}]|~)/u,op=Z(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Sf?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),sp=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,cp=Z(sp,`u`).replace(/punct/g,Qf).getRegex(),lp=Z(sp,`u`).replace(/punct/g,rp).getRegex(),up=Z(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,np).replace(/punct/g,Qf).getRegex(),dp=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fp=Z(dp,`gu`).replace(/notPunctSpace/g,ep).replace(/punctSpace/g,$f).replace(/punct/g,Qf).getRegex(),pp=Z(dp,`gu`).replace(/notPunctSpace/g,ap).replace(/punctSpace/g,ip).replace(/punct/g,rp).getRegex(),mp=Z(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ep).replace(/punctSpace/g,$f).replace(/punct/g,Qf).getRegex(),hp=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ep).replace(/punctSpace/g,$f).replace(/punct/g,Qf).getRegex(),gp=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ep).replace(/punctSpace/g,$f).replace(/punct/g,Qf).getRegex(),_p=Z(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Qf).getRegex(),vp=Z(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ep).replace(/punctSpace/g,$f).replace(/punct/g,Qf).getRegex(),yp=Z(/\\(punct)/,`gu`).replace(/punct/g,Qf).getRegex(),bp=Z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xp=Z(zf).replace(`(?:-->|$)`,`-->`).getRegex(),Sp=Z(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,xp).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Cp=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,wp=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Cp).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tp=Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Cp).replace(`ref`,Ff).getRegex(),Ep=Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Ff).getRegex(),Dp=Z(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Tp).replace(`nolink`,Ep).getRegex(),Op=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,kp={_backpedal:bf,anyPunctuation:yp,autolink:bp,blockSkip:op,br:Xf,code:Yf,del:bf,delLDelim:bf,delRDelim:bf,emStrongLDelim:cp,emStrongRDelimAst:fp,emStrongRDelimUnd:hp,escape:Jf,link:wp,nolink:Ep,punctuation:tp,reflink:Tp,reflinkSearch:Dp,tag:Sp,text:Zf,url:bf},Ap={...kp,emStrongLDelim:up,emStrongRDelimAst:mp,emStrongRDelimUnd:gp,link:Z(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Cp).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Cp).getRegex()},jp={...kp,emStrongRDelimAst:pp,emStrongLDelim:lp,delLDelim:_p,delRDelim:vp,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Op).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Z(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Op).getRegex()},Mp={...jp,br:Z(Xf).replace(`{2,}`,`*`).getRegex(),text:Z(jp.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Np={normal:Wf,gfm:Kf,pedantic:qf},Pp={normal:kp,gfm:jp,breaks:Mp,pedantic:Ap},Fp={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ip=e=>Fp[e];function Lp(e,t){if(t){if(Cf.escapeTest.test(e))return e.replace(Cf.escapeReplace,Ip)}else if(Cf.escapeTestNoEncode.test(e))return e.replace(Cf.escapeReplaceNoEncode,Ip);return e}function Rp(e){try{e=encodeURI(e).replace(Cf.percentDecode,`%`)}catch{return null}return e}function zp(e,t){let n=e.replace(Cf.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Cf.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(Cf.slashPipe,`|`);return n}function Bp(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Vp(e){let t=e.split(`
|
package/dist/web/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/omms-icon.svg" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>omms Memory Explorer</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CIODmA62.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-BktRr9cC.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/opencode/tui.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenCode TUI entry: shows "omms:
|
|
2
|
+
* OpenCode TUI entry: shows "omms: ✔" in the prompt footer, and a toast
|
|
3
3
|
* when a newer om-memory-system is on npm. OpenCode compiles this file itself;
|
|
4
4
|
* the logic lives in dist/adapters/opencode/tui-status.js.
|
|
5
5
|
*
|
|
@@ -17,7 +17,7 @@ import { jsx } from "opentui:runtime-module:%40opentui%2Fsolid%2Fjsx-runtime";
|
|
|
17
17
|
export default {
|
|
18
18
|
id: "omms.tui",
|
|
19
19
|
async setup(context: any) {
|
|
20
|
-
const [text, setText] = createSignal("omms:
|
|
20
|
+
const [text, setText] = createSignal("omms: ⧖");
|
|
21
21
|
const removeSlot = context.ui.slot({
|
|
22
22
|
append: "prompt.footer.status",
|
|
23
23
|
render: () =>
|
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
context.ui.toast.show({ title: "OMMS", message, variant: "info", duration: 10_000 }),
|
|
40
40
|
});
|
|
41
41
|
} catch {
|
|
42
|
-
setText("omms:
|
|
42
|
+
setText("omms: ✘");
|
|
43
43
|
}
|
|
44
44
|
return () => {
|
|
45
45
|
stop?.();
|