lula2 0.7.3 → 0.7.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.
Files changed (35) hide show
  1. package/README.md +0 -1
  2. package/dist/_app/immutable/chunks/{DqNseCFX.js → BI-GirXZ.js} +1 -1
  3. package/dist/_app/immutable/chunks/{DHBD-O6i.js → BIdjJ0zz.js} +1 -1
  4. package/dist/_app/immutable/chunks/BSyVkqhj.js +2 -0
  5. package/dist/_app/immutable/chunks/{DzukiT8m.js → Cng7c2CG.js} +1 -1
  6. package/dist/_app/immutable/chunks/CxBMFlfX.js +1 -0
  7. package/dist/_app/immutable/chunks/{D5ermNRH.js → DArZRX9-.js} +36 -36
  8. package/dist/_app/immutable/chunks/{CUt21Xol.js → DH2IP9c7.js} +1 -1
  9. package/dist/_app/immutable/chunks/{BBITAbWI.js → DXSHWIjJ.js} +1 -1
  10. package/dist/_app/immutable/chunks/{Cih4fRH-.js → DsuS1uUo.js} +1 -1
  11. package/dist/_app/immutable/chunks/urFjAlpd.js +1 -0
  12. package/dist/_app/immutable/entry/{app.BvGur0mr.js → app.CjycYot0.js} +2 -2
  13. package/dist/_app/immutable/entry/start.Bgy9x4Qb.js +1 -0
  14. package/dist/_app/immutable/nodes/{0.Dx6r-xPK.js → 0.CGKh5y4X.js} +1 -1
  15. package/dist/_app/immutable/nodes/{1.COpX6TiD.js → 1.D5L7DxSG.js} +1 -1
  16. package/dist/_app/immutable/nodes/{2.zlTZskRg.js → 2.Hrl6uq-b.js} +1 -1
  17. package/dist/_app/immutable/nodes/{3.BafDPdLR.js → 3.BoHxdRm3.js} +1 -1
  18. package/dist/_app/immutable/nodes/{4.CoEqSeTv.js → 4.DAVWsDkK.js} +1 -1
  19. package/dist/_app/version.json +1 -1
  20. package/dist/cli/commands/ui.js +46 -41
  21. package/dist/cli/server/index.js +46 -41
  22. package/dist/cli/server/server.js +46 -41
  23. package/dist/cli/server/serverState.js +23 -11
  24. package/dist/cli/server/websocketServer.js +40 -41
  25. package/dist/index.html +11 -11
  26. package/dist/index.js +49 -44
  27. package/package.json +2 -2
  28. package/src/lib/components/controls/MappingCard.svelte +3 -3
  29. package/src/lib/components/controls/tabs/MappingsTab.svelte +27 -17
  30. package/src/lib/types.ts +2 -0
  31. package/src/lib/websocket.ts +2 -6
  32. package/dist/_app/immutable/chunks/B3ME9fYB.js +0 -1
  33. package/dist/_app/immutable/chunks/DtiGB2s7.js +0 -2
  34. package/dist/_app/immutable/chunks/R-CI0WwD.js +0 -1
  35. package/dist/_app/immutable/entry/start.yE51hRYN.js +0 -1
@@ -109,6 +109,7 @@ import {
109
109
  } from "fs";
110
110
  import * as yaml2 from "js-yaml";
111
111
  import { join as join2 } from "path";
112
+ import { createHash } from "crypto";
112
113
  var FileStore;
