kandown 0.33.3 → 0.33.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/bin/kandown.js +94 -14
- package/bin/tui.js +124 -76
- package/dist/index.html +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.33.5 — 2026-07-24 — "Sidebar Task Switch Fix"
|
|
4
|
+
|
|
5
|
+
- **Fixed**: **BlockNote Editor Not Refreshing on Sidebar Task Switch** — the BlockNote markdown editor now properly reloads when switching between tasks via the sidebar explorer. Previously, the editor body kept showing the previous task's content because the `useEffect` only ran once on mount. The fix compares the editor's current markdown (normalized) against the incoming `value` prop and only calls `replaceBlocks` when they differ. This makes the editor reactive to external value changes (task switch) while preserving cursor/focus during the user's own typing sessions.
|
|
6
|
+
- **Changed**: **Agent Work Rules Default Output Mode** — the agent work output base rules mode changed from `verbose` to `full` for more complete context generation.
|
|
7
|
+
- **Changed**: **UI Theme** — updated default skin from `kandown` to `linear` for a more modern appearance.
|
|
8
|
+
- **Added**: **Stack Default State** — new `stackDefaultState: collapsed` configuration option for the UI.
|
|
9
|
+
|
|
10
|
+
## 0.33.4 — 2026-07-21 — "Daemon Update Recovery"
|
|
11
|
+
|
|
12
|
+
- **Fixed**: **Default `kandown` Launch Reusing Stale Daemons** — running `kandown` now validates the already-running project daemon version before reusing it. If the daemon is missing a version or is running a different CLI version than the current command, Kandown safely stops it and starts a fresh daemon from the active CLI so the browser opens the current web app instead of stale in-memory code.
|
|
13
|
+
- **Fixed**: **Web UI Auto-Update Not Taking Effect Immediately** — successful `/api/update/apply` calls now schedule a detached daemon restart after the HTTP success response is sent. This makes one-click Web UI updates actually switch the local server process to the newly installed package instead of requiring a manual daemon stop/start.
|
|
14
|
+
- **Fixed**: **Auto-Updater False Success Across Multiple Node Prefixes** — global package update attempts now verify the resolved `kandown --version` after each package-manager install command. If `npm`, `pnpm`, `yarn`, or `bun` updates a different global prefix than the executable on PATH, the updater keeps trying fallbacks and no longer reports success while the active command remains stale.
|
|
15
|
+
- **Changed**: **Daemon Health Metadata** — daemon status checks now read and propagate the remote daemon version from `/api/daemon`, keeping CLI-side restart decisions aligned with the process that is actually serving the project.
|
|
16
|
+
- **Changed**: **Update Route Messaging** — the update API success message now explicitly says the daemon is restarting, making the expected short reconnect window clearer for the Web UI.
|
|
17
|
+
|
|
3
18
|
## 0.33.3 — 2026-07-21 — "CLI Recovery"
|
|
4
19
|
|
|
5
20
|
- **Fixed**: **Default `kandown` Launch Regression** — restored the pre-split zero-setup startup flow where running `kandown` inside any project automatically initializes `.kandown/` when needed, refreshes the web bundle, starts the per-project daemon, and enters the normal board launch path.
|
package/bin/kandown.js
CHANGED
|
@@ -16,7 +16,7 @@ import { spawn, execSync } from "child_process";
|
|
|
16
16
|
import { homedir } from "os";
|
|
17
17
|
|
|
18
18
|
// src/lib/version.ts
|
|
19
|
-
var KANDOWN_VERSION = "0.33.
|
|
19
|
+
var KANDOWN_VERSION = "0.33.5";
|
|
20
20
|
|
|
21
21
|
// src/cli/lib/updater.ts
|
|
22
22
|
import { fileURLToPath } from "url";
|
|
@@ -99,6 +99,31 @@ function resolveKandownBin() {
|
|
|
99
99
|
}
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
+
async function readInstalledKandownVersion(targetVersion) {
|
|
103
|
+
const localVersion = getCurrentVersion();
|
|
104
|
+
const bin = resolveKandownBin();
|
|
105
|
+
if (!bin) return localVersion;
|
|
106
|
+
return await new Promise((resolveVersion) => {
|
|
107
|
+
const child = spawn(bin, ["--version"], {
|
|
108
|
+
timeout: 5e3,
|
|
109
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
110
|
+
env: { ...process.env, KANDOWN_NO_UPDATE: "1" },
|
|
111
|
+
detached: false
|
|
112
|
+
});
|
|
113
|
+
let stdout = "";
|
|
114
|
+
child.stdout.on("data", (d) => {
|
|
115
|
+
stdout += d;
|
|
116
|
+
});
|
|
117
|
+
child.stderr.on("data", () => {
|
|
118
|
+
});
|
|
119
|
+
child.on("error", () => resolveVersion(localVersion));
|
|
120
|
+
child.on("close", (code) => {
|
|
121
|
+
if (code !== 0) return resolveVersion(localVersion);
|
|
122
|
+
const match = stdout.trim().match(/v?(\d+\.\d+\.\d+(?:-[\w.-]+)?)/);
|
|
123
|
+
resolveVersion(match ? match[1] : localVersion);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
102
127
|
function updateCheckedRecently() {
|
|
103
128
|
try {
|
|
104
129
|
if (!existsSync(UPDATE_CHECK_CACHE)) return false;
|
|
@@ -115,6 +140,10 @@ function rememberUpdateCheck() {
|
|
|
115
140
|
} catch {
|
|
116
141
|
}
|
|
117
142
|
}
|
|
143
|
+
function requestedSemver(packageSpec) {
|
|
144
|
+
const match = packageSpec.match(/@(\d+\.\d+\.\d+(?:-[\w.-]+)?)$/);
|
|
145
|
+
return match ? match[1] : null;
|
|
146
|
+
}
|
|
118
147
|
async function performGlobalPackageUpdate(packageSpec) {
|
|
119
148
|
const cleanEnv = { ...process.env };
|
|
120
149
|
for (const k of Object.keys(cleanEnv)) {
|
|
@@ -122,6 +151,12 @@ async function performGlobalPackageUpdate(packageSpec) {
|
|
|
122
151
|
delete cleanEnv[k];
|
|
123
152
|
}
|
|
124
153
|
}
|
|
154
|
+
const targetVersion = requestedSemver(packageSpec);
|
|
155
|
+
const verifyInstalledVersion = async () => {
|
|
156
|
+
if (!targetVersion) return true;
|
|
157
|
+
const installedVersion = await readInstalledKandownVersion(targetVersion);
|
|
158
|
+
return semverGt(installedVersion, targetVersion) >= 0;
|
|
159
|
+
};
|
|
125
160
|
const tryPkgCmd = (cmd, args) => {
|
|
126
161
|
return new Promise((res) => {
|
|
127
162
|
const child = spawn(cmd, args, {
|
|
@@ -138,22 +173,26 @@ async function performGlobalPackageUpdate(packageSpec) {
|
|
|
138
173
|
child.on("close", (code) => res(code === 0));
|
|
139
174
|
});
|
|
140
175
|
};
|
|
176
|
+
const tryPkgCmdAndVerify = async (cmd, args) => {
|
|
177
|
+
if (!await tryPkgCmd(cmd, args)) return false;
|
|
178
|
+
return verifyInstalledVersion();
|
|
179
|
+
};
|
|
141
180
|
const currentBin = resolveKandownBin() || "";
|
|
142
181
|
const currentBinDir = currentBin ? dirname(currentBin) : null;
|
|
143
182
|
const siblingNpm = currentBinDir ? join(currentBinDir, "npm") : null;
|
|
144
183
|
const siblingPnpm = currentBinDir ? join(currentBinDir, "pnpm") : null;
|
|
145
184
|
const isPnpmInstall = currentBin.includes("pnpm");
|
|
146
|
-
if (siblingPnpm && existsSync(siblingPnpm) && await
|
|
147
|
-
if (siblingNpm && existsSync(siblingNpm) && await
|
|
185
|
+
if (siblingPnpm && existsSync(siblingPnpm) && await tryPkgCmdAndVerify(siblingPnpm, ["add", "-g", packageSpec])) return true;
|
|
186
|
+
if (siblingNpm && existsSync(siblingNpm) && await tryPkgCmdAndVerify(siblingNpm, ["install", "-g", packageSpec, "--force"])) return true;
|
|
148
187
|
if (isPnpmInstall) {
|
|
149
|
-
if (await
|
|
150
|
-
if (await
|
|
188
|
+
if (await tryPkgCmdAndVerify("pnpm", ["add", "-g", packageSpec])) return true;
|
|
189
|
+
if (await tryPkgCmdAndVerify("npm", ["install", "-g", packageSpec, "--force"])) return true;
|
|
151
190
|
} else {
|
|
152
|
-
if (await
|
|
153
|
-
if (await
|
|
191
|
+
if (await tryPkgCmdAndVerify("npm", ["install", "-g", packageSpec, "--force"])) return true;
|
|
192
|
+
if (await tryPkgCmdAndVerify("pnpm", ["add", "-g", packageSpec])) return true;
|
|
154
193
|
}
|
|
155
|
-
if (await
|
|
156
|
-
return await
|
|
194
|
+
if (await tryPkgCmdAndVerify("yarn", ["global", "add", packageSpec])) return true;
|
|
195
|
+
return await tryPkgCmdAndVerify("bun", ["add", "-g", packageSpec]);
|
|
157
196
|
}
|
|
158
197
|
async function checkForUpdate(argv = process.argv) {
|
|
159
198
|
if (process.env.KANDOWN_NO_UPDATE === "1") return;
|
|
@@ -802,9 +841,10 @@ function isProcessAlive(pid) {
|
|
|
802
841
|
}
|
|
803
842
|
function parseRemoteDaemonInfo(value) {
|
|
804
843
|
if (!isRecord(value)) return null;
|
|
805
|
-
const { ok, pid, kandownDir } = value;
|
|
844
|
+
const { ok, pid, kandownDir, version } = value;
|
|
806
845
|
if (ok !== true || typeof pid !== "number" || !Number.isInteger(pid) || typeof kandownDir !== "string") return null;
|
|
807
|
-
|
|
846
|
+
if (version !== null && typeof version !== "string" && version !== void 0) return null;
|
|
847
|
+
return { ok, pid, kandownDir, version: typeof version === "string" ? version : null };
|
|
808
848
|
}
|
|
809
849
|
async function fetchDaemonInfo(port) {
|
|
810
850
|
try {
|
|
@@ -846,7 +886,7 @@ async function getDaemonStatus(kandownDir) {
|
|
|
846
886
|
removeDaemonMetadata(kandownDir);
|
|
847
887
|
return { running: false, metadata: null };
|
|
848
888
|
}
|
|
849
|
-
return { running: true, metadata };
|
|
889
|
+
return { running: true, metadata: { ...metadata, version: remote.version ?? metadata.version } };
|
|
850
890
|
}
|
|
851
891
|
async function waitForDaemon(kandownDir, timeoutMs = 8e3) {
|
|
852
892
|
const started = Date.now();
|
|
@@ -861,7 +901,10 @@ async function waitForDaemon(kandownDir, timeoutMs = 8e3) {
|
|
|
861
901
|
}
|
|
862
902
|
async function startProjectDaemon(kandownDir, preferredPort) {
|
|
863
903
|
const current = await getDaemonStatus(kandownDir);
|
|
864
|
-
if (current.running)
|
|
904
|
+
if (current.running) {
|
|
905
|
+
if (current.metadata?.version === getCurrentVersion()) return current;
|
|
906
|
+
await stopProjectDaemon(kandownDir);
|
|
907
|
+
}
|
|
865
908
|
const cliPath = process.argv[1];
|
|
866
909
|
if (!cliPath) throw new Error("Cannot locate kandown CLI entrypoint");
|
|
867
910
|
const args = [
|
|
@@ -984,6 +1027,42 @@ function syncProjectKandownHtml(kandownDir) {
|
|
|
984
1027
|
}
|
|
985
1028
|
return false;
|
|
986
1029
|
}
|
|
1030
|
+
function readDaemonPort(kandownDir) {
|
|
1031
|
+
try {
|
|
1032
|
+
const raw = JSON.parse(readFileSync5(join5(kandownDir, "daemon.json"), "utf8"));
|
|
1033
|
+
return typeof raw.port === "number" && Number.isInteger(raw.port) ? raw.port : null;
|
|
1034
|
+
} catch {
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
function restartDaemonAfterUpdateResponse(res, kandownDir) {
|
|
1039
|
+
const cliPath = process.argv[1];
|
|
1040
|
+
if (!cliPath) return;
|
|
1041
|
+
const args = ["--no-update-check", "daemon", "run", "--path", kandownDir];
|
|
1042
|
+
const port = readDaemonPort(kandownDir);
|
|
1043
|
+
if (port !== null) args.push("--port", String(port));
|
|
1044
|
+
const launcher = `
|
|
1045
|
+
const { spawn } = require('node:child_process');
|
|
1046
|
+
const [nodeBin, cliPath, ...cliArgs] = process.argv.slice(1);
|
|
1047
|
+
setTimeout(() => {
|
|
1048
|
+
const child = spawn(nodeBin, [cliPath, ...cliArgs], {
|
|
1049
|
+
detached: true,
|
|
1050
|
+
stdio: 'ignore',
|
|
1051
|
+
env: { ...process.env, KANDOWN_DAEMON: '1' },
|
|
1052
|
+
});
|
|
1053
|
+
child.unref();
|
|
1054
|
+
}, 350);
|
|
1055
|
+
`;
|
|
1056
|
+
res.on("finish", () => {
|
|
1057
|
+
const child = spawn3(process.execPath, ["-e", launcher, process.execPath, cliPath, ...args], {
|
|
1058
|
+
detached: true,
|
|
1059
|
+
stdio: "ignore",
|
|
1060
|
+
env: { ...process.env, KANDOWN_DAEMON: "1" }
|
|
1061
|
+
});
|
|
1062
|
+
child.unref();
|
|
1063
|
+
setTimeout(() => process.exit(0), 50).unref();
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
987
1066
|
async function handleApi(req, res, url, kandownDir) {
|
|
988
1067
|
const path = url.pathname;
|
|
989
1068
|
const method = req.method || "GET";
|
|
@@ -1050,7 +1129,8 @@ async function handleApi(req, res, url, kandownDir) {
|
|
|
1050
1129
|
const ok = await performGlobalPackageUpdate(`kandown@${targetVersion}`);
|
|
1051
1130
|
syncProjectKandownHtml(kandownDir);
|
|
1052
1131
|
if (ok) {
|
|
1053
|
-
|
|
1132
|
+
restartDaemonAfterUpdateResponse(res, kandownDir);
|
|
1133
|
+
writeJson(res, 200, { ok: true, version: targetVersion, message: "Update installed successfully; daemon is restarting" });
|
|
1054
1134
|
broadcastSseEvent({ type: "update", version: targetVersion });
|
|
1055
1135
|
} else {
|
|
1056
1136
|
writeJson(res, 500, { ok: false, message: "Global package installation failed" });
|
package/bin/tui.js
CHANGED
|
@@ -907,21 +907,21 @@ var require_react_development = __commonJS({
|
|
|
907
907
|
);
|
|
908
908
|
actScopeDepth = prevActScopeDepth;
|
|
909
909
|
}
|
|
910
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
910
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve4, reject) {
|
|
911
911
|
var queue = ReactSharedInternals.actQueue;
|
|
912
912
|
if (null !== queue)
|
|
913
913
|
if (0 !== queue.length)
|
|
914
914
|
try {
|
|
915
915
|
flushActQueue(queue);
|
|
916
916
|
enqueueTask(function() {
|
|
917
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
917
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
|
|
918
918
|
});
|
|
919
919
|
return;
|
|
920
920
|
} catch (error) {
|
|
921
921
|
ReactSharedInternals.thrownErrors.push(error);
|
|
922
922
|
}
|
|
923
923
|
else ReactSharedInternals.actQueue = null;
|
|
924
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
924
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve4(returnValue);
|
|
925
925
|
}
|
|
926
926
|
function flushActQueue(queue) {
|
|
927
927
|
if (!isFlushing) {
|
|
@@ -1108,7 +1108,7 @@ var require_react_development = __commonJS({
|
|
|
1108
1108
|
));
|
|
1109
1109
|
});
|
|
1110
1110
|
return {
|
|
1111
|
-
then: function(
|
|
1111
|
+
then: function(resolve4, reject) {
|
|
1112
1112
|
didAwaitActCall = true;
|
|
1113
1113
|
thenable.then(
|
|
1114
1114
|
function(returnValue) {
|
|
@@ -1118,7 +1118,7 @@ var require_react_development = __commonJS({
|
|
|
1118
1118
|
flushActQueue(queue), enqueueTask(function() {
|
|
1119
1119
|
return recursivelyFlushAsyncActWork(
|
|
1120
1120
|
returnValue,
|
|
1121
|
-
|
|
1121
|
+
resolve4,
|
|
1122
1122
|
reject
|
|
1123
1123
|
);
|
|
1124
1124
|
});
|
|
@@ -1132,7 +1132,7 @@ var require_react_development = __commonJS({
|
|
|
1132
1132
|
ReactSharedInternals.thrownErrors.length = 0;
|
|
1133
1133
|
reject(_thrownError);
|
|
1134
1134
|
}
|
|
1135
|
-
} else
|
|
1135
|
+
} else resolve4(returnValue);
|
|
1136
1136
|
},
|
|
1137
1137
|
function(error) {
|
|
1138
1138
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
@@ -1154,15 +1154,15 @@ var require_react_development = __commonJS({
|
|
|
1154
1154
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1155
1155
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
1156
1156
|
return {
|
|
1157
|
-
then: function(
|
|
1157
|
+
then: function(resolve4, reject) {
|
|
1158
1158
|
didAwaitActCall = true;
|
|
1159
1159
|
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
1160
1160
|
return recursivelyFlushAsyncActWork(
|
|
1161
1161
|
returnValue$jscomp$0,
|
|
1162
|
-
|
|
1162
|
+
resolve4,
|
|
1163
1163
|
reject
|
|
1164
1164
|
);
|
|
1165
|
-
})) :
|
|
1165
|
+
})) : resolve4(returnValue$jscomp$0);
|
|
1166
1166
|
}
|
|
1167
1167
|
};
|
|
1168
1168
|
};
|
|
@@ -3048,8 +3048,8 @@ var require_react_reconciler_production = __commonJS({
|
|
|
3048
3048
|
currentEntangledActionThenable = {
|
|
3049
3049
|
status: "pending",
|
|
3050
3050
|
value: void 0,
|
|
3051
|
-
then: function(
|
|
3052
|
-
entangledListeners.push(
|
|
3051
|
+
then: function(resolve4) {
|
|
3052
|
+
entangledListeners.push(resolve4);
|
|
3053
3053
|
}
|
|
3054
3054
|
};
|
|
3055
3055
|
}
|
|
@@ -3072,8 +3072,8 @@ var require_react_reconciler_production = __commonJS({
|
|
|
3072
3072
|
status: "pending",
|
|
3073
3073
|
value: null,
|
|
3074
3074
|
reason: null,
|
|
3075
|
-
then: function(
|
|
3076
|
-
listeners.push(
|
|
3075
|
+
then: function(resolve4) {
|
|
3076
|
+
listeners.push(resolve4);
|
|
3077
3077
|
}
|
|
3078
3078
|
};
|
|
3079
3079
|
thenable.then(
|
|
@@ -12672,8 +12672,8 @@ var require_react_reconciler_development = __commonJS({
|
|
|
12672
12672
|
currentEntangledActionThenable = {
|
|
12673
12673
|
status: "pending",
|
|
12674
12674
|
value: void 0,
|
|
12675
|
-
then: function(
|
|
12676
|
-
entangledListeners.push(
|
|
12675
|
+
then: function(resolve4) {
|
|
12676
|
+
entangledListeners.push(resolve4);
|
|
12677
12677
|
}
|
|
12678
12678
|
};
|
|
12679
12679
|
}
|
|
@@ -12696,8 +12696,8 @@ var require_react_reconciler_development = __commonJS({
|
|
|
12696
12696
|
status: "pending",
|
|
12697
12697
|
value: null,
|
|
12698
12698
|
reason: null,
|
|
12699
|
-
then: function(
|
|
12700
|
-
listeners.push(
|
|
12699
|
+
then: function(resolve4) {
|
|
12700
|
+
listeners.push(resolve4);
|
|
12701
12701
|
}
|
|
12702
12702
|
};
|
|
12703
12703
|
thenable.then(
|
|
@@ -44418,22 +44418,22 @@ var init_devtools = __esm({
|
|
|
44418
44418
|
init_devtools_window_polyfill();
|
|
44419
44419
|
init_wrapper();
|
|
44420
44420
|
import_react_devtools_core = __toESM(require_backend(), 1);
|
|
44421
|
-
isDevToolsReachable = async () => new Promise((
|
|
44421
|
+
isDevToolsReachable = async () => new Promise((resolve4) => {
|
|
44422
44422
|
const socket = new wrapper_default("ws://localhost:8097");
|
|
44423
44423
|
const timeout = setTimeout(() => {
|
|
44424
44424
|
socket.terminate();
|
|
44425
|
-
|
|
44425
|
+
resolve4(false);
|
|
44426
44426
|
}, 2e3);
|
|
44427
44427
|
timeout.unref();
|
|
44428
44428
|
socket.on("open", () => {
|
|
44429
44429
|
clearTimeout(timeout);
|
|
44430
44430
|
socket.terminate();
|
|
44431
|
-
|
|
44431
|
+
resolve4(true);
|
|
44432
44432
|
});
|
|
44433
44433
|
socket.on("error", () => {
|
|
44434
44434
|
clearTimeout(timeout);
|
|
44435
44435
|
socket.terminate();
|
|
44436
|
-
|
|
44436
|
+
resolve4(false);
|
|
44437
44437
|
});
|
|
44438
44438
|
});
|
|
44439
44439
|
if (await isDevToolsReachable()) {
|
|
@@ -52683,8 +52683,8 @@ var kittyModifiers = {
|
|
|
52683
52683
|
var noop = () => {
|
|
52684
52684
|
};
|
|
52685
52685
|
var textEncoder = new TextEncoder();
|
|
52686
|
-
var yieldImmediate = async () => new Promise((
|
|
52687
|
-
setImmediate(
|
|
52686
|
+
var yieldImmediate = async () => new Promise((resolve4) => {
|
|
52687
|
+
setImmediate(resolve4);
|
|
52688
52688
|
});
|
|
52689
52689
|
var kittyQueryEscapeByte = 27;
|
|
52690
52690
|
var kittyQueryOpenBracketByte = 91;
|
|
@@ -52888,8 +52888,8 @@ var Ink = class {
|
|
|
52888
52888
|
};
|
|
52889
52889
|
}
|
|
52890
52890
|
this.initKittyKeyboard();
|
|
52891
|
-
this.exitPromise = new Promise((
|
|
52892
|
-
this.resolveExitPromise =
|
|
52891
|
+
this.exitPromise = new Promise((resolve4, reject) => {
|
|
52892
|
+
this.resolveExitPromise = resolve4;
|
|
52893
52893
|
this.rejectExitPromise = reject;
|
|
52894
52894
|
});
|
|
52895
52895
|
void this.exitPromise.catch(noop);
|
|
@@ -53182,9 +53182,9 @@ var Ink = class {
|
|
|
53182
53182
|
settleThrottle(this.throttledOnRender, canWriteToStdout);
|
|
53183
53183
|
settleThrottle(this.throttledLog, canWriteToStdout);
|
|
53184
53184
|
if (canWriteToStdout && hasWritableState) {
|
|
53185
|
-
await new Promise((
|
|
53185
|
+
await new Promise((resolve4) => {
|
|
53186
53186
|
this.options.stdout.write("", () => {
|
|
53187
|
-
|
|
53187
|
+
resolve4();
|
|
53188
53188
|
});
|
|
53189
53189
|
});
|
|
53190
53190
|
return;
|
|
@@ -53251,8 +53251,8 @@ var Ink = class {
|
|
|
53251
53251
|
async awaitNextRender() {
|
|
53252
53252
|
if (!this.nextRenderCommit) {
|
|
53253
53253
|
let resolveRender;
|
|
53254
|
-
const promise = new Promise((
|
|
53255
|
-
resolveRender =
|
|
53254
|
+
const promise = new Promise((resolve4) => {
|
|
53255
|
+
resolveRender = resolve4;
|
|
53256
53256
|
});
|
|
53257
53257
|
this.nextRenderCommit = { promise, resolve: resolveRender };
|
|
53258
53258
|
}
|
|
@@ -53984,7 +53984,7 @@ var import_react32 = __toESM(require_react(), 1);
|
|
|
53984
53984
|
var import_react33 = __toESM(require_react(), 1);
|
|
53985
53985
|
|
|
53986
53986
|
// src/cli/tui.tsx
|
|
53987
|
-
import { fileURLToPath as
|
|
53987
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
53988
53988
|
|
|
53989
53989
|
// src/cli/app.tsx
|
|
53990
53990
|
var import_react38 = __toESM(require_react(), 1);
|
|
@@ -54434,7 +54434,7 @@ function ValueDisplay({ setting, value, focused }) {
|
|
|
54434
54434
|
// src/cli/screens/board.tsx
|
|
54435
54435
|
var import_react37 = __toESM(require_react(), 1);
|
|
54436
54436
|
import { spawnSync } from "child_process";
|
|
54437
|
-
import { join as
|
|
54437
|
+
import { join as join9 } from "path";
|
|
54438
54438
|
|
|
54439
54439
|
// src/cli/lib/board-reader.ts
|
|
54440
54440
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3, mkdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
@@ -54923,12 +54923,56 @@ function archiveTaskInBoard(kandownDir, taskId) {
|
|
|
54923
54923
|
}
|
|
54924
54924
|
|
|
54925
54925
|
// src/cli/lib/daemon.ts
|
|
54926
|
-
import { existsSync as
|
|
54927
|
-
import { dirname as
|
|
54928
|
-
import { execFileSync as execFileSync3, spawn } from "child_process";
|
|
54926
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, unlinkSync as unlinkSync4 } from "fs";
|
|
54927
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
54928
|
+
import { execFileSync as execFileSync3, spawn as spawn2 } from "child_process";
|
|
54929
54929
|
import { createConnection } from "net";
|
|
54930
|
+
|
|
54931
|
+
// src/cli/lib/updater.ts
|
|
54932
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync2, unlinkSync as unlinkSync3, statSync, mkdirSync as mkdirSync2 } from "fs";
|
|
54933
|
+
import { join as join3, resolve } from "path";
|
|
54934
|
+
import { spawn, execSync } from "child_process";
|
|
54935
|
+
import { homedir as homedir2 } from "os";
|
|
54936
|
+
|
|
54937
|
+
// src/lib/version.ts
|
|
54938
|
+
var KANDOWN_VERSION = "0.33.5";
|
|
54939
|
+
|
|
54940
|
+
// src/cli/lib/updater.ts
|
|
54941
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
54942
|
+
import { dirname as dirname2 } from "path";
|
|
54943
|
+
function getPackageRoot() {
|
|
54944
|
+
try {
|
|
54945
|
+
const currentFile = fileURLToPath2(import.meta.url);
|
|
54946
|
+
if (currentFile.includes("/bin/")) {
|
|
54947
|
+
return resolve(dirname2(currentFile), "..");
|
|
54948
|
+
}
|
|
54949
|
+
return resolve(dirname2(currentFile), "../../..");
|
|
54950
|
+
} catch {
|
|
54951
|
+
return process.cwd();
|
|
54952
|
+
}
|
|
54953
|
+
}
|
|
54954
|
+
var PKG_ROOT2 = getPackageRoot();
|
|
54955
|
+
var CACHE_DIR = join3(homedir2(), ".kandown");
|
|
54956
|
+
var UPDATE_CHECK_CACHE = join3(CACHE_DIR, ".update-check.json");
|
|
54957
|
+
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
54958
|
+
function getCurrentVersion() {
|
|
54959
|
+
if (KANDOWN_VERSION && KANDOWN_VERSION !== "0.0.0-dev") {
|
|
54960
|
+
return KANDOWN_VERSION;
|
|
54961
|
+
}
|
|
54962
|
+
try {
|
|
54963
|
+
const pkgPath = resolve(import.meta.url ? new URL("../../..", import.meta.url).pathname : process.cwd(), "package.json");
|
|
54964
|
+
if (existsSync4(pkgPath)) {
|
|
54965
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf8"));
|
|
54966
|
+
if (pkg.version) return pkg.version;
|
|
54967
|
+
}
|
|
54968
|
+
} catch {
|
|
54969
|
+
}
|
|
54970
|
+
return KANDOWN_VERSION || "0.32.1";
|
|
54971
|
+
}
|
|
54972
|
+
|
|
54973
|
+
// src/cli/lib/daemon.ts
|
|
54930
54974
|
function metadataPath(kandownDir) {
|
|
54931
|
-
return
|
|
54975
|
+
return join4(kandownDir, "daemon.json");
|
|
54932
54976
|
}
|
|
54933
54977
|
function isRecord(value) {
|
|
54934
54978
|
return typeof value === "object" && value !== null;
|
|
@@ -54946,9 +54990,9 @@ function parseMetadata(value) {
|
|
|
54946
54990
|
}
|
|
54947
54991
|
function readDaemonMetadata(kandownDir) {
|
|
54948
54992
|
const path = metadataPath(kandownDir);
|
|
54949
|
-
if (!
|
|
54993
|
+
if (!existsSync5(path)) return null;
|
|
54950
54994
|
try {
|
|
54951
|
-
return parseMetadata(JSON.parse(
|
|
54995
|
+
return parseMetadata(JSON.parse(readFileSync5(path, "utf8")));
|
|
54952
54996
|
} catch {
|
|
54953
54997
|
return null;
|
|
54954
54998
|
}
|
|
@@ -54956,7 +55000,7 @@ function readDaemonMetadata(kandownDir) {
|
|
|
54956
55000
|
function removeDaemonMetadata(kandownDir) {
|
|
54957
55001
|
try {
|
|
54958
55002
|
const path = metadataPath(kandownDir);
|
|
54959
|
-
if (
|
|
55003
|
+
if (existsSync5(path)) unlinkSync4(path);
|
|
54960
55004
|
} catch {
|
|
54961
55005
|
}
|
|
54962
55006
|
}
|
|
@@ -54970,9 +55014,10 @@ function isProcessAlive(pid) {
|
|
|
54970
55014
|
}
|
|
54971
55015
|
function parseRemoteDaemonInfo(value) {
|
|
54972
55016
|
if (!isRecord(value)) return null;
|
|
54973
|
-
const { ok, pid, kandownDir } = value;
|
|
55017
|
+
const { ok, pid, kandownDir, version } = value;
|
|
54974
55018
|
if (ok !== true || typeof pid !== "number" || !Number.isInteger(pid) || typeof kandownDir !== "string") return null;
|
|
54975
|
-
|
|
55019
|
+
if (version !== null && typeof version !== "string" && version !== void 0) return null;
|
|
55020
|
+
return { ok, pid, kandownDir, version: typeof version === "string" ? version : null };
|
|
54976
55021
|
}
|
|
54977
55022
|
async function fetchDaemonInfo(port) {
|
|
54978
55023
|
try {
|
|
@@ -54986,16 +55031,16 @@ async function fetchDaemonInfo(port) {
|
|
|
54986
55031
|
}
|
|
54987
55032
|
}
|
|
54988
55033
|
function isPortListening(port, timeoutMs = 400) {
|
|
54989
|
-
return new Promise((
|
|
55034
|
+
return new Promise((resolve4) => {
|
|
54990
55035
|
const socket = createConnection({ port, host: "127.0.0.1" }, () => {
|
|
54991
55036
|
socket.destroy();
|
|
54992
|
-
|
|
55037
|
+
resolve4(true);
|
|
54993
55038
|
});
|
|
54994
|
-
socket.on("error", () =>
|
|
55039
|
+
socket.on("error", () => resolve4(false));
|
|
54995
55040
|
socket.setTimeout(timeoutMs);
|
|
54996
55041
|
socket.on("timeout", () => {
|
|
54997
55042
|
socket.destroy();
|
|
54998
|
-
|
|
55043
|
+
resolve4(false);
|
|
54999
55044
|
});
|
|
55000
55045
|
});
|
|
55001
55046
|
}
|
|
@@ -55014,7 +55059,7 @@ async function getDaemonStatus(kandownDir) {
|
|
|
55014
55059
|
removeDaemonMetadata(kandownDir);
|
|
55015
55060
|
return { running: false, metadata: null };
|
|
55016
55061
|
}
|
|
55017
|
-
return { running: true, metadata };
|
|
55062
|
+
return { running: true, metadata: { ...metadata, version: remote.version ?? metadata.version } };
|
|
55018
55063
|
}
|
|
55019
55064
|
async function waitForDaemon(kandownDir, timeoutMs = 8e3) {
|
|
55020
55065
|
const started = Date.now();
|
|
@@ -55023,13 +55068,16 @@ async function waitForDaemon(kandownDir, timeoutMs = 8e3) {
|
|
|
55023
55068
|
if (metadata && isProcessAlive(metadata.pid) && await isPortListening(metadata.port)) {
|
|
55024
55069
|
return { running: true, metadata };
|
|
55025
55070
|
}
|
|
55026
|
-
await new Promise((
|
|
55071
|
+
await new Promise((resolve4) => setTimeout(resolve4, 120));
|
|
55027
55072
|
}
|
|
55028
55073
|
return { running: false, metadata: null };
|
|
55029
55074
|
}
|
|
55030
55075
|
async function startProjectDaemon(kandownDir, preferredPort) {
|
|
55031
55076
|
const current = await getDaemonStatus(kandownDir);
|
|
55032
|
-
if (current.running)
|
|
55077
|
+
if (current.running) {
|
|
55078
|
+
if (current.metadata?.version === getCurrentVersion()) return current;
|
|
55079
|
+
await stopProjectDaemon(kandownDir);
|
|
55080
|
+
}
|
|
55033
55081
|
const cliPath = process.argv[1];
|
|
55034
55082
|
if (!cliPath) throw new Error("Cannot locate kandown CLI entrypoint");
|
|
55035
55083
|
const args = [
|
|
@@ -55043,8 +55091,8 @@ async function startProjectDaemon(kandownDir, preferredPort) {
|
|
|
55043
55091
|
if (typeof preferredPort === "number" && Number.isInteger(preferredPort)) {
|
|
55044
55092
|
args.push("--port", String(preferredPort));
|
|
55045
55093
|
}
|
|
55046
|
-
const child =
|
|
55047
|
-
cwd:
|
|
55094
|
+
const child = spawn2(process.execPath, args, {
|
|
55095
|
+
cwd: dirname3(kandownDir),
|
|
55048
55096
|
detached: true,
|
|
55049
55097
|
stdio: "ignore",
|
|
55050
55098
|
env: { ...process.env, KANDOWN_DAEMON: "1" }
|
|
@@ -55083,7 +55131,7 @@ async function stopProjectDaemon(kandownDir) {
|
|
|
55083
55131
|
}
|
|
55084
55132
|
const started = Date.now();
|
|
55085
55133
|
while (Date.now() - started < 2500 && isProcessAlive(pid)) {
|
|
55086
|
-
await new Promise((
|
|
55134
|
+
await new Promise((resolve4) => setTimeout(resolve4, 100));
|
|
55087
55135
|
}
|
|
55088
55136
|
if (isProcessAlive(pid)) {
|
|
55089
55137
|
try {
|
|
@@ -55096,9 +55144,9 @@ async function stopProjectDaemon(kandownDir) {
|
|
|
55096
55144
|
}
|
|
55097
55145
|
|
|
55098
55146
|
// src/cli/lib/file-watcher.ts
|
|
55099
|
-
import { createReadStream, statSync } from "fs";
|
|
55147
|
+
import { createReadStream, statSync as statSync2 } from "fs";
|
|
55100
55148
|
import { createHash } from "crypto";
|
|
55101
|
-
import { join as
|
|
55149
|
+
import { join as join7 } from "path";
|
|
55102
55150
|
|
|
55103
55151
|
// node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
55104
55152
|
import { stat as statcb } from "fs";
|
|
@@ -55829,9 +55877,9 @@ var NodeFsHandler = class {
|
|
|
55829
55877
|
if (this.fsw.closed) {
|
|
55830
55878
|
return;
|
|
55831
55879
|
}
|
|
55832
|
-
const
|
|
55880
|
+
const dirname6 = sysPath.dirname(file);
|
|
55833
55881
|
const basename3 = sysPath.basename(file);
|
|
55834
|
-
const parent = this.fsw._getWatchedDir(
|
|
55882
|
+
const parent = this.fsw._getWatchedDir(dirname6);
|
|
55835
55883
|
let prevStats = stats;
|
|
55836
55884
|
if (parent.has(basename3))
|
|
55837
55885
|
return;
|
|
@@ -55858,7 +55906,7 @@ var NodeFsHandler = class {
|
|
|
55858
55906
|
prevStats = newStats2;
|
|
55859
55907
|
}
|
|
55860
55908
|
} catch (error) {
|
|
55861
|
-
this.fsw._remove(
|
|
55909
|
+
this.fsw._remove(dirname6, basename3);
|
|
55862
55910
|
}
|
|
55863
55911
|
} else if (parent.has(basename3)) {
|
|
55864
55912
|
const at = newStats.atimeMs;
|
|
@@ -55954,7 +56002,7 @@ var NodeFsHandler = class {
|
|
|
55954
56002
|
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
55955
56003
|
}
|
|
55956
56004
|
}).on(EV.ERROR, this._boundHandleError);
|
|
55957
|
-
return new Promise((
|
|
56005
|
+
return new Promise((resolve4, reject) => {
|
|
55958
56006
|
if (!stream)
|
|
55959
56007
|
return reject();
|
|
55960
56008
|
stream.once(STR_END, () => {
|
|
@@ -55963,7 +56011,7 @@ var NodeFsHandler = class {
|
|
|
55963
56011
|
return;
|
|
55964
56012
|
}
|
|
55965
56013
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
55966
|
-
|
|
56014
|
+
resolve4(void 0);
|
|
55967
56015
|
previous.getChildren().filter((item) => {
|
|
55968
56016
|
return item !== directory && !current.has(item);
|
|
55969
56017
|
}).forEach((item) => {
|
|
@@ -56792,11 +56840,11 @@ function watch(paths, options = {}) {
|
|
|
56792
56840
|
|
|
56793
56841
|
// src/cli/lib/file-watcher.ts
|
|
56794
56842
|
function hashFile(filePath) {
|
|
56795
|
-
return new Promise((
|
|
56843
|
+
return new Promise((resolve4, reject) => {
|
|
56796
56844
|
const hash = createHash("sha256");
|
|
56797
56845
|
const stream = createReadStream(filePath);
|
|
56798
56846
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
56799
|
-
stream.on("end", () =>
|
|
56847
|
+
stream.on("end", () => resolve4(hash.digest("hex")));
|
|
56800
56848
|
stream.on("error", reject);
|
|
56801
56849
|
});
|
|
56802
56850
|
}
|
|
@@ -56824,17 +56872,17 @@ var FileWatcher = class {
|
|
|
56824
56872
|
*/
|
|
56825
56873
|
start(kandownDir) {
|
|
56826
56874
|
const tasksDir = getTasksDir(kandownDir);
|
|
56827
|
-
const configPath =
|
|
56875
|
+
const configPath = join7(kandownDir, "kandown.json");
|
|
56828
56876
|
const existingIds = listTaskIds(kandownDir);
|
|
56829
56877
|
for (const id of existingIds) {
|
|
56830
56878
|
this.knownTaskIds.add(id);
|
|
56831
56879
|
try {
|
|
56832
|
-
const filePath =
|
|
56880
|
+
const filePath = join7(tasksDir, `${id}.md`);
|
|
56833
56881
|
this.taskHashes.set(id, hashFileSync(filePath));
|
|
56834
56882
|
} catch {
|
|
56835
56883
|
}
|
|
56836
56884
|
}
|
|
56837
|
-
this.watcher = watch([
|
|
56885
|
+
this.watcher = watch([join7(tasksDir, "*.md"), configPath], {
|
|
56838
56886
|
ignoreInitial: true,
|
|
56839
56887
|
awaitWriteFinish: { stabilityThreshold: 25, pollInterval: 25 },
|
|
56840
56888
|
alwaysStat: true
|
|
@@ -56883,7 +56931,7 @@ var FileWatcher = class {
|
|
|
56883
56931
|
handleFsEvent(event, filePath, kandownDir) {
|
|
56884
56932
|
if (this.stopped) return;
|
|
56885
56933
|
const tasksDir = getTasksDir(kandownDir);
|
|
56886
|
-
const configPath =
|
|
56934
|
+
const configPath = join7(kandownDir, "kandown.json");
|
|
56887
56935
|
if (filePath === configPath) {
|
|
56888
56936
|
const key = `config:${event}`;
|
|
56889
56937
|
const existing = this.debounceTimers.get(key);
|
|
@@ -56936,15 +56984,15 @@ var FileWatcher = class {
|
|
|
56936
56984
|
async pollHashes(kandownDir) {
|
|
56937
56985
|
if (this.stopped) return;
|
|
56938
56986
|
const tasksDir = getTasksDir(kandownDir);
|
|
56939
|
-
const configPath =
|
|
56987
|
+
const configPath = join7(kandownDir, "kandown.json");
|
|
56940
56988
|
try {
|
|
56941
56989
|
const newHash = hashFileSync(configPath);
|
|
56942
56990
|
} catch {
|
|
56943
56991
|
}
|
|
56944
56992
|
for (const taskId of this.knownTaskIds) {
|
|
56945
|
-
const filePath =
|
|
56993
|
+
const filePath = join7(tasksDir, `${taskId}.md`);
|
|
56946
56994
|
try {
|
|
56947
|
-
|
|
56995
|
+
statSync2(filePath);
|
|
56948
56996
|
const newHash = await hashFile(filePath);
|
|
56949
56997
|
const oldHash = this.taskHashes.get(taskId);
|
|
56950
56998
|
if (oldHash !== void 0 && newHash !== oldHash) {
|
|
@@ -56959,7 +57007,7 @@ var FileWatcher = class {
|
|
|
56959
57007
|
const currentIds = listTaskIds(kandownDir);
|
|
56960
57008
|
for (const id of currentIds) {
|
|
56961
57009
|
if (!this.knownTaskIds.has(id)) {
|
|
56962
|
-
const filePath =
|
|
57010
|
+
const filePath = join7(tasksDir, `${id}.md`);
|
|
56963
57011
|
try {
|
|
56964
57012
|
const newHash = await hashFile(filePath);
|
|
56965
57013
|
this.knownTaskIds.add(id);
|
|
@@ -57134,9 +57182,9 @@ function buildPrompt(agentDoc, taskContent, taskId, kandownDir) {
|
|
|
57134
57182
|
}
|
|
57135
57183
|
|
|
57136
57184
|
// src/cli/lib/launcher.ts
|
|
57137
|
-
import { execSync, spawn as
|
|
57138
|
-
import { writeFileSync as
|
|
57139
|
-
import { join as
|
|
57185
|
+
import { execSync as execSync2, spawn as spawn3 } from "child_process";
|
|
57186
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
57187
|
+
import { join as join8 } from "path";
|
|
57140
57188
|
import { tmpdir } from "os";
|
|
57141
57189
|
function isInTmux() {
|
|
57142
57190
|
return !!process.env.TMUX;
|
|
@@ -57169,9 +57217,9 @@ function launchAgent(opts) {
|
|
|
57169
57217
|
if (!taskMoved) {
|
|
57170
57218
|
throw new Error(`Could not move task ${taskId} to In Progress \u2014 task file missing or unwritable.`);
|
|
57171
57219
|
}
|
|
57172
|
-
const contextFile =
|
|
57220
|
+
const contextFile = join8(tmpdir(), `kandown-${taskId}-context.md`);
|
|
57173
57221
|
try {
|
|
57174
|
-
|
|
57222
|
+
writeFileSync3(contextFile, `${systemPrompt}
|
|
57175
57223
|
|
|
57176
57224
|
---
|
|
57177
57225
|
|
|
@@ -57193,7 +57241,7 @@ ${taskPrompt}`, "utf8");
|
|
|
57193
57241
|
`KANDOWN_DIR=${shellescape(kandownDir)}`
|
|
57194
57242
|
].join(" ");
|
|
57195
57243
|
try {
|
|
57196
|
-
|
|
57244
|
+
execSync2(`tmux split-window -h -p 50 ${shellescape(`env ${envPrefix} ${shellCmd}`)}`, {
|
|
57197
57245
|
stdio: "inherit"
|
|
57198
57246
|
});
|
|
57199
57247
|
} catch (e) {
|
|
@@ -57203,7 +57251,7 @@ ${taskPrompt}`, "utf8");
|
|
|
57203
57251
|
} else {
|
|
57204
57252
|
try {
|
|
57205
57253
|
onBeforeExec?.();
|
|
57206
|
-
const child =
|
|
57254
|
+
const child = spawn3(binary, args, {
|
|
57207
57255
|
stdio: "inherit",
|
|
57208
57256
|
env: {
|
|
57209
57257
|
...process.env,
|
|
@@ -58361,7 +58409,7 @@ function Board({ kandownDir, version }) {
|
|
|
58361
58409
|
if (input === "e") {
|
|
58362
58410
|
const task = getFocusedTask();
|
|
58363
58411
|
if (task) {
|
|
58364
|
-
const taskPath =
|
|
58412
|
+
const taskPath = join9(getTasksDir(kandownDir), `${task.id}.md`);
|
|
58365
58413
|
const editor = process.env.EDITOR || "nano";
|
|
58366
58414
|
try {
|
|
58367
58415
|
spawnSync(editor, [taskPath], { stdio: "inherit" });
|
|
@@ -58784,7 +58832,7 @@ async function run(screen, kandownDir, version) {
|
|
|
58784
58832
|
});
|
|
58785
58833
|
await instance.waitUntilExit();
|
|
58786
58834
|
}
|
|
58787
|
-
if (process.argv[1] ===
|
|
58835
|
+
if (process.argv[1] === fileURLToPath3(import.meta.url)) {
|
|
58788
58836
|
const screen = process.argv[2] || "board";
|
|
58789
58837
|
const kandownDir = process.argv[3];
|
|
58790
58838
|
const version = process.argv[4];
|
package/dist/index.html
CHANGED
|
@@ -201,7 +201,7 @@ Error generating stack: `+_.message+`
|
|
|
201
201
|
|
|
202
202
|
## Subtasks
|
|
203
203
|
|
|
204
|
-
`}}async function bH(t,e){try{return await(await(await(await t.getDirectoryHandle("archive",{create:!1})).getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}}async function ope(t,e){try{return await(await t.getDirectoryHandle("archive",{create:!1})).getFileHandle(`${e}.md`),!0}catch{return!1}}async function vH(t,e){try{return await t.getDirectoryHandle("archive",{create:e})}catch{return null}}async function cpe(t){if(Lt())return fS();const e=new Set;for await(const n of t.values())n.kind==="file"&&n.name.endsWith(".md")&&e.add(n.name.slice(0,-3));try{const n=await t.getDirectoryHandle("archive",{create:!1});for await(const a of n.values())a.kind==="file"&&a.name.endsWith(".md")&&e.add(a.name.slice(0,-3))}catch{}return[...e].sort((n,a)=>n.localeCompare(a,void 0,{numeric:!0}))}async function Ps(t,e){if(Lt())try{const i=await gS(e);return Fg(i)}catch{return FL(e)}const a=await(async i=>{try{return await(await(await i.getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}})(t)??await bH(t,e);return a!==null?Fg(a):FL(e)}async function ppe(t,e){if(Lt())try{const a=await gS(e);return{ok:!0,task:Fg(a)}}catch(a){return a.name==="NotFoundError"?{ok:!1,reason:"not-found"}:{ok:!1,reason:"unknown",error:a}}let n=null;try{n=await(await(await t.getFileHandle(`${e}.md`)).getFile()).text()}catch{}if(n===null)try{n=await bH(t,e)}catch(a){return{ok:!1,reason:"unknown",error:a}}if(n===null)return{ok:!1,reason:"not-found"};if(n.trim()==="")return{ok:!1,reason:"corrupted",error:new Error(`Task file ${e}.md is empty`)};try{return{ok:!0,task:Fg(n)}}catch(a){return{ok:!1,reason:"corrupted",error:a}}}async function pu(t,e,n,a){const i=dS(n,a);if(Lt())return Xce(e,i);try{const o=await(await(await ope(t,e)?await vH(t,!0):t).getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await o.write(i)}finally{await o.close()}}catch(r){throw Lh(r,`${e}.md`)}}async function zL(t,e){if(Lt())return Qce(e);try{await t.removeEntry(`${e}.md`)}catch{}try{await(await t.getDirectoryHandle("archive",{create:!1})).removeEntry(`${e}.md`)}catch{}}async function lpe(t,e){await gi(`/api/tasks/${encodeURIComponent(t)}/archive`,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})}async function dpe(t,e){await gi(`/api/tasks/${encodeURIComponent(t)}/unarchive`,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})}async function upe(t,e,n,a){const i=dS(n,a);if(Lt())return lpe(e,i);try{const o=await(await(await vH(t,!0)).getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await o.write(i)}finally{await o.close()}try{await t.removeEntry(`${e}.md`)}catch{}}catch(r){throw Lh(r,`archive/${e}.md`)}}async function mpe(t,e,n,a){const i=dS(n,a);if(Lt())return dpe(e,i);try{const s=await(await t.getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await s.write(i)}finally{await s.close()}try{await(await t.getDirectoryHandle("archive",{create:!1})).removeEntry(`${e}.md`)}catch{}}catch(r){throw Lh(r,`${e}.md`)}}const fpe="kanban-md",gpe=1,sp="recentProjects";function hS(){return new Promise((t,e)=>{const n=indexedDB.open(fpe,gpe);n.onerror=()=>e(n.error),n.onsuccess=()=>t(n.result),n.onupgradeneeded=()=>{const a=n.result;a.objectStoreNames.contains(sp)||a.createObjectStore(sp,{keyPath:"id"})}})}async function H2(t){const e=await hS();return new Promise((n,a)=>{const i=e.transaction(sp,"readwrite");i.objectStore(sp).put(t),i.oncomplete=()=>n(),i.onerror=()=>a(i.error)})}async function Fy(){const t=await hS();return new Promise((e,n)=>{const i=t.transaction(sp,"readonly").objectStore(sp).getAll();i.onsuccess=()=>{const r=i.result||[];r.sort((s,o)=>o.lastOpened-s.lastOpened),e(r.slice(0,10))},i.onerror=()=>n(i.error)})}async function hpe(t){const e=await hS();return new Promise((n,a)=>{const i=e.transaction(sp,"readwrite");i.objectStore(sp).delete(t),i.oncomplete=()=>n(),i.onerror=()=>a(i.error)})}async function HL(t,e=!0){const n={mode:e?"readwrite":"read"};try{return await t.queryPermission(n)==="granted"||await t.requestPermission(n)==="granted"}catch(a){return console.warn("[FS] verifyPermission: handle is no longer valid:",a),!1}}async function bpe(){try{return await(await gi("/api/update/check")).json()}catch{return null}}async function yH(){try{return await(await gi("/api/update/apply",{method:"POST"})).json()}catch{return null}}function _H(t=Ei){const e=t.board.columns;return e[e.length-1]??"Done"}function vpe(t,e=Ei){return t===_H(e)||t.toLowerCase()==="archived"}class ype{dirHandle=null;tasksDirHandle=null;intervalId=null;configHash=null;taskHashes=new Map;knownTaskIds=new Set;listeners=new Map;debounceTimers=new Map;debounceDelay=150;consecutiveErrors=0;maxConsecutiveErrors=5;disabled=!1;eventSource=null;start(e,n){this.dirHandle=e,this.tasksDirHandle=n,this.consecutiveErrors=0,this.disabled=!1,Lt()&&this.startServerSse(),e&&n&&(this.initHashes(),this.intervalId=setInterval(()=>void this.tick(),300))}startServerSse(){if(typeof window>"u"||!Lt()||this.eventSource)return;const e=window.__KANDOWN_TOKEN__,n=e?`/api/events?token=${encodeURIComponent(e)}`:"/api/events";try{this.eventSource=new EventSource(n),this.eventSource.onmessage=a=>{try{const i=JSON.parse(a.data);i.type==="change"&&(i.taskId?this.emit("taskChanged",i.taskId):(this.emit("configChanged"),this.emit("taskChanged","")))}catch{}}}catch(a){console.warn("[Watcher] EventSource init failed:",a)}}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.configHash=null,this.taskHashes.clear(),this.knownTaskIds.clear(),this.listeners.clear(),this.debounceTimers.forEach(e=>clearTimeout(e)),this.debounceTimers.clear(),this.consecutiveErrors=0,this.disabled=!1}isDisabled(){return this.disabled}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}getKnownTaskIds(){return Array.from(this.knownTaskIds)}async initHashes(){if(!(!this.dirHandle||!this.tasksDirHandle))try{const e=await BL(this.dirHandle);e!==null&&(this.configHash=await this.hash(e)),await this.syncTaskDir(!1)}catch(e){console.warn("[Watcher] initHashes error:",e)}}async tick(){if(!(!this.dirHandle||!this.tasksDirHandle)&&!this.disabled)try{const e=await BL(this.dirHandle);if(e!==null){const n=await this.hash(e);this.configHash!==null&&n!==this.configHash&&(this.configHash=n,this.debouncedEmit("configChanged"))}for(const n of[...this.knownTaskIds])try{const a=await UL(this.tasksDirHandle,n);if(a!==null){const i=await this.hash(a),r=this.taskHashes.get(n);r!==void 0&&i!==r&&(this.taskHashes.set(n,i),this.debouncedEmit("taskChanged",n))}}catch(a){console.warn(`[Watcher] Error reading task ${n}:`,a)}await this.syncTaskDir(!0),this.consecutiveErrors=0}catch(e){this.consecutiveErrors++,console.error(`[Watcher] Tick failed (${this.consecutiveErrors}/${this.maxConsecutiveErrors}):`,e),this.consecutiveErrors>=this.maxConsecutiveErrors&&this.disable(`File watcher stopped after ${this.maxConsecutiveErrors} consecutive errors: ${e.message}`)}}disable(e){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.disabled=!0,this.emit("watcherError",e)}debouncedEmit(e,...n){const a=e+JSON.stringify(n),i=this.debounceTimers.get(a);i&&clearTimeout(i);const r=setTimeout(()=>{this.debounceTimers.delete(a),this.emit(e,...n)},this.debounceDelay);this.debounceTimers.set(a,r)}async syncTaskDir(e){if(!this.tasksDirHandle)return;let n;try{n=this.tasksDirHandle.values()}catch(a){throw a}for await(const a of n){if(a.kind!=="file"||!a.name.endsWith(".md"))continue;const i=a.name.replace(".md","");if(!this.knownTaskIds.has(i))try{this.knownTaskIds.add(i);const r=await UL(this.tasksDirHandle,i);r!==null&&(this.taskHashes.set(i,await this.hash(r)),e&&this.debouncedEmit("newTaskDetected",i))}catch(r){console.warn(`[Watcher] syncTaskDir: failed to read ${i}:`,r)}}}async hash(e){const a=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}emit(e,...n){this.listeners.get(e)?.forEach(i=>{if(e==="configChanged"){i();return}if(e==="taskChanged"){const[s]=n;i(s);return}if(e==="newTaskDetected"){const[s]=n;i(s);return}const[r]=n;i(r)})}}async function BL(t){try{return await(await(await t.getFileHandle("kandown.json")).getFile()).text()}catch{return null}}async function UL(t,e){try{return await(await(await t.getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}}const Lo=new ype,_pe={soft:[{frequency:520,durationMs:90,delayMs:0,type:"sine"},{frequency:720,durationMs:120,delayMs:95,type:"sine"}],chime:[{frequency:660,durationMs:120,delayMs:0,type:"triangle"},{frequency:880,durationMs:160,delayMs:125,type:"triangle"}],ping:[{frequency:920,durationMs:110,delayMs:0,type:"sine"}],pop:[{frequency:260,durationMs:55,delayMs:0,type:"square"},{frequency:520,durationMs:80,delayMs:60,type:"square"}]};let qL=null;function kH(){return"Notification"in window?Notification.permission:"unsupported"}async function kpe(){return"Notification"in window?await Notification.requestPermission():"unsupported"}function B2({title:t,body:e,config:n}){if(n.notifications.webhookUrl&&fetch(n.notifications.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"kandown_notification",title:t,body:e,timestamp:new Date().toISOString()})}).catch(()=>{}),n.notifications.sound&&wpe(n.notifications.soundId),!(!n.notifications.browser||kH()!=="granted"))try{new Notification(t,{body:e})}catch{}}function wpe(t){const e=_pe[t],n=window.AudioContext??window.webkitAudioContext;if(!(!n||e.length===0))try{qL??=new n;const a=qL;a.state==="suspended"&&a.resume();const i=a.currentTime+.01;e.forEach(r=>{const s=a.createOscillator(),o=a.createGain(),c=i+r.delayMs/1e3,p=c+r.durationMs/1e3;s.type=r.type??"sine",s.frequency.setValueAtTime(r.frequency,c),o.gain.setValueAtTime(1e-4,c),o.gain.exponentialRampToValueAtTime(.08,c+.01),o.gain.exponentialRampToValueAtTime(1e-4,p),s.connect(o),o.connect(a.destination),s.start(c),s.stop(p+.02)})}catch{}}async function jf(t,e={}){const{maxAttempts:n=3,baseDelayMs:a=500,retryableCheck:i=Zce}=e;let r;for(let s=1;s<=n;s++)try{return await t()}catch(o){if(r=o,!i(o))throw o;if(s<n){const c=a*Math.pow(2,s-1);await new Promise(p=>setTimeout(p,c))}}throw r}function xpe(t){const e=t.toLowerCase(),n=new Date;if(e==="today")return n.toISOString().split("T")[0];if(e==="tomorrow"){const i=new Date(n);return i.setDate(i.getDate()+1),i.toISOString().split("T")[0]}const a=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];if(a.includes(e)){const i=a.indexOf(e),r=new Date(n);let s=i-r.getDay();return s<=0&&(s+=7),r.setDate(r.getDate()+s),r.toISOString().split("T")[0]}return t}function Ape(t){let e=t.trim(),n;const a=[];let i,r;const s=[];return e=e.replace(/(?:^|\s)p([1-4])(?:\s|$)/i,(c,p)=>(n=`P${p}`," ")),e=e.replace(/(?:^|\s)#([a-zA-Z0-9_-]+)/g,(c,p)=>(a.push(p.toLowerCase())," ")),e=e.replace(/(?:^|\s)@([a-zA-Z0-9_-]+)/g,(c,p)=>(i=p," ")),e=e.replace(/(?:^|\s)due:([^\s]+)/i,(c,p)=>(r=xpe(p)," ")),e=e.replace(/(?:^|\s)\+([a-zA-Z0-9_-]+)/g,(c,p)=>(s.push(p)," ")),{title:e.replace(/\s+/g," ").trim()||t,...n?{priority:n}:{},...a.length>0?{tags:a}:{},...i?{assignee:i}:{},...r?{due:r}:{},...s.length>0?{depends_on:s}:{}}}const Cpe=/^[A-Za-z0-9_-]+$/;function U2(t){if(!t)return null;const e=t.trim().replace(/^\/+|\/+$/g,"").replace(/^#/,"");return!e||e.includes("/")||e.includes(".")||!Cpe.test(e)?null:/^\d+$/.test(e)?`t${e}`:e}function Npe(t){const e=new URLSearchParams(t.search).get("p");if(!e)return null;const[n]=e.split("/").filter(Boolean);return n||null}function zy(t){const e=new URLSearchParams(t.search),n=U2(e.get("task"));if(n)return n;const a=e.get("p");if(a){const[,...r]=a.split("/").filter(Boolean),s=U2(r.join("/"));if(s)return s}return U2(decodeURIComponent(t.pathname))}function T3(t){return t?`/?p=${encodeURIComponent(t)}`:"/"}function bS(t,e){const n=t.replace(/^t(?=\d+$)/,""),a=`/${encodeURIComponent(n)}`;return e?`${a}?p=${encodeURIComponent(e)}`:a}function Hy(t,e=!1){typeof window>"u"||`${window.location.pathname}${window.location.search}`===t||(e?window.history.replaceState({},"",t):window.history.pushState({},"",t),window.dispatchEvent(new Event("kandown:urlchange")))}function Iv(t){typeof window<"u"&&zy(window.location)||Hy(T3(t))}function Spe(t){let e=-1;for(const n of t)for(const a of n.tasks){const i=a.id.match(/^t(\d+)$/);if(i){const r=parseInt(i[1],10);r>e&&(e=r)}}return"t"+(e+1)}async function $pe(){const t=await fS();return await Promise.all(t.map(async n=>{const{frontmatter:a,body:i}=await hH(n),r={...a,id:a.id||n,status:a.status||"Backlog"},{subtasks:s,bodyWithoutSubtasks:o}=Rs(i);return{id:n,frontmatter:r,body:o,subtasks:s}}))}async function Epe(t){const e=await cpe(t),n=await Promise.all(e.map(async r=>{const s=await ppe(t,r);return{id:r,result:s}})),a=[],i=[];for(const{id:r,result:s}of n)if(s.ok){const o={...s.task.frontmatter,id:s.task.frontmatter.id||r,status:s.task.frontmatter.status||"Backlog"},{subtasks:c,bodyWithoutSubtasks:p}=Rs(s.task.body);a.push({id:r,frontmatter:o,body:p,subtasks:c})}else{if(s.reason==="not-found")continue;i.push(r)}return{tasks:a,failedIds:i}}async function VL(t,e,n){const a=[];for(const s of e){const o=s.name;s.tasks.forEach((c,p)=>{const d=(async()=>{const{frontmatter:m,body:f}=await Ps(t,c.id);await pu(t,c.id,{...m,id:c.id,status:o,order:p},f)})();a.push({id:c.id,promise:d})})}const i=await Promise.allSettled(a.map(s=>s.promise)),r=[];return i.forEach((s,o)=>{s.status==="rejected"&&r.push(a[o].id)}),{failedIds:r}}function pl(t){mH(t.ui.theme,t.ui.skin,t.ui.font,t.ui.background)}function P3(t){return{title:t.frontmatter.title||t.id,status:t.frontmatter.status||"Backlog",body:t.body,subtasks:t.subtasks}}function q2(t){yu.clear(),t.forEach(e=>{yu.set(e.id,P3(e))})}function Tpe(t){const e=t.split(/[\\/]+/).filter(Boolean),n=e[e.length-1];return n===".kandown"?e[e.length-2]??"Project":n??"Project"}function Ppe(t,e){return e.reduce((n,a,i)=>{const r=t[i]?.done??!1;return n+(a.done&&!r?1:0)},0)}function Mpe(t,e){const n=t.subtasks.map(i=>({text:i.text,description:i.description??"",report:i.report??""})),a=e.subtasks.map(i=>({text:i.text,description:i.description??"",report:i.report??""}));return t.title!==e.title||t.body!==e.body||JSON.stringify(n)!==JSON.stringify(a)}let Lpe=0;const yu=new Map,Df=new Map;let V2=null;const se=Lce((t,e)=>({isOpen:!1,loading:!1,dirHandle:null,projectName:null,tasksDirHandle:null,boardTitle:"Project Kanban",columns:[],archivedTasks:[],showArchives:!1,showMetadata:!0,taskContents:new Map,searchMatches:new Map,viewMode:localStorage.getItem("kandown:view")||"board",density:localStorage.getItem("kandown:density")||"comfortable",filters:{search:"",priority:null,tag:null,assignee:null,ownerType:null},commandOpen:!1,cheatsheetOpen:!1,drawerTaskId:null,drawerData:null,currentPage:"board",config:Ei,recentProjects:[],toasts:[],agentHook:null,isReloading:!1,lastReloadError:null,failedTaskIds:[],watcherError:null,hasUnsavedDrawerEdits:!1,lastSaveError:null,drawerRecoveryData:new Map,selectedTaskIds:[],toggleTaskSelection:n=>{t(a=>({selectedTaskIds:a.selectedTaskIds.includes(n)?a.selectedTaskIds.filter(s=>s!==n):[...a.selectedTaskIds,n]}))},clearTaskSelection:()=>t({selectedTaskIds:[]}),bulkMoveTasks:async n=>{const{selectedTaskIds:a,columns:i,moveTask:r}=e();for(const s of a){let o="Backlog";for(const c of i)if(c.tasks.some(p=>p.id===s)){o=c.name;break}await r(s,o,n)}t({selectedTaskIds:[]})},bulkDeleteTasks:async()=>{const{selectedTaskIds:n,deleteTask:a}=e();for(const i of n)await a(i);t({selectedTaskIds:[]})},drawerBaseVersion:null,conflictState:null,showConflictModal:!1,openFolder:async()=>{if(!fH()){const c=navigator.userAgent||"this browser";e().toast(new Vce(c).message,"error",8e3);return}let n;try{n=await npe()}catch(c){c instanceof mS?e().toast("Permission denied — please grant access to the project folder","error"):e().toast("Failed to open folder: "+c.message,"error");return}if(!n)return;const{projectHandle:a,kandownHandle:i,tasksHandle:r}=n,s=a.name;t({dirHandle:i,tasksDirHandle:r,projectName:s}),Iv(s);const o=Lt()?z2():null;try{await H2({id:a.name,name:a.name,handle:a,lastOpened:Date.now(),...o?{kandownDir:o}:{}})}catch(c){console.warn("[Store] Failed to save recent project:",c)}await e().loadConfig(),await e().reloadBoard();try{const c=await Fy();t({recentProjects:c})}catch(c){console.warn("[Store] Failed to load recent projects:",c)}e().setupWatcher()},openRecentProject:async n=>{const a={dirHandle:e().dirHandle,tasksDirHandle:e().tasksDirHandle,projectName:e().projectName};if(!await HL(n.handle,!0)){let r=!1;try{await Oy(n.handle),r=!0}catch{r=!1}if(!r){e().toast(`"${n.name}" is no longer accessible. Removed from recent projects.`,"warning",8e3);try{await hpe(n.id);const s=await Fy();t({recentProjects:s})}catch{}return}e().toast("Permission denied — please grant access to the folder","error");return}try{const r=await Oy(n.handle),s=await E3(n.handle),o=n.handle.name;t({dirHandle:r,tasksDirHandle:s,projectName:o}),Iv(o);try{await H2({...n,lastOpened:Date.now()})}catch(c){console.warn("[Store] Failed to update recent project:",c)}await e().loadConfig(),await e().reloadBoard(),e().setupWatcher()}catch(r){t(a),e().toast(`Failed to open project: ${r.message}`,"error")}},openServerProject:async()=>{t({loading:!0});try{const n=z2();if(!n)throw new Error("No server root");await OL();const a=Tpe(n),i=await gH();pl(i);const r=await fS(),s=await Promise.all(r.map(async f=>{const{frontmatter:h,body:v}=await hH(f),k={...h,id:h.id||f,status:h.status||"Backlog"},{subtasks:w,bodyWithoutSubtasks:A}=Rs(v);return{id:f,frontmatter:k,body:A,subtasks:w}}));q2(s);const o=s.map(f=>({frontmatter:f.frontmatter,body:Wd(f.body,f.subtasks)})),c=R2(o,i.board.columns),p=O2(o),d=c.reduce((f,h)=>f+h.tasks.length,0),m=new Map;if(d<=10)for(const f of s)m.set(f.frontmatter.id,{frontmatter:f.frontmatter,subtasks:f.subtasks,body:f.body});t({loading:!1,isOpen:!0,config:i,columns:c,archivedTasks:p,boardTitle:"Project Kanban",projectName:a,taskContents:m,searchMatches:new Map}),Iv(a),e().setupWatcher(),e().refreshAgentHook()}catch{t({loading:!1,isOpen:!1}),e().toast("Impossible de charger le projet. Relancez `kandown`.","error")}},tryAutoOpenServerProject:async()=>{if(!Lt())return;const n=z2();if(!n)return;await OL();const a=await Fy(),i=a.find(p=>p.kandownDir===n);if(!i){await e().openServerProject();return}if(!await HL(i.handle,!0)){await e().openServerProject();return}const s=await Oy(i.handle),o=await E3(i.handle),c=i.handle.name;t({dirHandle:s,tasksDirHandle:o,projectName:c,recentProjects:a,isOpen:!0}),Iv(c),await H2({...i,lastOpened:Date.now()}),await e().loadConfig(),await e().reloadBoard(),e().setupWatcher()},loadConfig:async()=>{const{dirHandle:n}=e();if(!(!n&&!Lt()))try{const a=await ape(n);if(a.ok){t({config:a.config}),pl(a.config);return}if(a.reason==="corrupted"){if(a.rawContent&&n)try{const r=await(await n.getFileHandle("kandown.json.backup",{create:!0})).createWritable();try{await r.write(a.rawContent)}finally{await r.close()}}catch{}e().toast("kandown.json is corrupted — using default settings. A backup was saved as kandown.json.backup.","warning",1e4)}t({config:Ei}),pl(Ei)}catch{t({config:Ei}),pl(Ei)}},updateConfig:async n=>{const{dirHandle:a,config:i}=e();if(!a&&!Lt())return;const r=n(i);t({config:r}),pl(r);try{await ipe(a,r)}catch(s){const o=s;o instanceof To?e().toast("Disk is full — settings were not saved.","error",8e3):e().toast("Failed to save config: "+o.message,"error")}},reloadBoard:async()=>{const{tasksDirHandle:n,config:a}=e();t({isReloading:!0,lastReloadError:null});try{if(Lt()){const i=await $pe();q2(i);const r=i.map(d=>({frontmatter:d.frontmatter,body:Wd(d.body,d.subtasks)})),s=R2(r,a.board.columns),o=O2(r);t({boardTitle:"Project Kanban",columns:s,archivedTasks:o});const c=s.reduce((d,m)=>d+m.tasks.length,0),p=new Map;if(c<=10)for(const d of i)p.set(d.frontmatter.id,{frontmatter:d.frontmatter,subtasks:d.subtasks,body:d.body});t({taskContents:p,searchMatches:new Map,failedTaskIds:[],isReloading:!1})}else if(n){const{tasks:i,failedIds:r}=await Epe(n);q2(i);const s=i.map(m=>({frontmatter:m.frontmatter,body:Wd(m.body,m.subtasks)})),o=R2(s,a.board.columns),c=O2(s);t({boardTitle:"Project Kanban",columns:o,archivedTasks:c});const p=o.reduce((m,f)=>m+f.tasks.length,0),d=new Map;if(p<=10)for(const m of i)d.set(m.frontmatter.id,{frontmatter:m.frontmatter,subtasks:m.subtasks,body:m.body});if(r.length>0){const m=r.length===1?`Task ${r[0]} could not be loaded`:`${r.length} tasks could not be loaded`;e().toast(m,"warning",8e3)}t({taskContents:d,searchMatches:new Map,failedTaskIds:r,isReloading:!1})}else t({isReloading:!1})}catch(i){const r=i.message||String(i);t({isReloading:!1,lastReloadError:`Failed to reload board: ${r}`}),e().toast(`Board reload failed — showing last loaded state (${r})`,"warning",8e3)}},moveTask:async(n,a,i,r)=>{const{columns:s,config:o,taskContents:c,searchMatches:p}=e(),d=Lt();if(!d&&!e().tasksDirHandle)return;const m=s.find(T=>T.name===a),f=s.find(T=>T.name===i);if(!m||!f)return;const h=m.tasks.findIndex(T=>T.id===n);if(h===-1)return;const v=m.tasks[h];if(!v)return;if(vpe(i,o)){const T=new Map,M=_H(o).toLowerCase();for(const D of s)for(const I of D.tasks){const H=I.frontmatter&&(I.frontmatter.archived===!0||I.frontmatter.archived==="true");T.set(I.id,{exists:!0,resolved:H||I.id===n||D.name.toLowerCase()===M})}const j=[];for(const D of v.dependsOn){if(typeof D!="string"||!D.trim()||D===n)continue;const I=T.get(D);(!I||!I.resolved)&&j.push(D)}if(j.length>0){const D=j.length===1?j[0]:`${j.slice(0,-1).join(", ")} and ${j[j.length-1]}`;e().toast(`Cannot move ${n} to ${i}: blocked by ${D}`,"error");return}}const k=s.map(T=>({...T,tasks:[...T.tasks]})),w=k.find(T=>T.name===a),A=k.find(T=>T.name===i),[$]=w.tasks.splice(h,1);/done|termin|closed|complet/i.test(i)?$.checked=!0:$.checked=!1,r!==void 0?A.tasks.splice(r,0,$):A.tasks.push($),t({columns:k});try{const{tasksDirHandle:T}=e();if(!T&&!d)return;const M=a===i?k.filter(D=>D.name===i):k.filter(D=>D.name===a||D.name===i),{failedIds:j}=await jf(()=>VL(T??null,M,o.board.columns),{maxAttempts:3});if(j.length>0){const D=j.length===1?`Could not save move for ${j[0]}`:`${j.length} tasks could not be moved`;e().toast(D,"warning",8e3),await e().reloadBoard()}}catch(T){const M=T;M instanceof To?e().toast("Disk is full — move was not saved. Free up space and try again.","error",8e3):e().toast("Failed to save: "+M.message,"error"),t({columns:s,taskContents:c,searchMatches:p})}},reorderInColumn:async(n,a,i)=>{const{columns:r,tasksDirHandle:s,config:o,taskContents:c,searchMatches:p}=e();if(!s&&!Lt())return;const d=r.map(h=>({...h,tasks:[...h.tasks]})),m=d.find(h=>h.name===n);if(!m)return;const[f]=m.tasks.splice(a,1);m.tasks.splice(i,0,f),t({columns:d});try{const{tasksDirHandle:h}=e(),v=Lt();if(!h&&!v)return;const{failedIds:k}=await jf(()=>VL(h??null,[m],o.board.columns),{maxAttempts:3});k.length>0&&(e().toast(`Could not save reorder for ${k.length} task(s)`,"warning",8e3),await e().reloadBoard())}catch(h){const v=h;v instanceof To?e().toast("Disk is full — reorder was not saved.","error",8e3):e().toast("Failed to save: "+v.message,"error"),t({columns:r,taskContents:c,searchMatches:p})}},addColumn:async n=>{const a=n.trim();if(!a)return;const{config:i}=e();i.board.columns.some(r=>r.toLowerCase()===a.toLowerCase())||(await e().updateConfig(r=>({...r,board:{...r.board,columns:[...r.board.columns,a]}})),await e().reloadBoard())},renameColumn:async(n,a)=>{const i=a.trim(),{columns:r,tasksDirHandle:s,config:o}=e();if(!s||!i||i.toLowerCase()===n.toLowerCase())return;if(r.some(d=>d.name.toLowerCase()===i.toLowerCase())){e().toast("Column already exists","error");return}const c=r,p=r.map(d=>d.name===n?{...d,name:i}:d);t({columns:p});try{const d=c.find(m=>m.name===n);if(d){const f=(await Promise.allSettled(d.tasks.map(async(h,v)=>{const{frontmatter:k,body:w}=await Ps(s,h.id);await pu(s,h.id,{...k,id:h.id,status:i,order:v},w)}))).filter(h=>h.status==="rejected").length;f>0&&e().toast(`${f} task(s) could not be renamed`,"warning",8e3)}await e().updateConfig(m=>{const f={...m.board.columnColors??{}},h=f[n.toLowerCase()];h&&(f[i.toLowerCase()]=h,delete f[n.toLowerCase()]);const v=m.board.columns.some(k=>k.toLowerCase()===n.toLowerCase())?m.board.columns:[...m.board.columns,n];return{...m,board:{...m.board,columns:v.map(k=>k.toLowerCase()===n.toLowerCase()?i:k),columnColors:f}}}),await e().reloadBoard()}catch(d){e().toast("Failed to rename column: "+d.message,"error"),t({columns:c})}},reorderColumns:async(n,a)=>{const{config:i,columns:r,tasksDirHandle:s}=e();if(n<0||a<0||n>=r.length||a>=r.length||n===a||!s&&!Lt())return;const o=Array.from(r),[c]=o.splice(n,1);o.splice(a,0,c),t({columns:o});const p=o.map(d=>d.name);try{await e().updateConfig(d=>({...d,board:{...d.board,columns:p}})),await e().reloadBoard()}catch(d){e().toast("Failed to reorder columns: "+d.message,"error"),t({columns:r})}},deleteColumn:async n=>{const{columns:a,tasksDirHandle:i}=e();if(!i&&!Lt())return;const r=a.find(o=>o.name===n);if(!r)return;const s=a;t({columns:a.filter(o=>o.name!==n)});try{const c=(await Promise.allSettled(r.tasks.map(p=>zL(i,p.id)))).filter(p=>p.status==="rejected").length;c>0&&e().toast(`${c} task(s) could not be deleted`,"warning",8e3),await e().updateConfig(p=>{const d={...p.board.columnColors??{}};return delete d[n.toLowerCase()],{...p,board:{...p.board,columns:p.board.columns.filter(m=>m.toLowerCase()!==n.toLowerCase()),columnColors:d}}}),await e().reloadBoard(),e().toast("Column deleted")}catch(o){e().toast("Failed to delete column: "+o.message,"error"),t({columns:s})}},createTask:async(n,a)=>{const{columns:i,tasksDirHandle:r,config:s,taskContents:o,searchMatches:c}=e();if(!r&&!Lt()||!i.length)return null;const p=n||s.board.columns[0]||i[0].name,d=Spe(i),m=i.find($=>$.name===p)?.tasks.length??0,f=a?Ape(a):null,h={id:d,title:f?.title||"",checked:!1,dependsOn:f?.depends_on||[],tags:f?.tags||[],assignee:f?.assignee||null,priority:f?.priority||(s.fields.priority?s.board.defaultPriority:null),ownerType:s.fields.ownerType?s.board.defaultOwnerType:"",progress:null,frontmatter:{}},v=i.map($=>$.name===p?{...$,tasks:[...$.tasks,h]}:$),k=new Map(o),w={id:d,title:f?.title||"",status:p,order:m,priority:f?.priority||(s.fields.priority?s.board.defaultPriority:""),tags:f?.tags||[],assignee:f?.assignee||"",due:f?.due||"",depends_on:f?.depends_on||[],created:new Date().toISOString().slice(0,10),ownerType:s.fields.ownerType?s.board.defaultOwnerType:"",tools:""},A="";k.set(d,{frontmatter:w,subtasks:[],body:A}),t({columns:v,taskContents:k});try{const $=r||null;return await jf(()=>pu($,d,w,A),{maxAttempts:3}),e().toast(`Created ${d.replace(/^t/,"")}`),await e().openDrawer(d),d}catch($){const T=$;return T instanceof To?e().toast("Disk is full — task was not created.","error",8e3):e().toast("Failed to create: "+T.message,"error"),t({columns:i,taskContents:o,searchMatches:c}),null}},deleteTask:async n=>{const{columns:a,tasksDirHandle:i,taskContents:r,searchMatches:s}=e();if(!i&&!Lt())return;const o=a.map(d=>({...d,tasks:d.tasks.filter(m=>m.id!==n)}));t({columns:o});const c=new Map(r);c.delete(n);const p=new Map(s);p.delete(n),t({taskContents:c,searchMatches:p});try{await zL(i||null,n),e().toast("Deleted")}catch(d){const m=d;e().toast("Failed to delete: "+m.message,"error"),t({columns:a,taskContents:r,searchMatches:s})}},archiveTask:async n=>{const{tasksDirHandle:a}=e();if(!(!a&&!Lt()))try{const{frontmatter:i,body:r}=await Ps(a||null,n);await upe(a||null,n,{...i,archived:!0},r),e().drawerTaskId===n&&e().closeDrawer(),await e().reloadBoard(),e().toast("Archived")}catch(i){const r=i;r instanceof To?e().toast("Disk is full — task was not archived.","error",8e3):e().toast("Failed to archive: "+r.message,"error")}},unarchiveTask:async n=>{const{tasksDirHandle:a}=e();if(!(!a&&!Lt()))try{const{frontmatter:i,body:r}=await Ps(a||null,n),s={...i};delete s.archived,await mpe(a||null,n,s,r),await e().reloadBoard(),e().toast("Restored")}catch(i){const r=i;r instanceof To?e().toast("Disk is full — task was not restored.","error",8e3):e().toast("Failed to restore: "+r.message,"error")}},setShowArchives:n=>t({showArchives:n}),setShowMetadata:n=>t({showMetadata:n}),openDrawer:async(n,a={})=>{const{tasksDirHandle:i,projectName:r}=e();if(!(!i&&!Lt()))try{const{frontmatter:s,body:o}=await Ps(i,n),{subtasks:c,bodyWithoutSubtasks:p}=Rs(o),d={frontmatter:s,subtasks:c,body:p,savedAt:Date.now()},m=e().drawerRecoveryData.get(n),f=m?{frontmatter:m.frontmatter,subtasks:m.subtasks,body:m.body}:{frontmatter:s,subtasks:c,body:p},h=new Map(e().drawerRecoveryData);h.delete(n),a.syncUrl!==!1&&Hy(bS(n,r),a.replace),t({drawerTaskId:n,drawerData:f,drawerBaseVersion:d,conflictState:null,showConflictModal:!1,hasUnsavedDrawerEdits:!!m,lastSaveError:null,drawerRecoveryData:h}),m&&e().toast("Restored your unsaved edits for this task","info")}catch(s){e().toast("Failed to open: "+s.message,"error")}},closeDrawer:(n={})=>{n.syncUrl!==!1&&Hy(T3(e().projectName),n.replace),t({drawerTaskId:null,drawerData:null,drawerBaseVersion:null,conflictState:null,showConflictModal:!1,hasUnsavedDrawerEdits:!1,lastSaveError:null})},markDrawerDirty:()=>t({hasUnsavedDrawerEdits:!0}),forceCloseDrawer:()=>{const{drawerTaskId:n,drawerData:a}=e();if(n&&a){const i=new Map(e().drawerRecoveryData);i.set(n,{frontmatter:a.frontmatter,subtasks:a.subtasks,body:a.body}),t({drawerRecoveryData:i})}e().closeDrawer()},updateDrawerData:n=>{const{drawerData:a}=e();a&&t({drawerData:n(a)})},saveDrawer:async()=>{const{drawerTaskId:n,drawerData:a,tasksDirHandle:i,taskContents:r}=e();if(!n||!a)return;const s=Wd(a.body,a.subtasks),o={...a.frontmatter,id:n};try{await jf(()=>pu(i||null,n,o,s),{maxAttempts:3}),e().toast("Saved");const c=new Map(e().drawerRecoveryData);c.delete(n),Hy(T3(e().projectName)),t({drawerTaskId:null,drawerData:null,hasUnsavedDrawerEdits:!1,lastSaveError:null,drawerRecoveryData:c});const p=new Map(r);p.set(n,{frontmatter:o,subtasks:a.subtasks,body:a.body}),t({taskContents:p}),await e().reloadBoard()}catch(c){const p=c,d=p instanceof To?"Disk is full — your edits are kept. Free up space and retry.":"Failed to save: "+p.message;e().toast(d,"error",8e3),t({lastSaveError:d})}},saveDrawerMetadata:async()=>{const{drawerTaskId:n,drawerData:a,tasksDirHandle:i,taskContents:r}=e();if(!(!n||!a))try{const s=Wd(a.body,a.subtasks),o={...a.frontmatter,id:n};await jf(()=>pu(i||null,n,o,s),{maxAttempts:3});const c=new Map(r);c.set(n,{frontmatter:o,subtasks:a.subtasks,body:a.body}),t({taskContents:c,hasUnsavedDrawerEdits:!1,lastSaveError:null}),await e().reloadBoard()}catch(s){const o=s,c=o instanceof To?"Disk is full — your edits are kept.":"Failed to save: "+o.message;t({hasUnsavedDrawerEdits:!0,lastSaveError:c})}},setViewMode:n=>{localStorage.setItem("kandown:view",n),t({viewMode:n})},setDensity:n=>{localStorage.setItem("kandown:density",n),t({density:n})},setFilter:(n,a)=>{if(t(i=>({filters:{...i.filters,[n]:a}})),n==="search"){const{columns:i,tasksDirHandle:r,taskContents:s}=e(),o=a,c=i.flatMap(p=>p.tasks.map(d=>d.id));if(r){const p=c.filter(d=>!s.has(d));p.length>0?e().loadTaskContents(p).then(()=>{e().computeSearchMatches(o)}):e().computeSearchMatches(o)}}},clearFilters:()=>t({filters:{search:"",priority:null,tag:null,assignee:null,ownerType:null},searchMatches:new Map}),setCommandOpen:n=>t({commandOpen:n}),setCheatsheetOpen:n=>t({cheatsheetOpen:n}),refreshAgentHook:async()=>{if(!Lt()){t({agentHook:null});return}const n=await Jce();t({agentHook:n?.agentHook??null})},sendTaskToAgent:async n=>{const a=e().agentHook;if(!a){e().toast("Agent hook not configured","error");return}e().toast(`Sending to ${a.label}…`);const i=await epe(n);if(i===null){e().toast("Could not reach the daemon","error");return}i.ok?e().toast(`Sent to ${a.label}`):e().toast(i.error||"Agent hook failed","error")},setCurrentPage:n=>t({currentPage:n}),loadTaskContents:async n=>{const{tasksDirHandle:a}=e();if(!a)return;const i=new Map(e().taskContents);await Promise.all(n.map(async r=>{if(!i.has(r))try{const{frontmatter:s,body:o}=await Ps(a,r),{subtasks:c,bodyWithoutSubtasks:p}=Rs(o);i.set(r,{frontmatter:s,subtasks:c,body:p})}catch{}})),t({taskContents:i})},computeSearchMatches:n=>{if(!n.trim()){t({searchMatches:new Map});return}const{taskContents:a}=e(),i=new Map,r=n.toLowerCase();for(const[s,o]of a){const c=lH(o,r);c.length>0&&i.set(s,c)}t({searchMatches:i})},toast:(n,a="success",i)=>{const r=++Lpe,s=i??(a==="error"||a==="warning"?6e3:2500);t(o=>({toasts:[...o.toasts,{id:r,message:n,type:a}]})),setTimeout(()=>{t(o=>({toasts:o.toasts.filter(c=>c.id!==r)}))},s)},dismissToast:n=>t(a=>({toasts:a.toasts.filter(i=>i.id!==n)})),resolveConflict:async n=>{const{conflictState:a,drawerData:i,tasksDirHandle:r,drawerTaskId:s,drawerBaseVersion:o}=e();if(!(!a||!r||!s))if(n==="reload"){const{frontmatter:c,body:p}=await Ps(r,s),{subtasks:d,bodyWithoutSubtasks:m}=Rs(p);t({drawerData:{frontmatter:c,subtasks:d,body:m},drawerBaseVersion:{frontmatter:c,subtasks:d,body:m,savedAt:Date.now()},conflictState:null,showConflictModal:!1}),e().toast("Reloaded from disk")}else if(n==="overwrite"){if(i&&s&&o){const c=Wd(i.body,i.subtasks),p={...i.frontmatter,id:s};try{await pu(r,s,p,c),t({drawerBaseVersion:{...i,savedAt:Date.now()},conflictState:null,showConflictModal:!1}),e().toast("Overwritten remote changes")}catch(d){e().toast("Failed to overwrite: "+d.message,"error")}}}else t({conflictState:null,showConflictModal:!1})},setupWatcher:()=>{if(Lt()){V2&&clearInterval(V2),V2=setInterval(()=>{e().reloadBoard()},2e3);return}const{dirHandle:n,tasksDirHandle:a}=e();if(!n||!a)return;Lo.stop(),Df.forEach(s=>clearTimeout(s)),Df.clear(),Lo.start(n,a);const i=(s,o)=>{const c=Df.get(s);c&&clearTimeout(c);const p=Math.max(2e3,e().config.notifications.editDebounceMs),d=setTimeout(()=>{Df.delete(s);const m=e().config;m.notifications.taskEdits&&B2({title:"Task edited",body:`${o} changed on disk.`,config:m})},p);Df.set(s,d)},r=async s=>{const{tasksDirHandle:o,config:c}=e();if(!o)return;let p,d;try{({frontmatter:p,body:d}=await Ps(o,s))}catch(A){console.warn(`[Watcher] notifyTaskChange: failed to read ${s}:`,A);return}const{subtasks:m,bodyWithoutSubtasks:f}=Rs(d),h={id:s,frontmatter:{...p,id:p.id||s,status:p.status||"Backlog"},body:f,subtasks:m},v=P3(h),k=yu.get(s);if(!k){yu.set(s,v);return}c.notifications.statusChanges&&k.status!==v.status&&B2({title:"Task status changed",body:`${v.title}: ${k.status} → ${v.status}`,config:c});const w=Ppe(k.subtasks,v.subtasks);c.notifications.subtaskCompletions&&w>0&&B2({title:"Subtask completed",body:w===1?`${v.title}: 1 subtask completed.`:`${v.title}: ${w} subtasks completed.`,config:c}),Mpe(k,v)&&i(s,v.title),yu.set(s,v)};Lo.on("configChanged",()=>{try{e().loadConfig(),e().toast("Settings updated externally","info")}catch(s){console.error("[Watcher] configChanged handler error:",s)}}),Lo.on("taskChanged",async s=>{try{const{drawerTaskId:o,drawerBaseVersion:c,tasksDirHandle:p}=e();if(await r(s),o===s&&c&&p){let d,m;try{({frontmatter:d,body:m}=await Ps(p,s))}catch(T){console.warn(`[Watcher] taskChanged: failed to re-read ${s}:`,T);return}const{subtasks:f,bodyWithoutSubtasks:h}=Rs(m),v=c,k=JSON.stringify(v.frontmatter)!==JSON.stringify(d),w=v.body!==h,A=JSON.stringify(v.subtasks)!==JSON.stringify(f);if(!k&&!w&&!A)return;let $="none";k&&(w||A)?$="full":k?$="metadata-only":(w||A)&&($="body-only"),t({conflictState:{taskId:s,type:$,local:v,remote:{frontmatter:d,body:h,subtasks:f}},showConflictModal:$==="full"})}else await e().reloadBoard()}catch(o){console.error(`[Watcher] taskChanged handler error for ${s}:`,o)}}),Lo.on("newTaskDetected",async s=>{try{const{tasksDirHandle:o}=e();if(o){let c,p;try{({frontmatter:c,body:p}=await Ps(o,s))}catch(f){console.warn(`[Watcher] newTaskDetected: failed to read ${s}:`,f),e().toast(`New task ${s} detected but could not be loaded`,"warning");return}const{subtasks:d,bodyWithoutSubtasks:m}=Rs(p);yu.set(s,P3({id:s,frontmatter:{...c,id:c.id||s,status:c.status||"Backlog"},body:m,subtasks:d}))}await e().reloadBoard()}catch(o){console.error(`[Watcher] newTaskDetected handler error for ${s}:`,o)}}),Lo.on("watcherError",s=>{t({watcherError:s}),e().toast(s,"warning",1e4)})},restartWatcher:()=>{const{dirHandle:n,tasksDirHandle:a}=e();!n||!a||(t({watcherError:null}),e().setupWatcher(),e().toast("File watcher restarted"))}}));Fy().then(t=>{se.setState({recentProjects:t})}).catch(t=>{console.warn("[Store] Failed to hydrate recent projects:",t)});pl(Ei);window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{pl(se.getState().config)});const jpe=Object.freeze(Object.defineProperty({__proto__:null,useStore:se},Symbol.toStringTag,{value:"Module"}));function Dpe({icon:t,value:e,label:n,isActive:a,onClick:i,layoutId:r}){return b.jsxs("button",{type:"button",className:T1("relative flex size-8 cursor-default items-center justify-center rounded-full transition-all [&_svg]:size-4",a?"text-zinc-950 dark:text-zinc-50":"text-zinc-400 hover:text-zinc-950 dark:text-zinc-500 dark:hover:text-zinc-50"),role:"radio","aria-checked":a,"aria-label":`Switch to ${n} theme`,onClick:()=>i(e),children:[t,a&&b.jsx(nt.div,{layoutId:r,transition:{type:"spring",bounce:.3,duration:.6},className:"absolute inset-0 rounded-full border border-zinc-200 dark:border-zinc-700"})]})}const Ipe=[{icon:b.jsx(yce,{}),value:"auto",label:"system"},{icon:b.jsx(Sce,{}),value:"light",label:"light"},{icon:b.jsx(kce,{}),value:"dark",label:"dark"}];function Rpe({value:t,onChange:e,className:n}){const a=se(d=>d.config.ui.theme),i=se(d=>d.updateConfig),r=`theme-option-${S.useId()}`,[s,o]=S.useState(!1);S.useEffect(()=>{o(!0)},[]);const c=t??a,p=e??(d=>{i(m=>({...m,ui:{...m.ui,theme:d}}))});return s?b.jsx(nt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},className:T1("inline-flex items-center overflow-hidden rounded-full bg-white ring-1 ring-zinc-200 ring-inset dark:bg-zinc-950 dark:ring-zinc-700",n),role:"radiogroup","aria-label":"Theme mode",children:Ipe.map(d=>b.jsx(Dpe,{icon:d.icon,value:d.value,label:d.label,isActive:c===d.value,onClick:p,layoutId:r},d.value))},String(s)):b.jsx("div",{className:T1("flex h-8 w-24",n)})}function Ope(t){const e=soe(t,{stiffness:180,damping:22,mass:.8});return S.useEffect(()=>{e.set(t)},[t,e]),Uz(e,a=>Math.round(a).toString())}const M3="0.33.3";function wH({className:t="w-6 h-6"}){return b.jsxs("svg",{viewBox:"0 0 150 150",className:t,version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:2},children:[b.jsx("path",{d:"M148,21.594L148,128.406C148,139.22 139.22,148 128.406,148L21.594,148C10.78,148 2,139.22 2,128.406L2,21.594C2,10.78 10.78,2 21.594,2C139.22,2 148,10.78 148,21.594Z",style:{fill:"url(#_KandownLinear1)"}}),b.jsxs("g",{transform:"matrix(0.823551,0,0,0.823551,12.830775,11.282318)",children:[b.jsx("g",{transform:"matrix(1.620982,0,0,1.566239,-41.718998,-41.628205)",children:b.jsx("path",{d:"M56.491,62.601C57.2,61.897 57.602,60.925 57.606,59.908C57.627,53.936 57.7,33.2 57.7,33.2C57.6,29.7 55,27.6 52,27.6L42.075,27.6C38.544,27.6 35.673,30.547 35.644,34.201C35.528,48.996 35.327,83.484 35.956,83.013C35.956,83.013 52.072,66.994 56.491,62.601Z",style:{fill:"rgb(252,255,239)",fillRule:"nonzero"}})}),b.jsx("g",{transform:"matrix(1.566239,0,0,1.566239,-39.774573,-41.628205)",children:b.jsx("path",{d:"M87.6,43.8C84.2,43.9 80.5,45.1 77.7,47.5L39.2,86.2C37.1,88.3 35.8,91 35.7,93.7L35.7,116.574C35.7,117.219 36.088,117.802 36.683,118.051C37.278,118.3 37.965,118.167 38.425,117.714C50.467,105.842 98.836,58.16 110.608,46.555C111.047,46.122 111.185,45.468 110.956,44.894C110.728,44.321 110.178,43.94 109.561,43.928C106.663,43.871 103.089,43.8 103.089,43.8L87.6,43.8Z",style:{fill:"rgb(241,255,184)",fillRule:"nonzero"}})}),b.jsx("g",{transform:"matrix(0.766318,0.766329,-1.302872,1.302853,170.442469,-47.541879)",children:b.jsx("path",{d:"M38.038,101.45C35.808,101.45 34,100.387 34,99.075C34,95.326 34,88.102 34,84.58C34,84.042 34.364,83.525 35.011,83.145C35.658,82.764 36.536,82.55 37.452,82.55C46.372,82.55 69.5,82.55 69.5,82.55C69.5,82.55 69.5,77.52 69.5,74.389C69.5,73.947 69.936,73.545 70.617,73.359C71.298,73.173 72.101,73.236 72.675,73.521C80.028,77.17 98.075,86.125 104.279,89.204C104.832,89.479 105.168,89.876 105.206,90.301C105.245,90.727 104.982,91.143 104.481,91.45C98.972,94.832 83.072,104.591 75.013,109.539C74.195,110.041 72.946,110.206 71.841,109.959C70.737,109.712 69.99,109.101 69.946,108.406C69.744,105.262 69.5,101.45 69.5,101.45L38.038,101.45Z",style:{fill:"rgb(136,225,56)"}})})]}),b.jsx("defs",{children:b.jsxs("linearGradient",{id:"_KandownLinear1",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(62,131,-131,62,9,8)",children:[b.jsx("stop",{offset:"0",style:{stopColor:"rgb(12,29,23)",stopOpacity:1}}),b.jsx("stop",{offset:"1",style:{stopColor:"rgb(24,41,35)",stopOpacity:1}})]})})]})}function Fpe(){const{t}=Tn(),e=se(B=>B.dirHandle),n=se(B=>B.isOpen),a=se(B=>B.projectName),i=se(B=>B.closeDrawer),r=se(B=>B.drawerTaskId),s=se(B=>B.saveDrawer),o=se(B=>B.archivedTasks.length),c=se(B=>B.showArchives),p=se(B=>B.setShowArchives),d=se(B=>B.columns),m=se(B=>B.openFolder),f=se(B=>B.reloadBoard),h=se(B=>B.createTask),v=se(B=>B.setCommandOpen),k=se(B=>B.viewMode),w=se(B=>B.setViewMode),A=se(B=>B.density),$=se(B=>B.setDensity),T=se(B=>B.setCurrentPage),M=se(B=>B.recentProjects),j=se(B=>B.openRecentProject),D=se(B=>B.filters),I=se(B=>B.setFilter),H=se(B=>B.clearFilters),R=se(B=>B.config.fields),L=se(B=>B.lastReloadError),G=se(B=>B.watcherError),Y=se(B=>B.restartWatcher),[ne,U]=S.useState(!1),[F,V]=S.useState(!0),Q=S.useRef(null),J=S.useRef(null),oe=d.reduce((B,ae)=>B+ae.tasks.length,0),O=Ope(oe),Z=[];R.priority&&D.priority&&Z.push({type:"priority",label:D.priority,value:D.priority}),R.tags&&D.tag&&Z.push({type:"tag",label:"#"+D.tag,value:D.tag}),R.assignee&&D.assignee&&Z.push({type:"assignee",label:"@"+D.assignee,value:D.assignee});const K=[{label:t("filterBar.ownerAll"),value:""},{label:t("filterBar.ownerHuman"),value:"human"},{label:t("filterBar.ownerAI"),value:"ai"}],E=Z.length>0||D.search||R.ownerType&&D.ownerType;return S.useEffect(()=>{if(!ne)return;const B=ae=>{Q.current&&!Q.current.contains(ae.target)&&U(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[ne]),S.useEffect(()=>{const B=setTimeout(()=>V(!1),5e3);return()=>clearTimeout(B)},[]),S.useEffect(()=>{document.title=a?`${a} · Kandown`:"Kandown"},[a]),b.jsxs(b.Fragment,{children:[(L||G)&&b.jsxs("div",{className:"flex items-center gap-2 px-5 py-1.5 bg-amber-500/10 border-b border-amber-500/30 text-[12px] text-amber-700 dark:text-amber-300",children:[b.jsx("span",{className:"flex-1 truncate",children:G?`⚠ ${G}`:`⚠ ${L}`}),G&&b.jsx("button",{type:"button",onClick:Y,className:"px-2 py-0.5 rounded bg-amber-500/20 hover:bg-amber-500/30 text-[11.5px] font-medium",children:"Restart watcher"}),b.jsx("button",{type:"button",onClick:f,className:"px-2 py-0.5 rounded bg-amber-500/20 hover:bg-amber-500/30 text-[11.5px] font-medium",children:"Reload"})]}),b.jsxs("header",{className:"flex items-center justify-between px-5 h-[64px] border-b border-border bg-card/80 backdrop-blur-xl relative z-10",children:[b.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[b.jsxs("div",{className:"flex items-center gap-2.5 flex-shrink-0",children:[b.jsxs("button",{onClick:()=>{r?s():i({replace:!0})},className:"flex items-center gap-2 cursor-pointer",children:[b.jsx(wH,{className:"w-[34px] h-[34px] dark:text-white text-black"}),b.jsx(Wa,{mode:"wait",initial:!1,children:F?b.jsxs(nt.span,{className:"flex items-center gap-2",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.45},children:[b.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-fg",children:"kandown"}),b.jsxs("span",{className:"inline-flex items-center h-5 px-1.5 text-[10.5px] font-semibold text-red-600 bg-red-50 dark:text-red-400 dark:bg-red-500/15 rounded-md",children:["v",M3]})]},"boot"):a?b.jsx(nt.span,{className:"text-[15px] font-semibold tracking-tight text-fg truncate max-w-[240px]",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.45},children:a},"project"):null})]}),r&&b.jsxs("button",{type:"button",onClick:()=>{s()},className:"hidden md:inline-flex items-center gap-2 rounded-xl border border-border bg-bg px-3 py-2 text-[13px] font-semibold text-fg shadow-sm transition-colors hover:border-border-strong hover:bg-bg-2",title:t("taskWorkspace.backToCards"),children:[b.jsx(Wn.ArrowLeft,{size:15}),b.jsx("span",{children:t("common.back")})]})]}),e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"w-px h-[20px] bg-black/[0.08] dark:bg-white/[0.08] flex-shrink-0"}),b.jsxs("div",{className:"flex items-center gap-2 px-3 h-9 bg-secondary/60 border border-border rounded-xl min-w-[200px] max-w-[280px] focus-within:border-border-focus focus-within:bg-secondary transition-all",children:[b.jsx(Wn.Search,{size:14,className:"text-fg-muted/60 flex-shrink-0"}),b.jsx("input",{ref:J,type:"text",placeholder:t("filterBar.searchPlaceholder"),value:D.search,onChange:B=>I("search",B.target.value),className:"bg-transparent border-none outline-none text-fg text-[13px] w-full placeholder:text-fg-muted/60"}),D.search?b.jsx("button",{onClick:()=>I("search",""),className:"text-fg-muted/60 hover:text-fg flex-shrink-0",children:b.jsx(Wn.X,{size:14})}):b.jsx("kbd",{className:"inline-flex items-center h-5 px-1.5 text-[10px] font-medium text-fg-muted/50 bg-black/[0.04] dark:bg-white/[0.08] rounded border border-black/[0.06] dark:border-white/[0.1]",children:"⌘K"})]}),b.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap overflow-hidden",children:[b.jsx(Wa,{children:Z.map(B=>b.jsxs(nt.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},onClick:()=>I(B.type,null),className:"inline-flex items-center gap-1 h-6 px-2.5 text-[12px] text-fg bg-black/[0.05] dark:bg-white/[0.1] border border-black/[0.08] dark:border-white/[0.12] rounded-lg hover:bg-black/[0.08] dark:hover:bg-white/[0.15] transition-colors",children:[B.label,b.jsx(Wn.X,{size:10,className:"text-fg-muted/60"})]},B.type+B.value))}),R.ownerType&&b.jsx("div",{className:"flex items-center h-6 border border-black/[0.06] dark:border-white/[0.1] rounded-lg overflow-hidden",children:K.map(B=>b.jsx("button",{onClick:()=>I("ownerType",B.value),className:`h-full px-2.5 text-[12px] transition-colors ${D.ownerType===B.value?"bg-black/[0.06] dark:bg-white/[0.12] text-fg":"text-fg-muted/70 hover:text-fg"}`,children:B.label},B.value))}),E&&b.jsx("button",{onClick:H,className:"text-[12px] text-fg-muted/60 hover:text-fg transition-colors",children:t("filterBar.clearAll")})]})]}),e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"w-px h-[20px] bg-black/[0.08] dark:bg-white/[0.08] flex-shrink-0"}),b.jsxs("div",{className:"relative flex-shrink-0",ref:Q,children:[b.jsxs("button",{onClick:()=>U(B=>!B),className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] text-fg-muted hover:text-fg hover:bg-black/[0.04] dark:hover:bg-white/[0.06] rounded-lg transition-colors border border-transparent hover:border-black/[0.06] dark:hover:border-white/[0.1]",children:[b.jsx(Wn.Folder,{size:13,className:"text-fg-muted/70"}),b.jsxs("span",{className:"font-medium",children:[".",e.name]}),b.jsx(Wn.ChevronDown,{size:11,className:"opacity-50"})]}),b.jsx(Wa,{children:ne&&b.jsx(nt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.12},className:"absolute top-full left-0 mt-2 min-w-[240px] glass rounded-xl shadow-[0_16px_48px_rgba(0,0,0,0.5)] overflow-hidden z-50",children:b.jsxs("div",{className:"py-1.5",children:[M.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-fg-muted/60",children:t("header.recentProjects")}),M.map(B=>b.jsxs("button",{onClick:()=>{U(!1),j(B)},className:"w-full flex items-center gap-2 px-3 py-2 text-[13.5px] text-left hover:bg-black/[0.04] dark:hover:bg-white/[0.06] transition-colors",children:[b.jsx(Wn.Folder,{size:12,className:"text-fg-muted/60"}),b.jsx("span",{className:"truncate",children:B.name}),B.id===e.name&&b.jsx(Wn.Check,{size:12,className:"ml-auto text-emerald-500"})]},B.id)),b.jsx("div",{className:"h-px bg-black/[0.06] dark:bg-white/[0.08] my-1.5 mx-2"})]}),b.jsxs("button",{onClick:()=>{U(!1),m()},className:"w-full flex items-center gap-2 px-3 py-2 text-[13.5px] text-left hover:bg-black/[0.04] dark:hover:bg-white/[0.06] transition-colors",children:[b.jsx(Wn.Plus,{size:12,className:"text-fg-muted/60"}),b.jsx("span",{children:t("header.openFolder...")})]})]})})})]})]})]}),b.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n||e?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center gap-2 mr-2 text-[12.5px] text-fg-muted/70",children:[b.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-emerald-500"}),b.jsx(nt.span,{className:"tabular-nums font-medium",children:O}),b.jsx("span",{children:t("header.tasks")})]}),b.jsxs("div",{className:"flex items-center bg-black/[0.04] dark:bg-white/[0.06] border border-black/[0.06] dark:border-white/[0.1] rounded-xl p-0.5 h-10",children:[b.jsx("button",{onClick:()=>w("board"),className:`w-9 h-9 inline-flex items-center justify-center rounded-lg transition-all ${k==="board"?"bg-card text-fg shadow-sm":"text-fg-muted/70 hover:text-fg"}`,title:t("common.board"),children:b.jsx(Wn.LayoutBoard,{size:18})}),b.jsx("button",{onClick:()=>w("list"),className:`w-9 h-9 inline-flex items-center justify-center rounded-lg transition-all ${k==="list"?"bg-card text-fg shadow-sm":"text-fg-muted/70 hover:text-fg"}`,title:t("common.list"),children:b.jsx(Wn.LayoutList,{size:18})})]}),b.jsx(an,{variant:"icon",icon:"Archive",onClick:()=>p(!c),title:c?t("header.backToBoard"):`${t("header.archives")} (${o})`,className:c?"text-accent":""}),b.jsx(an,{variant:"icon",icon:"Density",onClick:()=>$(A==="compact"?"comfortable":"compact"),title:`Density: ${A}`}),b.jsx(an,{variant:"icon",icon:"Settings",onClick:()=>T("settings"),title:t("common.settings")}),b.jsx(Rpe,{}),b.jsx("div",{className:"w-px h-5 bg-black/[0.08] dark:bg-white/[0.08] mx-1"}),b.jsx(an,{variant:"secondary",icon:"Search",label:t("common.search"),shortcut:"⌘K",onClick:()=>v(!0),title:"Command palette (⌘K)"}),b.jsx(an,{variant:"icon",icon:"Refresh",onClick:f,title:`${t("common.reload")} (R)`}),b.jsx(an,{variant:"primary",icon:"Plus",label:t("common.newTask"),shortcut:"N",onClick:()=>h()})]}):b.jsx(an,{variant:"primary",label:t("common.openFolder"),onClick:m})})]})]})}/**
|
|
204
|
+
`}}async function bH(t,e){try{return await(await(await(await t.getDirectoryHandle("archive",{create:!1})).getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}}async function ope(t,e){try{return await(await t.getDirectoryHandle("archive",{create:!1})).getFileHandle(`${e}.md`),!0}catch{return!1}}async function vH(t,e){try{return await t.getDirectoryHandle("archive",{create:e})}catch{return null}}async function cpe(t){if(Lt())return fS();const e=new Set;for await(const n of t.values())n.kind==="file"&&n.name.endsWith(".md")&&e.add(n.name.slice(0,-3));try{const n=await t.getDirectoryHandle("archive",{create:!1});for await(const a of n.values())a.kind==="file"&&a.name.endsWith(".md")&&e.add(a.name.slice(0,-3))}catch{}return[...e].sort((n,a)=>n.localeCompare(a,void 0,{numeric:!0}))}async function Ps(t,e){if(Lt())try{const i=await gS(e);return Fg(i)}catch{return FL(e)}const a=await(async i=>{try{return await(await(await i.getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}})(t)??await bH(t,e);return a!==null?Fg(a):FL(e)}async function ppe(t,e){if(Lt())try{const a=await gS(e);return{ok:!0,task:Fg(a)}}catch(a){return a.name==="NotFoundError"?{ok:!1,reason:"not-found"}:{ok:!1,reason:"unknown",error:a}}let n=null;try{n=await(await(await t.getFileHandle(`${e}.md`)).getFile()).text()}catch{}if(n===null)try{n=await bH(t,e)}catch(a){return{ok:!1,reason:"unknown",error:a}}if(n===null)return{ok:!1,reason:"not-found"};if(n.trim()==="")return{ok:!1,reason:"corrupted",error:new Error(`Task file ${e}.md is empty`)};try{return{ok:!0,task:Fg(n)}}catch(a){return{ok:!1,reason:"corrupted",error:a}}}async function pu(t,e,n,a){const i=dS(n,a);if(Lt())return Xce(e,i);try{const o=await(await(await ope(t,e)?await vH(t,!0):t).getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await o.write(i)}finally{await o.close()}}catch(r){throw Lh(r,`${e}.md`)}}async function zL(t,e){if(Lt())return Qce(e);try{await t.removeEntry(`${e}.md`)}catch{}try{await(await t.getDirectoryHandle("archive",{create:!1})).removeEntry(`${e}.md`)}catch{}}async function lpe(t,e){await gi(`/api/tasks/${encodeURIComponent(t)}/archive`,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})}async function dpe(t,e){await gi(`/api/tasks/${encodeURIComponent(t)}/unarchive`,{method:"POST",body:e,headers:{"Content-Type":"text/plain"}})}async function upe(t,e,n,a){const i=dS(n,a);if(Lt())return lpe(e,i);try{const o=await(await(await vH(t,!0)).getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await o.write(i)}finally{await o.close()}try{await t.removeEntry(`${e}.md`)}catch{}}catch(r){throw Lh(r,`archive/${e}.md`)}}async function mpe(t,e,n,a){const i=dS(n,a);if(Lt())return dpe(e,i);try{const s=await(await t.getFileHandle(`${e}.md`,{create:!0})).createWritable();try{await s.write(i)}finally{await s.close()}try{await(await t.getDirectoryHandle("archive",{create:!1})).removeEntry(`${e}.md`)}catch{}}catch(r){throw Lh(r,`${e}.md`)}}const fpe="kanban-md",gpe=1,sp="recentProjects";function hS(){return new Promise((t,e)=>{const n=indexedDB.open(fpe,gpe);n.onerror=()=>e(n.error),n.onsuccess=()=>t(n.result),n.onupgradeneeded=()=>{const a=n.result;a.objectStoreNames.contains(sp)||a.createObjectStore(sp,{keyPath:"id"})}})}async function H2(t){const e=await hS();return new Promise((n,a)=>{const i=e.transaction(sp,"readwrite");i.objectStore(sp).put(t),i.oncomplete=()=>n(),i.onerror=()=>a(i.error)})}async function Fy(){const t=await hS();return new Promise((e,n)=>{const i=t.transaction(sp,"readonly").objectStore(sp).getAll();i.onsuccess=()=>{const r=i.result||[];r.sort((s,o)=>o.lastOpened-s.lastOpened),e(r.slice(0,10))},i.onerror=()=>n(i.error)})}async function hpe(t){const e=await hS();return new Promise((n,a)=>{const i=e.transaction(sp,"readwrite");i.objectStore(sp).delete(t),i.oncomplete=()=>n(),i.onerror=()=>a(i.error)})}async function HL(t,e=!0){const n={mode:e?"readwrite":"read"};try{return await t.queryPermission(n)==="granted"||await t.requestPermission(n)==="granted"}catch(a){return console.warn("[FS] verifyPermission: handle is no longer valid:",a),!1}}async function bpe(){try{return await(await gi("/api/update/check")).json()}catch{return null}}async function yH(){try{return await(await gi("/api/update/apply",{method:"POST"})).json()}catch{return null}}function _H(t=Ei){const e=t.board.columns;return e[e.length-1]??"Done"}function vpe(t,e=Ei){return t===_H(e)||t.toLowerCase()==="archived"}class ype{dirHandle=null;tasksDirHandle=null;intervalId=null;configHash=null;taskHashes=new Map;knownTaskIds=new Set;listeners=new Map;debounceTimers=new Map;debounceDelay=150;consecutiveErrors=0;maxConsecutiveErrors=5;disabled=!1;eventSource=null;start(e,n){this.dirHandle=e,this.tasksDirHandle=n,this.consecutiveErrors=0,this.disabled=!1,Lt()&&this.startServerSse(),e&&n&&(this.initHashes(),this.intervalId=setInterval(()=>void this.tick(),300))}startServerSse(){if(typeof window>"u"||!Lt()||this.eventSource)return;const e=window.__KANDOWN_TOKEN__,n=e?`/api/events?token=${encodeURIComponent(e)}`:"/api/events";try{this.eventSource=new EventSource(n),this.eventSource.onmessage=a=>{try{const i=JSON.parse(a.data);i.type==="change"&&(i.taskId?this.emit("taskChanged",i.taskId):(this.emit("configChanged"),this.emit("taskChanged","")))}catch{}}}catch(a){console.warn("[Watcher] EventSource init failed:",a)}}stop(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.configHash=null,this.taskHashes.clear(),this.knownTaskIds.clear(),this.listeners.clear(),this.debounceTimers.forEach(e=>clearTimeout(e)),this.debounceTimers.clear(),this.consecutiveErrors=0,this.disabled=!1}isDisabled(){return this.disabled}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{this.listeners.get(e)?.delete(n)}}getKnownTaskIds(){return Array.from(this.knownTaskIds)}async initHashes(){if(!(!this.dirHandle||!this.tasksDirHandle))try{const e=await BL(this.dirHandle);e!==null&&(this.configHash=await this.hash(e)),await this.syncTaskDir(!1)}catch(e){console.warn("[Watcher] initHashes error:",e)}}async tick(){if(!(!this.dirHandle||!this.tasksDirHandle)&&!this.disabled)try{const e=await BL(this.dirHandle);if(e!==null){const n=await this.hash(e);this.configHash!==null&&n!==this.configHash&&(this.configHash=n,this.debouncedEmit("configChanged"))}for(const n of[...this.knownTaskIds])try{const a=await UL(this.tasksDirHandle,n);if(a!==null){const i=await this.hash(a),r=this.taskHashes.get(n);r!==void 0&&i!==r&&(this.taskHashes.set(n,i),this.debouncedEmit("taskChanged",n))}}catch(a){console.warn(`[Watcher] Error reading task ${n}:`,a)}await this.syncTaskDir(!0),this.consecutiveErrors=0}catch(e){this.consecutiveErrors++,console.error(`[Watcher] Tick failed (${this.consecutiveErrors}/${this.maxConsecutiveErrors}):`,e),this.consecutiveErrors>=this.maxConsecutiveErrors&&this.disable(`File watcher stopped after ${this.maxConsecutiveErrors} consecutive errors: ${e.message}`)}}disable(e){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.disabled=!0,this.emit("watcherError",e)}debouncedEmit(e,...n){const a=e+JSON.stringify(n),i=this.debounceTimers.get(a);i&&clearTimeout(i);const r=setTimeout(()=>{this.debounceTimers.delete(a),this.emit(e,...n)},this.debounceDelay);this.debounceTimers.set(a,r)}async syncTaskDir(e){if(!this.tasksDirHandle)return;let n;try{n=this.tasksDirHandle.values()}catch(a){throw a}for await(const a of n){if(a.kind!=="file"||!a.name.endsWith(".md"))continue;const i=a.name.replace(".md","");if(!this.knownTaskIds.has(i))try{this.knownTaskIds.add(i);const r=await UL(this.tasksDirHandle,i);r!==null&&(this.taskHashes.set(i,await this.hash(r)),e&&this.debouncedEmit("newTaskDetected",i))}catch(r){console.warn(`[Watcher] syncTaskDir: failed to read ${i}:`,r)}}}async hash(e){const a=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",a);return Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("")}emit(e,...n){this.listeners.get(e)?.forEach(i=>{if(e==="configChanged"){i();return}if(e==="taskChanged"){const[s]=n;i(s);return}if(e==="newTaskDetected"){const[s]=n;i(s);return}const[r]=n;i(r)})}}async function BL(t){try{return await(await(await t.getFileHandle("kandown.json")).getFile()).text()}catch{return null}}async function UL(t,e){try{return await(await(await t.getFileHandle(`${e}.md`)).getFile()).text()}catch{return null}}const Lo=new ype,_pe={soft:[{frequency:520,durationMs:90,delayMs:0,type:"sine"},{frequency:720,durationMs:120,delayMs:95,type:"sine"}],chime:[{frequency:660,durationMs:120,delayMs:0,type:"triangle"},{frequency:880,durationMs:160,delayMs:125,type:"triangle"}],ping:[{frequency:920,durationMs:110,delayMs:0,type:"sine"}],pop:[{frequency:260,durationMs:55,delayMs:0,type:"square"},{frequency:520,durationMs:80,delayMs:60,type:"square"}]};let qL=null;function kH(){return"Notification"in window?Notification.permission:"unsupported"}async function kpe(){return"Notification"in window?await Notification.requestPermission():"unsupported"}function B2({title:t,body:e,config:n}){if(n.notifications.webhookUrl&&fetch(n.notifications.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"kandown_notification",title:t,body:e,timestamp:new Date().toISOString()})}).catch(()=>{}),n.notifications.sound&&wpe(n.notifications.soundId),!(!n.notifications.browser||kH()!=="granted"))try{new Notification(t,{body:e})}catch{}}function wpe(t){const e=_pe[t],n=window.AudioContext??window.webkitAudioContext;if(!(!n||e.length===0))try{qL??=new n;const a=qL;a.state==="suspended"&&a.resume();const i=a.currentTime+.01;e.forEach(r=>{const s=a.createOscillator(),o=a.createGain(),c=i+r.delayMs/1e3,p=c+r.durationMs/1e3;s.type=r.type??"sine",s.frequency.setValueAtTime(r.frequency,c),o.gain.setValueAtTime(1e-4,c),o.gain.exponentialRampToValueAtTime(.08,c+.01),o.gain.exponentialRampToValueAtTime(1e-4,p),s.connect(o),o.connect(a.destination),s.start(c),s.stop(p+.02)})}catch{}}async function jf(t,e={}){const{maxAttempts:n=3,baseDelayMs:a=500,retryableCheck:i=Zce}=e;let r;for(let s=1;s<=n;s++)try{return await t()}catch(o){if(r=o,!i(o))throw o;if(s<n){const c=a*Math.pow(2,s-1);await new Promise(p=>setTimeout(p,c))}}throw r}function xpe(t){const e=t.toLowerCase(),n=new Date;if(e==="today")return n.toISOString().split("T")[0];if(e==="tomorrow"){const i=new Date(n);return i.setDate(i.getDate()+1),i.toISOString().split("T")[0]}const a=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];if(a.includes(e)){const i=a.indexOf(e),r=new Date(n);let s=i-r.getDay();return s<=0&&(s+=7),r.setDate(r.getDate()+s),r.toISOString().split("T")[0]}return t}function Ape(t){let e=t.trim(),n;const a=[];let i,r;const s=[];return e=e.replace(/(?:^|\s)p([1-4])(?:\s|$)/i,(c,p)=>(n=`P${p}`," ")),e=e.replace(/(?:^|\s)#([a-zA-Z0-9_-]+)/g,(c,p)=>(a.push(p.toLowerCase())," ")),e=e.replace(/(?:^|\s)@([a-zA-Z0-9_-]+)/g,(c,p)=>(i=p," ")),e=e.replace(/(?:^|\s)due:([^\s]+)/i,(c,p)=>(r=xpe(p)," ")),e=e.replace(/(?:^|\s)\+([a-zA-Z0-9_-]+)/g,(c,p)=>(s.push(p)," ")),{title:e.replace(/\s+/g," ").trim()||t,...n?{priority:n}:{},...a.length>0?{tags:a}:{},...i?{assignee:i}:{},...r?{due:r}:{},...s.length>0?{depends_on:s}:{}}}const Cpe=/^[A-Za-z0-9_-]+$/;function U2(t){if(!t)return null;const e=t.trim().replace(/^\/+|\/+$/g,"").replace(/^#/,"");return!e||e.includes("/")||e.includes(".")||!Cpe.test(e)?null:/^\d+$/.test(e)?`t${e}`:e}function Npe(t){const e=new URLSearchParams(t.search).get("p");if(!e)return null;const[n]=e.split("/").filter(Boolean);return n||null}function zy(t){const e=new URLSearchParams(t.search),n=U2(e.get("task"));if(n)return n;const a=e.get("p");if(a){const[,...r]=a.split("/").filter(Boolean),s=U2(r.join("/"));if(s)return s}return U2(decodeURIComponent(t.pathname))}function T3(t){return t?`/?p=${encodeURIComponent(t)}`:"/"}function bS(t,e){const n=t.replace(/^t(?=\d+$)/,""),a=`/${encodeURIComponent(n)}`;return e?`${a}?p=${encodeURIComponent(e)}`:a}function Hy(t,e=!1){typeof window>"u"||`${window.location.pathname}${window.location.search}`===t||(e?window.history.replaceState({},"",t):window.history.pushState({},"",t),window.dispatchEvent(new Event("kandown:urlchange")))}function Iv(t){typeof window<"u"&&zy(window.location)||Hy(T3(t))}function Spe(t){let e=-1;for(const n of t)for(const a of n.tasks){const i=a.id.match(/^t(\d+)$/);if(i){const r=parseInt(i[1],10);r>e&&(e=r)}}return"t"+(e+1)}async function $pe(){const t=await fS();return await Promise.all(t.map(async n=>{const{frontmatter:a,body:i}=await hH(n),r={...a,id:a.id||n,status:a.status||"Backlog"},{subtasks:s,bodyWithoutSubtasks:o}=Rs(i);return{id:n,frontmatter:r,body:o,subtasks:s}}))}async function Epe(t){const e=await cpe(t),n=await Promise.all(e.map(async r=>{const s=await ppe(t,r);return{id:r,result:s}})),a=[],i=[];for(const{id:r,result:s}of n)if(s.ok){const o={...s.task.frontmatter,id:s.task.frontmatter.id||r,status:s.task.frontmatter.status||"Backlog"},{subtasks:c,bodyWithoutSubtasks:p}=Rs(s.task.body);a.push({id:r,frontmatter:o,body:p,subtasks:c})}else{if(s.reason==="not-found")continue;i.push(r)}return{tasks:a,failedIds:i}}async function VL(t,e,n){const a=[];for(const s of e){const o=s.name;s.tasks.forEach((c,p)=>{const d=(async()=>{const{frontmatter:m,body:f}=await Ps(t,c.id);await pu(t,c.id,{...m,id:c.id,status:o,order:p},f)})();a.push({id:c.id,promise:d})})}const i=await Promise.allSettled(a.map(s=>s.promise)),r=[];return i.forEach((s,o)=>{s.status==="rejected"&&r.push(a[o].id)}),{failedIds:r}}function pl(t){mH(t.ui.theme,t.ui.skin,t.ui.font,t.ui.background)}function P3(t){return{title:t.frontmatter.title||t.id,status:t.frontmatter.status||"Backlog",body:t.body,subtasks:t.subtasks}}function q2(t){yu.clear(),t.forEach(e=>{yu.set(e.id,P3(e))})}function Tpe(t){const e=t.split(/[\\/]+/).filter(Boolean),n=e[e.length-1];return n===".kandown"?e[e.length-2]??"Project":n??"Project"}function Ppe(t,e){return e.reduce((n,a,i)=>{const r=t[i]?.done??!1;return n+(a.done&&!r?1:0)},0)}function Mpe(t,e){const n=t.subtasks.map(i=>({text:i.text,description:i.description??"",report:i.report??""})),a=e.subtasks.map(i=>({text:i.text,description:i.description??"",report:i.report??""}));return t.title!==e.title||t.body!==e.body||JSON.stringify(n)!==JSON.stringify(a)}let Lpe=0;const yu=new Map,Df=new Map;let V2=null;const se=Lce((t,e)=>({isOpen:!1,loading:!1,dirHandle:null,projectName:null,tasksDirHandle:null,boardTitle:"Project Kanban",columns:[],archivedTasks:[],showArchives:!1,showMetadata:!0,taskContents:new Map,searchMatches:new Map,viewMode:localStorage.getItem("kandown:view")||"board",density:localStorage.getItem("kandown:density")||"comfortable",filters:{search:"",priority:null,tag:null,assignee:null,ownerType:null},commandOpen:!1,cheatsheetOpen:!1,drawerTaskId:null,drawerData:null,currentPage:"board",config:Ei,recentProjects:[],toasts:[],agentHook:null,isReloading:!1,lastReloadError:null,failedTaskIds:[],watcherError:null,hasUnsavedDrawerEdits:!1,lastSaveError:null,drawerRecoveryData:new Map,selectedTaskIds:[],toggleTaskSelection:n=>{t(a=>({selectedTaskIds:a.selectedTaskIds.includes(n)?a.selectedTaskIds.filter(s=>s!==n):[...a.selectedTaskIds,n]}))},clearTaskSelection:()=>t({selectedTaskIds:[]}),bulkMoveTasks:async n=>{const{selectedTaskIds:a,columns:i,moveTask:r}=e();for(const s of a){let o="Backlog";for(const c of i)if(c.tasks.some(p=>p.id===s)){o=c.name;break}await r(s,o,n)}t({selectedTaskIds:[]})},bulkDeleteTasks:async()=>{const{selectedTaskIds:n,deleteTask:a}=e();for(const i of n)await a(i);t({selectedTaskIds:[]})},drawerBaseVersion:null,conflictState:null,showConflictModal:!1,openFolder:async()=>{if(!fH()){const c=navigator.userAgent||"this browser";e().toast(new Vce(c).message,"error",8e3);return}let n;try{n=await npe()}catch(c){c instanceof mS?e().toast("Permission denied — please grant access to the project folder","error"):e().toast("Failed to open folder: "+c.message,"error");return}if(!n)return;const{projectHandle:a,kandownHandle:i,tasksHandle:r}=n,s=a.name;t({dirHandle:i,tasksDirHandle:r,projectName:s}),Iv(s);const o=Lt()?z2():null;try{await H2({id:a.name,name:a.name,handle:a,lastOpened:Date.now(),...o?{kandownDir:o}:{}})}catch(c){console.warn("[Store] Failed to save recent project:",c)}await e().loadConfig(),await e().reloadBoard();try{const c=await Fy();t({recentProjects:c})}catch(c){console.warn("[Store] Failed to load recent projects:",c)}e().setupWatcher()},openRecentProject:async n=>{const a={dirHandle:e().dirHandle,tasksDirHandle:e().tasksDirHandle,projectName:e().projectName};if(!await HL(n.handle,!0)){let r=!1;try{await Oy(n.handle),r=!0}catch{r=!1}if(!r){e().toast(`"${n.name}" is no longer accessible. Removed from recent projects.`,"warning",8e3);try{await hpe(n.id);const s=await Fy();t({recentProjects:s})}catch{}return}e().toast("Permission denied — please grant access to the folder","error");return}try{const r=await Oy(n.handle),s=await E3(n.handle),o=n.handle.name;t({dirHandle:r,tasksDirHandle:s,projectName:o}),Iv(o);try{await H2({...n,lastOpened:Date.now()})}catch(c){console.warn("[Store] Failed to update recent project:",c)}await e().loadConfig(),await e().reloadBoard(),e().setupWatcher()}catch(r){t(a),e().toast(`Failed to open project: ${r.message}`,"error")}},openServerProject:async()=>{t({loading:!0});try{const n=z2();if(!n)throw new Error("No server root");await OL();const a=Tpe(n),i=await gH();pl(i);const r=await fS(),s=await Promise.all(r.map(async f=>{const{frontmatter:h,body:v}=await hH(f),k={...h,id:h.id||f,status:h.status||"Backlog"},{subtasks:w,bodyWithoutSubtasks:A}=Rs(v);return{id:f,frontmatter:k,body:A,subtasks:w}}));q2(s);const o=s.map(f=>({frontmatter:f.frontmatter,body:Wd(f.body,f.subtasks)})),c=R2(o,i.board.columns),p=O2(o),d=c.reduce((f,h)=>f+h.tasks.length,0),m=new Map;if(d<=10)for(const f of s)m.set(f.frontmatter.id,{frontmatter:f.frontmatter,subtasks:f.subtasks,body:f.body});t({loading:!1,isOpen:!0,config:i,columns:c,archivedTasks:p,boardTitle:"Project Kanban",projectName:a,taskContents:m,searchMatches:new Map}),Iv(a),e().setupWatcher(),e().refreshAgentHook()}catch{t({loading:!1,isOpen:!1}),e().toast("Impossible de charger le projet. Relancez `kandown`.","error")}},tryAutoOpenServerProject:async()=>{if(!Lt())return;const n=z2();if(!n)return;await OL();const a=await Fy(),i=a.find(p=>p.kandownDir===n);if(!i){await e().openServerProject();return}if(!await HL(i.handle,!0)){await e().openServerProject();return}const s=await Oy(i.handle),o=await E3(i.handle),c=i.handle.name;t({dirHandle:s,tasksDirHandle:o,projectName:c,recentProjects:a,isOpen:!0}),Iv(c),await H2({...i,lastOpened:Date.now()}),await e().loadConfig(),await e().reloadBoard(),e().setupWatcher()},loadConfig:async()=>{const{dirHandle:n}=e();if(!(!n&&!Lt()))try{const a=await ape(n);if(a.ok){t({config:a.config}),pl(a.config);return}if(a.reason==="corrupted"){if(a.rawContent&&n)try{const r=await(await n.getFileHandle("kandown.json.backup",{create:!0})).createWritable();try{await r.write(a.rawContent)}finally{await r.close()}}catch{}e().toast("kandown.json is corrupted — using default settings. A backup was saved as kandown.json.backup.","warning",1e4)}t({config:Ei}),pl(Ei)}catch{t({config:Ei}),pl(Ei)}},updateConfig:async n=>{const{dirHandle:a,config:i}=e();if(!a&&!Lt())return;const r=n(i);t({config:r}),pl(r);try{await ipe(a,r)}catch(s){const o=s;o instanceof To?e().toast("Disk is full — settings were not saved.","error",8e3):e().toast("Failed to save config: "+o.message,"error")}},reloadBoard:async()=>{const{tasksDirHandle:n,config:a}=e();t({isReloading:!0,lastReloadError:null});try{if(Lt()){const i=await $pe();q2(i);const r=i.map(d=>({frontmatter:d.frontmatter,body:Wd(d.body,d.subtasks)})),s=R2(r,a.board.columns),o=O2(r);t({boardTitle:"Project Kanban",columns:s,archivedTasks:o});const c=s.reduce((d,m)=>d+m.tasks.length,0),p=new Map;if(c<=10)for(const d of i)p.set(d.frontmatter.id,{frontmatter:d.frontmatter,subtasks:d.subtasks,body:d.body});t({taskContents:p,searchMatches:new Map,failedTaskIds:[],isReloading:!1})}else if(n){const{tasks:i,failedIds:r}=await Epe(n);q2(i);const s=i.map(m=>({frontmatter:m.frontmatter,body:Wd(m.body,m.subtasks)})),o=R2(s,a.board.columns),c=O2(s);t({boardTitle:"Project Kanban",columns:o,archivedTasks:c});const p=o.reduce((m,f)=>m+f.tasks.length,0),d=new Map;if(p<=10)for(const m of i)d.set(m.frontmatter.id,{frontmatter:m.frontmatter,subtasks:m.subtasks,body:m.body});if(r.length>0){const m=r.length===1?`Task ${r[0]} could not be loaded`:`${r.length} tasks could not be loaded`;e().toast(m,"warning",8e3)}t({taskContents:d,searchMatches:new Map,failedTaskIds:r,isReloading:!1})}else t({isReloading:!1})}catch(i){const r=i.message||String(i);t({isReloading:!1,lastReloadError:`Failed to reload board: ${r}`}),e().toast(`Board reload failed — showing last loaded state (${r})`,"warning",8e3)}},moveTask:async(n,a,i,r)=>{const{columns:s,config:o,taskContents:c,searchMatches:p}=e(),d=Lt();if(!d&&!e().tasksDirHandle)return;const m=s.find(T=>T.name===a),f=s.find(T=>T.name===i);if(!m||!f)return;const h=m.tasks.findIndex(T=>T.id===n);if(h===-1)return;const v=m.tasks[h];if(!v)return;if(vpe(i,o)){const T=new Map,M=_H(o).toLowerCase();for(const D of s)for(const I of D.tasks){const H=I.frontmatter&&(I.frontmatter.archived===!0||I.frontmatter.archived==="true");T.set(I.id,{exists:!0,resolved:H||I.id===n||D.name.toLowerCase()===M})}const j=[];for(const D of v.dependsOn){if(typeof D!="string"||!D.trim()||D===n)continue;const I=T.get(D);(!I||!I.resolved)&&j.push(D)}if(j.length>0){const D=j.length===1?j[0]:`${j.slice(0,-1).join(", ")} and ${j[j.length-1]}`;e().toast(`Cannot move ${n} to ${i}: blocked by ${D}`,"error");return}}const k=s.map(T=>({...T,tasks:[...T.tasks]})),w=k.find(T=>T.name===a),A=k.find(T=>T.name===i),[$]=w.tasks.splice(h,1);/done|termin|closed|complet/i.test(i)?$.checked=!0:$.checked=!1,r!==void 0?A.tasks.splice(r,0,$):A.tasks.push($),t({columns:k});try{const{tasksDirHandle:T}=e();if(!T&&!d)return;const M=a===i?k.filter(D=>D.name===i):k.filter(D=>D.name===a||D.name===i),{failedIds:j}=await jf(()=>VL(T??null,M,o.board.columns),{maxAttempts:3});if(j.length>0){const D=j.length===1?`Could not save move for ${j[0]}`:`${j.length} tasks could not be moved`;e().toast(D,"warning",8e3),await e().reloadBoard()}}catch(T){const M=T;M instanceof To?e().toast("Disk is full — move was not saved. Free up space and try again.","error",8e3):e().toast("Failed to save: "+M.message,"error"),t({columns:s,taskContents:c,searchMatches:p})}},reorderInColumn:async(n,a,i)=>{const{columns:r,tasksDirHandle:s,config:o,taskContents:c,searchMatches:p}=e();if(!s&&!Lt())return;const d=r.map(h=>({...h,tasks:[...h.tasks]})),m=d.find(h=>h.name===n);if(!m)return;const[f]=m.tasks.splice(a,1);m.tasks.splice(i,0,f),t({columns:d});try{const{tasksDirHandle:h}=e(),v=Lt();if(!h&&!v)return;const{failedIds:k}=await jf(()=>VL(h??null,[m],o.board.columns),{maxAttempts:3});k.length>0&&(e().toast(`Could not save reorder for ${k.length} task(s)`,"warning",8e3),await e().reloadBoard())}catch(h){const v=h;v instanceof To?e().toast("Disk is full — reorder was not saved.","error",8e3):e().toast("Failed to save: "+v.message,"error"),t({columns:r,taskContents:c,searchMatches:p})}},addColumn:async n=>{const a=n.trim();if(!a)return;const{config:i}=e();i.board.columns.some(r=>r.toLowerCase()===a.toLowerCase())||(await e().updateConfig(r=>({...r,board:{...r.board,columns:[...r.board.columns,a]}})),await e().reloadBoard())},renameColumn:async(n,a)=>{const i=a.trim(),{columns:r,tasksDirHandle:s,config:o}=e();if(!s||!i||i.toLowerCase()===n.toLowerCase())return;if(r.some(d=>d.name.toLowerCase()===i.toLowerCase())){e().toast("Column already exists","error");return}const c=r,p=r.map(d=>d.name===n?{...d,name:i}:d);t({columns:p});try{const d=c.find(m=>m.name===n);if(d){const f=(await Promise.allSettled(d.tasks.map(async(h,v)=>{const{frontmatter:k,body:w}=await Ps(s,h.id);await pu(s,h.id,{...k,id:h.id,status:i,order:v},w)}))).filter(h=>h.status==="rejected").length;f>0&&e().toast(`${f} task(s) could not be renamed`,"warning",8e3)}await e().updateConfig(m=>{const f={...m.board.columnColors??{}},h=f[n.toLowerCase()];h&&(f[i.toLowerCase()]=h,delete f[n.toLowerCase()]);const v=m.board.columns.some(k=>k.toLowerCase()===n.toLowerCase())?m.board.columns:[...m.board.columns,n];return{...m,board:{...m.board,columns:v.map(k=>k.toLowerCase()===n.toLowerCase()?i:k),columnColors:f}}}),await e().reloadBoard()}catch(d){e().toast("Failed to rename column: "+d.message,"error"),t({columns:c})}},reorderColumns:async(n,a)=>{const{config:i,columns:r,tasksDirHandle:s}=e();if(n<0||a<0||n>=r.length||a>=r.length||n===a||!s&&!Lt())return;const o=Array.from(r),[c]=o.splice(n,1);o.splice(a,0,c),t({columns:o});const p=o.map(d=>d.name);try{await e().updateConfig(d=>({...d,board:{...d.board,columns:p}})),await e().reloadBoard()}catch(d){e().toast("Failed to reorder columns: "+d.message,"error"),t({columns:r})}},deleteColumn:async n=>{const{columns:a,tasksDirHandle:i}=e();if(!i&&!Lt())return;const r=a.find(o=>o.name===n);if(!r)return;const s=a;t({columns:a.filter(o=>o.name!==n)});try{const c=(await Promise.allSettled(r.tasks.map(p=>zL(i,p.id)))).filter(p=>p.status==="rejected").length;c>0&&e().toast(`${c} task(s) could not be deleted`,"warning",8e3),await e().updateConfig(p=>{const d={...p.board.columnColors??{}};return delete d[n.toLowerCase()],{...p,board:{...p.board,columns:p.board.columns.filter(m=>m.toLowerCase()!==n.toLowerCase()),columnColors:d}}}),await e().reloadBoard(),e().toast("Column deleted")}catch(o){e().toast("Failed to delete column: "+o.message,"error"),t({columns:s})}},createTask:async(n,a)=>{const{columns:i,tasksDirHandle:r,config:s,taskContents:o,searchMatches:c}=e();if(!r&&!Lt()||!i.length)return null;const p=n||s.board.columns[0]||i[0].name,d=Spe(i),m=i.find($=>$.name===p)?.tasks.length??0,f=a?Ape(a):null,h={id:d,title:f?.title||"",checked:!1,dependsOn:f?.depends_on||[],tags:f?.tags||[],assignee:f?.assignee||null,priority:f?.priority||(s.fields.priority?s.board.defaultPriority:null),ownerType:s.fields.ownerType?s.board.defaultOwnerType:"",progress:null,frontmatter:{}},v=i.map($=>$.name===p?{...$,tasks:[...$.tasks,h]}:$),k=new Map(o),w={id:d,title:f?.title||"",status:p,order:m,priority:f?.priority||(s.fields.priority?s.board.defaultPriority:""),tags:f?.tags||[],assignee:f?.assignee||"",due:f?.due||"",depends_on:f?.depends_on||[],created:new Date().toISOString().slice(0,10),ownerType:s.fields.ownerType?s.board.defaultOwnerType:"",tools:""},A="";k.set(d,{frontmatter:w,subtasks:[],body:A}),t({columns:v,taskContents:k});try{const $=r||null;return await jf(()=>pu($,d,w,A),{maxAttempts:3}),e().toast(`Created ${d.replace(/^t/,"")}`),await e().openDrawer(d),d}catch($){const T=$;return T instanceof To?e().toast("Disk is full — task was not created.","error",8e3):e().toast("Failed to create: "+T.message,"error"),t({columns:i,taskContents:o,searchMatches:c}),null}},deleteTask:async n=>{const{columns:a,tasksDirHandle:i,taskContents:r,searchMatches:s}=e();if(!i&&!Lt())return;const o=a.map(d=>({...d,tasks:d.tasks.filter(m=>m.id!==n)}));t({columns:o});const c=new Map(r);c.delete(n);const p=new Map(s);p.delete(n),t({taskContents:c,searchMatches:p});try{await zL(i||null,n),e().toast("Deleted")}catch(d){const m=d;e().toast("Failed to delete: "+m.message,"error"),t({columns:a,taskContents:r,searchMatches:s})}},archiveTask:async n=>{const{tasksDirHandle:a}=e();if(!(!a&&!Lt()))try{const{frontmatter:i,body:r}=await Ps(a||null,n);await upe(a||null,n,{...i,archived:!0},r),e().drawerTaskId===n&&e().closeDrawer(),await e().reloadBoard(),e().toast("Archived")}catch(i){const r=i;r instanceof To?e().toast("Disk is full — task was not archived.","error",8e3):e().toast("Failed to archive: "+r.message,"error")}},unarchiveTask:async n=>{const{tasksDirHandle:a}=e();if(!(!a&&!Lt()))try{const{frontmatter:i,body:r}=await Ps(a||null,n),s={...i};delete s.archived,await mpe(a||null,n,s,r),await e().reloadBoard(),e().toast("Restored")}catch(i){const r=i;r instanceof To?e().toast("Disk is full — task was not restored.","error",8e3):e().toast("Failed to restore: "+r.message,"error")}},setShowArchives:n=>t({showArchives:n}),setShowMetadata:n=>t({showMetadata:n}),openDrawer:async(n,a={})=>{const{tasksDirHandle:i,projectName:r}=e();if(!(!i&&!Lt()))try{const{frontmatter:s,body:o}=await Ps(i,n),{subtasks:c,bodyWithoutSubtasks:p}=Rs(o),d={frontmatter:s,subtasks:c,body:p,savedAt:Date.now()},m=e().drawerRecoveryData.get(n),f=m?{frontmatter:m.frontmatter,subtasks:m.subtasks,body:m.body}:{frontmatter:s,subtasks:c,body:p},h=new Map(e().drawerRecoveryData);h.delete(n),a.syncUrl!==!1&&Hy(bS(n,r),a.replace),t({drawerTaskId:n,drawerData:f,drawerBaseVersion:d,conflictState:null,showConflictModal:!1,hasUnsavedDrawerEdits:!!m,lastSaveError:null,drawerRecoveryData:h}),m&&e().toast("Restored your unsaved edits for this task","info")}catch(s){e().toast("Failed to open: "+s.message,"error")}},closeDrawer:(n={})=>{n.syncUrl!==!1&&Hy(T3(e().projectName),n.replace),t({drawerTaskId:null,drawerData:null,drawerBaseVersion:null,conflictState:null,showConflictModal:!1,hasUnsavedDrawerEdits:!1,lastSaveError:null})},markDrawerDirty:()=>t({hasUnsavedDrawerEdits:!0}),forceCloseDrawer:()=>{const{drawerTaskId:n,drawerData:a}=e();if(n&&a){const i=new Map(e().drawerRecoveryData);i.set(n,{frontmatter:a.frontmatter,subtasks:a.subtasks,body:a.body}),t({drawerRecoveryData:i})}e().closeDrawer()},updateDrawerData:n=>{const{drawerData:a}=e();a&&t({drawerData:n(a)})},saveDrawer:async()=>{const{drawerTaskId:n,drawerData:a,tasksDirHandle:i,taskContents:r}=e();if(!n||!a)return;const s=Wd(a.body,a.subtasks),o={...a.frontmatter,id:n};try{await jf(()=>pu(i||null,n,o,s),{maxAttempts:3}),e().toast("Saved");const c=new Map(e().drawerRecoveryData);c.delete(n),Hy(T3(e().projectName)),t({drawerTaskId:null,drawerData:null,hasUnsavedDrawerEdits:!1,lastSaveError:null,drawerRecoveryData:c});const p=new Map(r);p.set(n,{frontmatter:o,subtasks:a.subtasks,body:a.body}),t({taskContents:p}),await e().reloadBoard()}catch(c){const p=c,d=p instanceof To?"Disk is full — your edits are kept. Free up space and retry.":"Failed to save: "+p.message;e().toast(d,"error",8e3),t({lastSaveError:d})}},saveDrawerMetadata:async()=>{const{drawerTaskId:n,drawerData:a,tasksDirHandle:i,taskContents:r}=e();if(!(!n||!a))try{const s=Wd(a.body,a.subtasks),o={...a.frontmatter,id:n};await jf(()=>pu(i||null,n,o,s),{maxAttempts:3});const c=new Map(r);c.set(n,{frontmatter:o,subtasks:a.subtasks,body:a.body}),t({taskContents:c,hasUnsavedDrawerEdits:!1,lastSaveError:null}),await e().reloadBoard()}catch(s){const o=s,c=o instanceof To?"Disk is full — your edits are kept.":"Failed to save: "+o.message;t({hasUnsavedDrawerEdits:!0,lastSaveError:c})}},setViewMode:n=>{localStorage.setItem("kandown:view",n),t({viewMode:n})},setDensity:n=>{localStorage.setItem("kandown:density",n),t({density:n})},setFilter:(n,a)=>{if(t(i=>({filters:{...i.filters,[n]:a}})),n==="search"){const{columns:i,tasksDirHandle:r,taskContents:s}=e(),o=a,c=i.flatMap(p=>p.tasks.map(d=>d.id));if(r){const p=c.filter(d=>!s.has(d));p.length>0?e().loadTaskContents(p).then(()=>{e().computeSearchMatches(o)}):e().computeSearchMatches(o)}}},clearFilters:()=>t({filters:{search:"",priority:null,tag:null,assignee:null,ownerType:null},searchMatches:new Map}),setCommandOpen:n=>t({commandOpen:n}),setCheatsheetOpen:n=>t({cheatsheetOpen:n}),refreshAgentHook:async()=>{if(!Lt()){t({agentHook:null});return}const n=await Jce();t({agentHook:n?.agentHook??null})},sendTaskToAgent:async n=>{const a=e().agentHook;if(!a){e().toast("Agent hook not configured","error");return}e().toast(`Sending to ${a.label}…`);const i=await epe(n);if(i===null){e().toast("Could not reach the daemon","error");return}i.ok?e().toast(`Sent to ${a.label}`):e().toast(i.error||"Agent hook failed","error")},setCurrentPage:n=>t({currentPage:n}),loadTaskContents:async n=>{const{tasksDirHandle:a}=e();if(!a)return;const i=new Map(e().taskContents);await Promise.all(n.map(async r=>{if(!i.has(r))try{const{frontmatter:s,body:o}=await Ps(a,r),{subtasks:c,bodyWithoutSubtasks:p}=Rs(o);i.set(r,{frontmatter:s,subtasks:c,body:p})}catch{}})),t({taskContents:i})},computeSearchMatches:n=>{if(!n.trim()){t({searchMatches:new Map});return}const{taskContents:a}=e(),i=new Map,r=n.toLowerCase();for(const[s,o]of a){const c=lH(o,r);c.length>0&&i.set(s,c)}t({searchMatches:i})},toast:(n,a="success",i)=>{const r=++Lpe,s=i??(a==="error"||a==="warning"?6e3:2500);t(o=>({toasts:[...o.toasts,{id:r,message:n,type:a}]})),setTimeout(()=>{t(o=>({toasts:o.toasts.filter(c=>c.id!==r)}))},s)},dismissToast:n=>t(a=>({toasts:a.toasts.filter(i=>i.id!==n)})),resolveConflict:async n=>{const{conflictState:a,drawerData:i,tasksDirHandle:r,drawerTaskId:s,drawerBaseVersion:o}=e();if(!(!a||!r||!s))if(n==="reload"){const{frontmatter:c,body:p}=await Ps(r,s),{subtasks:d,bodyWithoutSubtasks:m}=Rs(p);t({drawerData:{frontmatter:c,subtasks:d,body:m},drawerBaseVersion:{frontmatter:c,subtasks:d,body:m,savedAt:Date.now()},conflictState:null,showConflictModal:!1}),e().toast("Reloaded from disk")}else if(n==="overwrite"){if(i&&s&&o){const c=Wd(i.body,i.subtasks),p={...i.frontmatter,id:s};try{await pu(r,s,p,c),t({drawerBaseVersion:{...i,savedAt:Date.now()},conflictState:null,showConflictModal:!1}),e().toast("Overwritten remote changes")}catch(d){e().toast("Failed to overwrite: "+d.message,"error")}}}else t({conflictState:null,showConflictModal:!1})},setupWatcher:()=>{if(Lt()){V2&&clearInterval(V2),V2=setInterval(()=>{e().reloadBoard()},2e3);return}const{dirHandle:n,tasksDirHandle:a}=e();if(!n||!a)return;Lo.stop(),Df.forEach(s=>clearTimeout(s)),Df.clear(),Lo.start(n,a);const i=(s,o)=>{const c=Df.get(s);c&&clearTimeout(c);const p=Math.max(2e3,e().config.notifications.editDebounceMs),d=setTimeout(()=>{Df.delete(s);const m=e().config;m.notifications.taskEdits&&B2({title:"Task edited",body:`${o} changed on disk.`,config:m})},p);Df.set(s,d)},r=async s=>{const{tasksDirHandle:o,config:c}=e();if(!o)return;let p,d;try{({frontmatter:p,body:d}=await Ps(o,s))}catch(A){console.warn(`[Watcher] notifyTaskChange: failed to read ${s}:`,A);return}const{subtasks:m,bodyWithoutSubtasks:f}=Rs(d),h={id:s,frontmatter:{...p,id:p.id||s,status:p.status||"Backlog"},body:f,subtasks:m},v=P3(h),k=yu.get(s);if(!k){yu.set(s,v);return}c.notifications.statusChanges&&k.status!==v.status&&B2({title:"Task status changed",body:`${v.title}: ${k.status} → ${v.status}`,config:c});const w=Ppe(k.subtasks,v.subtasks);c.notifications.subtaskCompletions&&w>0&&B2({title:"Subtask completed",body:w===1?`${v.title}: 1 subtask completed.`:`${v.title}: ${w} subtasks completed.`,config:c}),Mpe(k,v)&&i(s,v.title),yu.set(s,v)};Lo.on("configChanged",()=>{try{e().loadConfig(),e().toast("Settings updated externally","info")}catch(s){console.error("[Watcher] configChanged handler error:",s)}}),Lo.on("taskChanged",async s=>{try{const{drawerTaskId:o,drawerBaseVersion:c,tasksDirHandle:p}=e();if(await r(s),o===s&&c&&p){let d,m;try{({frontmatter:d,body:m}=await Ps(p,s))}catch(T){console.warn(`[Watcher] taskChanged: failed to re-read ${s}:`,T);return}const{subtasks:f,bodyWithoutSubtasks:h}=Rs(m),v=c,k=JSON.stringify(v.frontmatter)!==JSON.stringify(d),w=v.body!==h,A=JSON.stringify(v.subtasks)!==JSON.stringify(f);if(!k&&!w&&!A)return;let $="none";k&&(w||A)?$="full":k?$="metadata-only":(w||A)&&($="body-only"),t({conflictState:{taskId:s,type:$,local:v,remote:{frontmatter:d,body:h,subtasks:f}},showConflictModal:$==="full"})}else await e().reloadBoard()}catch(o){console.error(`[Watcher] taskChanged handler error for ${s}:`,o)}}),Lo.on("newTaskDetected",async s=>{try{const{tasksDirHandle:o}=e();if(o){let c,p;try{({frontmatter:c,body:p}=await Ps(o,s))}catch(f){console.warn(`[Watcher] newTaskDetected: failed to read ${s}:`,f),e().toast(`New task ${s} detected but could not be loaded`,"warning");return}const{subtasks:d,bodyWithoutSubtasks:m}=Rs(p);yu.set(s,P3({id:s,frontmatter:{...c,id:c.id||s,status:c.status||"Backlog"},body:m,subtasks:d}))}await e().reloadBoard()}catch(o){console.error(`[Watcher] newTaskDetected handler error for ${s}:`,o)}}),Lo.on("watcherError",s=>{t({watcherError:s}),e().toast(s,"warning",1e4)})},restartWatcher:()=>{const{dirHandle:n,tasksDirHandle:a}=e();!n||!a||(t({watcherError:null}),e().setupWatcher(),e().toast("File watcher restarted"))}}));Fy().then(t=>{se.setState({recentProjects:t})}).catch(t=>{console.warn("[Store] Failed to hydrate recent projects:",t)});pl(Ei);window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{pl(se.getState().config)});const jpe=Object.freeze(Object.defineProperty({__proto__:null,useStore:se},Symbol.toStringTag,{value:"Module"}));function Dpe({icon:t,value:e,label:n,isActive:a,onClick:i,layoutId:r}){return b.jsxs("button",{type:"button",className:T1("relative flex size-8 cursor-default items-center justify-center rounded-full transition-all [&_svg]:size-4",a?"text-zinc-950 dark:text-zinc-50":"text-zinc-400 hover:text-zinc-950 dark:text-zinc-500 dark:hover:text-zinc-50"),role:"radio","aria-checked":a,"aria-label":`Switch to ${n} theme`,onClick:()=>i(e),children:[t,a&&b.jsx(nt.div,{layoutId:r,transition:{type:"spring",bounce:.3,duration:.6},className:"absolute inset-0 rounded-full border border-zinc-200 dark:border-zinc-700"})]})}const Ipe=[{icon:b.jsx(yce,{}),value:"auto",label:"system"},{icon:b.jsx(Sce,{}),value:"light",label:"light"},{icon:b.jsx(kce,{}),value:"dark",label:"dark"}];function Rpe({value:t,onChange:e,className:n}){const a=se(d=>d.config.ui.theme),i=se(d=>d.updateConfig),r=`theme-option-${S.useId()}`,[s,o]=S.useState(!1);S.useEffect(()=>{o(!0)},[]);const c=t??a,p=e??(d=>{i(m=>({...m,ui:{...m.ui,theme:d}}))});return s?b.jsx(nt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.3},className:T1("inline-flex items-center overflow-hidden rounded-full bg-white ring-1 ring-zinc-200 ring-inset dark:bg-zinc-950 dark:ring-zinc-700",n),role:"radiogroup","aria-label":"Theme mode",children:Ipe.map(d=>b.jsx(Dpe,{icon:d.icon,value:d.value,label:d.label,isActive:c===d.value,onClick:p,layoutId:r},d.value))},String(s)):b.jsx("div",{className:T1("flex h-8 w-24",n)})}function Ope(t){const e=soe(t,{stiffness:180,damping:22,mass:.8});return S.useEffect(()=>{e.set(t)},[t,e]),Uz(e,a=>Math.round(a).toString())}const M3="0.33.5";function wH({className:t="w-6 h-6"}){return b.jsxs("svg",{viewBox:"0 0 150 150",className:t,version:"1.1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:2},children:[b.jsx("path",{d:"M148,21.594L148,128.406C148,139.22 139.22,148 128.406,148L21.594,148C10.78,148 2,139.22 2,128.406L2,21.594C2,10.78 10.78,2 21.594,2C139.22,2 148,10.78 148,21.594Z",style:{fill:"url(#_KandownLinear1)"}}),b.jsxs("g",{transform:"matrix(0.823551,0,0,0.823551,12.830775,11.282318)",children:[b.jsx("g",{transform:"matrix(1.620982,0,0,1.566239,-41.718998,-41.628205)",children:b.jsx("path",{d:"M56.491,62.601C57.2,61.897 57.602,60.925 57.606,59.908C57.627,53.936 57.7,33.2 57.7,33.2C57.6,29.7 55,27.6 52,27.6L42.075,27.6C38.544,27.6 35.673,30.547 35.644,34.201C35.528,48.996 35.327,83.484 35.956,83.013C35.956,83.013 52.072,66.994 56.491,62.601Z",style:{fill:"rgb(252,255,239)",fillRule:"nonzero"}})}),b.jsx("g",{transform:"matrix(1.566239,0,0,1.566239,-39.774573,-41.628205)",children:b.jsx("path",{d:"M87.6,43.8C84.2,43.9 80.5,45.1 77.7,47.5L39.2,86.2C37.1,88.3 35.8,91 35.7,93.7L35.7,116.574C35.7,117.219 36.088,117.802 36.683,118.051C37.278,118.3 37.965,118.167 38.425,117.714C50.467,105.842 98.836,58.16 110.608,46.555C111.047,46.122 111.185,45.468 110.956,44.894C110.728,44.321 110.178,43.94 109.561,43.928C106.663,43.871 103.089,43.8 103.089,43.8L87.6,43.8Z",style:{fill:"rgb(241,255,184)",fillRule:"nonzero"}})}),b.jsx("g",{transform:"matrix(0.766318,0.766329,-1.302872,1.302853,170.442469,-47.541879)",children:b.jsx("path",{d:"M38.038,101.45C35.808,101.45 34,100.387 34,99.075C34,95.326 34,88.102 34,84.58C34,84.042 34.364,83.525 35.011,83.145C35.658,82.764 36.536,82.55 37.452,82.55C46.372,82.55 69.5,82.55 69.5,82.55C69.5,82.55 69.5,77.52 69.5,74.389C69.5,73.947 69.936,73.545 70.617,73.359C71.298,73.173 72.101,73.236 72.675,73.521C80.028,77.17 98.075,86.125 104.279,89.204C104.832,89.479 105.168,89.876 105.206,90.301C105.245,90.727 104.982,91.143 104.481,91.45C98.972,94.832 83.072,104.591 75.013,109.539C74.195,110.041 72.946,110.206 71.841,109.959C70.737,109.712 69.99,109.101 69.946,108.406C69.744,105.262 69.5,101.45 69.5,101.45L38.038,101.45Z",style:{fill:"rgb(136,225,56)"}})})]}),b.jsx("defs",{children:b.jsxs("linearGradient",{id:"_KandownLinear1",x1:"0",y1:"0",x2:"1",y2:"0",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(62,131,-131,62,9,8)",children:[b.jsx("stop",{offset:"0",style:{stopColor:"rgb(12,29,23)",stopOpacity:1}}),b.jsx("stop",{offset:"1",style:{stopColor:"rgb(24,41,35)",stopOpacity:1}})]})})]})}function Fpe(){const{t}=Tn(),e=se(B=>B.dirHandle),n=se(B=>B.isOpen),a=se(B=>B.projectName),i=se(B=>B.closeDrawer),r=se(B=>B.drawerTaskId),s=se(B=>B.saveDrawer),o=se(B=>B.archivedTasks.length),c=se(B=>B.showArchives),p=se(B=>B.setShowArchives),d=se(B=>B.columns),m=se(B=>B.openFolder),f=se(B=>B.reloadBoard),h=se(B=>B.createTask),v=se(B=>B.setCommandOpen),k=se(B=>B.viewMode),w=se(B=>B.setViewMode),A=se(B=>B.density),$=se(B=>B.setDensity),T=se(B=>B.setCurrentPage),M=se(B=>B.recentProjects),j=se(B=>B.openRecentProject),D=se(B=>B.filters),I=se(B=>B.setFilter),H=se(B=>B.clearFilters),R=se(B=>B.config.fields),L=se(B=>B.lastReloadError),G=se(B=>B.watcherError),Y=se(B=>B.restartWatcher),[ne,U]=S.useState(!1),[F,V]=S.useState(!0),Q=S.useRef(null),J=S.useRef(null),oe=d.reduce((B,ae)=>B+ae.tasks.length,0),O=Ope(oe),Z=[];R.priority&&D.priority&&Z.push({type:"priority",label:D.priority,value:D.priority}),R.tags&&D.tag&&Z.push({type:"tag",label:"#"+D.tag,value:D.tag}),R.assignee&&D.assignee&&Z.push({type:"assignee",label:"@"+D.assignee,value:D.assignee});const K=[{label:t("filterBar.ownerAll"),value:""},{label:t("filterBar.ownerHuman"),value:"human"},{label:t("filterBar.ownerAI"),value:"ai"}],E=Z.length>0||D.search||R.ownerType&&D.ownerType;return S.useEffect(()=>{if(!ne)return;const B=ae=>{Q.current&&!Q.current.contains(ae.target)&&U(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[ne]),S.useEffect(()=>{const B=setTimeout(()=>V(!1),5e3);return()=>clearTimeout(B)},[]),S.useEffect(()=>{document.title=a?`${a} · Kandown`:"Kandown"},[a]),b.jsxs(b.Fragment,{children:[(L||G)&&b.jsxs("div",{className:"flex items-center gap-2 px-5 py-1.5 bg-amber-500/10 border-b border-amber-500/30 text-[12px] text-amber-700 dark:text-amber-300",children:[b.jsx("span",{className:"flex-1 truncate",children:G?`⚠ ${G}`:`⚠ ${L}`}),G&&b.jsx("button",{type:"button",onClick:Y,className:"px-2 py-0.5 rounded bg-amber-500/20 hover:bg-amber-500/30 text-[11.5px] font-medium",children:"Restart watcher"}),b.jsx("button",{type:"button",onClick:f,className:"px-2 py-0.5 rounded bg-amber-500/20 hover:bg-amber-500/30 text-[11.5px] font-medium",children:"Reload"})]}),b.jsxs("header",{className:"flex items-center justify-between px-5 h-[64px] border-b border-border bg-card/80 backdrop-blur-xl relative z-10",children:[b.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[b.jsxs("div",{className:"flex items-center gap-2.5 flex-shrink-0",children:[b.jsxs("button",{onClick:()=>{r?s():i({replace:!0})},className:"flex items-center gap-2 cursor-pointer",children:[b.jsx(wH,{className:"w-[34px] h-[34px] dark:text-white text-black"}),b.jsx(Wa,{mode:"wait",initial:!1,children:F?b.jsxs(nt.span,{className:"flex items-center gap-2",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.45},children:[b.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-fg",children:"kandown"}),b.jsxs("span",{className:"inline-flex items-center h-5 px-1.5 text-[10.5px] font-semibold text-red-600 bg-red-50 dark:text-red-400 dark:bg-red-500/15 rounded-md",children:["v",M3]})]},"boot"):a?b.jsx(nt.span,{className:"text-[15px] font-semibold tracking-tight text-fg truncate max-w-[240px]",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.45},children:a},"project"):null})]}),r&&b.jsxs("button",{type:"button",onClick:()=>{s()},className:"hidden md:inline-flex items-center gap-2 rounded-xl border border-border bg-bg px-3 py-2 text-[13px] font-semibold text-fg shadow-sm transition-colors hover:border-border-strong hover:bg-bg-2",title:t("taskWorkspace.backToCards"),children:[b.jsx(Wn.ArrowLeft,{size:15}),b.jsx("span",{children:t("common.back")})]})]}),e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"w-px h-[20px] bg-black/[0.08] dark:bg-white/[0.08] flex-shrink-0"}),b.jsxs("div",{className:"flex items-center gap-2 px-3 h-9 bg-secondary/60 border border-border rounded-xl min-w-[200px] max-w-[280px] focus-within:border-border-focus focus-within:bg-secondary transition-all",children:[b.jsx(Wn.Search,{size:14,className:"text-fg-muted/60 flex-shrink-0"}),b.jsx("input",{ref:J,type:"text",placeholder:t("filterBar.searchPlaceholder"),value:D.search,onChange:B=>I("search",B.target.value),className:"bg-transparent border-none outline-none text-fg text-[13px] w-full placeholder:text-fg-muted/60"}),D.search?b.jsx("button",{onClick:()=>I("search",""),className:"text-fg-muted/60 hover:text-fg flex-shrink-0",children:b.jsx(Wn.X,{size:14})}):b.jsx("kbd",{className:"inline-flex items-center h-5 px-1.5 text-[10px] font-medium text-fg-muted/50 bg-black/[0.04] dark:bg-white/[0.08] rounded border border-black/[0.06] dark:border-white/[0.1]",children:"⌘K"})]}),b.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap overflow-hidden",children:[b.jsx(Wa,{children:Z.map(B=>b.jsxs(nt.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},onClick:()=>I(B.type,null),className:"inline-flex items-center gap-1 h-6 px-2.5 text-[12px] text-fg bg-black/[0.05] dark:bg-white/[0.1] border border-black/[0.08] dark:border-white/[0.12] rounded-lg hover:bg-black/[0.08] dark:hover:bg-white/[0.15] transition-colors",children:[B.label,b.jsx(Wn.X,{size:10,className:"text-fg-muted/60"})]},B.type+B.value))}),R.ownerType&&b.jsx("div",{className:"flex items-center h-6 border border-black/[0.06] dark:border-white/[0.1] rounded-lg overflow-hidden",children:K.map(B=>b.jsx("button",{onClick:()=>I("ownerType",B.value),className:`h-full px-2.5 text-[12px] transition-colors ${D.ownerType===B.value?"bg-black/[0.06] dark:bg-white/[0.12] text-fg":"text-fg-muted/70 hover:text-fg"}`,children:B.label},B.value))}),E&&b.jsx("button",{onClick:H,className:"text-[12px] text-fg-muted/60 hover:text-fg transition-colors",children:t("filterBar.clearAll")})]})]}),e&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"w-px h-[20px] bg-black/[0.08] dark:bg-white/[0.08] flex-shrink-0"}),b.jsxs("div",{className:"relative flex-shrink-0",ref:Q,children:[b.jsxs("button",{onClick:()=>U(B=>!B),className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[13px] text-fg-muted hover:text-fg hover:bg-black/[0.04] dark:hover:bg-white/[0.06] rounded-lg transition-colors border border-transparent hover:border-black/[0.06] dark:hover:border-white/[0.1]",children:[b.jsx(Wn.Folder,{size:13,className:"text-fg-muted/70"}),b.jsxs("span",{className:"font-medium",children:[".",e.name]}),b.jsx(Wn.ChevronDown,{size:11,className:"opacity-50"})]}),b.jsx(Wa,{children:ne&&b.jsx(nt.div,{initial:{opacity:0,y:-4,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.98},transition:{duration:.12},className:"absolute top-full left-0 mt-2 min-w-[240px] glass rounded-xl shadow-[0_16px_48px_rgba(0,0,0,0.5)] overflow-hidden z-50",children:b.jsxs("div",{className:"py-1.5",children:[M.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"px-3 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-fg-muted/60",children:t("header.recentProjects")}),M.map(B=>b.jsxs("button",{onClick:()=>{U(!1),j(B)},className:"w-full flex items-center gap-2 px-3 py-2 text-[13.5px] text-left hover:bg-black/[0.04] dark:hover:bg-white/[0.06] transition-colors",children:[b.jsx(Wn.Folder,{size:12,className:"text-fg-muted/60"}),b.jsx("span",{className:"truncate",children:B.name}),B.id===e.name&&b.jsx(Wn.Check,{size:12,className:"ml-auto text-emerald-500"})]},B.id)),b.jsx("div",{className:"h-px bg-black/[0.06] dark:bg-white/[0.08] my-1.5 mx-2"})]}),b.jsxs("button",{onClick:()=>{U(!1),m()},className:"w-full flex items-center gap-2 px-3 py-2 text-[13.5px] text-left hover:bg-black/[0.04] dark:hover:bg-white/[0.06] transition-colors",children:[b.jsx(Wn.Plus,{size:12,className:"text-fg-muted/60"}),b.jsx("span",{children:t("header.openFolder...")})]})]})})})]})]})]}),b.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n||e?b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex items-center gap-2 mr-2 text-[12.5px] text-fg-muted/70",children:[b.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-emerald-500"}),b.jsx(nt.span,{className:"tabular-nums font-medium",children:O}),b.jsx("span",{children:t("header.tasks")})]}),b.jsxs("div",{className:"flex items-center bg-black/[0.04] dark:bg-white/[0.06] border border-black/[0.06] dark:border-white/[0.1] rounded-xl p-0.5 h-10",children:[b.jsx("button",{onClick:()=>w("board"),className:`w-9 h-9 inline-flex items-center justify-center rounded-lg transition-all ${k==="board"?"bg-card text-fg shadow-sm":"text-fg-muted/70 hover:text-fg"}`,title:t("common.board"),children:b.jsx(Wn.LayoutBoard,{size:18})}),b.jsx("button",{onClick:()=>w("list"),className:`w-9 h-9 inline-flex items-center justify-center rounded-lg transition-all ${k==="list"?"bg-card text-fg shadow-sm":"text-fg-muted/70 hover:text-fg"}`,title:t("common.list"),children:b.jsx(Wn.LayoutList,{size:18})})]}),b.jsx(an,{variant:"icon",icon:"Archive",onClick:()=>p(!c),title:c?t("header.backToBoard"):`${t("header.archives")} (${o})`,className:c?"text-accent":""}),b.jsx(an,{variant:"icon",icon:"Density",onClick:()=>$(A==="compact"?"comfortable":"compact"),title:`Density: ${A}`}),b.jsx(an,{variant:"icon",icon:"Settings",onClick:()=>T("settings"),title:t("common.settings")}),b.jsx(Rpe,{}),b.jsx("div",{className:"w-px h-5 bg-black/[0.08] dark:bg-white/[0.08] mx-1"}),b.jsx(an,{variant:"secondary",icon:"Search",label:t("common.search"),shortcut:"⌘K",onClick:()=>v(!0),title:"Command palette (⌘K)"}),b.jsx(an,{variant:"icon",icon:"Refresh",onClick:f,title:`${t("common.reload")} (R)`}),b.jsx(an,{variant:"primary",icon:"Plus",label:t("common.newTask"),shortcut:"N",onClick:()=>h()})]}):b.jsx(an,{variant:"primary",label:t("common.openFolder"),onClick:m})})]})]})}/**
|
|
205
205
|
* @license @tabler/icons-react v3.41.1 - MIT
|
|
206
206
|
*
|
|
207
207
|
* This source code is licensed under the MIT license.
|
|
@@ -705,7 +705,7 @@ XID_Continue XIDC
|
|
|
705
705
|
XID_Start XIDS`.split(/\s/).map(t=>[Uk(t),t])),GFe=new Map([["s",ia(383)],[ia(383),"s"]]),WFe=new Map([[ia(223),ia(7838)],[ia(107),ia(8490)],[ia(229),ia(8491)],[ia(969),ia(8486)]]),KFe=new Map([Rc(453),Rc(456),Rc(459),Rc(498),...HC(8072,8079),...HC(8088,8095),...HC(8104,8111),Rc(8124),Rc(8140),Rc(8188)]),YFe=new Map([["alnum",rt`[\p{Alpha}\p{Nd}]`],["alpha",rt`\p{Alpha}`],["ascii",rt`\p{ASCII}`],["blank",rt`[\p{Zs}\t]`],["cntrl",rt`\p{Cc}`],["digit",rt`\p{Nd}`],["graph",rt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",rt`\p{Lower}`],["print",rt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",rt`[\p{P}\p{S}]`],["space",rt`\p{space}`],["upper",rt`\p{Upper}`],["word",rt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",rt`\p{AHex}`]]);function XFe(t,e){const n=[];for(let a=t;a<=e;a++)n.push(a);return n}function Rc(t){const e=ia(t);return[e.toLowerCase(),e]}function HC(t,e){return XFe(t,e).map(n=>Rc(n))}var eQ=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function QFe(t,e){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e};tQ(t);const a={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:C4(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};Pg(t,JFe,a);const i={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},r={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:a.subroutineRefMap};Pg(t,eze,r);const s={groupsByName:r.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:r.reffedNodesByReferencer};return Pg(t,tze,s),t._originMap=r.groupOriginByCopy,t._strategy=a.strategy,t}var JFe={AbsenceFunction({node:t,parent:e,replaceWith:n}){const{body:a,kind:i}=t;if(i==="repeater"){const r=es();r.body[0].body.push(ul({negate:!0,body:a}),gu("Any"));const s=es();s.body[0].body.push(ZX("greedy",0,1/0,r)),n(zn(s,e),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:t,parent:e,key:n},{flagDirectivesByAlt:a}){const i=t.body.filter(r=>r.kind==="flags");for(let r=n+1;r<e.body.length;r++){const s=e.body[r];Ah(a,s,[]).push(...i)}},exit({node:t},{flagDirectivesByAlt:e}){if(e.get(t)?.length){const n=aQ(e.get(t));if(n){const a=es({flags:n});a.body[0].body=t.body,t.body=[zn(a,t)]}}}},Assertion({node:t,parent:e,key:n,container:a,root:i,remove:r,replaceWith:s},o){const{kind:c,negate:p}=t,{asciiWordBoundaries:d,avoidSubclass:m,supportedGNodes:f,wordIsAscii:h}=o;if(c==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${p?"Y":"y"}"`);if(c==="line_end")s(zn(ul({body:[Ql({body:[k4("string_end")]}),Ql({body:[Bk(10)]})]}),e));else if(c==="line_start")s(zn($o(rt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),e));else if(c==="search_start")if(f.has(t))i.flags.sticky=!0,r();else{const v=a[n-1];if(v&&oze(v))s(zn(ul({negate:!0}),e));else{if(m)throw new Error(rt`Uses "\G" in a way that requires a subclass`);s(Oc(k4("string_start"),e)),o.strategy="clip_search"}}else if(!(c==="string_end"||c==="string_start"))if(c==="string_end_newline")s(zn($o(rt`(?=\n?\z)`),e));else if(c==="word_boundary"){if(!h&&!d){const v=`(?:(?<=${So})(?!${So})|(?<!${So})(?=${So}))`,k=`(?:(?<=${So})(?=${So})|(?<!${So})(?!${So}))`;s(zn($o(p?k:v),e))}}else throw new Error(`Unexpected assertion kind "${c}"`)},Backreference({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!UC(n)&&(n=BC(n,e),t.ref=n)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:n}){let{name:a}=t;a&&!UC(a)&&(a=BC(a,e),t.name=a),n.set(t.number,t),a&&n.set(a,t)},CharacterClassRange({node:t,parent:e,replaceWith:n}){if(e.kind==="intersection"){const a=m1({body:[t]});n(zn(a,e),{traverse:!0})}},CharacterSet({node:t,parent:e,replaceWith:n},{accuracy:a,minTargetEs2024:i,digitIsAscii:r,spaceIsAscii:s,wordIsAscii:o}){const{kind:c,negate:p,value:d}=t;if(r&&(c==="digit"||d==="digit")){n(Oc(x4("digit",{negate:p}),e));return}if(s&&(c==="space"||d==="space")){n(zn(qC($o(VFe),p),e));return}if(o&&(c==="word"||d==="word")){n(Oc(x4("word",{negate:p}),e));return}if(c==="any")n(Oc(gu("Any"),e));else if(c==="digit")n(Oc(gu("Nd",{negate:p}),e));else if(c!=="dot")if(c==="text_segment"){if(a==="strict")throw new Error(rt`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",f=rt`\p{RI}{2}|${m}(?:\u200D${m})*`;n(zn($o(rt`(?>\r\n|${i?rt`\p{RGI_Emoji}`:f}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),e))}else if(c==="hex")n(Oc(gu("AHex",{negate:p}),e));else if(c==="newline")n(zn($o(p?`[^
|
|
706
706
|
]`:`(?>\r
|
|
707
707
|
?|[
|
|
708
|
-
\v\f
\u2028\u2029])`),e));else if(c==="posix")if(!i&&(d==="graph"||d==="print")){if(a==="strict")throw new Error(`POSIX class "${d}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[d];p&&(m=`\0-${ia(m.codePointAt(0)-1)}${ia(m.codePointAt(2)+1)}-`),n(zn($o(`[${m}]`),e))}else n(zn(qC($o(YFe.get(d)),p),e));else if(c==="property")ST.has(Uk(d))||(t.key="sc");else if(c==="space")n(Oc(gu("space",{negate:p}),e));else if(c==="word")n(zn(qC($o(So),p),e));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:t,parent:e,root:n,remove:a,replaceWith:i,removeAllPrevSiblings:r,removeAllNextSiblings:s}){const{kind:o,flags:c}=t;if(o==="flags")if(!c.enable&&!c.disable)a();else{const p=es({flags:c});p.body[0].body=s(),i(zn(p,e),{traverse:!0})}else if(o==="keep"){const p=n.body[0],m=n.body.length===1&&UX(p,{type:"Group"})&&p.body[0].body.length===1?p.body[0]:n;if(e.parent!==m||m.body.length>1)throw new Error(rt`Uses "\K" in a way that's unsupported`);const f=ul({behind:!0});f.body[0].body=r(),i(zn(f,e))}else throw new Error(`Unexpected directive kind "${o}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:a}=t;if(a==="fail")n(zn(ul({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${a.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=es();e.body[0].body.push(t.body),t.body=zn(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let a=!1,i=!1;for(const r of t.body)if(r.body.length===1&&r.body[0].kind==="search_start")r.body.pop();else{const s=rQ(r.body);s?(a=!0,Array.isArray(s)?n.push(...s):n.push(s)):i=!0}a&&!i&&n.forEach(r=>e.add(r))},exit(t,{accuracy:e,passedLookbehind:n,strategy:a}){if(e==="strict"&&n&&a)throw new Error(rt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!UC(n)&&(n=BC(n,e),t.ref=n)}},eze={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:a,ref:i}=t;a||n.set(t,[...e.get(i).map(({node:r})=>r)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:a},{groupOriginByCopy:i,groupsByName:r,multiplexCapturesToLeftByRef:s,openRefs:o,reffedNodesByReferencer:c}){const p=i.get(t);if(p&&o.has(t.number)){const m=Oc(GR(t.number),e);c.set(m,o.get(t.number)),n(m);return}o.set(t.number,t),s.set(t.number,[]),t.name&&Ah(s,t.name,[]);const d=s.get(t.name??t.number);for(let m=0;m<d.length;m++){const f=d[m];if(p===f.node||p&&p===f.origin||t===f.origin){d.splice(m,1);break}}if(s.get(t.number).push({node:t,origin:p}),t.name&&s.get(t.name).push({node:t,origin:p}),t.name){const m=Ah(r,t.name,new Map);let f=!1;if(p)f=!0;else for(const h of m.values())if(!h.hasDuplicateNameToRemove){f=!0;break}r.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:f})}},exit({node:t},{openRefs:e}){e.get(t.number)===t&&e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Y_(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},a){const{isRecursive:i,ref:r}=t;if(i){let d=e;for(;(d=d.parent)&&!(d.type==="CapturingGroup"&&(d.name===r||d.number===r)););a.reffedNodesByReferencer.set(t,d);return}const s=a.subroutineRefMap.get(r),o=r===0,c=o?GR(0):nQ(s,a.groupOriginByCopy,null);let p=c;if(!o){const d=aQ(ize(s,f=>f.type==="Group"&&!!f.flags)),m=d?Y_(a.globalFlags,d):a.globalFlags;nze(m,a.currentFlags)||(p=es({flags:rze(m)}),p.body[0].body.push(c))}n(zn(p,e),{traverse:!o})}},tze={Backreference({node:t,parent:e,replaceWith:n},a){if(t.orphan){a.highestOrphanBackref=Math.max(a.highestOrphanBackref,t.ref);return}const r=a.reffedNodesByReferencer.get(t).filter(s=>aze(s,t));if(!r.length)n(zn(ul({negate:!0}),e));else if(r.length>1){const s=es({atomic:!0,body:r.reverse().map(o=>Ql({body:[w4(o.number)]}))});n(zn(s,e))}else t.ref=r[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let a=0;a<n;a++){const i=VX();t.body.at(-1).body.push(i)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function tQ(t){Pg(t,{"*"({node:e,parent:n}){e.parent=n}})}function nze(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function aze(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const a=iQ(n.parent);for(const i of a){if(i===n)break;if(i===t||sQ(i,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function nQ(t,e,n,a){const i=Array.isArray(t)?[]:{};for(const[r,s]of Object.entries(t))r==="parent"?i.parent=Array.isArray(n)?a:n:s&&typeof s=="object"?i[r]=nQ(s,e,i,n):(r==="type"&&s==="CapturingGroup"&&e.set(i,e.get(t)??t),i[r]=s);return i}function GR(t){const e=GX(t);return e.isRecursive=!0,e}function ize(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function BC(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function aQ(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:a})=>{e.forEach(i=>{a.enable?.[i]&&(delete n.disable[i],n.enable[i]=!0),a.disable?.[i]&&(n.disable[i]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function rze({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function iQ(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function rQ(t){const e=t.find(n=>n.kind==="search_start"||cze(n,{negate:!1})||!sze(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const a of e.body){const i=rQ(a.body);if(!i)return null;Array.isArray(i)?n.push(...i):n.push(i)}return n}return null}function sQ(t,e){const n=iQ(t)??[];for(const a of n)if(a===e||sQ(a,e))return!0;return!1}function sze({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function oze(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function cze(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&UX(t.body[0],{type:"Assertion",kind:"search_start"})}function UC(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function $o(t,e){const a=qX(t,{...e,unicodePropertyMap:ST}).body;return a.length>1||a[0].body.length>1?es({body:a}):a[0].body[0]}function qC(t,e){return t.negate=e,t}function Oc(t,e){return t.parent=e,t}function zn(t,e){return tQ(t),t.parent=e,t}function pze(t,e){const n=QX(e),a=C4(n.target,"ES2024"),i=C4(n.target,"ES2025"),r=n.rules.recursionLimit;if(!Number.isInteger(r)||r<2||r>20)throw new Error("Invalid recursionLimit; use 2-20");let s=null,o=null;if(!i){const h=[t.flags.ignoreCase];Pg(t,lze,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(v){h.push(v)},setHasCasedChar(){h.at(-1)?s=!0:o=!0}})}const c={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||s)&&!o)};let p=t;const d={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:p,originMap:t._originMap,recursionLimit:r,useAppliedIgnoreCase:!!(!i&&s&&o),useFlagMods:i,useFlagV:a,verbose:n.verbose};function m(h){return d.lastNode=p,p=h,UFe(dze[h.type],`Unexpected node type "${h.type}"`)(h,d,m)}const f={pattern:t.body.map(m).join("|"),flags:m(t.flags),options:{...t.options}};return a||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],d.captureMap.forEach((h,v)=>{h.hidden&&f._hiddenCaptures.push(v),h.transferTo&&Ah(f._captureTransfers,h.transferTo,[]).push(v)}),f}var lze={"*":{enter({node:t},e){if(KR(t)){const n=e.getCurrentModI();e.pushModI(t.flags?Y_({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){KR(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){$T(ia(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),oQ(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&eQ.has(t.value)&&e.setHasCasedChar()}},dze={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?rt`\B`:rt`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:a,name:i,number:r}=t,s={ignoreCase:e.currentFlags.ignoreCase},o=e.originMap.get(t);return o&&(s.hidden=!0,r>o.number&&(s.transferTo=o.number)),e.captureMap.set(r,s),`(${i?`?<${i}>`:""}${a.map(n).join("|")})`},Character({value:t},e){const n=ia(t),a=ou(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(a!==n)return a;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&$T(n)){const i=JX(n);return e.inCharClass?i.join(""):i.length>1?`[${i.join("")}]`:i[0]}return n},CharacterClass(t,e,n){const{kind:a,negate:i,parent:r}=t;let{body:s}=t;if(a==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ds.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&s.some(YR)&&(s=[Bk(45),...s.filter(p=>!YR(p))]);const o=()=>`[${i?"^":""}${s.map(n).join(a==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||ds.bugNestedClassIgnoresNegation)&&!i){const d=s.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(d.length){const m=es(),f=m.body[0];return m.parent=r,f.parent=m,s=s.filter(h=>!d.includes(h)),t.body=s,s.length?(t.parent=f,f.body.push(t)):m.body.pop(),d.forEach(h=>{const v=Ql({body:[h]});h.parent=v,v.parent=m,m.body.push(v)}),n(m)}}e.inCharClass=!0;const p=o();return e.inCharClass=!1,p}const c=s[0];if(a==="union"&&!i&&c&&((!e.useFlagV||!e.verbose)&&r.kind==="union"&&!(ds.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&r.kind==="intersection"&&s.length===1&&c.type!=="CharacterClassRange"))return s.map(n).join("");if(!e.useFlagV&&r.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return o()},CharacterClassRange(t,e){const n=t.min.value,a=t.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},r=ou(n,i),s=ou(a,i),o=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const c=oQ(t);hze(c).forEach(d=>{o.add(Array.isArray(d)?`${ou(d[0],i)}-${ou(d[1],i)}`:ou(d,i))})}return`${r}-${s}${[...o].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:a},i){if(t==="dot")return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":rt`[^\n]`;if(t==="digit")return e?rt`\D`:rt`\d`;if(t==="property"){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&eQ.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?rt`\P`:rt`\p`}{${a?`${a}=`:""}${n}}`}if(t==="word")return e?rt`\W`:rt`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:a},i,r){const s=i.currentFlags;n&&(i.currentFlags=Y_(s,n));const o=e.map(r).join("|"),c=!i.verbose&&e.length===1&&a.type!=="Quantifier"&&!t&&(!i.useFlagMods||!n)?o:`(?${bze(t,n,i.useFlagMods)}${o})`;return i.currentFlags=s,c},LookaroundAssertion({body:t,kind:e,negate:n},a,i){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(i).join("|")})`},Quantifier(t,e,n){return n(t.body)+vze(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const a=n.recursionLimit;return e===0?`(?R=${a})`:rt`\g<${e}&R=${a}>`}},uze=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),mze=new Set(["-","\\","]","^","["]),fze=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),WR=new Map([[9,rt`\t`],[10,rt`\n`],[11,rt`\v`],[12,rt`\f`],[13,rt`\r`],[8232,rt`\u2028`],[8233,rt`\u2029`],[65279,rt`\uFEFF`]]),gze=/^\p{Cased}$/u;function $T(t){return gze.test(t)}function oQ(t,e){const n=!!e?.firstOnly,a=t.min.value,i=t.max.value,r=[];if(a<65&&(i===65535||i>=131071)||a===65536&&i>=131071)return r;for(let s=a;s<=i;s++){const o=ia(s);if(!$T(o))continue;const c=JX(o).filter(p=>{const d=p.codePointAt(0);return d<a||d>i});if(c.length&&(r.push(...c),n))break}return r}function ou(t,{escDigit:e,inCharClass:n,useFlagV:a}){if(WR.has(t))return WR.get(t);if(t<32||t>126&&t<160||t>262143||e&&yze(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const i=n?a?fze:mze:uze,r=ia(t);return(i.has(r)?"\\":"")+r}function hze(t){const e=t.map(i=>i.codePointAt(0)).sort((i,r)=>i-r),n=[];let a=null;for(let i=0;i<e.length;i++)e[i+1]===e[i]+1?a??=e[i]:a===null?n.push(e[i]):(n.push([a,e[i]]),a=null);return n}function bze(t,e,n){if(t)return">";let a="";if(e&&n){const{enable:i,disable:r}=e;a=(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")+(r?"-":"")+(r?.ignoreCase?"i":"")+(r?.dotAll?"s":"")}return`${a}:`}function vze({kind:t,max:e,min:n}){let a;return!n&&e===1?a="?":!n&&e===1/0?a="*":n===1&&e===1/0?a="+":n===e?a=`{${n}}`:a=`{${n},${e===1/0?"":e}}`,a+{greedy:"",lazy:"?",possessive:"+"}[t]}function KR({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function yze(t){return t>47&&t<58}function YR({type:t,value:e}){return t==="Character"&&e===45}var y=class N4 extends RegExp{#t=new Map;#e=null;#a;#n=null;#i=null;rawOptions={};get source(){return this.#a||"(?:)"}constructor(e,n,a){const i=!!a?.lazyCompile;if(e instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const r=e;super(r,n),this.#a=r.source,r instanceof N4&&(this.#t=r.#t,this.#n=r.#n,this.#i=r.#i,this.rawOptions=r.rawOptions)}else{const r={hiddenCaptures:[],strategy:null,transfers:[],...a};super(i?"":e,n),this.#a=e,this.#t=kze(r.hiddenCaptures,r.transfers),this.#i=r.strategy,this.rawOptions=a??{}}i||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:i,...r}=this.rawOptions;this.#e=new N4(this.#a,this.flags,r)}const n=this.global||this.sticky,a=this.lastIndex;if(this.#i==="clip_search"&&n&&a){this.lastIndex=0;const i=this.#r(e.slice(a));return i&&(_ze(i,a,e,this.hasIndices),this.lastIndex+=a),i}return this.#r(e)}#r(e){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const a=[...n];n.length=1;let i;this.hasIndices&&(i=[...n.indices],n.indices.length=1);const r=[0];for(let s=1;s<a.length;s++){const{hidden:o,transferTo:c}=this.#t.get(s)??{};if(o?r.push(null):(r.push(n.length),n.push(a[s]),this.hasIndices&&n.indices.push(i[s])),c&&a[s]!==void 0){const p=r[c];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(n[p]=a[s],this.hasIndices&&(n.indices[p]=i[s]),n.groups){this.#n||(this.#n=wze(this.source));const d=this.#n.get(c);d&&(n.groups[d]=a[s],this.hasIndices&&(n.indices.groups[d]=i[s]))}}}return n}};function _ze(t,e,n,a){if(t.index+=e,t.input=n,a){const i=t.indices;for(let s=0;s<i.length;s++){const o=i[s];o&&(i[s]=[o[0]+e,o[1]+e])}const r=i.groups;r&&Object.keys(r).forEach(s=>{const o=r[s];o&&(r[s]=[o[0]+e,o[1]+e])})}}function kze(t,e){const n=new Map;for(const a of t)n.set(a,{hidden:!0});for(const[a,i]of e)for(const r of i)Ah(n,r,{}).transferTo=a;return n}function wze(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let a=0,i=0,r;for(;r=e.exec(t);){const{0:s,groups:{capture:o,name:c}}=r;s==="["?a++:a?s==="]"&&a--:o&&(i++,c&&n.set(i,c))}return n}function xze(t,e){const n=Aze(t,e);return n.options?new y(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Aze(t,e){const n=QX(e),a=qX(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ST}),i=QFe(a,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),r=pze(i,n),s=HFe(r.pattern,{captureTransfers:r._captureTransfers,hiddenCaptures:r._hiddenCaptures,mode:"external"}),o=FFe(s.pattern),c=OFe(o.pattern,{captureTransfers:s.captureTransfers,hiddenCaptures:s.hiddenCaptures}),p={pattern:c.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${r.flags}${r.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const d=c.hiddenCaptures.sort((v,k)=>v-k),m=Array.from(c.captureTransfers),f=i._strategy,h=p.pattern.length>=n.lazyCompileLength;(d.length||m.length||f||h)&&(p.options={...d.length&&{hiddenCaptures:d},...m.length&&{transfers:m},...f&&{strategy:f},...h&&{lazyCompile:h}})}return p}function Cze(t,e){return xze(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function Nze(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>Cze(n,{target:e.target}),{createScanner(n){return new BOe(n,e)},createString(n){return{content:n}}}}var Sze=HOe({langs:{c:()=>Ee(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url),cpp:()=>Ee(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url),"c++":()=>Ee(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url),css:()=>Ee(()=>Promise.resolve().then(()=>Cat),void 0,import.meta.url),glsl:()=>Ee(()=>Promise.resolve().then(()=>vat),void 0,import.meta.url),graphql:()=>Ee(()=>Promise.resolve().then(()=>RO),void 0,import.meta.url),gql:()=>Ee(()=>Promise.resolve().then(()=>RO),void 0,import.meta.url),haml:()=>Ee(()=>Promise.resolve().then(()=>Lat),void 0,import.meta.url),html:()=>Ee(()=>Promise.resolve().then(()=>Dat),void 0,import.meta.url),java:()=>Ee(()=>Promise.resolve().then(()=>Rat),void 0,import.meta.url),javascript:()=>Ee(()=>Promise.resolve().then(()=>jO),void 0,import.meta.url),js:()=>Ee(()=>Promise.resolve().then(()=>jO),void 0,import.meta.url),json:()=>Ee(()=>Promise.resolve().then(()=>Fat),void 0,import.meta.url),jsonc:()=>Ee(()=>Promise.resolve().then(()=>Bat),void 0,import.meta.url),jsonl:()=>Ee(()=>Promise.resolve().then(()=>Vat),void 0,import.meta.url),jsx:()=>Ee(()=>Promise.resolve().then(()=>Eat),void 0,import.meta.url),julia:()=>Ee(()=>Promise.resolve().then(()=>FO),void 0,import.meta.url),jl:()=>Ee(()=>Promise.resolve().then(()=>FO),void 0,import.meta.url),less:()=>Ee(()=>Promise.resolve().then(()=>Jat),void 0,import.meta.url),markdown:()=>Ee(()=>Promise.resolve().then(()=>zO),void 0,import.meta.url),md:()=>Ee(()=>Promise.resolve().then(()=>zO),void 0,import.meta.url),mdx:()=>Ee(()=>Promise.resolve().then(()=>iit),void 0,import.meta.url),php:()=>Ee(()=>Promise.resolve().then(()=>pit),void 0,import.meta.url),postcss:()=>Ee(()=>Promise.resolve().then(()=>dit),void 0,import.meta.url),pug:()=>Ee(()=>Promise.resolve().then(()=>HO),void 0,import.meta.url),jade:()=>Ee(()=>Promise.resolve().then(()=>HO),void 0,import.meta.url),python:()=>Ee(()=>Promise.resolve().then(()=>OO),void 0,import.meta.url),py:()=>Ee(()=>Promise.resolve().then(()=>OO),void 0,import.meta.url),r:()=>Ee(()=>Promise.resolve().then(()=>Wat),void 0,import.meta.url),regexp:()=>Ee(()=>Promise.resolve().then(()=>MO),void 0,import.meta.url),regex:()=>Ee(()=>Promise.resolve().then(()=>MO),void 0,import.meta.url),sass:()=>Ee(()=>Promise.resolve().then(()=>hit),void 0,import.meta.url),scss:()=>Ee(()=>Promise.resolve().then(()=>yit),void 0,import.meta.url),shellscript:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),bash:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),sh:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),shell:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),zsh:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),sql:()=>Ee(()=>Promise.resolve().then(()=>_at),void 0,import.meta.url),svelte:()=>Ee(()=>Promise.resolve().then(()=>xit),void 0,import.meta.url),typescript:()=>Ee(()=>Promise.resolve().then(()=>DO),void 0,import.meta.url),ts:()=>Ee(()=>Promise.resolve().then(()=>DO),void 0,import.meta.url),vue:()=>Ee(()=>Promise.resolve().then(()=>Iit),void 0,import.meta.url),"vue-html":()=>Ee(()=>Promise.resolve().then(()=>Fit),void 0,import.meta.url),wasm:()=>Ee(()=>Promise.resolve().then(()=>Bit),void 0,import.meta.url),wgsl:()=>Ee(()=>Promise.resolve().then(()=>Vit),void 0,import.meta.url),xml:()=>Ee(()=>Promise.resolve().then(()=>sit),void 0,import.meta.url),yaml:()=>Ee(()=>Promise.resolve().then(()=>BO),void 0,import.meta.url),yml:()=>Ee(()=>Promise.resolve().then(()=>BO),void 0,import.meta.url),tsx:()=>Ee(()=>Promise.resolve().then(()=>IO),void 0,import.meta.url),typescriptreact:()=>Ee(()=>Promise.resolve().then(()=>IO),void 0,import.meta.url),haskell:()=>Ee(()=>Promise.resolve().then(()=>UO),void 0,import.meta.url),hs:()=>Ee(()=>Promise.resolve().then(()=>UO),void 0,import.meta.url),"c#":()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),csharp:()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),cs:()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),latex:()=>Ee(()=>Promise.resolve().then(()=>trt),void 0,import.meta.url),lua:()=>Ee(()=>Promise.resolve().then(()=>art),void 0,import.meta.url),mermaid:()=>Ee(()=>Promise.resolve().then(()=>qO),void 0,import.meta.url),mmd:()=>Ee(()=>Promise.resolve().then(()=>qO),void 0,import.meta.url),ruby:()=>Ee(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url),rb:()=>Ee(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url),rust:()=>Ee(()=>Promise.resolve().then(()=>ZO),void 0,import.meta.url),rs:()=>Ee(()=>Promise.resolve().then(()=>ZO),void 0,import.meta.url),scala:()=>Ee(()=>Promise.resolve().then(()=>urt),void 0,import.meta.url),swift:()=>Ee(()=>Promise.resolve().then(()=>grt),void 0,import.meta.url),kotlin:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),kt:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),kts:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),"objective-c":()=>Ee(()=>Promise.resolve().then(()=>GO),void 0,import.meta.url),objc:()=>Ee(()=>Promise.resolve().then(()=>GO),void 0,import.meta.url)},themes:{"github-dark":()=>Ee(()=>Promise.resolve().then(()=>krt),void 0,import.meta.url),"github-light":()=>Ee(()=>Promise.resolve().then(()=>xrt),void 0,import.meta.url)},engine:()=>Nze()}),$ze={defaultLanguage:"javascript",supportedLanguages:{text:{name:"Plain Text",aliases:["text","txt","plain"]},c:{name:"C",aliases:["c"]},cpp:{name:"C++",aliases:["cpp","c++"]},css:{name:"CSS",aliases:["css"]},glsl:{name:"GLSL",aliases:["glsl"]},graphql:{name:"GraphQL",aliases:["graphql","gql"]},haml:{name:"Ruby Haml",aliases:["haml"]},html:{name:"HTML",aliases:["html"]},java:{name:"Java",aliases:["java"]},javascript:{name:"JavaScript",aliases:["javascript","js"]},json:{name:"JSON",aliases:["json"]},jsonc:{name:"JSON with Comments",aliases:["jsonc"]},jsonl:{name:"JSON Lines",aliases:["jsonl"]},jsx:{name:"JSX",aliases:["jsx"]},julia:{name:"Julia",aliases:["julia","jl"]},less:{name:"Less",aliases:["less"]},markdown:{name:"Markdown",aliases:["markdown","md"]},mdx:{name:"MDX",aliases:["mdx"]},php:{name:"PHP",aliases:["php"]},postcss:{name:"PostCSS",aliases:["postcss"]},pug:{name:"Pug",aliases:["pug","jade"]},python:{name:"Python",aliases:["python","py"]},r:{name:"R",aliases:["r"]},regexp:{name:"RegExp",aliases:["regexp","regex"]},sass:{name:"Sass",aliases:["sass"]},scss:{name:"SCSS",aliases:["scss"]},shellscript:{name:"Shell",aliases:["shellscript","bash","sh","shell","zsh"]},sql:{name:"SQL",aliases:["sql"]},svelte:{name:"Svelte",aliases:["svelte"]},typescript:{name:"TypeScript",aliases:["typescript","ts"]},vue:{name:"Vue",aliases:["vue"]},"vue-html":{name:"Vue HTML",aliases:["vue-html"]},wasm:{name:"WebAssembly",aliases:["wasm"]},wgsl:{name:"WGSL",aliases:["wgsl"]},xml:{name:"XML",aliases:["xml"]},yaml:{name:"YAML",aliases:["yaml","yml"]},tsx:{name:"TSX",aliases:["tsx","typescriptreact"]},haskell:{name:"Haskell",aliases:["haskell","hs"]},csharp:{name:"C#",aliases:["c#","csharp","cs"]},latex:{name:"LaTeX",aliases:["latex"]},lua:{name:"Lua",aliases:["lua"]},mermaid:{name:"Mermaid",aliases:["mermaid","mmd"]},ruby:{name:"Ruby",aliases:["ruby","rb"]},rust:{name:"Rust",aliases:["rust","rs"]},scala:{name:"Scala",aliases:["scala"]},swift:{name:"Swift",aliases:["swift"]},kotlin:{name:"Kotlin",aliases:["kotlin","kt","kts"]},"objective-c":{name:"Objective C",aliases:["objective-c","objc"]}},createHighlighter:()=>Sze({themes:["github-dark","github-light"],langs:[]})};const{audio:Grt,file:Wrt,video:Krt,table:Yrt,toggleListItem:Xrt,codeBlock:Qrt,...Eze}=ZV,{underline:Jrt,...Tze}=V0,Pze=U$.create({blockSpecs:{...Eze,codeBlock:IV($ze)},inlineContentSpecs:B$,styleSpecs:Tze});function XR(){const t=getComputedStyle(document.documentElement),e=a=>`hsl(${t.getPropertyValue(`--${a}`).trim()})`,n=t.getPropertyValue("--font-sans").trim();return{colors:{editor:{text:e("foreground"),background:e("background")},menu:{text:e("popover-foreground"),background:e("popover")},tooltip:{text:e("popover-foreground"),background:e("popover")},hovered:{text:e("accent-foreground"),background:e("accent")},selected:{text:e("primary-foreground"),background:e("primary")},disabled:{text:e("muted-foreground"),background:e("muted")},shadow:"transparent",border:e("border"),sideMenu:e("border-strong")},borderRadius:6,fontFamily:n||"Inter, system-ui, sans-serif"}}function Mze(){const[t,e]=S.useState(XR);return S.useEffect(()=>{const n=new MutationObserver(()=>e(XR()));return n.observe(document.documentElement,{attributeFilter:["class","style"]}),()=>n.disconnect()},[]),t}function X_({value:t,onChange:e,readOnly:n=!1,placeholder:a,minHeight:i="120px"}){const r=!n&&!!e,s=S.useRef(!0),o=Mze(),[c,p]=S.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light");S.useEffect(()=>{const f=new MutationObserver(()=>{p(document.documentElement.classList.contains("dark")?"dark":"light")});return f.observe(document.documentElement,{attributeFilter:["class"]}),()=>f.disconnect()},[]);const d=mk({schema:Pze});S.useEffect(()=>{const f=d.portalElement;f&&f.style.setProperty("--bn-ui-base-z-index","150")},[d]),S.useEffect(()=>{const f=d.portalElement;f&&(f.setAttribute("data-mantine-color-scheme",c),f.setAttribute("data-color-scheme",c))},[d,c]),S.useEffect(()=>{s.current=!0;const f=d.tryParseMarkdownToBlocks(t||"");d.replaceBlocks(d.document,f),requestAnimationFrame(()=>{s.current=!1})},[]);const m=S.useCallback(()=>{if(s.current||!e)return;const h=d.blocksToMarkdownLossy(d.document).replace(/^ +$/gm,"");e(h)},[d,e]);return b.jsx("div",{className:"blocknote-editor-wrapper rounded-[6px] overflow-hidden",style:{minHeight:i},"data-placeholder":a,"data-mantine-color-scheme":c,"data-color-scheme":c,children:b.jsx(lX,{editor:d,theme:o,editable:r,onChange:m})})}function Lze(){const{t}=Tn(),e=se(E=>E.drawerTaskId),n=se(E=>E.drawerData),a=se(E=>E.columns),i=se(E=>E.config),r=se(E=>E.projectName),s=se(E=>E.toast),o=se(E=>E.closeDrawer),c=se(E=>E.saveDrawer),p=se(E=>E.saveDrawerMetadata),d=se(E=>E.deleteTask),m=se(E=>E.archiveTask),f=se(E=>E.unarchiveTask),h=se(E=>E.agentHook),v=se(E=>E.sendTaskToAgent),k=se(E=>E.hasUnsavedDrawerEdits),w=se(E=>E.lastSaveError),A=se(E=>E.markDrawerDirty),$=se(E=>E.forceCloseDrawer),T=String(n?.frontmatter.archived)==="true",M=se(E=>E.updateDrawerData),j=S.useRef(null),D=S.useRef(null),I=S.useRef(!1),H=!!e&&!!n,[R,L]=S.useState(()=>window.matchMedia("(min-width: 768px)").matches);S.useEffect(()=>{const E=window.matchMedia("(min-width: 768px)"),B=()=>L(E.matches);return B(),E.addEventListener("change",B),()=>E.removeEventListener("change",B)},[]);const G=S.useCallback(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{I.current||(I.current=!0,p().finally(()=>{I.current=!1}))},150)},[p]),Y=S.useCallback(async()=>{D.current&&clearTimeout(D.current),D.current=null,I.current&&await new Promise(E=>{const B=setInterval(()=>{I.current||(clearInterval(B),E(void 0))},20)})},[]),ne=S.useCallback(async()=>{await Y(),await c()},[Y,c]),U=S.useCallback(async()=>{if(k||w){const E=w?`${w}
|
|
708
|
+
\v\f
\u2028\u2029])`),e));else if(c==="posix")if(!i&&(d==="graph"||d==="print")){if(a==="strict")throw new Error(`POSIX class "${d}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[d];p&&(m=`\0-${ia(m.codePointAt(0)-1)}${ia(m.codePointAt(2)+1)}-`),n(zn($o(`[${m}]`),e))}else n(zn(qC($o(YFe.get(d)),p),e));else if(c==="property")ST.has(Uk(d))||(t.key="sc");else if(c==="space")n(Oc(gu("space",{negate:p}),e));else if(c==="word")n(zn(qC($o(So),p),e));else throw new Error(`Unexpected character set kind "${c}"`)},Directive({node:t,parent:e,root:n,remove:a,replaceWith:i,removeAllPrevSiblings:r,removeAllNextSiblings:s}){const{kind:o,flags:c}=t;if(o==="flags")if(!c.enable&&!c.disable)a();else{const p=es({flags:c});p.body[0].body=s(),i(zn(p,e),{traverse:!0})}else if(o==="keep"){const p=n.body[0],m=n.body.length===1&&UX(p,{type:"Group"})&&p.body[0].body.length===1?p.body[0]:n;if(e.parent!==m||m.body.length>1)throw new Error(rt`Uses "\K" in a way that's unsupported`);const f=ul({behind:!0});f.body[0].body=r(),i(zn(f,e))}else throw new Error(`Unexpected directive kind "${o}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:a}=t;if(a==="fail")n(zn(ul({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${a.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=es();e.body[0].body.push(t.body),t.body=zn(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let a=!1,i=!1;for(const r of t.body)if(r.body.length===1&&r.body[0].kind==="search_start")r.body.pop();else{const s=rQ(r.body);s?(a=!0,Array.isArray(s)?n.push(...s):n.push(s)):i=!0}a&&!i&&n.forEach(r=>e.add(r))},exit(t,{accuracy:e,passedLookbehind:n,strategy:a}){if(e==="strict"&&n&&a)throw new Error(rt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!UC(n)&&(n=BC(n,e),t.ref=n)}},eze={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:a,ref:i}=t;a||n.set(t,[...e.get(i).map(({node:r})=>r)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:a},{groupOriginByCopy:i,groupsByName:r,multiplexCapturesToLeftByRef:s,openRefs:o,reffedNodesByReferencer:c}){const p=i.get(t);if(p&&o.has(t.number)){const m=Oc(GR(t.number),e);c.set(m,o.get(t.number)),n(m);return}o.set(t.number,t),s.set(t.number,[]),t.name&&Ah(s,t.name,[]);const d=s.get(t.name??t.number);for(let m=0;m<d.length;m++){const f=d[m];if(p===f.node||p&&p===f.origin||t===f.origin){d.splice(m,1);break}}if(s.get(t.number).push({node:t,origin:p}),t.name&&s.get(t.name).push({node:t,origin:p}),t.name){const m=Ah(r,t.name,new Map);let f=!1;if(p)f=!0;else for(const h of m.values())if(!h.hasDuplicateNameToRemove){f=!0;break}r.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:f})}},exit({node:t},{openRefs:e}){e.get(t.number)===t&&e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=Y_(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},a){const{isRecursive:i,ref:r}=t;if(i){let d=e;for(;(d=d.parent)&&!(d.type==="CapturingGroup"&&(d.name===r||d.number===r)););a.reffedNodesByReferencer.set(t,d);return}const s=a.subroutineRefMap.get(r),o=r===0,c=o?GR(0):nQ(s,a.groupOriginByCopy,null);let p=c;if(!o){const d=aQ(ize(s,f=>f.type==="Group"&&!!f.flags)),m=d?Y_(a.globalFlags,d):a.globalFlags;nze(m,a.currentFlags)||(p=es({flags:rze(m)}),p.body[0].body.push(c))}n(zn(p,e),{traverse:!o})}},tze={Backreference({node:t,parent:e,replaceWith:n},a){if(t.orphan){a.highestOrphanBackref=Math.max(a.highestOrphanBackref,t.ref);return}const r=a.reffedNodesByReferencer.get(t).filter(s=>aze(s,t));if(!r.length)n(zn(ul({negate:!0}),e));else if(r.length>1){const s=es({atomic:!0,body:r.reverse().map(o=>Ql({body:[w4(o.number)]}))});n(zn(s,e))}else t.ref=r[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let a=0;a<n;a++){const i=VX();t.body.at(-1).body.push(i)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function tQ(t){Pg(t,{"*"({node:e,parent:n}){e.parent=n}})}function nze(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function aze(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const a=iQ(n.parent);for(const i of a){if(i===n)break;if(i===t||sQ(i,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function nQ(t,e,n,a){const i=Array.isArray(t)?[]:{};for(const[r,s]of Object.entries(t))r==="parent"?i.parent=Array.isArray(n)?a:n:s&&typeof s=="object"?i[r]=nQ(s,e,i,n):(r==="type"&&s==="CapturingGroup"&&e.set(i,e.get(t)??t),i[r]=s);return i}function GR(t){const e=GX(t);return e.isRecursive=!0,e}function ize(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function BC(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function aQ(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:a})=>{e.forEach(i=>{a.enable?.[i]&&(delete n.disable[i],n.enable[i]=!0),a.disable?.[i]&&(n.disable[i]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function rze({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function iQ(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function rQ(t){const e=t.find(n=>n.kind==="search_start"||cze(n,{negate:!1})||!sze(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const a of e.body){const i=rQ(a.body);if(!i)return null;Array.isArray(i)?n.push(...i):n.push(i)}return n}return null}function sQ(t,e){const n=iQ(t)??[];for(const a of n)if(a===e||sQ(a,e))return!0;return!1}function sze({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function oze(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function cze(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&UX(t.body[0],{type:"Assertion",kind:"search_start"})}function UC(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function $o(t,e){const a=qX(t,{...e,unicodePropertyMap:ST}).body;return a.length>1||a[0].body.length>1?es({body:a}):a[0].body[0]}function qC(t,e){return t.negate=e,t}function Oc(t,e){return t.parent=e,t}function zn(t,e){return tQ(t),t.parent=e,t}function pze(t,e){const n=QX(e),a=C4(n.target,"ES2024"),i=C4(n.target,"ES2025"),r=n.rules.recursionLimit;if(!Number.isInteger(r)||r<2||r>20)throw new Error("Invalid recursionLimit; use 2-20");let s=null,o=null;if(!i){const h=[t.flags.ignoreCase];Pg(t,lze,{getCurrentModI:()=>h.at(-1),popModI(){h.pop()},pushModI(v){h.push(v)},setHasCasedChar(){h.at(-1)?s=!0:o=!0}})}const c={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||s)&&!o)};let p=t;const d={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:p,originMap:t._originMap,recursionLimit:r,useAppliedIgnoreCase:!!(!i&&s&&o),useFlagMods:i,useFlagV:a,verbose:n.verbose};function m(h){return d.lastNode=p,p=h,UFe(dze[h.type],`Unexpected node type "${h.type}"`)(h,d,m)}const f={pattern:t.body.map(m).join("|"),flags:m(t.flags),options:{...t.options}};return a||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],d.captureMap.forEach((h,v)=>{h.hidden&&f._hiddenCaptures.push(v),h.transferTo&&Ah(f._captureTransfers,h.transferTo,[]).push(v)}),f}var lze={"*":{enter({node:t},e){if(KR(t)){const n=e.getCurrentModI();e.pushModI(t.flags?Y_({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){KR(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){$T(ia(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),oQ(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&eQ.has(t.value)&&e.setHasCasedChar()}},dze={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?rt`\B`:rt`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:a,name:i,number:r}=t,s={ignoreCase:e.currentFlags.ignoreCase},o=e.originMap.get(t);return o&&(s.hidden=!0,r>o.number&&(s.transferTo=o.number)),e.captureMap.set(r,s),`(${i?`?<${i}>`:""}${a.map(n).join("|")})`},Character({value:t},e){const n=ia(t),a=ou(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(a!==n)return a;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&$T(n)){const i=JX(n);return e.inCharClass?i.join(""):i.length>1?`[${i.join("")}]`:i[0]}return n},CharacterClass(t,e,n){const{kind:a,negate:i,parent:r}=t;let{body:s}=t;if(a==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ds.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&s.some(YR)&&(s=[Bk(45),...s.filter(p=>!YR(p))]);const o=()=>`[${i?"^":""}${s.map(n).join(a==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||ds.bugNestedClassIgnoresNegation)&&!i){const d=s.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(d.length){const m=es(),f=m.body[0];return m.parent=r,f.parent=m,s=s.filter(h=>!d.includes(h)),t.body=s,s.length?(t.parent=f,f.body.push(t)):m.body.pop(),d.forEach(h=>{const v=Ql({body:[h]});h.parent=v,v.parent=m,m.body.push(v)}),n(m)}}e.inCharClass=!0;const p=o();return e.inCharClass=!1,p}const c=s[0];if(a==="union"&&!i&&c&&((!e.useFlagV||!e.verbose)&&r.kind==="union"&&!(ds.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&r.kind==="intersection"&&s.length===1&&c.type!=="CharacterClassRange"))return s.map(n).join("");if(!e.useFlagV&&r.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return o()},CharacterClassRange(t,e){const n=t.min.value,a=t.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},r=ou(n,i),s=ou(a,i),o=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const c=oQ(t);hze(c).forEach(d=>{o.add(Array.isArray(d)?`${ou(d[0],i)}-${ou(d[1],i)}`:ou(d,i))})}return`${r}-${s}${[...o].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:a},i){if(t==="dot")return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?".":"[^]":rt`[^\n]`;if(t==="digit")return e?rt`\D`:rt`\d`;if(t==="property"){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&eQ.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?rt`\P`:rt`\p`}{${a?`${a}=`:""}${n}}`}if(t==="word")return e?rt`\W`:rt`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:a},i,r){const s=i.currentFlags;n&&(i.currentFlags=Y_(s,n));const o=e.map(r).join("|"),c=!i.verbose&&e.length===1&&a.type!=="Quantifier"&&!t&&(!i.useFlagMods||!n)?o:`(?${bze(t,n,i.useFlagMods)}${o})`;return i.currentFlags=s,c},LookaroundAssertion({body:t,kind:e,negate:n},a,i){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(i).join("|")})`},Quantifier(t,e,n){return n(t.body)+vze(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const a=n.recursionLimit;return e===0?`(?R=${a})`:rt`\g<${e}&R=${a}>`}},uze=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),mze=new Set(["-","\\","]","^","["]),fze=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),WR=new Map([[9,rt`\t`],[10,rt`\n`],[11,rt`\v`],[12,rt`\f`],[13,rt`\r`],[8232,rt`\u2028`],[8233,rt`\u2029`],[65279,rt`\uFEFF`]]),gze=/^\p{Cased}$/u;function $T(t){return gze.test(t)}function oQ(t,e){const n=!!e?.firstOnly,a=t.min.value,i=t.max.value,r=[];if(a<65&&(i===65535||i>=131071)||a===65536&&i>=131071)return r;for(let s=a;s<=i;s++){const o=ia(s);if(!$T(o))continue;const c=JX(o).filter(p=>{const d=p.codePointAt(0);return d<a||d>i});if(c.length&&(r.push(...c),n))break}return r}function ou(t,{escDigit:e,inCharClass:n,useFlagV:a}){if(WR.has(t))return WR.get(t);if(t<32||t>126&&t<160||t>262143||e&&yze(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const i=n?a?fze:mze:uze,r=ia(t);return(i.has(r)?"\\":"")+r}function hze(t){const e=t.map(i=>i.codePointAt(0)).sort((i,r)=>i-r),n=[];let a=null;for(let i=0;i<e.length;i++)e[i+1]===e[i]+1?a??=e[i]:a===null?n.push(e[i]):(n.push([a,e[i]]),a=null);return n}function bze(t,e,n){if(t)return">";let a="";if(e&&n){const{enable:i,disable:r}=e;a=(i?.ignoreCase?"i":"")+(i?.dotAll?"s":"")+(r?"-":"")+(r?.ignoreCase?"i":"")+(r?.dotAll?"s":"")}return`${a}:`}function vze({kind:t,max:e,min:n}){let a;return!n&&e===1?a="?":!n&&e===1/0?a="*":n===1&&e===1/0?a="+":n===e?a=`{${n}}`:a=`{${n},${e===1/0?"":e}}`,a+{greedy:"",lazy:"?",possessive:"+"}[t]}function KR({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function yze(t){return t>47&&t<58}function YR({type:t,value:e}){return t==="Character"&&e===45}var y=class N4 extends RegExp{#t=new Map;#e=null;#a;#n=null;#i=null;rawOptions={};get source(){return this.#a||"(?:)"}constructor(e,n,a){const i=!!a?.lazyCompile;if(e instanceof RegExp){if(a)throw new Error("Cannot provide options when copying a regexp");const r=e;super(r,n),this.#a=r.source,r instanceof N4&&(this.#t=r.#t,this.#n=r.#n,this.#i=r.#i,this.rawOptions=r.rawOptions)}else{const r={hiddenCaptures:[],strategy:null,transfers:[],...a};super(i?"":e,n),this.#a=e,this.#t=kze(r.hiddenCaptures,r.transfers),this.#i=r.strategy,this.rawOptions=a??{}}i||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:i,...r}=this.rawOptions;this.#e=new N4(this.#a,this.flags,r)}const n=this.global||this.sticky,a=this.lastIndex;if(this.#i==="clip_search"&&n&&a){this.lastIndex=0;const i=this.#r(e.slice(a));return i&&(_ze(i,a,e,this.hasIndices),this.lastIndex+=a),i}return this.#r(e)}#r(e){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const a=[...n];n.length=1;let i;this.hasIndices&&(i=[...n.indices],n.indices.length=1);const r=[0];for(let s=1;s<a.length;s++){const{hidden:o,transferTo:c}=this.#t.get(s)??{};if(o?r.push(null):(r.push(n.length),n.push(a[s]),this.hasIndices&&n.indices.push(i[s])),c&&a[s]!==void 0){const p=r[c];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(n[p]=a[s],this.hasIndices&&(n.indices[p]=i[s]),n.groups){this.#n||(this.#n=wze(this.source));const d=this.#n.get(c);d&&(n.groups[d]=a[s],this.hasIndices&&(n.indices.groups[d]=i[s]))}}}return n}};function _ze(t,e,n,a){if(t.index+=e,t.input=n,a){const i=t.indices;for(let s=0;s<i.length;s++){const o=i[s];o&&(i[s]=[o[0]+e,o[1]+e])}const r=i.groups;r&&Object.keys(r).forEach(s=>{const o=r[s];o&&(r[s]=[o[0]+e,o[1]+e])})}}function kze(t,e){const n=new Map;for(const a of t)n.set(a,{hidden:!0});for(const[a,i]of e)for(const r of i)Ah(n,r,{}).transferTo=a;return n}function wze(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let a=0,i=0,r;for(;r=e.exec(t);){const{0:s,groups:{capture:o,name:c}}=r;s==="["?a++:a?s==="]"&&a--:o&&(i++,c&&n.set(i,c))}return n}function xze(t,e){const n=Aze(t,e);return n.options?new y(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Aze(t,e){const n=QX(e),a=qX(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ST}),i=QFe(a,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),r=pze(i,n),s=HFe(r.pattern,{captureTransfers:r._captureTransfers,hiddenCaptures:r._hiddenCaptures,mode:"external"}),o=FFe(s.pattern),c=OFe(o.pattern,{captureTransfers:s.captureTransfers,hiddenCaptures:s.hiddenCaptures}),p={pattern:c.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${r.flags}${r.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const d=c.hiddenCaptures.sort((v,k)=>v-k),m=Array.from(c.captureTransfers),f=i._strategy,h=p.pattern.length>=n.lazyCompileLength;(d.length||m.length||f||h)&&(p.options={...d.length&&{hiddenCaptures:d},...m.length&&{transfers:m},...f&&{strategy:f},...h&&{lazyCompile:h}})}return p}function Cze(t,e){return xze(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function Nze(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>Cze(n,{target:e.target}),{createScanner(n){return new BOe(n,e)},createString(n){return{content:n}}}}var Sze=HOe({langs:{c:()=>Ee(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url),cpp:()=>Ee(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url),"c++":()=>Ee(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url),css:()=>Ee(()=>Promise.resolve().then(()=>Cat),void 0,import.meta.url),glsl:()=>Ee(()=>Promise.resolve().then(()=>vat),void 0,import.meta.url),graphql:()=>Ee(()=>Promise.resolve().then(()=>RO),void 0,import.meta.url),gql:()=>Ee(()=>Promise.resolve().then(()=>RO),void 0,import.meta.url),haml:()=>Ee(()=>Promise.resolve().then(()=>Lat),void 0,import.meta.url),html:()=>Ee(()=>Promise.resolve().then(()=>Dat),void 0,import.meta.url),java:()=>Ee(()=>Promise.resolve().then(()=>Rat),void 0,import.meta.url),javascript:()=>Ee(()=>Promise.resolve().then(()=>jO),void 0,import.meta.url),js:()=>Ee(()=>Promise.resolve().then(()=>jO),void 0,import.meta.url),json:()=>Ee(()=>Promise.resolve().then(()=>Fat),void 0,import.meta.url),jsonc:()=>Ee(()=>Promise.resolve().then(()=>Bat),void 0,import.meta.url),jsonl:()=>Ee(()=>Promise.resolve().then(()=>Vat),void 0,import.meta.url),jsx:()=>Ee(()=>Promise.resolve().then(()=>Eat),void 0,import.meta.url),julia:()=>Ee(()=>Promise.resolve().then(()=>FO),void 0,import.meta.url),jl:()=>Ee(()=>Promise.resolve().then(()=>FO),void 0,import.meta.url),less:()=>Ee(()=>Promise.resolve().then(()=>Jat),void 0,import.meta.url),markdown:()=>Ee(()=>Promise.resolve().then(()=>zO),void 0,import.meta.url),md:()=>Ee(()=>Promise.resolve().then(()=>zO),void 0,import.meta.url),mdx:()=>Ee(()=>Promise.resolve().then(()=>iit),void 0,import.meta.url),php:()=>Ee(()=>Promise.resolve().then(()=>pit),void 0,import.meta.url),postcss:()=>Ee(()=>Promise.resolve().then(()=>dit),void 0,import.meta.url),pug:()=>Ee(()=>Promise.resolve().then(()=>HO),void 0,import.meta.url),jade:()=>Ee(()=>Promise.resolve().then(()=>HO),void 0,import.meta.url),python:()=>Ee(()=>Promise.resolve().then(()=>OO),void 0,import.meta.url),py:()=>Ee(()=>Promise.resolve().then(()=>OO),void 0,import.meta.url),r:()=>Ee(()=>Promise.resolve().then(()=>Wat),void 0,import.meta.url),regexp:()=>Ee(()=>Promise.resolve().then(()=>MO),void 0,import.meta.url),regex:()=>Ee(()=>Promise.resolve().then(()=>MO),void 0,import.meta.url),sass:()=>Ee(()=>Promise.resolve().then(()=>hit),void 0,import.meta.url),scss:()=>Ee(()=>Promise.resolve().then(()=>yit),void 0,import.meta.url),shellscript:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),bash:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),sh:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),shell:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),zsh:()=>Ee(()=>Promise.resolve().then(()=>Kf),void 0,import.meta.url),sql:()=>Ee(()=>Promise.resolve().then(()=>_at),void 0,import.meta.url),svelte:()=>Ee(()=>Promise.resolve().then(()=>xit),void 0,import.meta.url),typescript:()=>Ee(()=>Promise.resolve().then(()=>DO),void 0,import.meta.url),ts:()=>Ee(()=>Promise.resolve().then(()=>DO),void 0,import.meta.url),vue:()=>Ee(()=>Promise.resolve().then(()=>Iit),void 0,import.meta.url),"vue-html":()=>Ee(()=>Promise.resolve().then(()=>Fit),void 0,import.meta.url),wasm:()=>Ee(()=>Promise.resolve().then(()=>Bit),void 0,import.meta.url),wgsl:()=>Ee(()=>Promise.resolve().then(()=>Vit),void 0,import.meta.url),xml:()=>Ee(()=>Promise.resolve().then(()=>sit),void 0,import.meta.url),yaml:()=>Ee(()=>Promise.resolve().then(()=>BO),void 0,import.meta.url),yml:()=>Ee(()=>Promise.resolve().then(()=>BO),void 0,import.meta.url),tsx:()=>Ee(()=>Promise.resolve().then(()=>IO),void 0,import.meta.url),typescriptreact:()=>Ee(()=>Promise.resolve().then(()=>IO),void 0,import.meta.url),haskell:()=>Ee(()=>Promise.resolve().then(()=>UO),void 0,import.meta.url),hs:()=>Ee(()=>Promise.resolve().then(()=>UO),void 0,import.meta.url),"c#":()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),csharp:()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),cs:()=>Ee(()=>Promise.resolve().then(()=>XC),void 0,import.meta.url),latex:()=>Ee(()=>Promise.resolve().then(()=>trt),void 0,import.meta.url),lua:()=>Ee(()=>Promise.resolve().then(()=>art),void 0,import.meta.url),mermaid:()=>Ee(()=>Promise.resolve().then(()=>qO),void 0,import.meta.url),mmd:()=>Ee(()=>Promise.resolve().then(()=>qO),void 0,import.meta.url),ruby:()=>Ee(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url),rb:()=>Ee(()=>Promise.resolve().then(()=>VO),void 0,import.meta.url),rust:()=>Ee(()=>Promise.resolve().then(()=>ZO),void 0,import.meta.url),rs:()=>Ee(()=>Promise.resolve().then(()=>ZO),void 0,import.meta.url),scala:()=>Ee(()=>Promise.resolve().then(()=>urt),void 0,import.meta.url),swift:()=>Ee(()=>Promise.resolve().then(()=>grt),void 0,import.meta.url),kotlin:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),kt:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),kts:()=>Ee(()=>Promise.resolve().then(()=>QC),void 0,import.meta.url),"objective-c":()=>Ee(()=>Promise.resolve().then(()=>GO),void 0,import.meta.url),objc:()=>Ee(()=>Promise.resolve().then(()=>GO),void 0,import.meta.url)},themes:{"github-dark":()=>Ee(()=>Promise.resolve().then(()=>krt),void 0,import.meta.url),"github-light":()=>Ee(()=>Promise.resolve().then(()=>xrt),void 0,import.meta.url)},engine:()=>Nze()}),$ze={defaultLanguage:"javascript",supportedLanguages:{text:{name:"Plain Text",aliases:["text","txt","plain"]},c:{name:"C",aliases:["c"]},cpp:{name:"C++",aliases:["cpp","c++"]},css:{name:"CSS",aliases:["css"]},glsl:{name:"GLSL",aliases:["glsl"]},graphql:{name:"GraphQL",aliases:["graphql","gql"]},haml:{name:"Ruby Haml",aliases:["haml"]},html:{name:"HTML",aliases:["html"]},java:{name:"Java",aliases:["java"]},javascript:{name:"JavaScript",aliases:["javascript","js"]},json:{name:"JSON",aliases:["json"]},jsonc:{name:"JSON with Comments",aliases:["jsonc"]},jsonl:{name:"JSON Lines",aliases:["jsonl"]},jsx:{name:"JSX",aliases:["jsx"]},julia:{name:"Julia",aliases:["julia","jl"]},less:{name:"Less",aliases:["less"]},markdown:{name:"Markdown",aliases:["markdown","md"]},mdx:{name:"MDX",aliases:["mdx"]},php:{name:"PHP",aliases:["php"]},postcss:{name:"PostCSS",aliases:["postcss"]},pug:{name:"Pug",aliases:["pug","jade"]},python:{name:"Python",aliases:["python","py"]},r:{name:"R",aliases:["r"]},regexp:{name:"RegExp",aliases:["regexp","regex"]},sass:{name:"Sass",aliases:["sass"]},scss:{name:"SCSS",aliases:["scss"]},shellscript:{name:"Shell",aliases:["shellscript","bash","sh","shell","zsh"]},sql:{name:"SQL",aliases:["sql"]},svelte:{name:"Svelte",aliases:["svelte"]},typescript:{name:"TypeScript",aliases:["typescript","ts"]},vue:{name:"Vue",aliases:["vue"]},"vue-html":{name:"Vue HTML",aliases:["vue-html"]},wasm:{name:"WebAssembly",aliases:["wasm"]},wgsl:{name:"WGSL",aliases:["wgsl"]},xml:{name:"XML",aliases:["xml"]},yaml:{name:"YAML",aliases:["yaml","yml"]},tsx:{name:"TSX",aliases:["tsx","typescriptreact"]},haskell:{name:"Haskell",aliases:["haskell","hs"]},csharp:{name:"C#",aliases:["c#","csharp","cs"]},latex:{name:"LaTeX",aliases:["latex"]},lua:{name:"Lua",aliases:["lua"]},mermaid:{name:"Mermaid",aliases:["mermaid","mmd"]},ruby:{name:"Ruby",aliases:["ruby","rb"]},rust:{name:"Rust",aliases:["rust","rs"]},scala:{name:"Scala",aliases:["scala"]},swift:{name:"Swift",aliases:["swift"]},kotlin:{name:"Kotlin",aliases:["kotlin","kt","kts"]},"objective-c":{name:"Objective C",aliases:["objective-c","objc"]}},createHighlighter:()=>Sze({themes:["github-dark","github-light"],langs:[]})};const{audio:Grt,file:Wrt,video:Krt,table:Yrt,toggleListItem:Xrt,codeBlock:Qrt,...Eze}=ZV,{underline:Jrt,...Tze}=V0,Pze=U$.create({blockSpecs:{...Eze,codeBlock:IV($ze)},inlineContentSpecs:B$,styleSpecs:Tze});function XR(){const t=getComputedStyle(document.documentElement),e=a=>`hsl(${t.getPropertyValue(`--${a}`).trim()})`,n=t.getPropertyValue("--font-sans").trim();return{colors:{editor:{text:e("foreground"),background:e("background")},menu:{text:e("popover-foreground"),background:e("popover")},tooltip:{text:e("popover-foreground"),background:e("popover")},hovered:{text:e("accent-foreground"),background:e("accent")},selected:{text:e("primary-foreground"),background:e("primary")},disabled:{text:e("muted-foreground"),background:e("muted")},shadow:"transparent",border:e("border"),sideMenu:e("border-strong")},borderRadius:6,fontFamily:n||"Inter, system-ui, sans-serif"}}function Mze(){const[t,e]=S.useState(XR);return S.useEffect(()=>{const n=new MutationObserver(()=>e(XR()));return n.observe(document.documentElement,{attributeFilter:["class","style"]}),()=>n.disconnect()},[]),t}function X_({value:t,onChange:e,readOnly:n=!1,placeholder:a,minHeight:i="120px"}){const r=!n&&!!e,s=S.useRef(!0),o=Mze(),[c,p]=S.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light");S.useEffect(()=>{const f=new MutationObserver(()=>{p(document.documentElement.classList.contains("dark")?"dark":"light")});return f.observe(document.documentElement,{attributeFilter:["class"]}),()=>f.disconnect()},[]);const d=mk({schema:Pze});S.useEffect(()=>{const f=d.portalElement;f&&f.style.setProperty("--bn-ui-base-z-index","150")},[d]),S.useEffect(()=>{const f=d.portalElement;f&&(f.setAttribute("data-mantine-color-scheme",c),f.setAttribute("data-color-scheme",c))},[d,c]),S.useEffect(()=>{if(d.blocksToMarkdownLossy(d.document).replace(/^ +$/gm,"")===(t||""))return;s.current=!0;const h=d.tryParseMarkdownToBlocks(t||"");d.replaceBlocks(d.document,h),requestAnimationFrame(()=>{s.current=!1})},[t,d]);const m=S.useCallback(()=>{if(s.current||!e)return;const h=d.blocksToMarkdownLossy(d.document).replace(/^ +$/gm,"");e(h)},[d,e]);return b.jsx("div",{className:"blocknote-editor-wrapper rounded-[6px] overflow-hidden",style:{minHeight:i},"data-placeholder":a,"data-mantine-color-scheme":c,"data-color-scheme":c,children:b.jsx(lX,{editor:d,theme:o,editable:r,onChange:m})})}function Lze(){const{t}=Tn(),e=se(E=>E.drawerTaskId),n=se(E=>E.drawerData),a=se(E=>E.columns),i=se(E=>E.config),r=se(E=>E.projectName),s=se(E=>E.toast),o=se(E=>E.closeDrawer),c=se(E=>E.saveDrawer),p=se(E=>E.saveDrawerMetadata),d=se(E=>E.deleteTask),m=se(E=>E.archiveTask),f=se(E=>E.unarchiveTask),h=se(E=>E.agentHook),v=se(E=>E.sendTaskToAgent),k=se(E=>E.hasUnsavedDrawerEdits),w=se(E=>E.lastSaveError),A=se(E=>E.markDrawerDirty),$=se(E=>E.forceCloseDrawer),T=String(n?.frontmatter.archived)==="true",M=se(E=>E.updateDrawerData),j=S.useRef(null),D=S.useRef(null),I=S.useRef(!1),H=!!e&&!!n,[R,L]=S.useState(()=>window.matchMedia("(min-width: 768px)").matches);S.useEffect(()=>{const E=window.matchMedia("(min-width: 768px)"),B=()=>L(E.matches);return B(),E.addEventListener("change",B),()=>E.removeEventListener("change",B)},[]);const G=S.useCallback(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{I.current||(I.current=!0,p().finally(()=>{I.current=!1}))},150)},[p]),Y=S.useCallback(async()=>{D.current&&clearTimeout(D.current),D.current=null,I.current&&await new Promise(E=>{const B=setInterval(()=>{I.current||(clearInterval(B),E(void 0))},20)})},[]),ne=S.useCallback(async()=>{await Y(),await c()},[Y,c]),U=S.useCallback(async()=>{if(k||w){const E=w?`${w}
|
|
709
709
|
|
|
710
710
|
Discard your unsaved edits? They will be kept as a draft you can restore.`:"You have unsaved edits. Discard them? They will be kept as a draft you can restore.";if(!confirm(E))return;$();return}await ne()},[k,w,$,ne]),F=S.useCallback(async()=>{await Y(),o()},[Y,o]),V=S.useCallback(async()=>{e&&confirm(`${t("common.delete")} ${e.toUpperCase()}?`)&&(await d(e),await F())},[F,d,e,t]),Q=S.useCallback(async()=>{e&&(T?await f(e):(await Y(),await m(e)))},[e,T,m,f,Y]),J=e?a.find(E=>E.tasks.some(B=>B.id===e))?.name:null,oe=S.useCallback(()=>{e&&v(e)},[e,v]),O=S.useCallback(async()=>{if(!e)return;const E=new URL(bS(e,r),window.location.origin).toString();try{await navigator.clipboard.writeText(E),s("Task URL copied","success")}catch{s(E,"info",8e3)}},[e,r,s]),Z=S.useMemo(()=>{const E=new Map,B=(i.board.columns[i.board.columns.length-1]||"Done").toLowerCase();for(const ae of a)for(const X of ae.tasks){const ge=X.frontmatter&&(X.frontmatter.archived===!0||X.frontmatter.archived==="true");E.set(X.id,{exists:!0,resolved:ge||ae.name.toLowerCase()===B})}for(const ae of a)for(const X of ae.tasks){const ge=Array.isArray(X.frontmatter.depends_on)?X.frontmatter.depends_on:[];for(const be of ge)typeof be!="string"||!be.trim()||E.has(be)||E.set(be,{exists:!1,resolved:!0})}return E},[a,i.board.columns]);if(S.useEffect(()=>{H&&!R&&setTimeout(()=>j.current?.focus(),250)},[H,R]),S.useEffect(()=>{j.current&&(j.current.style.height="auto",j.current.style.height=j.current.scrollHeight+"px")},[n?.frontmatter.title]),S.useEffect(()=>{if(!H||R)return;const E=B=>{B.key==="Escape"&&!B.defaultPrevented&&U(),(B.metaKey||B.ctrlKey)&&B.key==="s"&&(B.preventDefault(),ne()),(B.metaKey||B.ctrlKey)&&B.key==="Backspace"&&(B.preventDefault(),V())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[H,R,U,ne,V]),!n||R)return null;const K=(E,B)=>{M(ae=>({...ae,frontmatter:{...ae.frontmatter,[E]:B}})),A(),G()};return b.jsx(Wa,{children:H&&b.jsxs(b.Fragment,{children:[b.jsx(nt.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0},onClick:U,className:"fixed inset-0 bg-black/50 backdrop-blur-[4px] z-[100]"}),b.jsx(nt.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:0},className:"fixed inset-0 z-[101] flex items-center justify-center p-[10vh] pointer-events-none",children:b.jsxs("div",{className:"w-[80vw] max-w-[1200px] h-[80vh] pointer-events-auto flex flex-col glass rounded-2xl shadow-2xl",children:[b.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border rounded-t-2xl",children:[b.jsxs("div",{className:"flex items-center gap-2.5",children:[b.jsx("span",{className:"font-mono text-[12.5px] text-fg-muted px-1.5 py-0.5 bg-bg-2 border border-border rounded-[4px]",children:e?.toUpperCase()}),J&&b.jsxs("span",{className:"text-[12.5px] text-fg-dim",children:["· ",J]}),b.jsx("button",{type:"button",onClick:O,className:"text-[12.5px] text-fg-muted underline underline-offset-2 hover:text-fg",title:"Copy task URL",children:"Copy URL"})]}),b.jsx(an,{variant:"icon",icon:"X",onClick:U,title:t("drawer.close")})]}),b.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-5",children:b.jsxs("div",{className:"flex flex-col gap-5",children:[b.jsx("textarea",{ref:j,value:n.frontmatter.title||"",onChange:E=>K("title",E.target.value),placeholder:t("drawer.taskTitle"),rows:1,className:"w-full bg-transparent border-none outline-none text-fg text-[22px] font-semibold tracking-tight leading-tight resize-none placeholder:text-fg-faint"}),b.jsx("div",{className:"h-px bg-border -mx-5"}),b.jsxs("div",{children:[b.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-wider text-fg-muted mb-2",children:t("dependencies.label")}),b.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:(Array.isArray(n.frontmatter.depends_on)?n.frontmatter.depends_on.filter(E=>typeof E=="string"):[]).map((E,B)=>{const ae=Z.get(E)?.resolved??!1,X=Z.get(E)?.exists??!0;return b.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-[12px] font-mono border ${X?ae?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-red-500/40 bg-red-500/10 text-red-700 dark:text-red-300"}`,title:t(X?ae?"dependencies.resolved":"dependencies.unresolved":"dependencies.unknown"),children:[E,b.jsx("button",{type:"button","aria-label":t("dependencies.remove"),onClick:()=>{const ge=(Array.isArray(n.frontmatter.depends_on)?n.frontmatter.depends_on:[]).filter((be,ke)=>ke!==B);K("depends_on",ge.length>0?ge:void 0)},className:"text-current opacity-60 hover:opacity-100",children:"×"})]},B)})}),b.jsx("input",{type:"text",className:"w-full bg-bg-2 border border-border rounded px-2 py-1.5 text-[13px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-border-strong",placeholder:t("dependencies.addPlaceholder"),onKeyDown:E=>{if(E.key!=="Enter")return;E.preventDefault();const B=(E.currentTarget.value||"").trim();if(!B)return;const ae=B.replace(/^#/,"").trim(),X=Array.isArray(n.frontmatter.depends_on)?n.frontmatter.depends_on.filter(ge=>typeof ge=="string"):[];if(X.includes(ae)||ae===n.frontmatter.id){E.currentTarget.value="";return}K("depends_on",[...X,ae]),E.currentTarget.value=""}})]}),b.jsx("div",{className:"h-px bg-border -mx-5"}),b.jsxs("div",{children:[b.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-wider text-fg-muted mb-2",children:t("drawer.description")}),b.jsx(X_,{value:n.body,onChange:E=>{M(B=>({...B,body:E})),A(),G()},placeholder:t("drawer.descriptionPlaceholder"),minHeight:"280px"})]}),b.jsx("div",{className:"h-px bg-border -mx-5"}),b.jsxs("div",{children:[b.jsx("div",{className:"text-[12px] font-semibold uppercase tracking-wider text-fg-muted mb-2",children:t("drawer.report")}),b.jsx(X_,{value:n.frontmatter.report||"",onChange:E=>K("report",E),placeholder:t("drawer.reportPlaceholder"),minHeight:"180px"})]})]})}),w&&b.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-danger/10 border-t border-danger/30",children:[b.jsx("span",{className:"text-danger text-[12px] flex-1 truncate",title:w,children:w}),b.jsx(an,{variant:"primary",label:"Retry save",onClick:c})]}),b.jsxs("div",{className:"flex items-center justify-between gap-2 px-5 py-3 border-t border-border rounded-b-2xl",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(an,{variant:"danger",icon:"Trash",label:t("drawer.deleteTask"),shortcut:"⌘⌫",onClick:V}),b.jsx(an,{variant:"secondary",icon:T?"ArchiveRestore":"Archive",label:t(T?"drawer.restore":"drawer.archive"),onClick:Q}),h&&b.jsx(an,{variant:"secondary",icon:"Arrow",label:`${t("drawer.sendToAgent")} · ${h.label}`,onClick:oe,title:t("drawer.sendToAgentTitle")})]}),b.jsxs("div",{className:"flex items-center gap-2",children:[k&&b.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-300",title:"Unsaved edits kept as a draft if you close",children:"● unsaved"}),b.jsx(an,{variant:"secondary",label:t("drawer.cancel"),shortcut:"Esc",onClick:U}),b.jsx(an,{variant:"primary",label:t("drawer.saveClose"),shortcut:"⌘S",onClick:c})]})]})]})})]})})}const jze={P1:"#e5484d",P2:"#e9a23b",P3:"#3e63dd",P4:"#6e6e6e"};function Dze(t){return[t.priority||null,t.assignee?`@${t.assignee}`:null,t.progress?`${t.progress.done}/${t.progress.total}`:null].filter(n=>!!n).join(" · ")}function Ize({collapsed:t}){return b.jsx("span",{"aria-hidden":"true",className:`inline-flex transition-transform ${t?"-rotate-90":""}`,children:b.jsx(Wn.ChevronDown,{size:13})})}function Rze({column:t,collapsed:e,activeTaskId:n,onToggle:a,onSelectTask:i}){return b.jsxs("section",{className:"overflow-hidden rounded-xl border border-border bg-bg/45",children:[b.jsxs("button",{type:"button",onClick:()=>a(t.name),className:"flex w-full items-center justify-between gap-3 border-b border-border bg-bg-1/70 px-3 py-2.5 text-left hover:bg-bg-2 transition-colors",children:[b.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[b.jsx(Ize,{collapsed:e}),b.jsx("span",{className:"truncate text-[13px] font-semibold text-fg",children:t.name})]}),b.jsx("span",{className:"rounded-full border border-border bg-bg px-2 py-0.5 font-mono text-[11px] text-fg-muted",children:t.tasks.length})]}),b.jsx(Wa,{initial:!1,children:!e&&b.jsx(nt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.16},className:"overflow-hidden",children:t.tasks.length===0?b.jsx("div",{className:"px-3 py-4 text-[12.5px] text-fg-muted",children:"No tasks in this status."}):b.jsx("div",{className:"py-1.5",children:t.tasks.map(r=>{const s=r.id===n,o=Dze(r);return b.jsxs("button",{type:"button",onClick:()=>i(r.id),className:`group flex w-full items-start gap-2.5 px-3 py-2.5 text-left transition-colors ${s?"bg-accent/15 text-fg":"text-fg-muted hover:bg-bg-2 hover:text-fg"}`,children:[b.jsx("span",{className:`mt-0.5 rounded border px-1.5 py-0.5 font-mono text-[11px] ${s?"border-accent/40 bg-accent/15 text-accent":"border-border bg-bg text-fg-muted"}`,children:r.id.replace(/^t/,"")}),b.jsxs("span",{className:"min-w-0 flex-1",children:[b.jsx("span",{className:`block truncate text-[13px] font-medium ${r.checked?"line-through opacity-70":""}`,children:r.title}),o&&b.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 truncate text-[11.5px] text-fg-faint",children:[r.priority&&b.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:jze[r.priority]}}),o]})]})]},r.id)})})})})]})}function Oze(){const{t}=Tn(),e=se(X=>X.drawerTaskId),n=se(X=>X.drawerData),a=se(X=>X.columns),i=se(X=>X.config),r=se(X=>X.projectName),s=se(X=>X.toast),o=se(X=>X.openDrawer),c=se(X=>X.closeDrawer),p=se(X=>X.saveDrawer),d=se(X=>X.saveDrawerMetadata),m=se(X=>X.deleteTask),f=se(X=>X.archiveTask),h=se(X=>X.unarchiveTask),v=se(X=>X.agentHook),k=se(X=>X.sendTaskToAgent),w=se(X=>X.hasUnsavedDrawerEdits),A=se(X=>X.lastSaveError),$=se(X=>X.markDrawerDirty),T=se(X=>X.forceCloseDrawer),M=se(X=>X.updateDrawerData),j=S.useRef(null),D=S.useRef(null),I=S.useRef(!1),[H,R]=S.useState(()=>new Set),L=String(n?.frontmatter.archived)==="true",G=!!e&&!!n,Y=e?a.find(X=>X.tasks.some(ge=>ge.id===e))?.name:null,ne=S.useMemo(()=>{const X=new Map,ge=(i.board.columns[i.board.columns.length-1]||"Done").toLowerCase();for(const be of a)for(const ke of be.tasks){const Xe=ke.frontmatter.archived===!0||ke.frontmatter.archived==="true";X.set(ke.id,{exists:!0,resolved:Xe||be.name.toLowerCase()===ge})}for(const be of a)for(const ke of be.tasks){const Xe=Array.isArray(ke.frontmatter.depends_on)?ke.frontmatter.depends_on:[];for(const it of Xe)typeof it!="string"||!it.trim()||X.has(it)||X.set(it,{exists:!1,resolved:!0})}return X},[a,i.board.columns]),U=S.useCallback(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{I.current||(I.current=!0,d().finally(()=>{I.current=!1}))},150)},[d]),F=S.useCallback(async()=>{D.current&&clearTimeout(D.current),D.current=null,I.current&&await new Promise(X=>{const ge=setInterval(()=>{I.current||(clearInterval(ge),X(void 0))},20)})},[]),V=S.useCallback(async()=>{await F(),await p()},[F,p]),Q=S.useCallback(async()=>{if(w||A){const X=A?`${A}
|
|
711
711
|
|