113
114
  var init_fileStore = __esm({
114
115
  "cli/server/infrastructure/fileStore.ts"() {
@@ -406,6 +407,10 @@ var init_fileStore = __esm({
406
407
  const content = readFileSync2(mappingFile, "utf8");
407
408
  const parsed = yaml2.load(content);
408
409
  if (Array.isArray(parsed)) {
410
+ parsed.forEach((mapping) => {
411
+ mapping.hash = createHash("sha256").update(JSON.stringify(mapping)).digest("hex");
412
+ return mapping;
413
+ });
409
414
  mappings.push(...parsed);
410
415
  }
411
416
  } catch (error) {
@@ -440,12 +445,9 @@ var init_fileStore = __esm({
440
445
  existingMappings = [];
441
446
  }
442
447
  }
443
- const existingIndex = existingMappings.findIndex((m) => m.uuid === mapping.uuid);
444
- if (existingIndex >= 0) {
445
- existingMappings[existingIndex] = mapping;
446
- } else {
447
- existingMappings.push(mapping);
448
- }
448
+ const cleanMapping = { ...mapping };
449
+ delete cleanMapping.hash;
450
+ existingMappings.push(cleanMapping);
449
451
  try {
450
452
  const yamlContent = yaml2.dump(existingMappings, {
451
453
  indent: 2,
@@ -470,7 +472,8 @@ var init_fileStore = __esm({
470
472
  let mappings = yaml2.load(content) || [];
471
473
  const originalLength = mappings.length;
472
474
  mappings = mappings.filter((m) => {
473
- return `${m.control_id}:${m.uuid}` !== compositeKey;
475
+ const hash = createHash("sha256").update(JSON.stringify(m)).digest("hex");
476
+ return `${m.control_id}:${hash}` !== compositeKey;
474
477
  });
475
478
  if (mappings.length < originalLength) {
476
479
  if (mappings.length === 0) {
@@ -533,8 +536,13 @@ var init_fileStore = __esm({
533
536
  if (!existsSync2(familyDir)) {
534
537
  mkdirSync(familyDir, { recursive: true });
535
538
  }
539
+ const cleanMappings = controlMappings.map((m) => {
540
+ const clean = { ...m };
541
+ delete clean.hash;
542
+ return clean;
543
+ });
536
544
  try {
537
- const yamlContent = yaml2.dump(controlMappings, {
545
+ const yamlContent = yaml2.dump(cleanMappings, {
538
546
  indent: 2,
539
547
  lineWidth: -1,
540
548
  noRefs: true
@@ -1453,6 +1461,7 @@ __export(serverState_exports, {
1453
1461
  saveMappingsToFile: () => saveMappingsToFile
1454
1462
  });
1455
1463
  import { join as join3 } from "path";
1464
+ import { createHash as createHash2 } from "crypto";
1456
1465
  function initializeServerState(controlSetDir, subdir = ".") {
1457
1466
  const fullPath = subdir === "." ? controlSetDir : join3(controlSetDir, subdir);
1458
1467
  serverState = {
@@ -1495,11 +1504,11 @@ function addMappingToIndexes(mapping) {
1495
1504
  if (!state.mappingsByFamily.has(family)) {
1496
1505
  state.mappingsByFamily.set(family, /* @__PURE__ */ new Set());
1497
1506
  }
1498
- state.mappingsByFamily.get(family).add(mapping.uuid);
1507
+ state.mappingsByFamily.get(family).add(mapping.hash);
1499
1508
  if (!state.mappingsByControl.has(mapping.control_id)) {
1500
1509
  state.mappingsByControl.set(mapping.control_id, /* @__PURE__ */ new Set());
1501
1510
  }
1502
- state.mappingsByControl.get(mapping.control_id).add(mapping.uuid);
1511
+ state.mappingsByControl.get(mapping.control_id).add(mapping.hash);
1503
1512
  }
1504
1513
  async function loadAllData() {
1505
1514
  const state = getServerState();
@@ -1513,7 +1522,10 @@ async function loadAllData() {
1513
1522
  debug(`Loaded ${controls.length} controls from individual files`);
1514
1523
  const mappings = await state.fileStore.loadMappings();
1515
1524
  for (const mapping of mappings) {
1516
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
1525
+ if (!mapping.hash) {
1526
+ mapping.hash = createHash2("sha256").update(JSON.stringify(mapping)).digest("hex");
1527
+ }
1528
+ const compositeKey = `${mapping.control_id}:${mapping.hash}`;
1517
1529
  state.mappingsCache.set(compositeKey, mapping);
1518
1530
  addMappingToIndexes(mapping);
1519
1531
  }
@@ -2646,6 +2658,7 @@ init_gitHistory();
2646
2658
  import * as yaml5 from "js-yaml";
2647
2659
  import { join as join5 } from "path";
2648
2660
  import { WebSocket, WebSocketServer } from "ws";
2661
+ import crypto2 from "node:crypto";
2649
2662
  var WebSocketManager = class {
2650
2663
  wss = null;
2651
2664
  clients = /* @__PURE__ */ new Set();
@@ -2710,21 +2723,24 @@ var WebSocketManager = class {
2710
2723
  if (payload && payload.control_id) {
2711
2724
  const mapping = payload;
2712
2725
  if (!mapping.uuid) {
2713
- const crypto2 = await import("crypto");
2714
- mapping.uuid = crypto2.randomUUID();
2726
+ const crypto3 = await import("crypto");
2727
+ mapping.uuid = crypto3.randomUUID();
2715
2728
  }
2729
+ if (!mapping.hash || mapping.hash === "") {
2730
+ mapping.hash = crypto2.createHash("sha256").update(JSON.stringify(mapping)).digest("hex");
2731
+ }
2732
+ const compositeKey = `${mapping.control_id}:${mapping.hash}`;
2716
2733
  await state.fileStore.saveMapping(mapping);
2717
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
2718
2734
  state.mappingsCache.set(compositeKey, mapping);
2719
2735
  const family = mapping.control_id.split("-")[0];
2720
2736
  if (!state.mappingsByFamily.has(family)) {
2721
2737
  state.mappingsByFamily.set(family, /* @__PURE__ */ new Set());
2722
2738
  }
2723
- state.mappingsByFamily.get(family)?.add(mapping.uuid);
2739
+ state.mappingsByFamily.get(family)?.add(mapping.hash);
2724
2740
  if (!state.mappingsByControl.has(mapping.control_id)) {
2725
2741
  state.mappingsByControl.set(mapping.control_id, /* @__PURE__ */ new Set());
2726
2742
  }
2727
- state.mappingsByControl.get(mapping.control_id)?.add(mapping.uuid);
2743
+ state.mappingsByControl.get(mapping.control_id)?.add(mapping.hash);
2728
2744
  ws.send(
2729
2745
  JSON.stringify({
2730
2746
  type: "mapping-created",
@@ -2735,38 +2751,21 @@ var WebSocketManager = class {
2735
2751
  }
2736
2752
  break;
2737
2753
  }
2738
- case "update-mapping": {
2739
- const state = getServerState();
2740
- if (payload && payload.uuid) {
2741
- const mapping = payload;
2742
- await state.fileStore.saveMapping(mapping);
2743
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
2744
- state.mappingsCache.set(compositeKey, mapping);
2745
- ws.send(
2746
- JSON.stringify({
2747
- type: "mapping-updated",
2748
- payload: { uuid: mapping.uuid, success: true }
2749
- })
2750
- );
2751
- this.broadcastState();
2752
- }
2753
- break;
2754
- }
2755
2754
  case "delete-mapping": {
2756
2755
  const state = getServerState();
2757
- if (payload && payload.uuid) {
2758
- const uuid = payload.uuid;
2759
- const mapping = state.mappingsCache.get(uuid);
2756
+ if (payload && payload.composite_key) {
2757
+ const composite_key = payload.composite_key;
2758
+ const mapping = state.mappingsCache.get(composite_key);
2760
2759
  if (mapping) {
2761
- await state.fileStore.deleteMapping(uuid);
2762
- state.mappingsCache.delete(uuid);
2760
+ await state.fileStore.deleteMapping(composite_key);
2761
+ state.mappingsCache.delete(composite_key);
2763
2762
  const family = mapping.control_id.split("-")[0];
2764
- state.mappingsByFamily.get(family)?.delete(uuid);
2765
- state.mappingsByControl.get(mapping.control_id)?.delete(uuid);
2763
+ state.mappingsByFamily.get(family)?.delete(mapping.hash);
2764
+ state.mappingsByControl.get(mapping.control_id)?.delete(mapping.hash);
2766
2765
  ws.send(
2767
2766
  JSON.stringify({
2768
2767
  type: "mapping-deleted",
2769
- payload: { uuid, success: true }
2768
+ payload: { hash: mapping.hash, success: true }
2770
2769
  })
2771
2770
  );
2772
2771
  this.broadcastState();
package/dist/index.html CHANGED
@@ -6,28 +6,28 @@
6
6
  <link rel="icon" href="/lula.png" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1" />
8
8
 
9
- <link rel="modulepreload" href="/_app/immutable/entry/start.yE51hRYN.js">
10
- <link rel="modulepreload" href="/_app/immutable/chunks/CUt21Xol.js">
11
- <link rel="modulepreload" href="/_app/immutable/chunks/B3ME9fYB.js">
12
- <link rel="modulepreload" href="/_app/immutable/entry/app.BvGur0mr.js">
13
- <link rel="modulepreload" href="/_app/immutable/chunks/BBITAbWI.js">
14
- <link rel="modulepreload" href="/_app/immutable/chunks/DzukiT8m.js">
15
- <link rel="modulepreload" href="/_app/immutable/chunks/R-CI0WwD.js">
16
- <link rel="modulepreload" href="/_app/immutable/chunks/Cih4fRH-.js">
9
+ <link rel="modulepreload" href="/_app/immutable/entry/start.Bgy9x4Qb.js">
10
+ <link rel="modulepreload" href="/_app/immutable/chunks/DH2IP9c7.js">
11
+ <link rel="modulepreload" href="/_app/immutable/chunks/CxBMFlfX.js">
12
+ <link rel="modulepreload" href="/_app/immutable/entry/app.CjycYot0.js">
13
+ <link rel="modulepreload" href="/_app/immutable/chunks/DXSHWIjJ.js">
14
+ <link rel="modulepreload" href="/_app/immutable/chunks/Cng7c2CG.js">
15
+ <link rel="modulepreload" href="/_app/immutable/chunks/urFjAlpd.js">
16
+ <link rel="modulepreload" href="/_app/immutable/chunks/DsuS1uUo.js">
17
17
  </head>
18
18
  <body data-sveltekit-preload-data="hover">
19
19
  <div style="display: contents">
20
20
  <script>
21
21
  {
22
- __sveltekit_owc510 = {
22
+ __sveltekit_sd3spo = {
23
23
  base: ""
24
24
  };
25
25
 
26
26
  const element = document.currentScript.parentElement;
27
27
 
28
28
  Promise.all([
29
- import("/_app/immutable/entry/start.yE51hRYN.js"),
30
- import("/_app/immutable/entry/app.BvGur0mr.js")
29
+ import("/_app/immutable/entry/start.Bgy9x4Qb.js"),
30
+ import("/_app/immutable/entry/app.CjycYot0.js")
31
31
  ]).then(([kit, app]) => {
32
32
  kit.start(app, element);
33
33
  });
package/dist/index.js CHANGED
@@ -1681,6 +1681,7 @@ import {
1681
1681
  } from "fs";
1682
1682
  import * as yaml2 from "js-yaml";
1683
1683
  import { join as join2 } from "path";
1684
+ import { createHash as createHash2 } from "crypto";
1684
1685
  var FileStore;
1685
1686
  var init_fileStore = __esm({
1686
1687
  "cli/server/infrastructure/fileStore.ts"() {
@@ -1978,6 +1979,10 @@ var init_fileStore = __esm({
1978
1979
  const content = readFileSync2(mappingFile, "utf8");
1979
1980
  const parsed = yaml2.load(content);
1980
1981
  if (Array.isArray(parsed)) {
1982
+ parsed.forEach((mapping) => {
1983
+ mapping.hash = createHash2("sha256").update(JSON.stringify(mapping)).digest("hex");
1984
+ return mapping;
1985
+ });
1981
1986
  mappings.push(...parsed);
1982
1987
  }
1983
1988
  } catch (error) {
@@ -2012,12 +2017,9 @@ var init_fileStore = __esm({
2012
2017
  existingMappings = [];
2013
2018
  }
2014
2019
  }
2015
- const existingIndex = existingMappings.findIndex((m) => m.uuid === mapping.uuid);
2016
- if (existingIndex >= 0) {
2017
- existingMappings[existingIndex] = mapping;
2018
- } else {
2019
- existingMappings.push(mapping);
2020
- }
2020
+ const cleanMapping = { ...mapping };
2021
+ delete cleanMapping.hash;
2022
+ existingMappings.push(cleanMapping);
2021
2023
  try {
2022
2024
  const yamlContent = yaml2.dump(existingMappings, {
2023
2025
  indent: 2,
@@ -2042,7 +2044,8 @@ var init_fileStore = __esm({
2042
2044
  let mappings = yaml2.load(content) || [];
2043
2045
  const originalLength = mappings.length;
2044
2046
  mappings = mappings.filter((m) => {
2045
- return `${m.control_id}:${m.uuid}` !== compositeKey;
2047
+ const hash = createHash2("sha256").update(JSON.stringify(m)).digest("hex");
2048
+ return `${m.control_id}:${hash}` !== compositeKey;
2046
2049
  });
2047
2050
  if (mappings.length < originalLength) {
2048
2051
  if (mappings.length === 0) {
@@ -2105,8 +2108,13 @@ var init_fileStore = __esm({
2105
2108
  if (!existsSync2(familyDir)) {
2106
2109
  mkdirSync(familyDir, { recursive: true });
2107
2110
  }
2111
+ const cleanMappings = controlMappings.map((m) => {
2112
+ const clean = { ...m };
2113
+ delete clean.hash;
2114
+ return clean;
2115
+ });
2108
2116
  try {
2109
- const yamlContent = yaml2.dump(controlMappings, {
2117
+ const yamlContent = yaml2.dump(cleanMappings, {
2110
2118
  indent: 2,
2111
2119
  lineWidth: -1,
2112
2120
  noRefs: true
@@ -3025,6 +3033,7 @@ __export(serverState_exports, {
3025
3033
  saveMappingsToFile: () => saveMappingsToFile
3026
3034
  });
3027
3035
  import { join as join3 } from "path";
3036
+ import { createHash as createHash3 } from "crypto";
3028
3037
  function initializeServerState(controlSetDir, subdir = ".") {
3029
3038
  const fullPath = subdir === "." ? controlSetDir : join3(controlSetDir, subdir);
3030
3039
  serverState = {
@@ -3067,11 +3076,11 @@ function addMappingToIndexes(mapping) {
3067
3076
  if (!state.mappingsByFamily.has(family)) {
3068
3077
  state.mappingsByFamily.set(family, /* @__PURE__ */ new Set());
3069
3078
  }
3070
- state.mappingsByFamily.get(family).add(mapping.uuid);
3079
+ state.mappingsByFamily.get(family).add(mapping.hash);
3071
3080
  if (!state.mappingsByControl.has(mapping.control_id)) {
3072
3081
  state.mappingsByControl.set(mapping.control_id, /* @__PURE__ */ new Set());
3073
3082
  }
3074
- state.mappingsByControl.get(mapping.control_id).add(mapping.uuid);
3083
+ state.mappingsByControl.get(mapping.control_id).add(mapping.hash);
3075
3084
  }
3076
3085
  async function loadAllData() {
3077
3086
  const state = getServerState();
@@ -3085,7 +3094,10 @@ async function loadAllData() {
3085
3094
  debug(`Loaded ${controls.length} controls from individual files`);
3086
3095
  const mappings = await state.fileStore.loadMappings();
3087
3096
  for (const mapping of mappings) {
3088
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
3097
+ if (!mapping.hash) {
3098
+ mapping.hash = createHash3("sha256").update(JSON.stringify(mapping)).digest("hex");
3099
+ }
3100
+ const compositeKey = `${mapping.control_id}:${mapping.hash}`;
3089
3101
  state.mappingsCache.set(compositeKey, mapping);
3090
3102
  addMappingToIndexes(mapping);
3091
3103
  }
@@ -5136,6 +5148,7 @@ init_gitHistory();
5136
5148
  import * as yaml5 from "js-yaml";
5137
5149
  import { join as join5 } from "path";
5138
5150
  import { WebSocket, WebSocketServer } from "ws";
5151
+ import crypto2 from "node:crypto";
5139
5152
  var WebSocketManager = class {
5140
5153
  wss = null;
5141
5154
  clients = /* @__PURE__ */ new Set();
@@ -5200,21 +5213,24 @@ var WebSocketManager = class {
5200
5213
  if (payload && payload.control_id) {
5201
5214
  const mapping = payload;
5202
5215
  if (!mapping.uuid) {
5203
- const crypto2 = await import("crypto");
5204
- mapping.uuid = crypto2.randomUUID();
5216
+ const crypto3 = await import("crypto");
5217
+ mapping.uuid = crypto3.randomUUID();
5205
5218
  }
5219
+ if (!mapping.hash || mapping.hash === "") {
5220
+ mapping.hash = crypto2.createHash("sha256").update(JSON.stringify(mapping)).digest("hex");
5221
+ }
5222
+ const compositeKey = `${mapping.control_id}:${mapping.hash}`;
5206
5223
  await state.fileStore.saveMapping(mapping);
5207
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
5208
5224
  state.mappingsCache.set(compositeKey, mapping);
5209
5225
  const family = mapping.control_id.split("-")[0];
5210
5226
  if (!state.mappingsByFamily.has(family)) {
5211
5227
  state.mappingsByFamily.set(family, /* @__PURE__ */ new Set());
5212
5228
  }
5213
- state.mappingsByFamily.get(family)?.add(mapping.uuid);
5229
+ state.mappingsByFamily.get(family)?.add(mapping.hash);
5214
5230
  if (!state.mappingsByControl.has(mapping.control_id)) {
5215
5231
  state.mappingsByControl.set(mapping.control_id, /* @__PURE__ */ new Set());
5216
5232
  }
5217
- state.mappingsByControl.get(mapping.control_id)?.add(mapping.uuid);
5233
+ state.mappingsByControl.get(mapping.control_id)?.add(mapping.hash);
5218
5234
  ws.send(
5219
5235
  JSON.stringify({
5220
5236
  type: "mapping-created",
@@ -5225,38 +5241,21 @@ var WebSocketManager = class {
5225
5241
  }
5226
5242
  break;
5227
5243
  }
5228
- case "update-mapping": {
5229
- const state = getServerState();
5230
- if (payload && payload.uuid) {
5231
- const mapping = payload;
5232
- await state.fileStore.saveMapping(mapping);
5233
- const compositeKey = `${mapping.control_id}:${mapping.uuid}`;
5234
- state.mappingsCache.set(compositeKey, mapping);
5235
- ws.send(
5236
- JSON.stringify({
5237
- type: "mapping-updated",
5238
- payload: { uuid: mapping.uuid, success: true }
5239
- })
5240
- );
5241
- this.broadcastState();
5242
- }
5243
- break;
5244
- }
5245
5244
  case "delete-mapping": {
5246
5245
  const state = getServerState();
5247
- if (payload && payload.uuid) {
5248
- const uuid = payload.uuid;
5249
- const mapping = state.mappingsCache.get(uuid);
5246
+ if (payload && payload.composite_key) {
5247
+ const composite_key = payload.composite_key;
5248
+ const mapping = state.mappingsCache.get(composite_key);
5250
5249
  if (mapping) {
5251
- await state.fileStore.deleteMapping(uuid);
5252
- state.mappingsCache.delete(uuid);
5250
+ await state.fileStore.deleteMapping(composite_key);
5251
+ state.mappingsCache.delete(composite_key);
5253
5252
  const family = mapping.control_id.split("-")[0];
5254
- state.mappingsByFamily.get(family)?.delete(uuid);
5255
- state.mappingsByControl.get(mapping.control_id)?.delete(uuid);
5253
+ state.mappingsByFamily.get(family)?.delete(mapping.hash);
5254
+ state.mappingsByControl.get(mapping.control_id)?.delete(mapping.hash);
5256
5255
  ws.send(
5257
5256
  JSON.stringify({
5258
5257
  type: "mapping-deleted",
5259
- payload: { uuid, success: true }
5258
+ payload: { hash: mapping.hash, success: true }
5260
5259
  })
5261
5260
  );
5262
5261
  this.broadcastState();
@@ -5733,6 +5732,7 @@ var WebSocketManager = class {
5733
5732
  var wsManager = new WebSocketManager();
5734
5733
 
5735
5734
  // cli/server/server.ts
5735
+ import { createHash as createHash4 } from "crypto";
5736
5736
  var __filename = fileURLToPath(import.meta.url);
5737
5737
  var __dirname = dirname2(__filename);
5738
5738
  async function createServer(options) {
@@ -5758,6 +5758,11 @@ async function createServer(options) {
5758
5758
  app.get("/*splat", (req, res) => {
5759
5759
  res.sendFile("index.html", { root: distPath });
5760
5760
  });
5761
+ app.post("/hash", (req, res) => {
5762
+ delete req.body.hash;
5763
+ const hash = createHash4("sha256").update(JSON.stringify(req.body)).digest("hex");
5764
+ res.status(200).json({ hash });
5765
+ });
5761
5766
  const httpServer = createHttpServer(app);
5762
5767
  wsManager.initialize(httpServer);
5763
5768
  return {
@@ -5869,7 +5874,7 @@ function getVersion() {
5869
5874
  import fs4 from "fs";
5870
5875
  import { Octokit } from "@octokit/rest";
5871
5876
  import { Command, Option } from "commander";
5872
- import { createHash as createHash2 } from "crypto";
5877
+ import { createHash as createHash5 } from "crypto";
5873
5878
  var closingBody = `
5874
5879
 
5875
5880
  ---
@@ -6077,7 +6082,7 @@ function generateChangedBlocksContent(filename, changedBlocks, newText) {
6077
6082
  `;
6078
6083
  for (const block of changedBlocks) {
6079
6084
  const newBlockText = newText.split("\n").slice(block.startLine, block.endLine).join("\n");
6080
- const blockSha256 = createHash2("sha256").update(newBlockText).digest("hex");
6085
+ const blockSha256 = createHash5("sha256").update(newBlockText).digest("hex");
6081
6086
  content += `**UUID:** \`${block.uuid}\`
6082
6087
  **sha256:** \`${blockSha256}\`
6083
6088
 
@@ -6110,7 +6115,7 @@ function generateRemovedBlocksContent(filename, removedBlocks, oldText) {
6110
6115
  `;
6111
6116
  for (const block of removedBlocks) {
6112
6117
  const oldBlockText = oldText.split("\n").slice(block.startLine, block.endLine).join("\n");
6113
- const blockSha256 = createHash2("sha256").update(oldBlockText).digest("hex");
6118
+ const blockSha256 = createHash5("sha256").update(oldBlockText).digest("hex");
6114
6119
  content += `**UUID:** \`${block.uuid}\`
6115
6120
  **sha256:** \`${blockSha256}\`
6116
6121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lula2",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "A tool for managing compliance as code in your GitHub repositories.",
5
5
  "bin": {
6
6
  "lula2": "./dist/lula2"
@@ -62,7 +62,7 @@
62
62
  "express-rate-limit": "8.2.1",
63
63
  "flowbite": "4.0.1",
64
64
  "glob": "13.0.0",
65
- "isomorphic-git": "1.35.1",
65
+ "isomorphic-git": "1.36.0",
66
66
  "js-yaml": "4.1.1",
67
67
  "multer": "2.0.2",
68
68
  "open": "11.0.0",
@@ -8,7 +8,7 @@
8
8
  interface Props {
9
9
  mapping: Mapping;
10
10
  onEdit?: (mapping: Mapping) => void;
11
- onDelete?: (uuid: string) => void;
11
+ onDelete?: (hash: string) => void;
12
12
  showActions?: boolean;
13
13
  }
14
14
 
@@ -23,8 +23,8 @@
23
23
  }
24
24
 
25
25
  function handleDelete() {
26
- if (confirm('Are you sure you want to delete this mapping?')) {
27
- onDelete?.(mapping.uuid);
26
+ if (confirm('Are you sure you want to delete this mapping? '+ mapping.uuid)) {
27
+ onDelete?.(mapping.hash!);
28
28
  }
29
29
  }
30
30
  </script>
@@ -35,8 +35,17 @@
35
35
  justification: data.justification,
36
36
  status: data.status,
37
37
  source_entries: data.source_entries,
38
- uuid: data.uuid || '' // Use the UUID from form or empty for auto-generation
38
+ uuid: data.uuid || '', // Use the UUID from form or empty for auto-generation,
39
+ hash: ''
39
40
  };
41
+ const hash = await fetch('/hash', {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ body: JSON.stringify(mappingData)
47
+ });
48
+ mappingData.hash = (await hash.json()).hash;
40
49
 
41
50
  await wsClient.createMapping(mappingData);
42
51
  resetMappingForm();
@@ -80,18 +89,12 @@
80
89
  uuid: data.uuid || editingMapping.uuid, // Use form UUID or fallback to original
81
90
  justification: data.justification,
82
91
  status: data.status,
83
- source_entries: data.source_entries
92
+ source_entries: data.source_entries,
84
93
  };
85
-
86
- const uuidChanged = updatedMapping.uuid !== editingMapping.uuid;
87
-
88
- if (uuidChanged) {
89
- const compositeId = `${control.id}:${editingMapping.uuid}`;
90
- await wsClient.deleteMapping(compositeId);
91
- await wsClient.createMapping(updatedMapping);
92
- } else {
93
- await wsClient.updateMapping(updatedMapping);
94
- }
94
+ // hashes change every time so we just delete an create
95
+ await wsClient.deleteMapping(`${editingMapping.control_id}:${editingMapping.hash!}`);
96
+ delete updatedMapping.hash;
97
+ await wsClient.createMapping(updatedMapping);
95
98
 
96
99
  resetMappingForm();
97
100
  } catch (error) {
@@ -99,10 +102,17 @@
99
102
  }
100
103
  }
101
104
 
102
- async function handleDeleteMapping(uuid: string) {
105
+ async function handleDeleteMapping(hash: string) {
106
+ // Find the mapping by hash to get the UUID for backend deletion
107
+ const mappingToDelete = mappings.find(m => (m.hash === hash));
108
+ if (!mappingToDelete) {
109
+ console.error('Mapping not found for deletion');
110
+ return;
111
+ }
112
+
103
113
  try {
104
- const compositeId = `${control.id}:${uuid}`;
105
- await wsClient.deleteMapping(compositeId);
114
+ // Backend expects UUID for file operations
115
+ await wsClient.deleteMapping(`${mappingToDelete.control_id}:${mappingToDelete.hash!}`);
106
116
  } catch (error) {
107
117
  console.error('Failed to delete mapping:', error);
108
118
  }
@@ -113,8 +123,8 @@
113
123
  <!-- Existing Mappings -->
114
124
  {#if mappings.length > 0}
115
125
  <div class="space-y-4">
116
- {#each mappings as mapping (mapping.uuid)}
117
- {#if editingMapping && editingMapping.uuid === mapping.uuid}
126
+ {#each mappings as mapping (mapping.hash)}
127
+ {#if editingMapping && editingMapping.hash === mapping.hash}
118
128
  <!-- Edit Form in place of the mapping being edited -->
119
129
  <div
120
130
  class="bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm"
package/src/lib/types.ts CHANGED
@@ -36,6 +36,8 @@ export interface Mapping {
36
36
  justification: string;
37
37
  source_entries: SourceEntry[];
38
38
  status: 'planned' | 'implemented' | 'verified';
39
+ cci?: string;
40
+ hash?: string;
39
41
  created_by?: string;
40
42
  }
41
43
 
@@ -355,12 +355,8 @@ class WebSocketClient {
355
355
  return this.sendCommand('create-mapping', mapping);
356
356
  }
357
357
 
358
- async updateMapping(mapping: Mapping) {
359
- return this.sendCommand('update-mapping', mapping);
360
- }
361
-
362
- async deleteMapping(uuid: string) {
363
- return this.sendCommand('delete-mapping', { uuid });
358
+ async deleteMapping(composite_key: string) {
359
+ return this.sendCommand('delete-mapping', { composite_key });
364
360
  }
365
361
 
366
362
  async switchControlSet(path: string) {
@@ -1 +0,0 @@
1
- var ct=Array.isArray,Zt=Array.prototype.indexOf,Vn=Array.from,$n=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Wt=Object.getOwnPropertyDescriptors,Jt=Object.prototype,Qt=Array.prototype,_t=Object.getPrototypeOf,st=Object.isExtensible;function Gn(e){return typeof e=="function"}const le=()=>{};function Kn(e){return e()}function vt(e){for(var t=0;t<e.length;t++)e[t]()}function dt(){var e,t,n=new Promise((r,s)=>{e=r,t=s});return{promise:n,resolve:e,reject:t}}function zn(e,t){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const n=[];for(const r of e)if(n.push(r),n.length===t)break;return n}const E=2,$e=4,Ce=8,ht=1<<24,j=16,q=32,se=64,Ge=128,D=512,m=1024,k=2048,C=4096,P=8192,H=16384,Ke=32768,Te=65536,qe=1<<17,pt=1<<18,be=1<<19,yt=1<<20,te=32768,Ye=1<<21,ze=1<<22,B=1<<23,J=Symbol("$state"),Xn=Symbol("legacy props"),Zn=Symbol(""),ae=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Xe=3,wt=8;function en(e){throw new Error("https://svelte.dev/e/experimental_async_required")}function Ze(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function tn(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function nn(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function rn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function sn(e){throw new Error("https://svelte.dev/e/effect_orphan")}function fn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function an(){throw new Error("https://svelte.dev/e/fork_discarded")}function ln(){throw new Error("https://svelte.dev/e/fork_timing")}function Jn(){throw new Error("https://svelte.dev/e/hydration_failed")}function Qn(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function un(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function on(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function cn(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function er(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const tr=1,nr=2,rr=4,sr=8,fr=16,ir=1,ar=2,lr=4,ur=8,or=16,cr=4,_r=1,vr=2,_n="[",vn="[!",dn="]",We={},g=Symbol(),dr="http://www.w3.org/1999/xhtml",hr="@attach";function Je(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function pr(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function yr(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let V=!1;function wr(e){V=e}let S;function ue(e){if(e===null)throw Je(),We;return S=e}function br(){return ue(K(S))}function Er(e){if(V){if(K(S)!==null)throw Je(),We;S=e}}function mr(e=1){if(V){for(var t=e,n=S;t--;)n=K(n);S=n}}function gr(e=!0){for(var t=0,n=S;;){if(n.nodeType===wt){var r=n.data;if(r===dn){if(t===0)return n;t-=1}else(r===_n||r===vn)&&(t+=1)}var s=K(n);e&&n.remove(),n=s}}function Tr(e){if(!e||e.nodeType!==wt)throw Je(),We;return e.data}function bt(e){return e===this.v}function Et(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function mt(e){return!Et(e,this.v)}let Ee=!1;function Ar(){Ee=!0}let y=null;function Ae(e){y=e}function kr(e,t=!1,n){y={p:y,i:!1,c:null,e:null,s:e,x:null,l:Ee&&!t?{s:null,u:null,$:[]}:null}}function xr(e){var t=y,n=t.e;if(n!==null){t.e=null;for(var r of n)Mt(r)}return t.i=!0,y=t.p,{}}function me(){return!Ee||y!==null&&y.l===null}let X=[];function gt(){var e=X;X=[],vt(e)}function Tt(e){if(X.length===0&&!ye){var t=X;queueMicrotask(()=>{t===X&&gt()})}X.push(e)}function hn(){for(;X.length>0;)gt()}function pn(e){var t=h;if(t===null)return v.f|=B,e;if((t.f&Ke)===0){if((t.f&Ge)===0)throw e;t.b.error(e)}else ke(e,t)}function ke(e,t){for(;t!==null;){if((t.f&Ge)!==0)try{t.b.error(e);return}catch(n){e=n}t=t.parent}throw e}const Z=new Set;let p=null,Le=null,A=null,O=[],Me=null,He=!1,ye=!1;class ${committed=!1;current=new Map;previous=new Map;#r=new Set;#s=new Set;#t=0;#n=0;#a=null;#f=[];#i=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#n>0}process(t){O=[],Le=null,this.apply();var n={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const r of t)this.#l(r,n);this.is_fork||this.#o(),this.is_deferred()?(this.#e(n.effects),this.#e(n.render_effects),this.#e(n.block_effects)):(Le=this,p=null,ft(n.render_effects),ft(n.effects),Le=null,this.#a?.resolve()),A=null}#l(t,n){t.f^=m;for(var r=t.first;r!==null;){var s=r.f,f=(s&(q|se))!==0,u=f&&(s&m)!==0,l=u||(s&P)!==0||this.skipped_effects.has(r);if((r.f&Ge)!==0&&r.b?.is_pending()&&(n={parent:n,effect:r,effects:[],render_effects:[],block_effects:[]}),!l&&r.fn!==null){f?r.f^=m:(s&$e)!==0?n.effects.push(r):ve(r)&&((r.f&j)!==0&&n.block_effects.push(r),ce(r));var a=r.first;if(a!==null){r=a;continue}}var i=r.parent;for(r=r.next;r===null&&i!==null;)i===n.effect&&(this.#e(n.effects),this.#e(n.render_effects),this.#e(n.block_effects),n=n.parent),r=i.next,i=i.parent}}#e(t){for(const n of t)((n.f&k)!==0?this.#f:this.#i).push(n),this.#u(n.deps),b(n,m)}#u(t){if(t!==null)for(const n of t)(n.f&E)===0||(n.f&te)===0||(n.f^=te,this.#u(n.deps))}capture(t,n){this.previous.has(t)||this.previous.set(t,n),(t.f&B)===0&&(this.current.set(t,t.v),A?.set(t,t.v))}activate(){p=this,this.apply()}deactivate(){p===this&&(p=null,A=null)}flush(){if(this.activate(),O.length>0){if(Ue(),p!==null&&p!==this)return}else this.#t===0&&this.process([]);this.deactivate()}discard(){for(const t of this.#s)t(this);this.#s.clear()}#o(){if(this.#n===0){for(const t of this.#r)t();this.#r.clear()}this.#t===0&&this.#c()}#c(){if(Z.size>1){this.previous.clear();var t=A,n=!0,r={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(const f of Z){if(f===this){n=!1;continue}const u=[];for(const[a,i]of this.current){if(f.current.has(a))if(n&&i!==f.current.get(a))f.current.set(a,i);else continue;u.push(a)}if(u.length===0)continue;const l=[...f.current.keys()].filter(a=>!this.current.has(a));if(l.length>0){var s=O;O=[];const a=new Set,i=new Map;for(const o of u)At(o,l,a,i);if(O.length>0){p=f,f.apply();for(const o of O)f.#l(o,r);f.deactivate()}O=s}}p=null,A=t}this.committed=!0,Z.delete(this)}increment(t){this.#t+=1,t&&(this.#n+=1)}decrement(t){this.#t-=1,t&&(this.#n-=1),this.revive()}revive(){for(const t of this.#f)b(t,k),ne(t);for(const t of this.#i)b(t,C),ne(t);this.#f=[],this.#i=[],this.flush()}oncommit(t){this.#r.add(t)}ondiscard(t){this.#s.add(t)}settled(){return(this.#a??=dt()).promise}static ensure(){if(p===null){const t=p=new $;Z.add(p),ye||$.enqueue(()=>{p===t&&t.flush()})}return p}static enqueue(t){Tt(t)}apply(){}}function Be(e){var t=ye;ye=!0;try{var n;for(e&&(p!==null&&Ue(),n=e());;){if(hn(),O.length===0&&(p?.flush(),O.length===0))return Me=null,n;Ue()}}finally{ye=t}}function Ue(){var e=Q;He=!0;var t=null;try{var n=0;for(Ie(!0);O.length>0;){var r=$.ensure();if(n++>1e3){var s,f;yn()}r.process(O),U.clear()}}finally{He=!1,Ie(e),Me=null}}function yn(){try{fn()}catch(e){ke(e,Me)}}let M=null;function ft(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(H|P))===0&&ve(r)&&(M=new Set,ce(r),r.deps===null&&r.first===null&&r.nodes===null&&(r.teardown===null&&r.ac===null?qt(r):r.fn=null),M?.size>0)){U.clear();for(const s of M){if((s.f&(H|P))!==0)continue;const f=[s];let u=s.parent;for(;u!==null;)M.has(u)&&(M.delete(u),f.push(u)),u=u.parent;for(let l=f.length-1;l>=0;l--){const a=f[l];(a.f&(H|P))===0&&ce(a)}}M.clear()}}M=null}}function At(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const s of e.reactions){const f=s.f;(f&E)!==0?At(s,t,n,r):(f&(ze|j))!==0&&(f&k)===0&&xt(s,t,r)&&(b(s,k),ne(s))}}function kt(e,t){if(e.reactions!==null)for(const n of e.reactions){const r=n.f;(r&E)!==0?kt(n,t):(r&qe)!==0&&(b(n,k),t.add(n))}}function xt(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(t.includes(s))return!0;if((s.f&E)!==0&&xt(s,t,n))return n.set(s,!0),!0}return n.set(e,!1),!1}function ne(e){for(var t=Me=e;t.parent!==null;){t=t.parent;var n=t.f;if(He&&t===h&&(n&j)!==0&&(n&pt)===0)return;if((n&(se|q))!==0){if((n&m)===0)return;t.f^=m}}O.push(t)}function Sr(e){en(),p!==null&&ln();var t=$.ensure();t.is_fork=!0,A=new Map;var n=!1,r=t.settled();Be(e),A=null;for(var[s,f]of t.previous)s.v=f;return{commit:async()=>{if(n){await r;return}Z.has(t)||an(),n=!0,t.is_fork=!1;for(var[u,l]of t.current)u.v=l;Be(()=>{var a=new Set;for(var i of t.current.keys())kt(i,a);Tn(a),Dt()}),t.revive(),await r},discard:()=>{!n&&Z.has(t)&&(Z.delete(t),t.discard())}}}function wn(e,t,n,r){const s=me()?Qe:mn;if(n.length===0&&e.length===0){r(t.map(s));return}var f=p,u=h,l=bn();function a(){Promise.all(n.map(i=>En(i))).then(i=>{l();try{r([...t.map(s),...i])}catch(o){(u.f&H)===0&&ke(o,u)}f?.deactivate(),xe()}).catch(i=>{ke(i,u)})}e.length>0?Promise.all(e).then(()=>{l();try{return a()}finally{f?.deactivate(),xe()}}):a()}function bn(){var e=h,t=v,n=y,r=p;return function(f=!0){oe(e),G(t),Ae(n),f&&r?.activate()}}function xe(){oe(null),G(null),Ae(null)}function Qe(e){var t=E|k,n=v!==null&&(v.f&E)!==0?v:null;return h!==null&&(h.f|=be),{ctx:y,deps:null,effects:null,equals:bt,f:t,fn:e,reactions:null,rv:0,v:g,wv:0,parent:n??h,ac:null}}function En(e,t){let n=h;n===null&&tn();var r=n.b,s=void 0,f=tt(g),u=!v,l=new Map;return Dn(()=>{var a=dt();s=a.promise;try{Promise.resolve(e()).then(a.resolve,a.reject).then(()=>{i===p&&i.committed&&i.deactivate(),xe()})}catch(c){a.reject(c),xe()}var i=p;if(u){var o=!r.is_pending();r.update_pending_count(1),i.increment(o),l.get(i)?.reject(ae),l.delete(i),l.set(i,a)}const _=(c,d=void 0)=>{if(i.activate(),d)d!==ae&&(f.f|=B,Re(f,d));else{(f.f&B)!==0&&(f.f^=B),Re(f,c);for(const[w,z]of l){if(l.delete(w),w===i)break;z.reject(ae)}}u&&(r.update_pending_count(-1),i.decrement(o))};a.promise.then(_,c=>_(null,c||"unknown"))}),Rn(()=>{for(const a of l.values())a.reject(ae)}),new Promise(a=>{function i(o){function _(){o===s?a(f):i(s)}o.then(_,_)}i(s)})}function Rr(e){const t=Qe(e);return Bt(t),t}function mn(e){const t=Qe(e);return t.equals=mt,t}function St(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)re(t[n])}}function gn(e){for(var t=e.parent;t!==null;){if((t.f&E)===0)return(t.f&H)===0?t:null;t=t.parent}return null}function et(e){var t,n=h;oe(gn(e));try{e.f&=~te,St(e),t=Gt(e)}finally{oe(n)}return t}function Rt(e){var t=et(e);if(e.equals(t)||(p?.is_fork||(e.v=t),e.wv=Vt()),!_e)if(A!==null)(Ne()||p?.is_fork)&&A.set(e,t);else{var n=(e.f&D)===0?C:m;b(e,n)}}let Se=new Set;const U=new Map;function Tn(e){Se=e}let Ot=!1;function tt(e,t){var n={f:0,v:e,reactions:null,equals:bt,rv:0,wv:0};return n}function Y(e,t){const n=tt(e);return Bt(n),n}function Or(e,t=!1,n=!0){const r=tt(e);return t||(r.equals=mt),Ee&&n&&y!==null&&y.l!==null&&(y.l.s??=[]).push(r),r}function Dr(e,t){return F(e,de(()=>W(e))),t}function F(e,t,n=!1){v!==null&&(!I||(v.f&qe)!==0)&&me()&&(v.f&(E|j|ze|qe))!==0&&!L?.includes(e)&&cn();let r=n?he(t):t;return Re(e,r)}function Re(e,t){if(!e.equals(t)){var n=e.v;_e?U.set(e,t):U.set(e,n),e.v=t;var r=$.ensure();r.capture(e,n),(e.f&E)!==0&&((e.f&k)!==0&&et(e),b(e,(e.f&D)!==0?m:C)),e.wv=Vt(),Nt(e,k),me()&&h!==null&&(h.f&m)!==0&&(h.f&(q|se))===0&&(R===null?Fn([e]):R.push(e)),!r.is_fork&&Se.size>0&&!Ot&&Dt()}return t}function Dt(){Ot=!1;var e=Q;Ie(!0);const t=Array.from(Se);try{for(const n of t)(n.f&m)!==0&&b(n,C),ve(n)&&ce(n)}finally{Ie(e)}Se.clear()}function Nr(e,t=1){var n=W(e),r=t===1?n++:n--;return F(e,n),r}function je(e){F(e,e.v+1)}function Nt(e,t){var n=e.reactions;if(n!==null)for(var r=me(),s=n.length,f=0;f<s;f++){var u=n[f],l=u.f;if(!(!r&&u===h)){var a=(l&k)===0;if(a&&b(u,t),(l&E)!==0){var i=u;A?.delete(i),(l&te)===0&&(l&D&&(u.f|=te),Nt(i,C))}else a&&((l&j)!==0&&M!==null&&M.add(u),ne(u))}}}function he(e){if(typeof e!="object"||e===null||J in e)return e;const t=_t(e);if(t!==Jt&&t!==Qt)return e;var n=new Map,r=ct(e),s=Y(0),f=ee,u=l=>{if(ee===f)return l();var a=v,i=ee;G(null),ot(f);var o=l();return G(a),ot(i),o};return r&&n.set("length",Y(e.length)),new Proxy(e,{defineProperty(l,a,i){(!("value"in i)||i.configurable===!1||i.enumerable===!1||i.writable===!1)&&un();var o=n.get(a);return o===void 0?o=u(()=>{var _=Y(i.value);return n.set(a,_),_}):F(o,i.value,!0),!0},deleteProperty(l,a){var i=n.get(a);if(i===void 0){if(a in l){const o=u(()=>Y(g));n.set(a,o),je(s)}}else F(i,g),je(s);return!0},get(l,a,i){if(a===J)return e;var o=n.get(a),_=a in l;if(o===void 0&&(!_||pe(l,a)?.writable)&&(o=u(()=>{var d=he(_?l[a]:g),w=Y(d);return w}),n.set(a,o)),o!==void 0){var c=W(o);return c===g?void 0:c}return Reflect.get(l,a,i)},getOwnPropertyDescriptor(l,a){var i=Reflect.getOwnPropertyDescriptor(l,a);if(i&&"value"in i){var o=n.get(a);o&&(i.value=W(o))}else if(i===void 0){var _=n.get(a),c=_?.v;if(_!==void 0&&c!==g)return{enumerable:!0,configurable:!0,value:c,writable:!0}}return i},has(l,a){if(a===J)return!0;var i=n.get(a),o=i!==void 0&&i.v!==g||Reflect.has(l,a);if(i!==void 0||h!==null&&(!o||pe(l,a)?.writable)){i===void 0&&(i=u(()=>{var c=o?he(l[a]):g,d=Y(c);return d}),n.set(a,i));var _=W(i);if(_===g)return!1}return o},set(l,a,i,o){var _=n.get(a),c=a in l;if(r&&a==="length")for(var d=i;d<_.v;d+=1){var w=n.get(d+"");w!==void 0?F(w,g):d in l&&(w=u(()=>Y(g)),n.set(d+"",w))}if(_===void 0)(!c||pe(l,a)?.writable)&&(_=u(()=>Y(void 0)),F(_,he(i)),n.set(a,_));else{c=_.v!==g;var z=u(()=>he(i));F(_,z)}var ge=Reflect.getOwnPropertyDescriptor(l,a);if(ge?.set&&ge.set.call(o,i),!c){if(r&&typeof a=="string"){var rt=n.get("length"),Fe=Number(a);Number.isInteger(Fe)&&Fe>=rt.v&&F(rt,Fe+1)}je(s)}return!0},ownKeys(l){W(s);var a=Reflect.ownKeys(l).filter(_=>{var c=n.get(_);return c===void 0||c.v!==g});for(var[i,o]of n)o.v!==g&&!(i in l)&&a.push(i);return a},setPrototypeOf(){on()}})}function it(e){try{if(e!==null&&typeof e=="object"&&J in e)return e[J]}catch{}return e}function Ir(e,t){return Object.is(it(e),it(t))}var at,An,It,Pt;function Pr(){if(at===void 0){at=window,An=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;It=pe(t,"firstChild").get,Pt=pe(t,"nextSibling").get,st(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),st(n)&&(n.__t=void 0)}}function Oe(e=""){return document.createTextNode(e)}function De(e){return It.call(e)}function K(e){return Pt.call(e)}function Cr(e,t){if(!V)return De(e);var n=De(S);if(n===null)n=S.appendChild(Oe());else if(t&&n.nodeType!==Xe){var r=Oe();return n?.before(r),ue(r),r}return ue(n),n}function Mr(e,t=!1){if(!V){var n=De(e);return n instanceof Comment&&n.data===""?K(n):n}if(t&&S?.nodeType!==Xe){var r=Oe();return S?.before(r),ue(r),r}return S}function Fr(e,t=1,n=!1){let r=V?S:e;for(var s;t--;)s=r,r=K(r);if(!V)return r;if(n&&r?.nodeType!==Xe){var f=Oe();return r===null?s?.after(f):r.before(f),ue(f),f}return ue(r),r}function kn(e){e.textContent=""}function Lr(){return!1}function jr(e,t){if(t){const n=document.body;e.autofocus=!0,Tt(()=>{document.activeElement===n&&e.focus()})}}function qr(e){V&&De(e)!==null&&kn(e)}let lt=!1;function xn(){lt||(lt=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const t of e.target.elements)t.__on_r?.()})},{capture:!0}))}function nt(e){var t=v,n=h;G(null),oe(null);try{return e()}finally{G(t),oe(n)}}function Yr(e,t,n,r=n){e.addEventListener(t,()=>nt(n));const s=e.__on_r;s?e.__on_r=()=>{s(),r(!0)}:e.__on_r=()=>r(!0),xn()}function Ct(e){h===null&&(v===null&&sn(),rn()),_e&&nn()}function Sn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function N(e,t,n){var r=h;r!==null&&(r.f&P)!==0&&(e|=P);var s={ctx:y,deps:null,nodes:null,f:e|k|D,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{ce(s),s.f|=Ke}catch(l){throw re(s),l}else t!==null&&ne(s);var f=s;if(n&&f.deps===null&&f.teardown===null&&f.nodes===null&&f.first===f.last&&(f.f&be)===0&&(f=f.first,(e&j)!==0&&(e&Te)!==0&&f!==null&&(f.f|=Te)),f!==null&&(f.parent=r,r!==null&&Sn(f,r),v!==null&&(v.f&E)!==0&&(e&se)===0)){var u=v;(u.effects??=[]).push(f)}return s}function Ne(){return v!==null&&!I}function Rn(e){const t=N(Ce,null,!1);return b(t,m),t.teardown=e,t}function On(e){Ct();var t=h.f,n=!v&&(t&q)!==0&&(t&Ke)===0;if(n){var r=y;(r.e??=[]).push(e)}else return Mt(e)}function Mt(e){return N($e|yt,e,!1)}function Hr(e){return Ct(),N(Ce|yt,e,!0)}function Br(e){$.ensure();const t=N(se|be,e,!0);return(n={})=>new Promise(r=>{n.outro?Pn(t,()=>{re(t),r(void 0)}):(re(t),r(void 0))})}function Ur(e){return N($e,e,!1)}function Vr(e,t){var n=y,r={effect:null,ran:!1,deps:e};n.l.$.push(r),r.effect=Ft(()=>{e(),!r.ran&&(r.ran=!0,de(t))})}function $r(){var e=y;Ft(()=>{for(var t of e.l.$){t.deps();var n=t.effect;(n.f&m)!==0&&b(n,C),ve(n)&&ce(n),t.ran=!1}})}function Dn(e){return N(ze|be,e,!0)}function Ft(e,t=0){return N(Ce|t,e,!0)}function Gr(e,t=[],n=[],r=[]){wn(r,t,n,s=>{N(Ce,()=>e(...s.map(W)),!0)})}function Kr(e,t=0){var n=N(j|t,e,!0);return n}function zr(e,t=0){var n=N(ht|t,e,!0);return n}function Xr(e){return N(q|be,e,!0)}function Lt(e){var t=e.teardown;if(t!==null){const n=_e,r=v;ut(!0),G(null);try{t.call(null)}finally{ut(n),G(r)}}}function jt(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const s=n.ac;s!==null&&nt(()=>{s.abort(ae)});var r=n.next;(n.f&se)!==0?n.parent=null:re(n,t),n=r}}function Nn(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&q)===0&&re(t),t=n}}function re(e,t=!0){var n=!1;(t||(e.f&pt)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(In(e.nodes.start,e.nodes.end),n=!0),jt(e,t&&!n),Pe(e,0),b(e,H);var r=e.nodes&&e.nodes.t;if(r!==null)for(const f of r)f.stop();Lt(e);var s=e.parent;s!==null&&s.first!==null&&qt(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function In(e,t){for(;e!==null;){var n=e===t?null:K(e);e.remove(),e=n}}function qt(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pn(e,t,n=!0){var r=[];Yt(e,r,!0),Cn(r,()=>{n&&re(e),t&&t()})}function Cn(e,t){var n=e.length;if(n>0){var r=()=>--n||t();for(var s of e)s.out(r)}else t()}function Yt(e,t,n){if((e.f&P)===0){e.f^=P;var r=e.nodes&&e.nodes.t;if(r!==null)for(const l of r)(l.is_global||n)&&t.push(l);for(var s=e.first;s!==null;){var f=s.next,u=(s.f&Te)!==0||(s.f&q)!==0&&(e.f&j)!==0;Yt(s,t,u?n:!1),s=f}}}function Zr(e){Ht(e,!0)}function Ht(e,t){if((e.f&P)!==0){e.f^=P,(e.f&m)===0&&(b(e,k),ne(e));for(var n=e.first;n!==null;){var r=n.next,s=(n.f&Te)!==0||(n.f&q)!==0;Ht(n,s?t:!1),n=r}var f=e.nodes&&e.nodes.t;if(f!==null)for(const u of f)(u.is_global||t)&&u.in()}}function Wr(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var s=n===r?null:K(n);t.append(n),n=s}}let ie=null;function Mn(e){var t=ie;try{if(ie=new Set,de(e),t!==null)for(var n of ie)t.add(n);return ie}finally{ie=t}}function Jr(e){for(var t of Mn(e))Re(t,t.v)}let Q=!1;function Ie(e){Q=e}let _e=!1;function ut(e){_e=e}let v=null,I=!1;function G(e){v=e}let h=null;function oe(e){h=e}let L=null;function Bt(e){v!==null&&(L===null?L=[e]:L.push(e))}let T=null,x=0,R=null;function Fn(e){R=e}let Ut=1,we=0,ee=we;function ot(e){ee=e}function Vt(){return++Ut}function ve(e){var t=e.f;if((t&k)!==0)return!0;if(t&E&&(e.f&=~te),(t&C)!==0){var n=e.deps;if(n!==null)for(var r=n.length,s=0;s<r;s++){var f=n[s];if(ve(f)&&Rt(f),f.wv>e.wv)return!0}(t&D)!==0&&A===null&&b(e,m)}return!1}function $t(e,t,n=!0){var r=e.reactions;if(r!==null&&!L?.includes(e))for(var s=0;s<r.length;s++){var f=r[s];(f.f&E)!==0?$t(f,t,!1):t===f&&(n?b(f,k):(f.f&m)!==0&&b(f,C),ne(f))}}function Gt(e){var t=T,n=x,r=R,s=v,f=L,u=y,l=I,a=ee,i=e.f;T=null,x=0,R=null,v=(i&(q|se))===0?e:null,L=null,Ae(e.ctx),I=!1,ee=++we,e.ac!==null&&(nt(()=>{e.ac.abort(ae)}),e.ac=null);try{e.f|=Ye;var o=e.fn,_=o(),c=e.deps;if(T!==null){var d;if(Pe(e,x),c!==null&&x>0)for(c.length=x+T.length,d=0;d<T.length;d++)c[x+d]=T[d];else e.deps=c=T;if(Ne()&&(e.f&D)!==0)for(d=x;d<c.length;d++)(c[d].reactions??=[]).push(e)}else c!==null&&x<c.length&&(Pe(e,x),c.length=x);if(me()&&R!==null&&!I&&c!==null&&(e.f&(E|C|k))===0)for(d=0;d<R.length;d++)$t(R[d],e);return s!==null&&s!==e&&(we++,R!==null&&(r===null?r=R:r.push(...R))),(e.f&B)!==0&&(e.f^=B),_}catch(w){return pn(w)}finally{e.f^=Ye,T=t,x=n,R=r,v=s,L=f,Ae(u),I=l,ee=a}}function Ln(e,t){let n=t.reactions;if(n!==null){var r=Zt.call(n,e);if(r!==-1){var s=n.length-1;s===0?n=t.reactions=null:(n[r]=n[s],n.pop())}}n===null&&(t.f&E)!==0&&(T===null||!T.includes(t))&&(b(t,C),(t.f&D)!==0&&(t.f^=D,t.f&=~te),St(t),Pe(t,0))}function Pe(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Ln(e,n[r])}function ce(e){var t=e.f;if((t&H)===0){b(e,m);var n=h,r=Q;h=e,Q=!0;try{(t&(j|ht))!==0?Nn(e):jt(e),Lt(e);var s=Gt(e);e.teardown=typeof s=="function"?s:null,e.wv=Ut;var f}finally{Q=r,h=n}}}async function Qr(){await Promise.resolve(),Be()}function es(){return $.ensure().settled()}function W(e){var t=e.f,n=(t&E)!==0;if(ie?.add(e),v!==null&&!I){var r=h!==null&&(h.f&H)!==0;if(!r&&!L?.includes(e)){var s=v.deps;if((v.f&Ye)!==0)e.rv<we&&(e.rv=we,T===null&&s!==null&&s[x]===e?x++:T===null?T=[e]:T.includes(e)||T.push(e));else{(v.deps??=[]).push(e);var f=e.reactions;f===null?e.reactions=[v]:f.includes(v)||f.push(v)}}}if(_e){if(U.has(e))return U.get(e);if(n){var u=e,l=u.v;return((u.f&m)===0&&u.reactions!==null||zt(u))&&(l=et(u)),U.set(u,l),l}}else n&&(!A?.has(e)||p?.is_fork&&!Ne())&&(u=e,ve(u)&&Rt(u),Q&&Ne()&&(u.f&D)===0&&Kt(u));if(A?.has(e))return A.get(e);if((e.f&B)!==0)throw e.v;return e.v}function Kt(e){if(e.deps!==null){e.f^=D;for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&E)!==0&&(t.f&D)===0&&Kt(t)}}function zt(e){if(e.v===g)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(U.has(t)||(t.f&E)!==0&&zt(t))return!0;return!1}function de(e){var t=I;try{return I=!0,e()}finally{I=t}}const jn=-7169;function b(e,t){e.f=e.f&jn|t}function ts(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(J in e)Ve(e);else if(!Array.isArray(e))for(let t in e){const n=e[t];typeof n=="object"&&n&&J in n&&Ve(n)}}}function Ve(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{Ve(e[r],t)}catch{}const n=_t(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const r=Wt(n);for(let s in r){const f=r[s].get;if(f)try{f.call(e)}catch{}}}}}function Xt(e,t,n){if(e==null)return t(void 0),n&&n(void 0),le;const r=de(()=>e.subscribe(t,n));return r.unsubscribe?()=>r.unsubscribe():r}const fe=[];function qn(e,t){return{subscribe:Yn(e,t).subscribe}}function Yn(e,t=le){let n=null;const r=new Set;function s(l){if(Et(e,l)&&(e=l,n)){const a=!fe.length;for(const i of r)i[1](),fe.push(i,e);if(a){for(let i=0;i<fe.length;i+=2)fe[i][0](fe[i+1]);fe.length=0}}}function f(l){s(l(e))}function u(l,a=le){const i=[l,a];return r.add(i),r.size===1&&(n=t(s,f)||le),l(e),()=>{r.delete(i),r.size===0&&n&&(n(),n=null)}}return{set:s,update:f,subscribe:u}}function ns(e,t,n){const r=!Array.isArray(e),s=r?[e]:e;if(!s.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const f=t.length<2;return qn(n,(u,l)=>{let a=!1;const i=[];let o=0,_=le;const c=()=>{if(o)return;_();const w=t(r?i[0]:i,u,l);f?u(w):_=typeof w=="function"?w:le},d=s.map((w,z)=>Xt(w,ge=>{i[z]=ge,o&=~(1<<z),a&&c()},()=>{o|=1<<z}));return a=!0,c(),function(){vt(d),_(),a=!1}})}function rs(e){let t;return Xt(e,n=>t=n)(),t}function Hn(e){y===null&&Ze(),Ee&&y.l!==null?Un(y).m.push(e):On(()=>{const t=de(e);if(typeof t=="function")return t})}function ss(e){y===null&&Ze(),Hn(()=>()=>de(e))}function Bn(e,t,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(e,{detail:t,bubbles:n,cancelable:r})}function fs(){const e=y;return e===null&&Ze(),(t,n,r)=>{const s=e.s.$$events?.[t];if(s){const f=ct(s)?s.slice():[s],u=Bn(t,n,r);for(const l of f)l.call(e.x,u);return!u.defaultPrevented}return!0}}function Un(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}export{h as $,Gr as A,p as B,Zr as C,re as D,Te as E,Pn as F,Oe as G,Xr as H,S as I,Wr as J,Lr as K,Tr as L,vn as M,gr as N,ue as O,wr as P,le as Q,Or as R,J as S,Xt as T,rs as U,Rn as V,$n as W,pe as X,Qn as Y,lr as Z,he as _,F as a,pr as a$,H as a0,mn as a1,ur as a2,Ee as a3,ar as a4,ir as a5,or as a6,_e as a7,Xn as a8,tt as a9,An as aA,_r as aB,vr as aC,Ke as aD,Xe as aE,Pr as aF,_n as aG,K as aH,We as aI,Jn as aJ,kn as aK,Vn as aL,Br as aM,dn as aN,Je as aO,ct as aP,nr as aQ,tr as aR,fr as aS,rr as aT,P as aU,sr as aV,Yt as aW,Cn as aX,zr as aY,Yr as aZ,Le as a_,Nr as aa,oe as ab,Be as ac,Qr as ad,Rr as ae,Vr as af,$r as ag,fs as ah,Jr as ai,zn as aj,Ne as ak,je as al,wt as am,$ as an,G as ao,Ae as ap,pn as aq,v as ar,Re as as,ke as at,er as au,be as av,Ge as aw,yr as ax,nt as ay,De as az,xr as b,Ir as b0,wn as b1,hr as b2,jr as b3,g as b4,xn as b5,dr as b6,_t as b7,Zn as b8,Wt as b9,Yn as ba,j as bb,cr as bc,Gn as bd,Et as be,at as bf,ss as bg,In as bh,qr as bi,ns as bj,Dr as bk,Sr as bl,es as bm,Cr as c,Y as d,Ur as e,Mr as f,W as g,Ft as h,de as i,V as j,br as k,Kr as l,y as m,mr as n,Hn as o,kr as p,Tt as q,Er as r,Fr as s,Hr as t,On as u,vt as v,Kn as w,ts as x,Qe as y,Ar as z};