@tensorix/metahub 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cli.js +2311 -1633
  2. package/dist/cli.js.map +26 -22
  3. package/dist/core/audit.d.ts +97 -0
  4. package/dist/core/audit.d.ts.map +1 -0
  5. package/dist/core/crdt.d.ts +13 -1
  6. package/dist/core/crdt.d.ts.map +1 -1
  7. package/dist/core/databases.d.ts.map +1 -1
  8. package/dist/core/documents.d.ts +6 -0
  9. package/dist/core/documents.d.ts.map +1 -1
  10. package/dist/core/grants-core.d.ts.map +1 -1
  11. package/dist/core/history.d.ts +31 -0
  12. package/dist/core/history.d.ts.map +1 -1
  13. package/dist/core/indexing.d.ts +1 -1
  14. package/dist/core/integrity.d.ts +1 -1
  15. package/dist/core/integrity.d.ts.map +1 -1
  16. package/dist/core/properties.d.ts +1 -1
  17. package/dist/core/properties.d.ts.map +1 -1
  18. package/dist/core/records.d.ts +5 -0
  19. package/dist/core/records.d.ts.map +1 -1
  20. package/dist/core/relation-cells.d.ts +23 -0
  21. package/dist/core/relation-cells.d.ts.map +1 -0
  22. package/dist/core/resolve.d.ts +4 -0
  23. package/dist/core/resolve.d.ts.map +1 -1
  24. package/dist/core/sync/files.d.ts.map +1 -1
  25. package/dist/core/sync/server.d.ts.map +1 -1
  26. package/dist/core/sync/share-serve.d.ts.map +1 -1
  27. package/dist/db-worker.js +100 -98
  28. package/dist/edge-worker.js +74 -26
  29. package/dist/index.js +2267 -1423
  30. package/dist/index.js.map +18 -16
  31. package/dist/metahub-sdk.js +7 -7
  32. package/dist/mh-runtime.js +1 -1
  33. package/dist/sw.js +7 -7
  34. package/dist/webui/server/assets.d.ts +3 -1
  35. package/dist/webui/server/assets.d.ts.map +1 -1
  36. package/dist/webui/server/changes-route.d.ts +7 -0
  37. package/dist/webui/server/changes-route.d.ts.map +1 -0
  38. package/dist/webui/server/routes.d.ts.map +1 -1
  39. package/dist/webui-fmt-clang.js +1 -1
  40. package/dist/webui-fmt-gofmt.js +1 -1
  41. package/dist/webui-fmt-lua.js +2 -2
  42. package/dist/webui-fmt-ruff.js +2 -2
  43. package/dist/webui-fmt-sh.js +8 -8
  44. package/dist/webui-fmt-taplo.js +2 -2
  45. package/dist/webui-fmt.js +346 -346
  46. package/dist/webui.js +178 -174
  47. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -20,12 +20,14 @@ var __toESM = (mod, isNodeMode, target) => {
20
20
  }
21
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
22
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
23
+ if (mod && typeof mod === "object" || typeof mod === "function") {
24
+ for (let key of __getOwnPropNames(mod))
25
+ if (!__hasOwnProp.call(to, key))
26
+ __defProp(to, key, {
27
+ get: __accessProp.bind(mod, key),
28
+ enumerable: true
29
+ });
30
+ }
29
31
  if (canCache)
30
32
  cache.set(mod, to);
31
33
  return to;
@@ -49,8 +51,8 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
49
51
  // node_modules/consola/dist/chunks/prompt.mjs
50
52
  var exports_prompt = {};
51
53
  __export(exports_prompt, {
52
- prompt: () => prompt,
53
- kCancel: () => kCancel
54
+ kCancel: () => kCancel,
55
+ prompt: () => prompt
54
56
  });
55
57
  import g, { stdin, stdout } from "process";
56
58
  import f from "readline";
@@ -807,7 +809,7 @@ var package_default;
807
809
  var init_package = __esm(() => {
808
810
  package_default = {
809
811
  name: "@tensorix/metahub",
810
- version: "0.4.1",
812
+ version: "0.5.0",
811
813
  description: "Metahub core library and CLI",
812
814
  license: "AGPL-3.0-only",
813
815
  type: "module",
@@ -1150,6 +1152,12 @@ var init_intent_retention = __esm(() => {
1150
1152
  });
1151
1153
 
1152
1154
  // src/core/crdt.ts
1155
+ function setActorTag(tag) {
1156
+ if (tag !== null && !ACTOR_TAG_RE.test(tag)) {
1157
+ throw new Error(`invalid actor tag: ${tag}`);
1158
+ }
1159
+ currentActor = tag;
1160
+ }
1153
1161
  function withNodeId(node, fn) {
1154
1162
  const prev = currentNodeOverride;
1155
1163
  currentNodeOverride = node;
@@ -1162,7 +1170,7 @@ function withNodeId(node, fn) {
1162
1170
  function withChangeGroup(label, fn) {
1163
1171
  if (currentTxn !== null)
1164
1172
  return fn();
1165
- currentTxn = (label ? label + ":" : "") + randomSuffix(8);
1173
+ currentTxn = (currentActor ? currentActor + "/" : "") + (label ? label + ":" : "") + randomSuffix(8);
1166
1174
  try {
1167
1175
  return fn();
1168
1176
  } finally {
@@ -1321,13 +1329,14 @@ function changesAfterSeq(db, seq, opts = {}) {
1321
1329
  }
1322
1330
  return { changes: rows.map(({ seq: _seq, ...c3 }) => c3), cursor };
1323
1331
  }
1324
- var CHANGE_COLS, CHANGE_SELECT, currentTxn = null, currentNodeOverride = null, DOMAIN, RECORD_META, OPLOG_ONLY_DATASETS, NOT_NULL_ZERO_COLS;
1332
+ var CHANGE_COLS, CHANGE_SELECT, currentTxn = null, currentActor = null, ACTOR_TAG_RE, currentNodeOverride = null, DOMAIN, RECORD_META, OPLOG_ONLY_DATASETS, NOT_NULL_ZERO_COLS;
1325
1333
  var init_crdt = __esm(() => {
1326
1334
  init_node();
1327
1335
  init_ids();
1328
1336
  init_intent_retention();
1329
1337
  CHANGE_COLS = ["hlc", "node_id", "dataset", "row_id", "col", "value", "txn"];
1330
1338
  CHANGE_SELECT = CHANGE_COLS.join(", ");
1339
+ ACTOR_TAG_RE = /^[a-z0-9_-]{1,16}$/;
1331
1340
  DOMAIN = {
1332
1341
  databases: {
1333
1342
  table: "databases",
@@ -2581,69 +2590,69 @@ var init_core = __esm(() => {
2581
2590
  // node_modules/zod/v4/core/util.js
2582
2591
  var exports_util = {};
2583
2592
  __export(exports_util, {
2584
- unwrapMessage: () => unwrapMessage,
2585
- uint8ArrayToHex: () => uint8ArrayToHex,
2586
- uint8ArrayToBase64url: () => uint8ArrayToBase64url,
2587
- uint8ArrayToBase64: () => uint8ArrayToBase64,
2588
- stringifyPrimitive: () => stringifyPrimitive,
2589
- slugify: () => slugify2,
2590
- shallowClone: () => shallowClone,
2591
- safeExtend: () => safeExtend,
2592
- required: () => required,
2593
- randomString: () => randomString,
2594
- propertyKeyTypes: () => propertyKeyTypes,
2595
- promiseAllObject: () => promiseAllObject,
2596
- primitiveTypes: () => primitiveTypes,
2597
- prefixIssues: () => prefixIssues,
2598
- pick: () => pick,
2599
- partial: () => partial,
2600
- parsedType: () => parsedType,
2601
- optionalKeys: () => optionalKeys,
2602
- omit: () => omit,
2603
- objectClone: () => objectClone,
2604
- numKeys: () => numKeys,
2605
- nullish: () => nullish,
2606
- normalizeParams: () => normalizeParams,
2607
- mergeDefs: () => mergeDefs,
2608
- merge: () => merge,
2609
- jsonStringifyReplacer: () => jsonStringifyReplacer,
2610
- joinValues: () => joinValues,
2611
- issue: () => issue,
2612
- isPlainObject: () => isPlainObject2,
2613
- isObject: () => isObject,
2614
- hexToUint8Array: () => hexToUint8Array,
2615
- getSizableOrigin: () => getSizableOrigin,
2616
- getParsedType: () => getParsedType,
2617
- getLengthableOrigin: () => getLengthableOrigin,
2618
- getEnumValues: () => getEnumValues,
2619
- getElementAtPath: () => getElementAtPath,
2620
- floatSafeRemainder: () => floatSafeRemainder,
2621
- finalizeIssue: () => finalizeIssue,
2622
- extend: () => extend,
2623
- explicitlyAborted: () => explicitlyAborted,
2624
- escapeRegex: () => escapeRegex,
2625
- esc: () => esc,
2626
- defineLazy: () => defineLazy,
2627
- createTransparentProxy: () => createTransparentProxy,
2628
- cloneDef: () => cloneDef,
2629
- clone: () => clone,
2630
- cleanRegex: () => cleanRegex,
2631
- cleanEnum: () => cleanEnum,
2632
- captureStackTrace: () => captureStackTrace,
2633
- cached: () => cached,
2634
- base64urlToUint8Array: () => base64urlToUint8Array,
2635
- base64ToUint8Array: () => base64ToUint8Array,
2636
- assignProp: () => assignProp,
2637
- assertNotEqual: () => assertNotEqual,
2638
- assertNever: () => assertNever,
2639
- assertIs: () => assertIs,
2640
- assertEqual: () => assertEqual,
2641
- assert: () => assert,
2642
- allowsEval: () => allowsEval,
2643
- aborted: () => aborted,
2644
- NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
2593
+ BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
2645
2594
  Class: () => Class,
2646
- BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES
2595
+ NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
2596
+ aborted: () => aborted,
2597
+ allowsEval: () => allowsEval,
2598
+ assert: () => assert,
2599
+ assertEqual: () => assertEqual,
2600
+ assertIs: () => assertIs,
2601
+ assertNever: () => assertNever,
2602
+ assertNotEqual: () => assertNotEqual,
2603
+ assignProp: () => assignProp,
2604
+ base64ToUint8Array: () => base64ToUint8Array,
2605
+ base64urlToUint8Array: () => base64urlToUint8Array,
2606
+ cached: () => cached,
2607
+ captureStackTrace: () => captureStackTrace,
2608
+ cleanEnum: () => cleanEnum,
2609
+ cleanRegex: () => cleanRegex,
2610
+ clone: () => clone,
2611
+ cloneDef: () => cloneDef,
2612
+ createTransparentProxy: () => createTransparentProxy,
2613
+ defineLazy: () => defineLazy,
2614
+ esc: () => esc,
2615
+ escapeRegex: () => escapeRegex,
2616
+ explicitlyAborted: () => explicitlyAborted,
2617
+ extend: () => extend,
2618
+ finalizeIssue: () => finalizeIssue,
2619
+ floatSafeRemainder: () => floatSafeRemainder,
2620
+ getElementAtPath: () => getElementAtPath,
2621
+ getEnumValues: () => getEnumValues,
2622
+ getLengthableOrigin: () => getLengthableOrigin,
2623
+ getParsedType: () => getParsedType,
2624
+ getSizableOrigin: () => getSizableOrigin,
2625
+ hexToUint8Array: () => hexToUint8Array,
2626
+ isObject: () => isObject,
2627
+ isPlainObject: () => isPlainObject2,
2628
+ issue: () => issue,
2629
+ joinValues: () => joinValues,
2630
+ jsonStringifyReplacer: () => jsonStringifyReplacer,
2631
+ merge: () => merge,
2632
+ mergeDefs: () => mergeDefs,
2633
+ normalizeParams: () => normalizeParams,
2634
+ nullish: () => nullish,
2635
+ numKeys: () => numKeys,
2636
+ objectClone: () => objectClone,
2637
+ omit: () => omit,
2638
+ optionalKeys: () => optionalKeys,
2639
+ parsedType: () => parsedType,
2640
+ partial: () => partial,
2641
+ pick: () => pick,
2642
+ prefixIssues: () => prefixIssues,
2643
+ primitiveTypes: () => primitiveTypes,
2644
+ promiseAllObject: () => promiseAllObject,
2645
+ propertyKeyTypes: () => propertyKeyTypes,
2646
+ randomString: () => randomString,
2647
+ required: () => required,
2648
+ safeExtend: () => safeExtend,
2649
+ shallowClone: () => shallowClone,
2650
+ slugify: () => slugify2,
2651
+ stringifyPrimitive: () => stringifyPrimitive,
2652
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
2653
+ uint8ArrayToBase64url: () => uint8ArrayToBase64url,
2654
+ uint8ArrayToHex: () => uint8ArrayToHex,
2655
+ unwrapMessage: () => unwrapMessage
2647
2656
  });
2648
2657
  function assertEqual(val) {
2649
2658
  return val;
@@ -3502,65 +3511,65 @@ var init_parse = __esm(() => {
3502
3511
  // node_modules/zod/v4/core/regexes.js
3503
3512
  var exports_regexes = {};
3504
3513
  __export(exports_regexes, {
3505
- xid: () => xid,
3506
- uuid7: () => uuid7,
3507
- uuid6: () => uuid6,
3508
- uuid4: () => uuid4,
3509
- uuid: () => uuid,
3510
- uppercase: () => uppercase,
3511
- unicodeEmail: () => unicodeEmail,
3512
- undefined: () => _undefined,
3513
- ulid: () => ulid,
3514
- time: () => time,
3515
- string: () => string,
3516
- sha512_hex: () => sha512_hex,
3517
- sha512_base64url: () => sha512_base64url,
3518
- sha512_base64: () => sha512_base64,
3519
- sha384_hex: () => sha384_hex,
3520
- sha384_base64url: () => sha384_base64url,
3521
- sha384_base64: () => sha384_base64,
3522
- sha256_hex: () => sha256_hex,
3523
- sha256_base64url: () => sha256_base64url,
3524
- sha256_base64: () => sha256_base64,
3525
- sha1_hex: () => sha1_hex,
3526
- sha1_base64url: () => sha1_base64url,
3527
- sha1_base64: () => sha1_base64,
3528
- rfc5322Email: () => rfc5322Email,
3529
- number: () => number,
3530
- null: () => _null,
3531
- nanoid: () => nanoid,
3532
- md5_hex: () => md5_hex,
3533
- md5_base64url: () => md5_base64url,
3534
- md5_base64: () => md5_base64,
3535
- mac: () => mac,
3536
- lowercase: () => lowercase,
3537
- ksuid: () => ksuid,
3538
- ipv6: () => ipv6,
3539
- ipv4: () => ipv4,
3540
- integer: () => integer,
3541
- idnEmail: () => idnEmail,
3542
- httpProtocol: () => httpProtocol,
3543
- html5Email: () => html5Email,
3544
- hostname: () => hostname,
3545
- hex: () => hex,
3546
- guid: () => guid,
3547
- extendedDuration: () => extendedDuration,
3548
- emoji: () => emoji,
3549
- email: () => email,
3550
- e164: () => e164,
3551
- duration: () => duration,
3552
- domain: () => domain,
3553
- datetime: () => datetime,
3554
- date: () => date,
3555
- cuid2: () => cuid2,
3556
- cuid: () => cuid,
3557
- cidrv6: () => cidrv6,
3558
- cidrv4: () => cidrv4,
3559
- browserEmail: () => browserEmail,
3560
- boolean: () => boolean,
3561
- bigint: () => bigint,
3514
+ base64: () => base64,
3562
3515
  base64url: () => base64url,
3563
- base64: () => base64
3516
+ bigint: () => bigint,
3517
+ boolean: () => boolean,
3518
+ browserEmail: () => browserEmail,
3519
+ cidrv4: () => cidrv4,
3520
+ cidrv6: () => cidrv6,
3521
+ cuid: () => cuid,
3522
+ cuid2: () => cuid2,
3523
+ date: () => date,
3524
+ datetime: () => datetime,
3525
+ domain: () => domain,
3526
+ duration: () => duration,
3527
+ e164: () => e164,
3528
+ email: () => email,
3529
+ emoji: () => emoji,
3530
+ extendedDuration: () => extendedDuration,
3531
+ guid: () => guid,
3532
+ hex: () => hex,
3533
+ hostname: () => hostname,
3534
+ html5Email: () => html5Email,
3535
+ httpProtocol: () => httpProtocol,
3536
+ idnEmail: () => idnEmail,
3537
+ integer: () => integer,
3538
+ ipv4: () => ipv4,
3539
+ ipv6: () => ipv6,
3540
+ ksuid: () => ksuid,
3541
+ lowercase: () => lowercase,
3542
+ mac: () => mac,
3543
+ md5_base64: () => md5_base64,
3544
+ md5_base64url: () => md5_base64url,
3545
+ md5_hex: () => md5_hex,
3546
+ nanoid: () => nanoid,
3547
+ null: () => _null,
3548
+ number: () => number,
3549
+ rfc5322Email: () => rfc5322Email,
3550
+ sha1_base64: () => sha1_base64,
3551
+ sha1_base64url: () => sha1_base64url,
3552
+ sha1_hex: () => sha1_hex,
3553
+ sha256_base64: () => sha256_base64,
3554
+ sha256_base64url: () => sha256_base64url,
3555
+ sha256_hex: () => sha256_hex,
3556
+ sha384_base64: () => sha384_base64,
3557
+ sha384_base64url: () => sha384_base64url,
3558
+ sha384_hex: () => sha384_hex,
3559
+ sha512_base64: () => sha512_base64,
3560
+ sha512_base64url: () => sha512_base64url,
3561
+ sha512_hex: () => sha512_hex,
3562
+ string: () => string,
3563
+ time: () => time,
3564
+ ulid: () => ulid,
3565
+ undefined: () => _undefined,
3566
+ unicodeEmail: () => unicodeEmail,
3567
+ uppercase: () => uppercase,
3568
+ uuid: () => uuid,
3569
+ uuid4: () => uuid4,
3570
+ uuid6: () => uuid6,
3571
+ uuid7: () => uuid7,
3572
+ xid: () => xid
3564
3573
  });
3565
3574
  function emoji() {
3566
3575
  return new RegExp(_emoji, "u");
@@ -12405,58 +12414,58 @@ var init_yo = __esm(() => {
12405
12414
  // node_modules/zod/v4/locales/index.js
12406
12415
  var exports_locales = {};
12407
12416
  __export(exports_locales, {
12408
- zhTW: () => zh_TW_default,
12409
- zhCN: () => zh_CN_default,
12410
- yo: () => yo_default,
12411
- vi: () => vi_default,
12412
- uz: () => uz_default,
12413
- ur: () => ur_default,
12414
- uk: () => uk_default,
12415
- ua: () => ua_default,
12416
- tr: () => tr_default,
12417
- th: () => th_default,
12418
- ta: () => ta_default,
12419
- sv: () => sv_default,
12420
- sl: () => sl_default,
12421
- ru: () => ru_default,
12422
- ro: () => ro_default,
12423
- pt: () => pt_default,
12424
- ps: () => ps_default,
12425
- pl: () => pl_default,
12426
- ota: () => ota_default,
12427
- no: () => no_default,
12428
- nl: () => nl_default,
12429
- ms: () => ms_default,
12430
- mk: () => mk_default,
12431
- lt: () => lt_default,
12432
- ko: () => ko_default,
12433
- km: () => km_default,
12434
- kh: () => kh_default,
12435
- ka: () => ka_default,
12436
- ja: () => ja_default,
12437
- it: () => it_default,
12438
- is: () => is_default,
12439
- id: () => id_default,
12440
- hy: () => hy_default,
12441
- hu: () => hu_default,
12442
- hr: () => hr_default,
12443
- he: () => he_default,
12444
- frCA: () => fr_CA_default,
12445
- fr: () => fr_default,
12446
- fi: () => fi_default,
12447
- fa: () => fa_default,
12448
- es: () => es_default,
12449
- eo: () => eo_default,
12450
- en: () => en_default,
12451
- el: () => el_default,
12452
- de: () => de_default,
12453
- da: () => da_default,
12454
- cs: () => cs_default,
12455
- ca: () => ca_default,
12456
- bg: () => bg_default,
12457
- be: () => be_default,
12417
+ ar: () => ar_default,
12458
12418
  az: () => az_default,
12459
- ar: () => ar_default
12419
+ be: () => be_default,
12420
+ bg: () => bg_default,
12421
+ ca: () => ca_default,
12422
+ cs: () => cs_default,
12423
+ da: () => da_default,
12424
+ de: () => de_default,
12425
+ el: () => el_default,
12426
+ en: () => en_default,
12427
+ eo: () => eo_default,
12428
+ es: () => es_default,
12429
+ fa: () => fa_default,
12430
+ fi: () => fi_default,
12431
+ fr: () => fr_default,
12432
+ frCA: () => fr_CA_default,
12433
+ he: () => he_default,
12434
+ hr: () => hr_default,
12435
+ hu: () => hu_default,
12436
+ hy: () => hy_default,
12437
+ id: () => id_default,
12438
+ is: () => is_default,
12439
+ it: () => it_default,
12440
+ ja: () => ja_default,
12441
+ ka: () => ka_default,
12442
+ kh: () => kh_default,
12443
+ km: () => km_default,
12444
+ ko: () => ko_default,
12445
+ lt: () => lt_default,
12446
+ mk: () => mk_default,
12447
+ ms: () => ms_default,
12448
+ nl: () => nl_default,
12449
+ no: () => no_default,
12450
+ ota: () => ota_default,
12451
+ pl: () => pl_default,
12452
+ ps: () => ps_default,
12453
+ pt: () => pt_default,
12454
+ ro: () => ro_default,
12455
+ ru: () => ru_default,
12456
+ sl: () => sl_default,
12457
+ sv: () => sv_default,
12458
+ ta: () => ta_default,
12459
+ th: () => th_default,
12460
+ tr: () => tr_default,
12461
+ ua: () => ua_default,
12462
+ uk: () => uk_default,
12463
+ ur: () => ur_default,
12464
+ uz: () => uz_default,
12465
+ vi: () => vi_default,
12466
+ yo: () => yo_default,
12467
+ zhCN: () => zh_CN_default,
12468
+ zhTW: () => zh_TW_default
12460
12469
  });
12461
12470
  var init_locales = __esm(() => {
12462
12471
  init_ar();
@@ -14424,280 +14433,280 @@ var init_json_schema = () => {};
14424
14433
  // node_modules/zod/v4/core/index.js
14425
14434
  var exports_core2 = {};
14426
14435
  __export(exports_core2, {
14427
- version: () => version,
14428
- util: () => exports_util,
14429
- treeifyError: () => treeifyError,
14430
- toJSONSchema: () => toJSONSchema,
14431
- toDotPath: () => toDotPath,
14432
- safeParseAsync: () => safeParseAsync,
14433
- safeParse: () => safeParse,
14434
- safeEncodeAsync: () => safeEncodeAsync,
14435
- safeEncode: () => safeEncode,
14436
- safeDecodeAsync: () => safeDecodeAsync,
14437
- safeDecode: () => safeDecode,
14438
- registry: () => registry,
14439
- regexes: () => exports_regexes,
14440
- process: () => process2,
14441
- prettifyError: () => prettifyError,
14442
- parseAsync: () => parseAsync,
14443
- parse: () => parse,
14444
- meta: () => meta,
14445
- locales: () => exports_locales,
14446
- isValidJWT: () => isValidJWT,
14447
- isValidBase64URL: () => isValidBase64URL,
14448
- isValidBase64: () => isValidBase64,
14449
- initializeContext: () => initializeContext,
14450
- globalRegistry: () => globalRegistry,
14451
- globalConfig: () => globalConfig,
14452
- formatError: () => formatError,
14453
- flattenError: () => flattenError,
14454
- finalize: () => finalize,
14455
- extractDefs: () => extractDefs,
14456
- encodeAsync: () => encodeAsync,
14457
- encode: () => encode,
14458
- describe: () => describe,
14459
- decodeAsync: () => decodeAsync,
14460
- decode: () => decode,
14461
- createToJSONSchemaMethod: () => createToJSONSchemaMethod,
14462
- createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
14463
- config: () => config,
14464
- clone: () => clone,
14465
- _xor: () => _xor,
14466
- _xid: () => _xid,
14467
- _void: () => _void,
14468
- _uuidv7: () => _uuidv7,
14469
- _uuidv6: () => _uuidv6,
14470
- _uuidv4: () => _uuidv4,
14471
- _uuid: () => _uuid,
14472
- _url: () => _url,
14473
- _uppercase: () => _uppercase,
14474
- _unknown: () => _unknown,
14475
- _union: () => _union,
14476
- _undefined: () => _undefined2,
14477
- _ulid: () => _ulid,
14478
- _uint64: () => _uint64,
14479
- _uint32: () => _uint32,
14480
- _tuple: () => _tuple,
14481
- _trim: () => _trim,
14482
- _transform: () => _transform,
14483
- _toUpperCase: () => _toUpperCase,
14484
- _toLowerCase: () => _toLowerCase,
14485
- _templateLiteral: () => _templateLiteral,
14486
- _symbol: () => _symbol,
14487
- _superRefine: () => _superRefine,
14488
- _success: () => _success,
14489
- _stringbool: () => _stringbool,
14490
- _stringFormat: () => _stringFormat,
14491
- _string: () => _string,
14492
- _startsWith: () => _startsWith,
14493
- _slugify: () => _slugify,
14494
- _size: () => _size,
14495
- _set: () => _set,
14496
- _safeParseAsync: () => _safeParseAsync,
14497
- _safeParse: () => _safeParse,
14498
- _safeEncodeAsync: () => _safeEncodeAsync,
14499
- _safeEncode: () => _safeEncode,
14500
- _safeDecodeAsync: () => _safeDecodeAsync,
14501
- _safeDecode: () => _safeDecode,
14502
- _regex: () => _regex,
14503
- _refine: () => _refine,
14504
- _record: () => _record,
14505
- _readonly: () => _readonly,
14506
- _property: () => _property,
14507
- _promise: () => _promise,
14508
- _positive: () => _positive,
14509
- _pipe: () => _pipe,
14510
- _parseAsync: () => _parseAsync,
14511
- _parse: () => _parse,
14512
- _overwrite: () => _overwrite,
14513
- _optional: () => _optional,
14514
- _number: () => _number,
14515
- _nullable: () => _nullable,
14516
- _null: () => _null2,
14517
- _normalize: () => _normalize,
14518
- _nonpositive: () => _nonpositive,
14519
- _nonoptional: () => _nonoptional,
14520
- _nonnegative: () => _nonnegative,
14521
- _never: () => _never,
14522
- _negative: () => _negative,
14523
- _nativeEnum: () => _nativeEnum,
14524
- _nanoid: () => _nanoid,
14525
- _nan: () => _nan,
14526
- _multipleOf: () => _multipleOf,
14527
- _minSize: () => _minSize,
14528
- _minLength: () => _minLength,
14529
- _min: () => _gte,
14530
- _mime: () => _mime,
14531
- _maxSize: () => _maxSize,
14532
- _maxLength: () => _maxLength,
14533
- _max: () => _lte,
14534
- _map: () => _map,
14535
- _mac: () => _mac,
14536
- _lte: () => _lte,
14537
- _lt: () => _lt,
14538
- _lowercase: () => _lowercase,
14539
- _literal: () => _literal,
14540
- _length: () => _length,
14541
- _lazy: () => _lazy,
14542
- _ksuid: () => _ksuid,
14543
- _jwt: () => _jwt,
14544
- _isoTime: () => _isoTime,
14545
- _isoDuration: () => _isoDuration,
14546
- _isoDateTime: () => _isoDateTime,
14547
- _isoDate: () => _isoDate,
14548
- _ipv6: () => _ipv6,
14549
- _ipv4: () => _ipv4,
14550
- _intersection: () => _intersection,
14551
- _int64: () => _int64,
14552
- _int32: () => _int32,
14553
- _int: () => _int,
14554
- _includes: () => _includes,
14555
- _guid: () => _guid,
14556
- _gte: () => _gte,
14557
- _gt: () => _gt,
14558
- _float64: () => _float64,
14559
- _float32: () => _float32,
14560
- _file: () => _file,
14561
- _enum: () => _enum,
14562
- _endsWith: () => _endsWith,
14563
- _encodeAsync: () => _encodeAsync,
14564
- _encode: () => _encode,
14565
- _emoji: () => _emoji2,
14566
- _email: () => _email,
14567
- _e164: () => _e164,
14568
- _discriminatedUnion: () => _discriminatedUnion,
14569
- _default: () => _default,
14570
- _decodeAsync: () => _decodeAsync,
14571
- _decode: () => _decode,
14572
- _date: () => _date,
14573
- _custom: () => _custom,
14574
- _cuid2: () => _cuid2,
14575
- _cuid: () => _cuid,
14576
- _coercedString: () => _coercedString,
14577
- _coercedNumber: () => _coercedNumber,
14578
- _coercedDate: () => _coercedDate,
14579
- _coercedBoolean: () => _coercedBoolean,
14580
- _coercedBigint: () => _coercedBigint,
14581
- _cidrv6: () => _cidrv6,
14582
- _cidrv4: () => _cidrv4,
14583
- _check: () => _check,
14584
- _catch: () => _catch,
14585
- _boolean: () => _boolean,
14586
- _bigint: () => _bigint,
14587
- _base64url: () => _base64url,
14588
- _base64: () => _base64,
14589
- _array: () => _array,
14590
- _any: () => _any,
14591
- TimePrecision: () => TimePrecision,
14592
- NEVER: () => NEVER,
14593
- JSONSchemaGenerator: () => JSONSchemaGenerator,
14594
- JSONSchema: () => exports_json_schema,
14595
- Doc: () => Doc,
14596
- $output: () => $output,
14597
- $input: () => $input,
14598
- $constructor: () => $constructor,
14599
- $brand: () => $brand,
14600
- $ZodXor: () => $ZodXor,
14601
- $ZodXID: () => $ZodXID,
14602
- $ZodVoid: () => $ZodVoid,
14603
- $ZodUnknown: () => $ZodUnknown,
14604
- $ZodUnion: () => $ZodUnion,
14605
- $ZodUndefined: () => $ZodUndefined,
14606
- $ZodUUID: () => $ZodUUID,
14607
- $ZodURL: () => $ZodURL,
14608
- $ZodULID: () => $ZodULID,
14609
- $ZodType: () => $ZodType,
14610
- $ZodTuple: () => $ZodTuple,
14611
- $ZodTransform: () => $ZodTransform,
14612
- $ZodTemplateLiteral: () => $ZodTemplateLiteral,
14613
- $ZodSymbol: () => $ZodSymbol,
14614
- $ZodSuccess: () => $ZodSuccess,
14615
- $ZodStringFormat: () => $ZodStringFormat,
14616
- $ZodString: () => $ZodString,
14617
- $ZodSet: () => $ZodSet,
14618
- $ZodRegistry: () => $ZodRegistry,
14619
- $ZodRecord: () => $ZodRecord,
14620
- $ZodRealError: () => $ZodRealError,
14621
- $ZodReadonly: () => $ZodReadonly,
14622
- $ZodPromise: () => $ZodPromise,
14623
- $ZodPreprocess: () => $ZodPreprocess,
14624
- $ZodPrefault: () => $ZodPrefault,
14625
- $ZodPipe: () => $ZodPipe,
14626
- $ZodOptional: () => $ZodOptional,
14627
- $ZodObjectJIT: () => $ZodObjectJIT,
14628
- $ZodObject: () => $ZodObject,
14629
- $ZodNumberFormat: () => $ZodNumberFormat,
14630
- $ZodNumber: () => $ZodNumber,
14631
- $ZodNullable: () => $ZodNullable,
14632
- $ZodNull: () => $ZodNull,
14633
- $ZodNonOptional: () => $ZodNonOptional,
14634
- $ZodNever: () => $ZodNever,
14635
- $ZodNanoID: () => $ZodNanoID,
14636
- $ZodNaN: () => $ZodNaN,
14637
- $ZodMap: () => $ZodMap,
14638
- $ZodMAC: () => $ZodMAC,
14639
- $ZodLiteral: () => $ZodLiteral,
14640
- $ZodLazy: () => $ZodLazy,
14641
- $ZodKSUID: () => $ZodKSUID,
14642
- $ZodJWT: () => $ZodJWT,
14643
- $ZodIntersection: () => $ZodIntersection,
14644
- $ZodISOTime: () => $ZodISOTime,
14645
- $ZodISODuration: () => $ZodISODuration,
14646
- $ZodISODateTime: () => $ZodISODateTime,
14647
- $ZodISODate: () => $ZodISODate,
14648
- $ZodIPv6: () => $ZodIPv6,
14649
- $ZodIPv4: () => $ZodIPv4,
14650
- $ZodGUID: () => $ZodGUID,
14651
- $ZodFunction: () => $ZodFunction,
14652
- $ZodFile: () => $ZodFile,
14653
- $ZodExactOptional: () => $ZodExactOptional,
14654
- $ZodError: () => $ZodError,
14655
- $ZodEnum: () => $ZodEnum,
14656
- $ZodEncodeError: () => $ZodEncodeError,
14657
- $ZodEmoji: () => $ZodEmoji,
14658
- $ZodEmail: () => $ZodEmail,
14659
- $ZodE164: () => $ZodE164,
14660
- $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
14661
- $ZodDefault: () => $ZodDefault,
14662
- $ZodDate: () => $ZodDate,
14663
- $ZodCustomStringFormat: () => $ZodCustomStringFormat,
14664
- $ZodCustom: () => $ZodCustom,
14665
- $ZodCodec: () => $ZodCodec,
14666
- $ZodCheckUpperCase: () => $ZodCheckUpperCase,
14667
- $ZodCheckStringFormat: () => $ZodCheckStringFormat,
14668
- $ZodCheckStartsWith: () => $ZodCheckStartsWith,
14669
- $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
14670
- $ZodCheckRegex: () => $ZodCheckRegex,
14671
- $ZodCheckProperty: () => $ZodCheckProperty,
14672
- $ZodCheckOverwrite: () => $ZodCheckOverwrite,
14673
- $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
14674
- $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
14675
- $ZodCheckMinSize: () => $ZodCheckMinSize,
14676
- $ZodCheckMinLength: () => $ZodCheckMinLength,
14677
- $ZodCheckMimeType: () => $ZodCheckMimeType,
14678
- $ZodCheckMaxSize: () => $ZodCheckMaxSize,
14679
- $ZodCheckMaxLength: () => $ZodCheckMaxLength,
14680
- $ZodCheckLowerCase: () => $ZodCheckLowerCase,
14681
- $ZodCheckLessThan: () => $ZodCheckLessThan,
14682
- $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
14683
- $ZodCheckIncludes: () => $ZodCheckIncludes,
14684
- $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
14685
- $ZodCheckEndsWith: () => $ZodCheckEndsWith,
14686
- $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
14687
- $ZodCheck: () => $ZodCheck,
14688
- $ZodCatch: () => $ZodCatch,
14689
- $ZodCUID2: () => $ZodCUID2,
14690
- $ZodCUID: () => $ZodCUID,
14691
- $ZodCIDRv6: () => $ZodCIDRv6,
14692
- $ZodCIDRv4: () => $ZodCIDRv4,
14693
- $ZodBoolean: () => $ZodBoolean,
14694
- $ZodBigIntFormat: () => $ZodBigIntFormat,
14695
- $ZodBigInt: () => $ZodBigInt,
14696
- $ZodBase64URL: () => $ZodBase64URL,
14697
- $ZodBase64: () => $ZodBase64,
14698
- $ZodAsyncError: () => $ZodAsyncError,
14436
+ $ZodAny: () => $ZodAny,
14699
14437
  $ZodArray: () => $ZodArray,
14700
- $ZodAny: () => $ZodAny
14438
+ $ZodAsyncError: () => $ZodAsyncError,
14439
+ $ZodBase64: () => $ZodBase64,
14440
+ $ZodBase64URL: () => $ZodBase64URL,
14441
+ $ZodBigInt: () => $ZodBigInt,
14442
+ $ZodBigIntFormat: () => $ZodBigIntFormat,
14443
+ $ZodBoolean: () => $ZodBoolean,
14444
+ $ZodCIDRv4: () => $ZodCIDRv4,
14445
+ $ZodCIDRv6: () => $ZodCIDRv6,
14446
+ $ZodCUID: () => $ZodCUID,
14447
+ $ZodCUID2: () => $ZodCUID2,
14448
+ $ZodCatch: () => $ZodCatch,
14449
+ $ZodCheck: () => $ZodCheck,
14450
+ $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
14451
+ $ZodCheckEndsWith: () => $ZodCheckEndsWith,
14452
+ $ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
14453
+ $ZodCheckIncludes: () => $ZodCheckIncludes,
14454
+ $ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
14455
+ $ZodCheckLessThan: () => $ZodCheckLessThan,
14456
+ $ZodCheckLowerCase: () => $ZodCheckLowerCase,
14457
+ $ZodCheckMaxLength: () => $ZodCheckMaxLength,
14458
+ $ZodCheckMaxSize: () => $ZodCheckMaxSize,
14459
+ $ZodCheckMimeType: () => $ZodCheckMimeType,
14460
+ $ZodCheckMinLength: () => $ZodCheckMinLength,
14461
+ $ZodCheckMinSize: () => $ZodCheckMinSize,
14462
+ $ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
14463
+ $ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
14464
+ $ZodCheckOverwrite: () => $ZodCheckOverwrite,
14465
+ $ZodCheckProperty: () => $ZodCheckProperty,
14466
+ $ZodCheckRegex: () => $ZodCheckRegex,
14467
+ $ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
14468
+ $ZodCheckStartsWith: () => $ZodCheckStartsWith,
14469
+ $ZodCheckStringFormat: () => $ZodCheckStringFormat,
14470
+ $ZodCheckUpperCase: () => $ZodCheckUpperCase,
14471
+ $ZodCodec: () => $ZodCodec,
14472
+ $ZodCustom: () => $ZodCustom,
14473
+ $ZodCustomStringFormat: () => $ZodCustomStringFormat,
14474
+ $ZodDate: () => $ZodDate,
14475
+ $ZodDefault: () => $ZodDefault,
14476
+ $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
14477
+ $ZodE164: () => $ZodE164,
14478
+ $ZodEmail: () => $ZodEmail,
14479
+ $ZodEmoji: () => $ZodEmoji,
14480
+ $ZodEncodeError: () => $ZodEncodeError,
14481
+ $ZodEnum: () => $ZodEnum,
14482
+ $ZodError: () => $ZodError,
14483
+ $ZodExactOptional: () => $ZodExactOptional,
14484
+ $ZodFile: () => $ZodFile,
14485
+ $ZodFunction: () => $ZodFunction,
14486
+ $ZodGUID: () => $ZodGUID,
14487
+ $ZodIPv4: () => $ZodIPv4,
14488
+ $ZodIPv6: () => $ZodIPv6,
14489
+ $ZodISODate: () => $ZodISODate,
14490
+ $ZodISODateTime: () => $ZodISODateTime,
14491
+ $ZodISODuration: () => $ZodISODuration,
14492
+ $ZodISOTime: () => $ZodISOTime,
14493
+ $ZodIntersection: () => $ZodIntersection,
14494
+ $ZodJWT: () => $ZodJWT,
14495
+ $ZodKSUID: () => $ZodKSUID,
14496
+ $ZodLazy: () => $ZodLazy,
14497
+ $ZodLiteral: () => $ZodLiteral,
14498
+ $ZodMAC: () => $ZodMAC,
14499
+ $ZodMap: () => $ZodMap,
14500
+ $ZodNaN: () => $ZodNaN,
14501
+ $ZodNanoID: () => $ZodNanoID,
14502
+ $ZodNever: () => $ZodNever,
14503
+ $ZodNonOptional: () => $ZodNonOptional,
14504
+ $ZodNull: () => $ZodNull,
14505
+ $ZodNullable: () => $ZodNullable,
14506
+ $ZodNumber: () => $ZodNumber,
14507
+ $ZodNumberFormat: () => $ZodNumberFormat,
14508
+ $ZodObject: () => $ZodObject,
14509
+ $ZodObjectJIT: () => $ZodObjectJIT,
14510
+ $ZodOptional: () => $ZodOptional,
14511
+ $ZodPipe: () => $ZodPipe,
14512
+ $ZodPrefault: () => $ZodPrefault,
14513
+ $ZodPreprocess: () => $ZodPreprocess,
14514
+ $ZodPromise: () => $ZodPromise,
14515
+ $ZodReadonly: () => $ZodReadonly,
14516
+ $ZodRealError: () => $ZodRealError,
14517
+ $ZodRecord: () => $ZodRecord,
14518
+ $ZodRegistry: () => $ZodRegistry,
14519
+ $ZodSet: () => $ZodSet,
14520
+ $ZodString: () => $ZodString,
14521
+ $ZodStringFormat: () => $ZodStringFormat,
14522
+ $ZodSuccess: () => $ZodSuccess,
14523
+ $ZodSymbol: () => $ZodSymbol,
14524
+ $ZodTemplateLiteral: () => $ZodTemplateLiteral,
14525
+ $ZodTransform: () => $ZodTransform,
14526
+ $ZodTuple: () => $ZodTuple,
14527
+ $ZodType: () => $ZodType,
14528
+ $ZodULID: () => $ZodULID,
14529
+ $ZodURL: () => $ZodURL,
14530
+ $ZodUUID: () => $ZodUUID,
14531
+ $ZodUndefined: () => $ZodUndefined,
14532
+ $ZodUnion: () => $ZodUnion,
14533
+ $ZodUnknown: () => $ZodUnknown,
14534
+ $ZodVoid: () => $ZodVoid,
14535
+ $ZodXID: () => $ZodXID,
14536
+ $ZodXor: () => $ZodXor,
14537
+ $brand: () => $brand,
14538
+ $constructor: () => $constructor,
14539
+ $input: () => $input,
14540
+ $output: () => $output,
14541
+ Doc: () => Doc,
14542
+ JSONSchema: () => exports_json_schema,
14543
+ JSONSchemaGenerator: () => JSONSchemaGenerator,
14544
+ NEVER: () => NEVER,
14545
+ TimePrecision: () => TimePrecision,
14546
+ _any: () => _any,
14547
+ _array: () => _array,
14548
+ _base64: () => _base64,
14549
+ _base64url: () => _base64url,
14550
+ _bigint: () => _bigint,
14551
+ _boolean: () => _boolean,
14552
+ _catch: () => _catch,
14553
+ _check: () => _check,
14554
+ _cidrv4: () => _cidrv4,
14555
+ _cidrv6: () => _cidrv6,
14556
+ _coercedBigint: () => _coercedBigint,
14557
+ _coercedBoolean: () => _coercedBoolean,
14558
+ _coercedDate: () => _coercedDate,
14559
+ _coercedNumber: () => _coercedNumber,
14560
+ _coercedString: () => _coercedString,
14561
+ _cuid: () => _cuid,
14562
+ _cuid2: () => _cuid2,
14563
+ _custom: () => _custom,
14564
+ _date: () => _date,
14565
+ _decode: () => _decode,
14566
+ _decodeAsync: () => _decodeAsync,
14567
+ _default: () => _default,
14568
+ _discriminatedUnion: () => _discriminatedUnion,
14569
+ _e164: () => _e164,
14570
+ _email: () => _email,
14571
+ _emoji: () => _emoji2,
14572
+ _encode: () => _encode,
14573
+ _encodeAsync: () => _encodeAsync,
14574
+ _endsWith: () => _endsWith,
14575
+ _enum: () => _enum,
14576
+ _file: () => _file,
14577
+ _float32: () => _float32,
14578
+ _float64: () => _float64,
14579
+ _gt: () => _gt,
14580
+ _gte: () => _gte,
14581
+ _guid: () => _guid,
14582
+ _includes: () => _includes,
14583
+ _int: () => _int,
14584
+ _int32: () => _int32,
14585
+ _int64: () => _int64,
14586
+ _intersection: () => _intersection,
14587
+ _ipv4: () => _ipv4,
14588
+ _ipv6: () => _ipv6,
14589
+ _isoDate: () => _isoDate,
14590
+ _isoDateTime: () => _isoDateTime,
14591
+ _isoDuration: () => _isoDuration,
14592
+ _isoTime: () => _isoTime,
14593
+ _jwt: () => _jwt,
14594
+ _ksuid: () => _ksuid,
14595
+ _lazy: () => _lazy,
14596
+ _length: () => _length,
14597
+ _literal: () => _literal,
14598
+ _lowercase: () => _lowercase,
14599
+ _lt: () => _lt,
14600
+ _lte: () => _lte,
14601
+ _mac: () => _mac,
14602
+ _map: () => _map,
14603
+ _max: () => _lte,
14604
+ _maxLength: () => _maxLength,
14605
+ _maxSize: () => _maxSize,
14606
+ _mime: () => _mime,
14607
+ _min: () => _gte,
14608
+ _minLength: () => _minLength,
14609
+ _minSize: () => _minSize,
14610
+ _multipleOf: () => _multipleOf,
14611
+ _nan: () => _nan,
14612
+ _nanoid: () => _nanoid,
14613
+ _nativeEnum: () => _nativeEnum,
14614
+ _negative: () => _negative,
14615
+ _never: () => _never,
14616
+ _nonnegative: () => _nonnegative,
14617
+ _nonoptional: () => _nonoptional,
14618
+ _nonpositive: () => _nonpositive,
14619
+ _normalize: () => _normalize,
14620
+ _null: () => _null2,
14621
+ _nullable: () => _nullable,
14622
+ _number: () => _number,
14623
+ _optional: () => _optional,
14624
+ _overwrite: () => _overwrite,
14625
+ _parse: () => _parse,
14626
+ _parseAsync: () => _parseAsync,
14627
+ _pipe: () => _pipe,
14628
+ _positive: () => _positive,
14629
+ _promise: () => _promise,
14630
+ _property: () => _property,
14631
+ _readonly: () => _readonly,
14632
+ _record: () => _record,
14633
+ _refine: () => _refine,
14634
+ _regex: () => _regex,
14635
+ _safeDecode: () => _safeDecode,
14636
+ _safeDecodeAsync: () => _safeDecodeAsync,
14637
+ _safeEncode: () => _safeEncode,
14638
+ _safeEncodeAsync: () => _safeEncodeAsync,
14639
+ _safeParse: () => _safeParse,
14640
+ _safeParseAsync: () => _safeParseAsync,
14641
+ _set: () => _set,
14642
+ _size: () => _size,
14643
+ _slugify: () => _slugify,
14644
+ _startsWith: () => _startsWith,
14645
+ _string: () => _string,
14646
+ _stringFormat: () => _stringFormat,
14647
+ _stringbool: () => _stringbool,
14648
+ _success: () => _success,
14649
+ _superRefine: () => _superRefine,
14650
+ _symbol: () => _symbol,
14651
+ _templateLiteral: () => _templateLiteral,
14652
+ _toLowerCase: () => _toLowerCase,
14653
+ _toUpperCase: () => _toUpperCase,
14654
+ _transform: () => _transform,
14655
+ _trim: () => _trim,
14656
+ _tuple: () => _tuple,
14657
+ _uint32: () => _uint32,
14658
+ _uint64: () => _uint64,
14659
+ _ulid: () => _ulid,
14660
+ _undefined: () => _undefined2,
14661
+ _union: () => _union,
14662
+ _unknown: () => _unknown,
14663
+ _uppercase: () => _uppercase,
14664
+ _url: () => _url,
14665
+ _uuid: () => _uuid,
14666
+ _uuidv4: () => _uuidv4,
14667
+ _uuidv6: () => _uuidv6,
14668
+ _uuidv7: () => _uuidv7,
14669
+ _void: () => _void,
14670
+ _xid: () => _xid,
14671
+ _xor: () => _xor,
14672
+ clone: () => clone,
14673
+ config: () => config,
14674
+ createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
14675
+ createToJSONSchemaMethod: () => createToJSONSchemaMethod,
14676
+ decode: () => decode,
14677
+ decodeAsync: () => decodeAsync,
14678
+ describe: () => describe,
14679
+ encode: () => encode,
14680
+ encodeAsync: () => encodeAsync,
14681
+ extractDefs: () => extractDefs,
14682
+ finalize: () => finalize,
14683
+ flattenError: () => flattenError,
14684
+ formatError: () => formatError,
14685
+ globalConfig: () => globalConfig,
14686
+ globalRegistry: () => globalRegistry,
14687
+ initializeContext: () => initializeContext,
14688
+ isValidBase64: () => isValidBase64,
14689
+ isValidBase64URL: () => isValidBase64URL,
14690
+ isValidJWT: () => isValidJWT,
14691
+ locales: () => exports_locales,
14692
+ meta: () => meta,
14693
+ parse: () => parse,
14694
+ parseAsync: () => parseAsync,
14695
+ prettifyError: () => prettifyError,
14696
+ process: () => process2,
14697
+ regexes: () => exports_regexes,
14698
+ registry: () => registry,
14699
+ safeDecode: () => safeDecode,
14700
+ safeDecodeAsync: () => safeDecodeAsync,
14701
+ safeEncode: () => safeEncode,
14702
+ safeEncodeAsync: () => safeEncodeAsync,
14703
+ safeParse: () => safeParse,
14704
+ safeParseAsync: () => safeParseAsync,
14705
+ toDotPath: () => toDotPath,
14706
+ toJSONSchema: () => toJSONSchema,
14707
+ treeifyError: () => treeifyError,
14708
+ util: () => exports_util,
14709
+ version: () => version
14701
14710
  });
14702
14711
  var init_core2 = __esm(() => {
14703
14712
  init_util();
@@ -14720,35 +14729,35 @@ var init_core2 = __esm(() => {
14720
14729
  // node_modules/zod/v4/classic/checks.js
14721
14730
  var exports_checks2 = {};
14722
14731
  __export(exports_checks2, {
14723
- uppercase: () => _uppercase,
14724
- trim: () => _trim,
14725
- toUpperCase: () => _toUpperCase,
14726
- toLowerCase: () => _toLowerCase,
14727
- startsWith: () => _startsWith,
14728
- slugify: () => _slugify,
14729
- size: () => _size,
14730
- regex: () => _regex,
14731
- property: () => _property,
14732
- positive: () => _positive,
14733
- overwrite: () => _overwrite,
14734
- normalize: () => _normalize,
14735
- nonpositive: () => _nonpositive,
14736
- nonnegative: () => _nonnegative,
14737
- negative: () => _negative,
14738
- multipleOf: () => _multipleOf,
14739
- minSize: () => _minSize,
14740
- minLength: () => _minLength,
14741
- mime: () => _mime,
14742
- maxSize: () => _maxSize,
14743
- maxLength: () => _maxLength,
14744
- lte: () => _lte,
14745
- lt: () => _lt,
14746
- lowercase: () => _lowercase,
14747
- length: () => _length,
14748
- includes: () => _includes,
14749
- gte: () => _gte,
14732
+ endsWith: () => _endsWith,
14750
14733
  gt: () => _gt,
14751
- endsWith: () => _endsWith
14734
+ gte: () => _gte,
14735
+ includes: () => _includes,
14736
+ length: () => _length,
14737
+ lowercase: () => _lowercase,
14738
+ lt: () => _lt,
14739
+ lte: () => _lte,
14740
+ maxLength: () => _maxLength,
14741
+ maxSize: () => _maxSize,
14742
+ mime: () => _mime,
14743
+ minLength: () => _minLength,
14744
+ minSize: () => _minSize,
14745
+ multipleOf: () => _multipleOf,
14746
+ negative: () => _negative,
14747
+ nonnegative: () => _nonnegative,
14748
+ nonpositive: () => _nonpositive,
14749
+ normalize: () => _normalize,
14750
+ overwrite: () => _overwrite,
14751
+ positive: () => _positive,
14752
+ property: () => _property,
14753
+ regex: () => _regex,
14754
+ size: () => _size,
14755
+ slugify: () => _slugify,
14756
+ startsWith: () => _startsWith,
14757
+ toLowerCase: () => _toLowerCase,
14758
+ toUpperCase: () => _toUpperCase,
14759
+ trim: () => _trim,
14760
+ uppercase: () => _uppercase
14752
14761
  });
14753
14762
  var init_checks2 = __esm(() => {
14754
14763
  init_core2();
@@ -14757,14 +14766,14 @@ var init_checks2 = __esm(() => {
14757
14766
  // node_modules/zod/v4/classic/iso.js
14758
14767
  var exports_iso = {};
14759
14768
  __export(exports_iso, {
14760
- time: () => time2,
14761
- duration: () => duration2,
14762
- datetime: () => datetime2,
14763
- date: () => date2,
14764
- ZodISOTime: () => ZodISOTime,
14765
- ZodISODuration: () => ZodISODuration,
14769
+ ZodISODate: () => ZodISODate,
14766
14770
  ZodISODateTime: () => ZodISODateTime,
14767
- ZodISODate: () => ZodISODate
14771
+ ZodISODuration: () => ZodISODuration,
14772
+ ZodISOTime: () => ZodISOTime,
14773
+ date: () => date2,
14774
+ datetime: () => datetime2,
14775
+ duration: () => duration2,
14776
+ time: () => time2
14768
14777
  });
14769
14778
  function datetime2(params) {
14770
14779
  return _isoDateTime(ZodISODateTime, params);
@@ -14862,172 +14871,172 @@ var init_parse2 = __esm(() => {
14862
14871
  // node_modules/zod/v4/classic/schemas.js
14863
14872
  var exports_schemas2 = {};
14864
14873
  __export(exports_schemas2, {
14865
- xor: () => xor,
14866
- xid: () => xid2,
14867
- void: () => _void2,
14868
- uuidv7: () => uuidv7,
14869
- uuidv6: () => uuidv6,
14870
- uuidv4: () => uuidv4,
14871
- uuid: () => uuid2,
14872
- url: () => url,
14873
- unknown: () => unknown,
14874
- union: () => union,
14875
- undefined: () => _undefined3,
14876
- ulid: () => ulid2,
14877
- uint64: () => uint64,
14878
- uint32: () => uint32,
14879
- tuple: () => tuple,
14880
- transform: () => transform,
14881
- templateLiteral: () => templateLiteral,
14882
- symbol: () => symbol,
14883
- superRefine: () => superRefine,
14884
- success: () => success,
14885
- stringbool: () => stringbool,
14886
- stringFormat: () => stringFormat,
14887
- string: () => string2,
14888
- strictObject: () => strictObject,
14889
- set: () => set,
14890
- refine: () => refine,
14891
- record: () => record,
14892
- readonly: () => readonly,
14893
- promise: () => promise,
14894
- preprocess: () => preprocess,
14895
- prefault: () => prefault,
14896
- pipe: () => pipe,
14897
- partialRecord: () => partialRecord,
14898
- optional: () => optional,
14899
- object: () => object,
14900
- number: () => number2,
14901
- nullish: () => nullish2,
14902
- nullable: () => nullable,
14903
- null: () => _null3,
14904
- nonoptional: () => nonoptional,
14905
- never: () => never,
14906
- nativeEnum: () => nativeEnum,
14907
- nanoid: () => nanoid2,
14908
- nan: () => nan,
14909
- meta: () => meta2,
14910
- map: () => map,
14911
- mac: () => mac2,
14912
- looseRecord: () => looseRecord,
14913
- looseObject: () => looseObject,
14914
- literal: () => literal,
14915
- lazy: () => lazy,
14916
- ksuid: () => ksuid2,
14917
- keyof: () => keyof,
14918
- jwt: () => jwt,
14919
- json: () => json,
14920
- ipv6: () => ipv62,
14921
- ipv4: () => ipv42,
14922
- invertCodec: () => invertCodec,
14923
- intersection: () => intersection,
14924
- int64: () => int64,
14925
- int32: () => int32,
14926
- int: () => int,
14927
- instanceof: () => _instanceof,
14928
- httpUrl: () => httpUrl,
14929
- hostname: () => hostname2,
14930
- hex: () => hex2,
14931
- hash: () => hash2,
14932
- guid: () => guid2,
14933
- function: () => _function,
14934
- float64: () => float64,
14935
- float32: () => float32,
14936
- file: () => file,
14937
- exactOptional: () => exactOptional,
14938
- enum: () => _enum2,
14939
- emoji: () => emoji2,
14940
- email: () => email2,
14941
- e164: () => e1642,
14942
- discriminatedUnion: () => discriminatedUnion,
14943
- describe: () => describe2,
14944
- date: () => date3,
14945
- custom: () => custom,
14946
- cuid2: () => cuid22,
14947
- cuid: () => cuid3,
14948
- codec: () => codec,
14949
- cidrv6: () => cidrv62,
14950
- cidrv4: () => cidrv42,
14951
- check: () => check,
14952
- catch: () => _catch2,
14953
- boolean: () => boolean2,
14954
- bigint: () => bigint2,
14955
- base64url: () => base64url2,
14956
- base64: () => base642,
14957
- array: () => array,
14958
- any: () => any,
14959
- _function: () => _function,
14960
- _default: () => _default2,
14961
- _ZodString: () => _ZodString,
14962
- ZodXor: () => ZodXor,
14963
- ZodXID: () => ZodXID,
14964
- ZodVoid: () => ZodVoid,
14965
- ZodUnknown: () => ZodUnknown,
14966
- ZodUnion: () => ZodUnion,
14967
- ZodUndefined: () => ZodUndefined,
14968
- ZodUUID: () => ZodUUID,
14969
- ZodURL: () => ZodURL,
14970
- ZodULID: () => ZodULID,
14971
- ZodType: () => ZodType,
14972
- ZodTuple: () => ZodTuple,
14973
- ZodTransform: () => ZodTransform,
14974
- ZodTemplateLiteral: () => ZodTemplateLiteral,
14975
- ZodSymbol: () => ZodSymbol,
14976
- ZodSuccess: () => ZodSuccess,
14977
- ZodStringFormat: () => ZodStringFormat,
14978
- ZodString: () => ZodString,
14979
- ZodSet: () => ZodSet,
14980
- ZodRecord: () => ZodRecord,
14981
- ZodReadonly: () => ZodReadonly,
14982
- ZodPromise: () => ZodPromise,
14983
- ZodPreprocess: () => ZodPreprocess,
14984
- ZodPrefault: () => ZodPrefault,
14985
- ZodPipe: () => ZodPipe,
14986
- ZodOptional: () => ZodOptional,
14987
- ZodObject: () => ZodObject,
14988
- ZodNumberFormat: () => ZodNumberFormat,
14989
- ZodNumber: () => ZodNumber,
14990
- ZodNullable: () => ZodNullable,
14991
- ZodNull: () => ZodNull,
14992
- ZodNonOptional: () => ZodNonOptional,
14993
- ZodNever: () => ZodNever,
14994
- ZodNanoID: () => ZodNanoID,
14995
- ZodNaN: () => ZodNaN,
14996
- ZodMap: () => ZodMap,
14997
- ZodMAC: () => ZodMAC,
14998
- ZodLiteral: () => ZodLiteral,
14999
- ZodLazy: () => ZodLazy,
15000
- ZodKSUID: () => ZodKSUID,
15001
- ZodJWT: () => ZodJWT,
15002
- ZodIntersection: () => ZodIntersection,
15003
- ZodIPv6: () => ZodIPv6,
15004
- ZodIPv4: () => ZodIPv4,
15005
- ZodGUID: () => ZodGUID,
15006
- ZodFunction: () => ZodFunction,
15007
- ZodFile: () => ZodFile,
15008
- ZodExactOptional: () => ZodExactOptional,
15009
- ZodEnum: () => ZodEnum,
15010
- ZodEmoji: () => ZodEmoji,
15011
- ZodEmail: () => ZodEmail,
15012
- ZodE164: () => ZodE164,
15013
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
15014
- ZodDefault: () => ZodDefault,
15015
- ZodDate: () => ZodDate,
15016
- ZodCustomStringFormat: () => ZodCustomStringFormat,
15017
- ZodCustom: () => ZodCustom,
15018
- ZodCodec: () => ZodCodec,
15019
- ZodCatch: () => ZodCatch,
15020
- ZodCUID2: () => ZodCUID2,
15021
- ZodCUID: () => ZodCUID,
15022
- ZodCIDRv6: () => ZodCIDRv6,
15023
- ZodCIDRv4: () => ZodCIDRv4,
15024
- ZodBoolean: () => ZodBoolean,
15025
- ZodBigIntFormat: () => ZodBigIntFormat,
15026
- ZodBigInt: () => ZodBigInt,
15027
- ZodBase64URL: () => ZodBase64URL,
15028
- ZodBase64: () => ZodBase64,
14874
+ ZodAny: () => ZodAny,
15029
14875
  ZodArray: () => ZodArray,
15030
- ZodAny: () => ZodAny
14876
+ ZodBase64: () => ZodBase64,
14877
+ ZodBase64URL: () => ZodBase64URL,
14878
+ ZodBigInt: () => ZodBigInt,
14879
+ ZodBigIntFormat: () => ZodBigIntFormat,
14880
+ ZodBoolean: () => ZodBoolean,
14881
+ ZodCIDRv4: () => ZodCIDRv4,
14882
+ ZodCIDRv6: () => ZodCIDRv6,
14883
+ ZodCUID: () => ZodCUID,
14884
+ ZodCUID2: () => ZodCUID2,
14885
+ ZodCatch: () => ZodCatch,
14886
+ ZodCodec: () => ZodCodec,
14887
+ ZodCustom: () => ZodCustom,
14888
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
14889
+ ZodDate: () => ZodDate,
14890
+ ZodDefault: () => ZodDefault,
14891
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
14892
+ ZodE164: () => ZodE164,
14893
+ ZodEmail: () => ZodEmail,
14894
+ ZodEmoji: () => ZodEmoji,
14895
+ ZodEnum: () => ZodEnum,
14896
+ ZodExactOptional: () => ZodExactOptional,
14897
+ ZodFile: () => ZodFile,
14898
+ ZodFunction: () => ZodFunction,
14899
+ ZodGUID: () => ZodGUID,
14900
+ ZodIPv4: () => ZodIPv4,
14901
+ ZodIPv6: () => ZodIPv6,
14902
+ ZodIntersection: () => ZodIntersection,
14903
+ ZodJWT: () => ZodJWT,
14904
+ ZodKSUID: () => ZodKSUID,
14905
+ ZodLazy: () => ZodLazy,
14906
+ ZodLiteral: () => ZodLiteral,
14907
+ ZodMAC: () => ZodMAC,
14908
+ ZodMap: () => ZodMap,
14909
+ ZodNaN: () => ZodNaN,
14910
+ ZodNanoID: () => ZodNanoID,
14911
+ ZodNever: () => ZodNever,
14912
+ ZodNonOptional: () => ZodNonOptional,
14913
+ ZodNull: () => ZodNull,
14914
+ ZodNullable: () => ZodNullable,
14915
+ ZodNumber: () => ZodNumber,
14916
+ ZodNumberFormat: () => ZodNumberFormat,
14917
+ ZodObject: () => ZodObject,
14918
+ ZodOptional: () => ZodOptional,
14919
+ ZodPipe: () => ZodPipe,
14920
+ ZodPrefault: () => ZodPrefault,
14921
+ ZodPreprocess: () => ZodPreprocess,
14922
+ ZodPromise: () => ZodPromise,
14923
+ ZodReadonly: () => ZodReadonly,
14924
+ ZodRecord: () => ZodRecord,
14925
+ ZodSet: () => ZodSet,
14926
+ ZodString: () => ZodString,
14927
+ ZodStringFormat: () => ZodStringFormat,
14928
+ ZodSuccess: () => ZodSuccess,
14929
+ ZodSymbol: () => ZodSymbol,
14930
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
14931
+ ZodTransform: () => ZodTransform,
14932
+ ZodTuple: () => ZodTuple,
14933
+ ZodType: () => ZodType,
14934
+ ZodULID: () => ZodULID,
14935
+ ZodURL: () => ZodURL,
14936
+ ZodUUID: () => ZodUUID,
14937
+ ZodUndefined: () => ZodUndefined,
14938
+ ZodUnion: () => ZodUnion,
14939
+ ZodUnknown: () => ZodUnknown,
14940
+ ZodVoid: () => ZodVoid,
14941
+ ZodXID: () => ZodXID,
14942
+ ZodXor: () => ZodXor,
14943
+ _ZodString: () => _ZodString,
14944
+ _default: () => _default2,
14945
+ _function: () => _function,
14946
+ any: () => any,
14947
+ array: () => array,
14948
+ base64: () => base642,
14949
+ base64url: () => base64url2,
14950
+ bigint: () => bigint2,
14951
+ boolean: () => boolean2,
14952
+ catch: () => _catch2,
14953
+ check: () => check,
14954
+ cidrv4: () => cidrv42,
14955
+ cidrv6: () => cidrv62,
14956
+ codec: () => codec,
14957
+ cuid: () => cuid3,
14958
+ cuid2: () => cuid22,
14959
+ custom: () => custom,
14960
+ date: () => date3,
14961
+ describe: () => describe2,
14962
+ discriminatedUnion: () => discriminatedUnion,
14963
+ e164: () => e1642,
14964
+ email: () => email2,
14965
+ emoji: () => emoji2,
14966
+ enum: () => _enum2,
14967
+ exactOptional: () => exactOptional,
14968
+ file: () => file,
14969
+ float32: () => float32,
14970
+ float64: () => float64,
14971
+ function: () => _function,
14972
+ guid: () => guid2,
14973
+ hash: () => hash2,
14974
+ hex: () => hex2,
14975
+ hostname: () => hostname2,
14976
+ httpUrl: () => httpUrl,
14977
+ instanceof: () => _instanceof,
14978
+ int: () => int,
14979
+ int32: () => int32,
14980
+ int64: () => int64,
14981
+ intersection: () => intersection,
14982
+ invertCodec: () => invertCodec,
14983
+ ipv4: () => ipv42,
14984
+ ipv6: () => ipv62,
14985
+ json: () => json,
14986
+ jwt: () => jwt,
14987
+ keyof: () => keyof,
14988
+ ksuid: () => ksuid2,
14989
+ lazy: () => lazy,
14990
+ literal: () => literal,
14991
+ looseObject: () => looseObject,
14992
+ looseRecord: () => looseRecord,
14993
+ mac: () => mac2,
14994
+ map: () => map,
14995
+ meta: () => meta2,
14996
+ nan: () => nan,
14997
+ nanoid: () => nanoid2,
14998
+ nativeEnum: () => nativeEnum,
14999
+ never: () => never,
15000
+ nonoptional: () => nonoptional,
15001
+ null: () => _null3,
15002
+ nullable: () => nullable,
15003
+ nullish: () => nullish2,
15004
+ number: () => number2,
15005
+ object: () => object,
15006
+ optional: () => optional,
15007
+ partialRecord: () => partialRecord,
15008
+ pipe: () => pipe,
15009
+ prefault: () => prefault,
15010
+ preprocess: () => preprocess,
15011
+ promise: () => promise,
15012
+ readonly: () => readonly,
15013
+ record: () => record,
15014
+ refine: () => refine,
15015
+ set: () => set,
15016
+ strictObject: () => strictObject,
15017
+ string: () => string2,
15018
+ stringFormat: () => stringFormat,
15019
+ stringbool: () => stringbool,
15020
+ success: () => success,
15021
+ superRefine: () => superRefine,
15022
+ symbol: () => symbol,
15023
+ templateLiteral: () => templateLiteral,
15024
+ transform: () => transform,
15025
+ tuple: () => tuple,
15026
+ uint32: () => uint32,
15027
+ uint64: () => uint64,
15028
+ ulid: () => ulid2,
15029
+ undefined: () => _undefined3,
15030
+ union: () => union,
15031
+ unknown: () => unknown,
15032
+ url: () => url,
15033
+ uuid: () => uuid2,
15034
+ uuidv4: () => uuidv4,
15035
+ uuidv6: () => uuidv6,
15036
+ uuidv7: () => uuidv7,
15037
+ void: () => _void2,
15038
+ xid: () => xid2,
15039
+ xor: () => xor
15031
15040
  });
15032
15041
  function _installLazyMethods(inst, group, methods) {
15033
15042
  const proto = Object.getPrototypeOf(inst);
@@ -16689,415 +16698,415 @@ function convertSchema(schema, ctx) {
16689
16698
  }
16690
16699
  if (schema.allOf && Array.isArray(schema.allOf)) {
16691
16700
  if (schema.allOf.length === 0) {
16692
- baseSchema = hasExplicitType ? baseSchema : z2.any();
16693
- } else {
16694
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
16695
- const startIdx = hasExplicitType ? 0 : 1;
16696
- for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
16697
- result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
16698
- }
16699
- baseSchema = result;
16700
- }
16701
- }
16702
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
16703
- baseSchema = z2.nullable(baseSchema);
16704
- }
16705
- if (schema.readOnly === true) {
16706
- baseSchema = z2.readonly(baseSchema);
16707
- }
16708
- if (schema.default !== undefined) {
16709
- baseSchema = baseSchema.default(schema.default);
16710
- }
16711
- const extraMeta = {};
16712
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
16713
- for (const key of coreMetadataKeys) {
16714
- if (key in schema) {
16715
- extraMeta[key] = schema[key];
16716
- }
16717
- }
16718
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
16719
- for (const key of contentMetadataKeys) {
16720
- if (key in schema) {
16721
- extraMeta[key] = schema[key];
16722
- }
16723
- }
16724
- for (const key of Object.keys(schema)) {
16725
- if (!RECOGNIZED_KEYS.has(key)) {
16726
- extraMeta[key] = schema[key];
16727
- }
16728
- }
16729
- if (Object.keys(extraMeta).length > 0) {
16730
- ctx.registry.add(baseSchema, extraMeta);
16731
- }
16732
- if (schema.description) {
16733
- baseSchema = baseSchema.describe(schema.description);
16734
- }
16735
- return baseSchema;
16736
- }
16737
- function fromJSONSchema(schema, params) {
16738
- if (typeof schema === "boolean") {
16739
- return schema ? z2.any() : z2.never();
16740
- }
16741
- let normalized;
16742
- try {
16743
- normalized = JSON.parse(JSON.stringify(schema));
16744
- } catch {
16745
- throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
16746
- }
16747
- const version2 = detectVersion(normalized, params?.defaultTarget);
16748
- const defs = normalized.$defs || normalized.definitions || {};
16749
- const ctx = {
16750
- version: version2,
16751
- defs,
16752
- refs: new Map,
16753
- processing: new Set,
16754
- rootSchema: normalized,
16755
- registry: params?.registry ?? globalRegistry
16756
- };
16757
- return convertSchema(normalized, ctx);
16758
- }
16759
- var z2, RECOGNIZED_KEYS;
16760
- var init_from_json_schema = __esm(() => {
16761
- init_registries();
16762
- init_checks2();
16763
- init_iso();
16764
- init_schemas2();
16765
- z2 = {
16766
- ...exports_schemas2,
16767
- ...exports_checks2,
16768
- iso: exports_iso
16769
- };
16770
- RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
16771
- "$schema",
16772
- "$ref",
16773
- "$defs",
16774
- "definitions",
16775
- "$id",
16776
- "id",
16777
- "$comment",
16778
- "$anchor",
16779
- "$vocabulary",
16780
- "$dynamicRef",
16781
- "$dynamicAnchor",
16782
- "type",
16783
- "enum",
16784
- "const",
16785
- "anyOf",
16786
- "oneOf",
16787
- "allOf",
16788
- "not",
16789
- "properties",
16790
- "required",
16791
- "additionalProperties",
16792
- "patternProperties",
16793
- "propertyNames",
16794
- "minProperties",
16795
- "maxProperties",
16796
- "items",
16797
- "prefixItems",
16798
- "additionalItems",
16799
- "minItems",
16800
- "maxItems",
16801
- "uniqueItems",
16802
- "contains",
16803
- "minContains",
16804
- "maxContains",
16805
- "minLength",
16806
- "maxLength",
16807
- "pattern",
16808
- "format",
16809
- "minimum",
16810
- "maximum",
16811
- "exclusiveMinimum",
16812
- "exclusiveMaximum",
16813
- "multipleOf",
16814
- "description",
16815
- "default",
16816
- "contentEncoding",
16817
- "contentMediaType",
16818
- "contentSchema",
16819
- "unevaluatedItems",
16820
- "unevaluatedProperties",
16821
- "if",
16822
- "then",
16823
- "else",
16824
- "dependentSchemas",
16825
- "dependentRequired",
16826
- "nullable",
16827
- "readOnly"
16828
- ]);
16829
- });
16830
-
16831
- // node_modules/zod/v4/classic/coerce.js
16832
- var exports_coerce = {};
16833
- __export(exports_coerce, {
16834
- string: () => string3,
16835
- number: () => number3,
16836
- date: () => date4,
16837
- boolean: () => boolean3,
16838
- bigint: () => bigint3
16839
- });
16840
- function string3(params) {
16841
- return _coercedString(ZodString, params);
16842
- }
16843
- function number3(params) {
16844
- return _coercedNumber(ZodNumber, params);
16845
- }
16846
- function boolean3(params) {
16847
- return _coercedBoolean(ZodBoolean, params);
16848
- }
16849
- function bigint3(params) {
16850
- return _coercedBigint(ZodBigInt, params);
16851
- }
16852
- function date4(params) {
16853
- return _coercedDate(ZodDate, params);
16854
- }
16855
- var init_coerce = __esm(() => {
16856
- init_core2();
16857
- init_schemas2();
16858
- });
16859
-
16860
- // node_modules/zod/v4/classic/external.js
16861
- var exports_external = {};
16862
- __export(exports_external, {
16863
- xor: () => xor,
16864
- xid: () => xid2,
16865
- void: () => _void2,
16866
- uuidv7: () => uuidv7,
16867
- uuidv6: () => uuidv6,
16868
- uuidv4: () => uuidv4,
16869
- uuid: () => uuid2,
16870
- util: () => exports_util,
16871
- url: () => url,
16872
- uppercase: () => _uppercase,
16873
- unknown: () => unknown,
16874
- union: () => union,
16875
- undefined: () => _undefined3,
16876
- ulid: () => ulid2,
16877
- uint64: () => uint64,
16878
- uint32: () => uint32,
16879
- tuple: () => tuple,
16880
- trim: () => _trim,
16881
- treeifyError: () => treeifyError,
16882
- transform: () => transform,
16883
- toUpperCase: () => _toUpperCase,
16884
- toLowerCase: () => _toLowerCase,
16885
- toJSONSchema: () => toJSONSchema,
16886
- templateLiteral: () => templateLiteral,
16887
- symbol: () => symbol,
16888
- superRefine: () => superRefine,
16889
- success: () => success,
16890
- stringbool: () => stringbool,
16891
- stringFormat: () => stringFormat,
16892
- string: () => string2,
16893
- strictObject: () => strictObject,
16894
- startsWith: () => _startsWith,
16895
- slugify: () => _slugify,
16896
- size: () => _size,
16897
- setErrorMap: () => setErrorMap,
16898
- set: () => set,
16899
- safeParseAsync: () => safeParseAsync2,
16900
- safeParse: () => safeParse2,
16901
- safeEncodeAsync: () => safeEncodeAsync2,
16902
- safeEncode: () => safeEncode2,
16903
- safeDecodeAsync: () => safeDecodeAsync2,
16904
- safeDecode: () => safeDecode2,
16905
- registry: () => registry,
16906
- regexes: () => exports_regexes,
16907
- regex: () => _regex,
16908
- refine: () => refine,
16909
- record: () => record,
16910
- readonly: () => readonly,
16911
- property: () => _property,
16912
- promise: () => promise,
16913
- prettifyError: () => prettifyError,
16914
- preprocess: () => preprocess,
16915
- prefault: () => prefault,
16916
- positive: () => _positive,
16917
- pipe: () => pipe,
16918
- partialRecord: () => partialRecord,
16919
- parseAsync: () => parseAsync2,
16920
- parse: () => parse3,
16921
- overwrite: () => _overwrite,
16922
- optional: () => optional,
16923
- object: () => object,
16924
- number: () => number2,
16925
- nullish: () => nullish2,
16926
- nullable: () => nullable,
16927
- null: () => _null3,
16928
- normalize: () => _normalize,
16929
- nonpositive: () => _nonpositive,
16930
- nonoptional: () => nonoptional,
16931
- nonnegative: () => _nonnegative,
16932
- never: () => never,
16933
- negative: () => _negative,
16934
- nativeEnum: () => nativeEnum,
16935
- nanoid: () => nanoid2,
16936
- nan: () => nan,
16937
- multipleOf: () => _multipleOf,
16938
- minSize: () => _minSize,
16939
- minLength: () => _minLength,
16940
- mime: () => _mime,
16941
- meta: () => meta2,
16942
- maxSize: () => _maxSize,
16943
- maxLength: () => _maxLength,
16944
- map: () => map,
16945
- mac: () => mac2,
16946
- lte: () => _lte,
16947
- lt: () => _lt,
16948
- lowercase: () => _lowercase,
16949
- looseRecord: () => looseRecord,
16950
- looseObject: () => looseObject,
16951
- locales: () => exports_locales,
16952
- literal: () => literal,
16953
- length: () => _length,
16954
- lazy: () => lazy,
16955
- ksuid: () => ksuid2,
16956
- keyof: () => keyof,
16957
- jwt: () => jwt,
16958
- json: () => json,
16959
- iso: () => exports_iso,
16960
- ipv6: () => ipv62,
16961
- ipv4: () => ipv42,
16962
- invertCodec: () => invertCodec,
16963
- intersection: () => intersection,
16964
- int64: () => int64,
16965
- int32: () => int32,
16966
- int: () => int,
16967
- instanceof: () => _instanceof,
16968
- includes: () => _includes,
16969
- httpUrl: () => httpUrl,
16970
- hostname: () => hostname2,
16971
- hex: () => hex2,
16972
- hash: () => hash2,
16973
- guid: () => guid2,
16974
- gte: () => _gte,
16975
- gt: () => _gt,
16976
- globalRegistry: () => globalRegistry,
16977
- getErrorMap: () => getErrorMap,
16978
- function: () => _function,
16979
- fromJSONSchema: () => fromJSONSchema,
16980
- formatError: () => formatError,
16981
- float64: () => float64,
16982
- float32: () => float32,
16983
- flattenError: () => flattenError,
16984
- file: () => file,
16985
- exactOptional: () => exactOptional,
16986
- enum: () => _enum2,
16987
- endsWith: () => _endsWith,
16988
- encodeAsync: () => encodeAsync2,
16989
- encode: () => encode2,
16990
- emoji: () => emoji2,
16991
- email: () => email2,
16992
- e164: () => e1642,
16993
- discriminatedUnion: () => discriminatedUnion,
16994
- describe: () => describe2,
16995
- decodeAsync: () => decodeAsync2,
16996
- decode: () => decode2,
16997
- date: () => date3,
16998
- custom: () => custom,
16999
- cuid2: () => cuid22,
17000
- cuid: () => cuid3,
17001
- core: () => exports_core2,
17002
- config: () => config,
17003
- coerce: () => exports_coerce,
17004
- codec: () => codec,
17005
- clone: () => clone,
17006
- cidrv6: () => cidrv62,
17007
- cidrv4: () => cidrv42,
17008
- check: () => check,
17009
- catch: () => _catch2,
17010
- boolean: () => boolean2,
17011
- bigint: () => bigint2,
17012
- base64url: () => base64url2,
17013
- base64: () => base642,
17014
- array: () => array,
17015
- any: () => any,
17016
- _function: () => _function,
17017
- _default: () => _default2,
17018
- _ZodString: () => _ZodString,
17019
- ZodXor: () => ZodXor,
17020
- ZodXID: () => ZodXID,
17021
- ZodVoid: () => ZodVoid,
17022
- ZodUnknown: () => ZodUnknown,
17023
- ZodUnion: () => ZodUnion,
17024
- ZodUndefined: () => ZodUndefined,
17025
- ZodUUID: () => ZodUUID,
17026
- ZodURL: () => ZodURL,
17027
- ZodULID: () => ZodULID,
17028
- ZodType: () => ZodType,
17029
- ZodTuple: () => ZodTuple,
17030
- ZodTransform: () => ZodTransform,
17031
- ZodTemplateLiteral: () => ZodTemplateLiteral,
17032
- ZodSymbol: () => ZodSymbol,
17033
- ZodSuccess: () => ZodSuccess,
17034
- ZodStringFormat: () => ZodStringFormat,
17035
- ZodString: () => ZodString,
17036
- ZodSet: () => ZodSet,
17037
- ZodRecord: () => ZodRecord,
17038
- ZodRealError: () => ZodRealError,
17039
- ZodReadonly: () => ZodReadonly,
17040
- ZodPromise: () => ZodPromise,
17041
- ZodPreprocess: () => ZodPreprocess,
17042
- ZodPrefault: () => ZodPrefault,
17043
- ZodPipe: () => ZodPipe,
17044
- ZodOptional: () => ZodOptional,
17045
- ZodObject: () => ZodObject,
17046
- ZodNumberFormat: () => ZodNumberFormat,
17047
- ZodNumber: () => ZodNumber,
17048
- ZodNullable: () => ZodNullable,
17049
- ZodNull: () => ZodNull,
17050
- ZodNonOptional: () => ZodNonOptional,
17051
- ZodNever: () => ZodNever,
17052
- ZodNanoID: () => ZodNanoID,
17053
- ZodNaN: () => ZodNaN,
17054
- ZodMap: () => ZodMap,
17055
- ZodMAC: () => ZodMAC,
17056
- ZodLiteral: () => ZodLiteral,
17057
- ZodLazy: () => ZodLazy,
17058
- ZodKSUID: () => ZodKSUID,
17059
- ZodJWT: () => ZodJWT,
17060
- ZodIssueCode: () => ZodIssueCode,
17061
- ZodIntersection: () => ZodIntersection,
17062
- ZodISOTime: () => ZodISOTime,
17063
- ZodISODuration: () => ZodISODuration,
17064
- ZodISODateTime: () => ZodISODateTime,
17065
- ZodISODate: () => ZodISODate,
17066
- ZodIPv6: () => ZodIPv6,
17067
- ZodIPv4: () => ZodIPv4,
17068
- ZodGUID: () => ZodGUID,
17069
- ZodFunction: () => ZodFunction,
17070
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
17071
- ZodFile: () => ZodFile,
17072
- ZodExactOptional: () => ZodExactOptional,
17073
- ZodError: () => ZodError,
17074
- ZodEnum: () => ZodEnum,
17075
- ZodEmoji: () => ZodEmoji,
17076
- ZodEmail: () => ZodEmail,
17077
- ZodE164: () => ZodE164,
17078
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
17079
- ZodDefault: () => ZodDefault,
17080
- ZodDate: () => ZodDate,
17081
- ZodCustomStringFormat: () => ZodCustomStringFormat,
17082
- ZodCustom: () => ZodCustom,
17083
- ZodCodec: () => ZodCodec,
17084
- ZodCatch: () => ZodCatch,
17085
- ZodCUID2: () => ZodCUID2,
17086
- ZodCUID: () => ZodCUID,
17087
- ZodCIDRv6: () => ZodCIDRv6,
17088
- ZodCIDRv4: () => ZodCIDRv4,
17089
- ZodBoolean: () => ZodBoolean,
17090
- ZodBigIntFormat: () => ZodBigIntFormat,
17091
- ZodBigInt: () => ZodBigInt,
17092
- ZodBase64URL: () => ZodBase64URL,
17093
- ZodBase64: () => ZodBase64,
17094
- ZodArray: () => ZodArray,
17095
- ZodAny: () => ZodAny,
17096
- TimePrecision: () => TimePrecision,
17097
- NEVER: () => NEVER,
17098
- $output: () => $output,
16701
+ baseSchema = hasExplicitType ? baseSchema : z2.any();
16702
+ } else {
16703
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
16704
+ const startIdx = hasExplicitType ? 0 : 1;
16705
+ for (let i2 = startIdx;i2 < schema.allOf.length; i2++) {
16706
+ result = z2.intersection(result, convertSchema(schema.allOf[i2], ctx));
16707
+ }
16708
+ baseSchema = result;
16709
+ }
16710
+ }
16711
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
16712
+ baseSchema = z2.nullable(baseSchema);
16713
+ }
16714
+ if (schema.readOnly === true) {
16715
+ baseSchema = z2.readonly(baseSchema);
16716
+ }
16717
+ if (schema.default !== undefined) {
16718
+ baseSchema = baseSchema.default(schema.default);
16719
+ }
16720
+ const extraMeta = {};
16721
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
16722
+ for (const key of coreMetadataKeys) {
16723
+ if (key in schema) {
16724
+ extraMeta[key] = schema[key];
16725
+ }
16726
+ }
16727
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
16728
+ for (const key of contentMetadataKeys) {
16729
+ if (key in schema) {
16730
+ extraMeta[key] = schema[key];
16731
+ }
16732
+ }
16733
+ for (const key of Object.keys(schema)) {
16734
+ if (!RECOGNIZED_KEYS.has(key)) {
16735
+ extraMeta[key] = schema[key];
16736
+ }
16737
+ }
16738
+ if (Object.keys(extraMeta).length > 0) {
16739
+ ctx.registry.add(baseSchema, extraMeta);
16740
+ }
16741
+ if (schema.description) {
16742
+ baseSchema = baseSchema.describe(schema.description);
16743
+ }
16744
+ return baseSchema;
16745
+ }
16746
+ function fromJSONSchema(schema, params) {
16747
+ if (typeof schema === "boolean") {
16748
+ return schema ? z2.any() : z2.never();
16749
+ }
16750
+ let normalized;
16751
+ try {
16752
+ normalized = JSON.parse(JSON.stringify(schema));
16753
+ } catch {
16754
+ throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
16755
+ }
16756
+ const version2 = detectVersion(normalized, params?.defaultTarget);
16757
+ const defs = normalized.$defs || normalized.definitions || {};
16758
+ const ctx = {
16759
+ version: version2,
16760
+ defs,
16761
+ refs: new Map,
16762
+ processing: new Set,
16763
+ rootSchema: normalized,
16764
+ registry: params?.registry ?? globalRegistry
16765
+ };
16766
+ return convertSchema(normalized, ctx);
16767
+ }
16768
+ var z2, RECOGNIZED_KEYS;
16769
+ var init_from_json_schema = __esm(() => {
16770
+ init_registries();
16771
+ init_checks2();
16772
+ init_iso();
16773
+ init_schemas2();
16774
+ z2 = {
16775
+ ...exports_schemas2,
16776
+ ...exports_checks2,
16777
+ iso: exports_iso
16778
+ };
16779
+ RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
16780
+ "$schema",
16781
+ "$ref",
16782
+ "$defs",
16783
+ "definitions",
16784
+ "$id",
16785
+ "id",
16786
+ "$comment",
16787
+ "$anchor",
16788
+ "$vocabulary",
16789
+ "$dynamicRef",
16790
+ "$dynamicAnchor",
16791
+ "type",
16792
+ "enum",
16793
+ "const",
16794
+ "anyOf",
16795
+ "oneOf",
16796
+ "allOf",
16797
+ "not",
16798
+ "properties",
16799
+ "required",
16800
+ "additionalProperties",
16801
+ "patternProperties",
16802
+ "propertyNames",
16803
+ "minProperties",
16804
+ "maxProperties",
16805
+ "items",
16806
+ "prefixItems",
16807
+ "additionalItems",
16808
+ "minItems",
16809
+ "maxItems",
16810
+ "uniqueItems",
16811
+ "contains",
16812
+ "minContains",
16813
+ "maxContains",
16814
+ "minLength",
16815
+ "maxLength",
16816
+ "pattern",
16817
+ "format",
16818
+ "minimum",
16819
+ "maximum",
16820
+ "exclusiveMinimum",
16821
+ "exclusiveMaximum",
16822
+ "multipleOf",
16823
+ "description",
16824
+ "default",
16825
+ "contentEncoding",
16826
+ "contentMediaType",
16827
+ "contentSchema",
16828
+ "unevaluatedItems",
16829
+ "unevaluatedProperties",
16830
+ "if",
16831
+ "then",
16832
+ "else",
16833
+ "dependentSchemas",
16834
+ "dependentRequired",
16835
+ "nullable",
16836
+ "readOnly"
16837
+ ]);
16838
+ });
16839
+
16840
+ // node_modules/zod/v4/classic/coerce.js
16841
+ var exports_coerce = {};
16842
+ __export(exports_coerce, {
16843
+ bigint: () => bigint3,
16844
+ boolean: () => boolean3,
16845
+ date: () => date4,
16846
+ number: () => number3,
16847
+ string: () => string3
16848
+ });
16849
+ function string3(params) {
16850
+ return _coercedString(ZodString, params);
16851
+ }
16852
+ function number3(params) {
16853
+ return _coercedNumber(ZodNumber, params);
16854
+ }
16855
+ function boolean3(params) {
16856
+ return _coercedBoolean(ZodBoolean, params);
16857
+ }
16858
+ function bigint3(params) {
16859
+ return _coercedBigint(ZodBigInt, params);
16860
+ }
16861
+ function date4(params) {
16862
+ return _coercedDate(ZodDate, params);
16863
+ }
16864
+ var init_coerce = __esm(() => {
16865
+ init_core2();
16866
+ init_schemas2();
16867
+ });
16868
+
16869
+ // node_modules/zod/v4/classic/external.js
16870
+ var exports_external = {};
16871
+ __export(exports_external, {
16872
+ $brand: () => $brand,
17099
16873
  $input: () => $input,
17100
- $brand: () => $brand
16874
+ $output: () => $output,
16875
+ NEVER: () => NEVER,
16876
+ TimePrecision: () => TimePrecision,
16877
+ ZodAny: () => ZodAny,
16878
+ ZodArray: () => ZodArray,
16879
+ ZodBase64: () => ZodBase64,
16880
+ ZodBase64URL: () => ZodBase64URL,
16881
+ ZodBigInt: () => ZodBigInt,
16882
+ ZodBigIntFormat: () => ZodBigIntFormat,
16883
+ ZodBoolean: () => ZodBoolean,
16884
+ ZodCIDRv4: () => ZodCIDRv4,
16885
+ ZodCIDRv6: () => ZodCIDRv6,
16886
+ ZodCUID: () => ZodCUID,
16887
+ ZodCUID2: () => ZodCUID2,
16888
+ ZodCatch: () => ZodCatch,
16889
+ ZodCodec: () => ZodCodec,
16890
+ ZodCustom: () => ZodCustom,
16891
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
16892
+ ZodDate: () => ZodDate,
16893
+ ZodDefault: () => ZodDefault,
16894
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
16895
+ ZodE164: () => ZodE164,
16896
+ ZodEmail: () => ZodEmail,
16897
+ ZodEmoji: () => ZodEmoji,
16898
+ ZodEnum: () => ZodEnum,
16899
+ ZodError: () => ZodError,
16900
+ ZodExactOptional: () => ZodExactOptional,
16901
+ ZodFile: () => ZodFile,
16902
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
16903
+ ZodFunction: () => ZodFunction,
16904
+ ZodGUID: () => ZodGUID,
16905
+ ZodIPv4: () => ZodIPv4,
16906
+ ZodIPv6: () => ZodIPv6,
16907
+ ZodISODate: () => ZodISODate,
16908
+ ZodISODateTime: () => ZodISODateTime,
16909
+ ZodISODuration: () => ZodISODuration,
16910
+ ZodISOTime: () => ZodISOTime,
16911
+ ZodIntersection: () => ZodIntersection,
16912
+ ZodIssueCode: () => ZodIssueCode,
16913
+ ZodJWT: () => ZodJWT,
16914
+ ZodKSUID: () => ZodKSUID,
16915
+ ZodLazy: () => ZodLazy,
16916
+ ZodLiteral: () => ZodLiteral,
16917
+ ZodMAC: () => ZodMAC,
16918
+ ZodMap: () => ZodMap,
16919
+ ZodNaN: () => ZodNaN,
16920
+ ZodNanoID: () => ZodNanoID,
16921
+ ZodNever: () => ZodNever,
16922
+ ZodNonOptional: () => ZodNonOptional,
16923
+ ZodNull: () => ZodNull,
16924
+ ZodNullable: () => ZodNullable,
16925
+ ZodNumber: () => ZodNumber,
16926
+ ZodNumberFormat: () => ZodNumberFormat,
16927
+ ZodObject: () => ZodObject,
16928
+ ZodOptional: () => ZodOptional,
16929
+ ZodPipe: () => ZodPipe,
16930
+ ZodPrefault: () => ZodPrefault,
16931
+ ZodPreprocess: () => ZodPreprocess,
16932
+ ZodPromise: () => ZodPromise,
16933
+ ZodReadonly: () => ZodReadonly,
16934
+ ZodRealError: () => ZodRealError,
16935
+ ZodRecord: () => ZodRecord,
16936
+ ZodSet: () => ZodSet,
16937
+ ZodString: () => ZodString,
16938
+ ZodStringFormat: () => ZodStringFormat,
16939
+ ZodSuccess: () => ZodSuccess,
16940
+ ZodSymbol: () => ZodSymbol,
16941
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
16942
+ ZodTransform: () => ZodTransform,
16943
+ ZodTuple: () => ZodTuple,
16944
+ ZodType: () => ZodType,
16945
+ ZodULID: () => ZodULID,
16946
+ ZodURL: () => ZodURL,
16947
+ ZodUUID: () => ZodUUID,
16948
+ ZodUndefined: () => ZodUndefined,
16949
+ ZodUnion: () => ZodUnion,
16950
+ ZodUnknown: () => ZodUnknown,
16951
+ ZodVoid: () => ZodVoid,
16952
+ ZodXID: () => ZodXID,
16953
+ ZodXor: () => ZodXor,
16954
+ _ZodString: () => _ZodString,
16955
+ _default: () => _default2,
16956
+ _function: () => _function,
16957
+ any: () => any,
16958
+ array: () => array,
16959
+ base64: () => base642,
16960
+ base64url: () => base64url2,
16961
+ bigint: () => bigint2,
16962
+ boolean: () => boolean2,
16963
+ catch: () => _catch2,
16964
+ check: () => check,
16965
+ cidrv4: () => cidrv42,
16966
+ cidrv6: () => cidrv62,
16967
+ clone: () => clone,
16968
+ codec: () => codec,
16969
+ coerce: () => exports_coerce,
16970
+ config: () => config,
16971
+ core: () => exports_core2,
16972
+ cuid: () => cuid3,
16973
+ cuid2: () => cuid22,
16974
+ custom: () => custom,
16975
+ date: () => date3,
16976
+ decode: () => decode2,
16977
+ decodeAsync: () => decodeAsync2,
16978
+ describe: () => describe2,
16979
+ discriminatedUnion: () => discriminatedUnion,
16980
+ e164: () => e1642,
16981
+ email: () => email2,
16982
+ emoji: () => emoji2,
16983
+ encode: () => encode2,
16984
+ encodeAsync: () => encodeAsync2,
16985
+ endsWith: () => _endsWith,
16986
+ enum: () => _enum2,
16987
+ exactOptional: () => exactOptional,
16988
+ file: () => file,
16989
+ flattenError: () => flattenError,
16990
+ float32: () => float32,
16991
+ float64: () => float64,
16992
+ formatError: () => formatError,
16993
+ fromJSONSchema: () => fromJSONSchema,
16994
+ function: () => _function,
16995
+ getErrorMap: () => getErrorMap,
16996
+ globalRegistry: () => globalRegistry,
16997
+ gt: () => _gt,
16998
+ gte: () => _gte,
16999
+ guid: () => guid2,
17000
+ hash: () => hash2,
17001
+ hex: () => hex2,
17002
+ hostname: () => hostname2,
17003
+ httpUrl: () => httpUrl,
17004
+ includes: () => _includes,
17005
+ instanceof: () => _instanceof,
17006
+ int: () => int,
17007
+ int32: () => int32,
17008
+ int64: () => int64,
17009
+ intersection: () => intersection,
17010
+ invertCodec: () => invertCodec,
17011
+ ipv4: () => ipv42,
17012
+ ipv6: () => ipv62,
17013
+ iso: () => exports_iso,
17014
+ json: () => json,
17015
+ jwt: () => jwt,
17016
+ keyof: () => keyof,
17017
+ ksuid: () => ksuid2,
17018
+ lazy: () => lazy,
17019
+ length: () => _length,
17020
+ literal: () => literal,
17021
+ locales: () => exports_locales,
17022
+ looseObject: () => looseObject,
17023
+ looseRecord: () => looseRecord,
17024
+ lowercase: () => _lowercase,
17025
+ lt: () => _lt,
17026
+ lte: () => _lte,
17027
+ mac: () => mac2,
17028
+ map: () => map,
17029
+ maxLength: () => _maxLength,
17030
+ maxSize: () => _maxSize,
17031
+ meta: () => meta2,
17032
+ mime: () => _mime,
17033
+ minLength: () => _minLength,
17034
+ minSize: () => _minSize,
17035
+ multipleOf: () => _multipleOf,
17036
+ nan: () => nan,
17037
+ nanoid: () => nanoid2,
17038
+ nativeEnum: () => nativeEnum,
17039
+ negative: () => _negative,
17040
+ never: () => never,
17041
+ nonnegative: () => _nonnegative,
17042
+ nonoptional: () => nonoptional,
17043
+ nonpositive: () => _nonpositive,
17044
+ normalize: () => _normalize,
17045
+ null: () => _null3,
17046
+ nullable: () => nullable,
17047
+ nullish: () => nullish2,
17048
+ number: () => number2,
17049
+ object: () => object,
17050
+ optional: () => optional,
17051
+ overwrite: () => _overwrite,
17052
+ parse: () => parse3,
17053
+ parseAsync: () => parseAsync2,
17054
+ partialRecord: () => partialRecord,
17055
+ pipe: () => pipe,
17056
+ positive: () => _positive,
17057
+ prefault: () => prefault,
17058
+ preprocess: () => preprocess,
17059
+ prettifyError: () => prettifyError,
17060
+ promise: () => promise,
17061
+ property: () => _property,
17062
+ readonly: () => readonly,
17063
+ record: () => record,
17064
+ refine: () => refine,
17065
+ regex: () => _regex,
17066
+ regexes: () => exports_regexes,
17067
+ registry: () => registry,
17068
+ safeDecode: () => safeDecode2,
17069
+ safeDecodeAsync: () => safeDecodeAsync2,
17070
+ safeEncode: () => safeEncode2,
17071
+ safeEncodeAsync: () => safeEncodeAsync2,
17072
+ safeParse: () => safeParse2,
17073
+ safeParseAsync: () => safeParseAsync2,
17074
+ set: () => set,
17075
+ setErrorMap: () => setErrorMap,
17076
+ size: () => _size,
17077
+ slugify: () => _slugify,
17078
+ startsWith: () => _startsWith,
17079
+ strictObject: () => strictObject,
17080
+ string: () => string2,
17081
+ stringFormat: () => stringFormat,
17082
+ stringbool: () => stringbool,
17083
+ success: () => success,
17084
+ superRefine: () => superRefine,
17085
+ symbol: () => symbol,
17086
+ templateLiteral: () => templateLiteral,
17087
+ toJSONSchema: () => toJSONSchema,
17088
+ toLowerCase: () => _toLowerCase,
17089
+ toUpperCase: () => _toUpperCase,
17090
+ transform: () => transform,
17091
+ treeifyError: () => treeifyError,
17092
+ trim: () => _trim,
17093
+ tuple: () => tuple,
17094
+ uint32: () => uint32,
17095
+ uint64: () => uint64,
17096
+ ulid: () => ulid2,
17097
+ undefined: () => _undefined3,
17098
+ union: () => union,
17099
+ unknown: () => unknown,
17100
+ uppercase: () => _uppercase,
17101
+ url: () => url,
17102
+ util: () => exports_util,
17103
+ uuid: () => uuid2,
17104
+ uuidv4: () => uuidv4,
17105
+ uuidv6: () => uuidv6,
17106
+ uuidv7: () => uuidv7,
17107
+ void: () => _void2,
17108
+ xid: () => xid2,
17109
+ xor: () => xor
17101
17110
  });
17102
17111
  var init_external = __esm(() => {
17103
17112
  init_core2();
@@ -17511,7 +17520,7 @@ function ensurePropIndex(db, databaseId, propId) {
17511
17520
  function maybeAutoIndex(db, databaseId, prop) {
17512
17521
  if (hasIndex(db, databaseId, prop.id))
17513
17522
  return;
17514
- if (prop.type !== "relation") {
17523
+ if (prop.type !== "relation" && prop.type !== "doc") {
17515
17524
  const row = db.query("SELECT COUNT(*) AS c FROM records WHERE database_id = ? AND __deleted = 0").get(databaseId);
17516
17525
  if (row.c < AUTO_INDEX_ROW_THRESHOLD)
17517
17526
  return;
@@ -17580,6 +17589,7 @@ var init_properties = __esm(() => {
17580
17589
  "multi_select",
17581
17590
  "date",
17582
17591
  "relation",
17592
+ "doc",
17583
17593
  "url"
17584
17594
  ]);
17585
17595
  PROPERTY_COLS = ["id", "database_id", "name", "type", "config", "position"];
@@ -17597,7 +17607,7 @@ var init_properties = __esm(() => {
17597
17607
  emit(db, "properties", id, "type", opts.type);
17598
17608
  emit(db, "properties", id, "config", config2);
17599
17609
  emit(db, "properties", id, "position", opts.position ?? nextPosition(db, databaseId));
17600
- if (opts.type === "relation" || opts.indexed === true)
17610
+ if (opts.type === "relation" || opts.type === "doc" || opts.indexed === true)
17601
17611
  ensurePropIndex(db, databaseId, id);
17602
17612
  return getProperty(db, id);
17603
17613
  });
@@ -17876,6 +17886,20 @@ function resolveRelation(db, prop, value) {
17876
17886
  }
17877
17887
  throw new MhError("ambiguous", `${prop.name}: ambiguous relation "${value}" (${cands.length} matches); use a full id`);
17878
17888
  }
17889
+ function resolveDoc(db, prop, value) {
17890
+ const cands = resolveCandidates(db, value, { kind: "doc" });
17891
+ const exact = cands.find((c3) => c3.id === value);
17892
+ if (exact)
17893
+ return exact.id;
17894
+ if (cands.length === 1)
17895
+ return cands[0].id;
17896
+ if (cands.length === 0) {
17897
+ if (idKind(value) === "doc")
17898
+ return value;
17899
+ throw new MhError("not_found", `${prop.name}: no such document: ${value}`);
17900
+ }
17901
+ throw new MhError("ambiguous", `${prop.name}: ambiguous document "${value}" (${cands.length} matches); use a full id`);
17902
+ }
17879
17903
  function coerce(db, prop, value) {
17880
17904
  switch (prop.type) {
17881
17905
  case "text":
@@ -17924,6 +17948,10 @@ function coerce(db, prop, value) {
17924
17948
  const arr = value === null ? [] : Array.isArray(value) ? value : [value];
17925
17949
  return arr.map((v2) => resolveRelation(db, prop, String(v2)));
17926
17950
  }
17951
+ case "doc": {
17952
+ const arr = value === null ? [] : Array.isArray(value) ? value : [value];
17953
+ return arr.map((v2) => resolveDoc(db, prop, String(v2)));
17954
+ }
17927
17955
  }
17928
17956
  }
17929
17957
  function propsByName(props) {
@@ -18075,6 +18103,17 @@ function listRecords(db, databaseId, opts = {}) {
18075
18103
  }
18076
18104
  return rows;
18077
18105
  }
18106
+ function recordTitleMap(db, databaseId) {
18107
+ const map2 = new Map;
18108
+ const tp = titlePropId(db, databaseId);
18109
+ if (!tp)
18110
+ return map2;
18111
+ const rows = db.query(`SELECT id, data ->> '${jsonKeyLit(tp)}' AS title FROM records WHERE database_id = ? AND __deleted = 0`).all(databaseId);
18112
+ for (const r3 of rows)
18113
+ if (r3.title)
18114
+ map2.set(r3.id, String(r3.title));
18115
+ return map2;
18116
+ }
18078
18117
  var backfillRecordOrderKeys, createRecordPrepared, createRecord, moveRecord, updateRecordPrepared, updateRecord, deleteRecord;
18079
18118
  var init_records = __esm(() => {
18080
18119
  init_ids();
@@ -18145,11 +18184,16 @@ var init_records = __esm(() => {
18145
18184
  return getRecord(db, id);
18146
18185
  });
18147
18186
  updateRecordPrepared = grouped(function updateRecordPrepared2(db, id, cells) {
18148
- const rec = db.query("SELECT id, database_id FROM records WHERE id = ? AND __deleted = 0").get(id);
18187
+ const rec = db.query("SELECT id, database_id, data FROM records WHERE id = ? AND __deleted = 0").get(id);
18149
18188
  if (!rec)
18150
18189
  throw new MhError("not_found", `no such record: ${id}`);
18151
- for (const { prop, value } of cells)
18152
- emit(db, "records", id, prop.id, value);
18190
+ const cur = JSON.parse(rec.data || "{}");
18191
+ for (const { prop, value } of cells) {
18192
+ const exists = Object.hasOwn(cur, prop.id);
18193
+ const same = value === undefined ? !exists : exists && JSON.stringify(value) === JSON.stringify(cur[prop.id]);
18194
+ if (!same)
18195
+ emit(db, "records", id, prop.id, value);
18196
+ }
18153
18197
  return getRecord(db, id);
18154
18198
  });
18155
18199
  updateRecord = grouped(function updateRecord2(db, id, data) {
@@ -18228,19 +18272,38 @@ var init_databases = __esm(() => {
18228
18272
  emit(db, "databases", dup.id, "meta", meta3);
18229
18273
  }
18230
18274
  const propIdMap = new Map;
18275
+ const selfRelNew = new Set;
18231
18276
  for (const p of listProperties(db, id)) {
18232
- const config2 = p.config?.database === id ? { ...p.config, database: dup.id } : p.config ?? undefined;
18277
+ const self = p.type === "relation" && p.config?.database === id;
18278
+ const config2 = self ? { ...p.config, database: dup.id } : p.config ?? undefined;
18233
18279
  const np = addProperty(db, dup.id, { name: p.name, type: p.type, config: config2, position: p.position });
18234
18280
  propIdMap.set(p.id, np.id);
18281
+ if (self)
18282
+ selfRelNew.add(np.id);
18235
18283
  }
18236
- for (const r3 of listRecords(db, id)) {
18284
+ const srcRecords = listRecords(db, id);
18285
+ const recIdMap = new Map;
18286
+ for (const r3 of srcRecords) {
18237
18287
  const data = {};
18238
18288
  for (const [pid, v2] of Object.entries(r3.cells)) {
18239
18289
  const nid = propIdMap.get(pid);
18240
- if (nid)
18241
- data[nid] = v2;
18290
+ if (!nid)
18291
+ continue;
18292
+ if (selfRelNew.has(nid) && Array.isArray(v2) && v2.length > 0)
18293
+ continue;
18294
+ data[nid] = v2;
18295
+ }
18296
+ recIdMap.set(r3.id, createRecord(db, dup.id, data).id);
18297
+ }
18298
+ for (const r3 of srcRecords) {
18299
+ const patch = {};
18300
+ for (const [pid, v2] of Object.entries(r3.cells)) {
18301
+ const nid = propIdMap.get(pid);
18302
+ if (nid && selfRelNew.has(nid) && Array.isArray(v2) && v2.length > 0)
18303
+ patch[nid] = v2.map((x2) => recIdMap.get(String(x2)) ?? x2);
18242
18304
  }
18243
- createRecord(db, dup.id, data);
18305
+ if (Object.keys(patch).length)
18306
+ updateRecord(db, recIdMap.get(r3.id), patch);
18244
18307
  }
18245
18308
  return getDatabase(db, dup.id);
18246
18309
  });
@@ -18387,29 +18450,33 @@ function liveRowCount(db, databaseId) {
18387
18450
  }
18388
18451
  function assertRelationAllowed(set2, principalKind, prop) {
18389
18452
  if (principalKind === "public")
18390
- throw new MhError("invalid_input", `${prop.name}: relation properties are not writable anonymously`);
18453
+ throw new MhError("invalid_input", `${prop.name}: ${prop.type} properties are not writable anonymously`);
18454
+ if (prop.type === "doc")
18455
+ throw new MhError("invalid_input", `${prop.name}: doc properties are not writable via shares (grants cannot scope documents)`);
18391
18456
  const target = prop.config?.database;
18392
18457
  if (!target || !grantFor(set2, target))
18393
18458
  throw new MhError("invalid_input", `${prop.name}: relation target database is not in this share's grants`);
18394
18459
  }
18460
+ function isLiveRefValue(prop, value) {
18461
+ return (prop.type === "relation" || prop.type === "doc") && value != null && !(Array.isArray(value) && value.length === 0);
18462
+ }
18395
18463
  function assertGuestPayload(db, set2, principal, database, values, opts = {}) {
18396
18464
  const limits = opts.limits ?? GUEST_LIMITS;
18397
18465
  const entries = Object.entries(values);
18398
18466
  if (entries.length > limits.maxCells)
18399
18467
  throw new MhError("invalid_input", `too many cells (max ${limits.maxCells})`);
18400
18468
  const props = listProperties(db, database.id);
18401
- const resolved = resolveData(props, values).map(({ prop, value }) => ({
18402
- prop,
18403
- value: coerce(db, prop, value)
18404
- }));
18469
+ const resolved = resolveData(props, values).map(({ prop, value }) => {
18470
+ if (isLiveRefValue(prop, value))
18471
+ assertRelationAllowed(set2, principal.kind, prop);
18472
+ return { prop, value: coerce(db, prop, value) };
18473
+ });
18405
18474
  let total = 0;
18406
18475
  for (const { prop, value } of resolved) {
18407
18476
  const size = utf8Len(JSON.stringify(value ?? null));
18408
18477
  if (size > limits.maxValueBytes)
18409
18478
  throw new MhError("invalid_input", `${prop.name}: value too large (max ${limits.maxValueBytes} bytes)`);
18410
18479
  total += size;
18411
- if (prop.type === "relation" && value != null && !(Array.isArray(value) && value.length === 0))
18412
- assertRelationAllowed(set2, principal.kind, prop);
18413
18480
  }
18414
18481
  if (total > limits.maxBodyBytes)
18415
18482
  throw new MhError("invalid_input", `payload too large (max ${limits.maxBodyBytes} bytes)`);
@@ -18479,7 +18546,7 @@ function checkGuestChanges(db, set2, guestNode, changes, principalKind = "public
18479
18546
  if (utf8Len(c3.value ?? "") > limits.maxValueBytes)
18480
18547
  throw new MhError("invalid_input", `${prop.name}: value too large (max ${limits.maxValueBytes} bytes)`);
18481
18548
  const value = c3.value == null ? null : JSON.parse(c3.value);
18482
- if (prop.type === "relation" && value != null && !(Array.isArray(value) && value.length === 0))
18549
+ if (isLiveRefValue(prop, value))
18483
18550
  assertRelationAllowed(set2, principalKind, prop);
18484
18551
  coerce(db, prop, value);
18485
18552
  }
@@ -19146,6 +19213,14 @@ function listDocuments(db, opts = {}) {
19146
19213
  return db.query(`${cols} AND database_id = ? ${ORDER_BY}`).all(opts.database_id);
19147
19214
  return db.query(`${cols} ${ORDER_BY}`).all();
19148
19215
  }
19216
+ function documentTitleMap(db) {
19217
+ const map2 = new Map;
19218
+ const rows = db.query("SELECT id, title FROM documents WHERE __deleted = 0").all();
19219
+ for (const r3 of rows)
19220
+ if (r3.title)
19221
+ map2.set(r3.id, String(r3.title));
19222
+ return map2;
19223
+ }
19149
19224
  function siblingWhere(parentId) {
19150
19225
  return parentId === null ? { clause: "parent_id IS NULL", args: [] } : { clause: "parent_id = ?", args: [parentId] };
19151
19226
  }
@@ -20335,15 +20410,15 @@ function roomUrlOf(config2) {
20335
20410
  // src/core/sync/room-peer.ts
20336
20411
  var exports_room_peer = {};
20337
20412
  __export(exports_room_peer, {
20338
- teardownRoomForShare: () => teardownRoomForShare,
20339
- syncRoomPeer: () => syncRoomPeer,
20340
- roomUrlOf: () => roomUrlOf,
20341
- roomTransport: () => roomTransport,
20342
- roomPeerKey: () => roomPeerKey,
20343
- registerRoomBlobResolver: () => registerRoomBlobResolver,
20344
- pushRoomBlobs: () => pushRoomBlobs,
20413
+ destroyRoom: () => destroyRoom,
20345
20414
  provisionRoomForShare: () => provisionRoomForShare,
20346
- destroyRoom: () => destroyRoom
20415
+ pushRoomBlobs: () => pushRoomBlobs,
20416
+ registerRoomBlobResolver: () => registerRoomBlobResolver,
20417
+ roomPeerKey: () => roomPeerKey,
20418
+ roomTransport: () => roomTransport,
20419
+ roomUrlOf: () => roomUrlOf,
20420
+ syncRoomPeer: () => syncRoomPeer,
20421
+ teardownRoomForShare: () => teardownRoomForShare
20347
20422
  });
20348
20423
  function registerRoomBlobResolver(resolve) {
20349
20424
  defaultBlobResolver = resolve;
@@ -21201,9 +21276,9 @@ var init_site_channel_store = __esm(() => {
21201
21276
  // src/core/sync/site-channel-reconcile.ts
21202
21277
  var exports_site_channel_reconcile = {};
21203
21278
  __export(exports_site_channel_reconcile, {
21204
- reconcileSiteChannelsQuietly: () => reconcileSiteChannelsQuietly,
21279
+ CONTROLLER_STATE_MISSING: () => CONTROLLER_STATE_MISSING,
21205
21280
  reconcileSiteChannels: () => reconcileSiteChannels,
21206
- CONTROLLER_STATE_MISSING: () => CONTROLLER_STATE_MISSING
21281
+ reconcileSiteChannelsQuietly: () => reconcileSiteChannelsQuietly
21207
21282
  });
21208
21283
  async function reconcileSiteChannelsQuietly(db) {
21209
21284
  try {
@@ -22737,7 +22812,7 @@ var init_data_map_db = __esm(() => {
22737
22812
  });
22738
22813
 
22739
22814
  // node_modules/sisteransi/src/index.js
22740
- var require_src = __commonJS((exports, module) => {
22815
+ var require_src = __commonJS(function(exports, module) {
22741
22816
  var ESC2 = "\x1B";
22742
22817
  var CSI2 = `${ESC2}[`;
22743
22818
  var beep = "\x07";
@@ -23391,9 +23466,9 @@ var init_drop_protocol = __esm(() => {
23391
23466
  // src/core/sync/drop-pull.ts
23392
23467
  var exports_drop_pull = {};
23393
23468
  __export(exports_drop_pull, {
23394
- pullDropsOnce: () => pullDropsOnce,
23469
+ changesMaxSeq: () => changesMaxSeq,
23395
23470
  dropWiredSites: () => dropWiredSites,
23396
- changesMaxSeq: () => changesMaxSeq
23471
+ pullDropsOnce: () => pullDropsOnce
23397
23472
  });
23398
23473
  function dropWiredSites(db) {
23399
23474
  return listSites(db).filter((s2) => parseGrantSet(s2.public_grants).tables.some((t2) => t2.ops.includes("create")));
@@ -24218,8 +24293,8 @@ var init_peers_routes = __esm(() => {
24218
24293
  // src/core/sync/blob-routes.ts
24219
24294
  var exports_blob_routes = {};
24220
24295
  __export(exports_blob_routes, {
24221
- serveBlob: () => serveBlob,
24222
- blobRoutes: () => blobRoutes
24296
+ blobRoutes: () => blobRoutes,
24297
+ serveBlob: () => serveBlob
24223
24298
  });
24224
24299
  function ext(ct3) {
24225
24300
  const t2 = ct3.toLowerCase().split(";")[0].trim();
@@ -25271,8 +25346,8 @@ var init_share_render = __esm(() => {
25271
25346
  // src/core/sync/sites-serve.ts
25272
25347
  var exports_sites_serve = {};
25273
25348
  __export(exports_sites_serve, {
25274
- serveSiteFile: () => serveSiteFile,
25275
- serveSite: () => serveSite
25349
+ serveSite: () => serveSite,
25350
+ serveSiteFile: () => serveSiteFile
25276
25351
  });
25277
25352
  async function serveSite(req, ctx, auth, opts = {}) {
25278
25353
  const url2 = new URL(req.url);
@@ -25516,16 +25591,16 @@ function docEditScript(slug, version2, body) {
25516
25591
  }
25517
25592
  });`;
25518
25593
  }
25519
- function cellText(prop, value) {
25594
+ function cellText(prop, value, titles) {
25520
25595
  if (value === null || value === undefined)
25521
25596
  return "";
25522
25597
  if (prop.type === "checkbox")
25523
25598
  return value ? "\u2713" : "";
25524
25599
  if (Array.isArray(value))
25525
- return value.map((v3) => String(v3)).join(", ");
25600
+ return value.map((v3) => titles?.get(String(v3)) ?? String(v3)).join(", ");
25526
25601
  return String(value);
25527
25602
  }
25528
- function cellHtml(prop, value) {
25603
+ function cellHtml(prop, value, titles) {
25529
25604
  if (value === null || value === undefined)
25530
25605
  return "";
25531
25606
  if (prop.type === "checkbox")
@@ -25535,7 +25610,7 @@ function cellHtml(prop, value) {
25535
25610
  return `<a href="${escapeHtml(s2)}" target="_blank" rel="noreferrer noopener">${escapeHtml(s2)}</a>`;
25536
25611
  }
25537
25612
  if (Array.isArray(value))
25538
- return value.map((v3) => `<span class="tag">${escapeHtml(String(v3))}</span>`).join(" ");
25613
+ return value.map((v3) => `<span class="tag">${escapeHtml(titles?.get(String(v3)) ?? String(v3))}</span>`).join(" ");
25539
25614
  return escapeHtml(String(value));
25540
25615
  }
25541
25616
  function editableType(t2) {
@@ -25569,6 +25644,16 @@ async function serveTable(ctx, req, share, sub) {
25569
25644
  if (sub !== "")
25570
25645
  return notFound();
25571
25646
  const records = listRecords(ctx.db, share.target_id);
25647
+ const grants2 = parseGrantSet(share.grants);
25648
+ const relTitles = new Map;
25649
+ for (const p2 of props) {
25650
+ const target = p2.type === "relation" ? p2.config?.database : undefined;
25651
+ if (!target || relTitles.has(target))
25652
+ continue;
25653
+ if (target === share.target_id || grantFor(grants2, target))
25654
+ relTitles.set(target, recordTitleMap(ctx.db, target));
25655
+ }
25656
+ const titlesFor = (p2) => p2.type === "relation" ? relTitles.get(p2.config?.database ?? "") : undefined;
25572
25657
  const editable = share.permission === "edit";
25573
25658
  const head = props.map((p2) => `<th>${escapeHtml(p2.name)}</th>`).join("");
25574
25659
  const rows = records.map((r3) => {
@@ -25577,7 +25662,7 @@ async function serveTable(ctx, req, share, sub) {
25577
25662
  if (editable && editableType(p2.type)) {
25578
25663
  return `<td contenteditable data-rec="${escapeHtml(r3.id)}" data-prop="${escapeHtml(p2.id)}" data-type="${p2.type}">${escapeHtml(cellText(p2, v3))}</td>`;
25579
25664
  }
25580
- return `<td>${cellHtml(p2, v3)}</td>`;
25665
+ return `<td>${cellHtml(p2, v3, titlesFor(p2))}</td>`;
25581
25666
  }).join("");
25582
25667
  return `<tr>${tds}</tr>`;
25583
25668
  }).join("");
@@ -25661,10 +25746,10 @@ async function serveSiteShare(ctx, req, share, sub, opts = {}) {
25661
25746
  }
25662
25747
  function siteFilesPage(ctx, share, siteId) {
25663
25748
  const files2 = listFiles(ctx.db, siteId);
25664
- const list7 = files2.map((f4) => `<li><button class="file" data-path="${escapeHtml(f4.path)}" data-text="${f4.encoding === "utf8" ? "1" : "0"}">${escapeHtml(f4.path)}</button> <span class="muted">${escapeHtml(f4.content_type)}</span></li>`).join("");
25749
+ const list8 = files2.map((f4) => `<li><button class="file" data-path="${escapeHtml(f4.path)}" data-text="${f4.encoding === "utf8" ? "1" : "0"}">${escapeHtml(f4.path)}</button> <span class="muted">${escapeHtml(f4.content_type)}</span></li>`).join("");
25665
25750
  const inner = `
25666
25751
  <p class="hint">\u7F16\u8F91\u7AD9\u70B9\u6587\u4EF6\uFF08\u6587\u672C\u6587\u4EF6\u53EF\u5728\u7EBF\u7F16\u8F91\uFF1B\u4FDD\u5B58\u5373\u5BF9\u6240\u6709\u8BBF\u95EE\u8005\u751F\u6548\uFF09\u3002</p>
25667
- <ul class="files">${list7 || '<li class="muted">\uFF08\u6682\u65E0\u6587\u4EF6\uFF09</li>'}</ul>
25752
+ <ul class="files">${list8 || '<li class="muted">\uFF08\u6682\u65E0\u6587\u4EF6\uFF09</li>'}</ul>
25668
25753
  <div id="editor" hidden>
25669
25754
  <div class="row"><strong id="fpath"></strong> <a id="open" target="_blank" rel="noreferrer">\u9884\u89C8 \u2197</a></div>
25670
25755
  <textarea class="mh-raw" id="fbody"></textarea>
@@ -25858,6 +25943,7 @@ var init_share_serve = __esm(() => {
25858
25943
  init_databases();
25859
25944
  init_properties();
25860
25945
  init_records();
25946
+ init_grants_core();
25861
25947
  init_sites();
25862
25948
  init_sites_serve();
25863
25949
  init_blobs();
@@ -27876,12 +27962,19 @@ function hlcMillis(hlc) {
27876
27962
  function hlcIso(hlc) {
27877
27963
  return new Date(hlcMillis(hlc)).toISOString();
27878
27964
  }
27965
+ function parseTxn(txn) {
27966
+ let rest = txn ?? "";
27967
+ let actor = null;
27968
+ const slash = rest.indexOf("/");
27969
+ if (slash > 0) {
27970
+ actor = rest.slice(0, slash);
27971
+ rest = rest.slice(slash + 1);
27972
+ }
27973
+ const kind = rest.startsWith("repair:") ? "repair" : rest.startsWith("revert:") ? "revert" : "user";
27974
+ return { actor, kind };
27975
+ }
27879
27976
  function revisionKind(txn) {
27880
- if (txn?.startsWith("repair:"))
27881
- return "repair";
27882
- if (txn?.startsWith("revert:"))
27883
- return "revert";
27884
- return "user";
27977
+ return parseTxn(txn).kind;
27885
27978
  }
27886
27979
  function clusterRevisions(changes) {
27887
27980
  const groups = [];
@@ -27974,6 +28067,7 @@ function listDocumentRevisions(db, id) {
27974
28067
  at: hlcIso(last.hlc),
27975
28068
  node_id: last.node_id,
27976
28069
  kind: revisionKind(last.txn),
28070
+ actor: parseTxn(last.txn).actor,
27977
28071
  changes: group.length,
27978
28072
  created,
27979
28073
  deleted,
@@ -28092,6 +28186,7 @@ function recordRevisionOf(group) {
28092
28186
  at: hlcIso(last.hlc),
28093
28187
  node_id: last.node_id,
28094
28188
  kind: revisionKind(last.txn),
28189
+ actor: parseTxn(last.txn).actor,
28095
28190
  changes: group.length,
28096
28191
  created,
28097
28192
  deleted,
@@ -28231,6 +28326,7 @@ function listPropertyRevisions(db, id) {
28231
28326
  at: hlcIso(last.hlc),
28232
28327
  node_id: last.node_id,
28233
28328
  kind: revisionKind(last.txn),
28329
+ actor: parseTxn(last.txn).actor,
28234
28330
  changes: group.length,
28235
28331
  created,
28236
28332
  deleted,
@@ -28292,7 +28388,7 @@ var revertProperty = grouped(function revertProperty2(db, id, to) {
28292
28388
  emit(db, "properties", id, "__deleted", 0);
28293
28389
  const schemaTxns = new Set(db.query("SELECT DISTINCT txn FROM crdt_changes WHERE dataset = 'properties' AND row_id = ? AND hlc > ? AND txn IS NOT NULL").all(id, to).map((r3) => r3.txn));
28294
28390
  const cellChanges = db.query("SELECT row_id, hlc, value, txn FROM crdt_changes WHERE dataset = 'records' AND col = ? ORDER BY row_id, hlc").all(id);
28295
- const isCascade = (txn) => txn !== null && (schemaTxns.has(txn) || txn.startsWith("repair:"));
28391
+ const isCascade = (txn) => txn !== null && (schemaTxns.has(txn) || parseTxn(txn).kind === "repair");
28296
28392
  let restored = 0;
28297
28393
  let skipped = 0;
28298
28394
  let i2 = 0;
@@ -28615,7 +28711,7 @@ var add = defineCommand({
28615
28711
  args: {
28616
28712
  name: { type: "positional", required: true, description: "Property name" },
28617
28713
  db: { type: "string", description: "Database ref (default: current)" },
28618
- type: { type: "string", required: true, description: "text|number|checkbox|select|multi_select|date|relation|url" },
28714
+ type: { type: "string", required: true, description: "text|number|checkbox|select|multi_select|date|relation|doc|url" },
28619
28715
  options: { type: "string", description: "Comma list for select/multi_select" },
28620
28716
  target: { type: "string", description: "Target database ref for relation" },
28621
28717
  config: { type: "string", description: "Raw config JSON (@file/@- ok)" },
@@ -28743,6 +28839,7 @@ var prop_default = defineCommand({
28743
28839
 
28744
28840
  // src/cli/commands/record.ts
28745
28841
  init_records();
28842
+ init_documents();
28746
28843
  init_properties();
28747
28844
  init_resolve();
28748
28845
  init_errors();
@@ -28768,6 +28865,27 @@ function flatten(r3) {
28768
28865
  out[k2] = v2 != null && typeof v2 === "object" ? JSON.stringify(v2) : v2;
28769
28866
  return out;
28770
28867
  }
28868
+ function titleize(db, databaseId, rows) {
28869
+ let docTitles = null;
28870
+ const maps = new Map;
28871
+ for (const p of listProperties(db, databaseId)) {
28872
+ if (p.type === "relation" && p.config?.database)
28873
+ maps.set(p.name, recordTitleMap(db, p.config.database));
28874
+ else if (p.type === "doc")
28875
+ maps.set(p.name, docTitles ??= documentTitleMap(db));
28876
+ }
28877
+ if (maps.size === 0)
28878
+ return rows;
28879
+ return rows.map((values) => {
28880
+ const out = { ...values };
28881
+ for (const [name, m2] of maps) {
28882
+ const v2 = out[name];
28883
+ if (Array.isArray(v2))
28884
+ out[name] = v2.map((x2) => m2.get(String(x2)) ?? String(x2)).join(", ");
28885
+ }
28886
+ return out;
28887
+ });
28888
+ }
28771
28889
  var create2 = defineCommand({
28772
28890
  meta: { name: "create", description: "Create a record (row)" },
28773
28891
  args: {
@@ -28801,7 +28919,10 @@ var list3 = defineCommand({
28801
28919
  sort,
28802
28920
  limit: args.limit != null ? Number(args.limit) : undefined
28803
28921
  });
28804
- print({ database: databaseId, count: rows.length, records: rows }, () => table(rows.map(flatten)));
28922
+ print({ database: databaseId, count: rows.length, records: rows }, () => {
28923
+ const titled = titleize(db, databaseId, rows.map((r3) => r3.values));
28924
+ return table(rows.map((r3, i2) => flatten({ id: r3.id, values: titled[i2] })));
28925
+ });
28805
28926
  })
28806
28927
  });
28807
28928
  var get2 = defineCommand({
@@ -28812,7 +28933,8 @@ var get2 = defineCommand({
28812
28933
  },
28813
28934
  run: guard(async (args) => {
28814
28935
  const db = await freshDb(args);
28815
- print(getRecord(db, resolveRef2(db, args.id, { kind: "rec" })));
28936
+ const row = getRecord(db, resolveRef2(db, args.id, { kind: "rec" }));
28937
+ print(row, () => table([flatten({ id: row.id, values: titleize(db, row.database_id, [row.values])[0] })]));
28816
28938
  })
28817
28939
  });
28818
28940
  var update2 = defineCommand({
@@ -31532,6 +31654,64 @@ function parseCsv(text) {
31532
31654
  return rows;
31533
31655
  }
31534
31656
 
31657
+ // src/core/relation-cells.ts
31658
+ var NEEDS_QUOTE2 = /^[\s[{]|[",]|\s$/;
31659
+ function encodeRelationCell(value, titles) {
31660
+ const arr = Array.isArray(value) ? value : value == null ? [] : [value];
31661
+ return arr.map((v2) => {
31662
+ const label = titles?.get(String(v2)) ?? String(v2);
31663
+ return NEEDS_QUOTE2.test(label) ? `"${label.replace(/"/g, '""')}"` : label;
31664
+ }).join(", ");
31665
+ }
31666
+ function decodeRelationCell(text) {
31667
+ const t2 = text.trim();
31668
+ if (!t2)
31669
+ return [];
31670
+ if (t2.startsWith("[")) {
31671
+ try {
31672
+ const arr = JSON.parse(t2);
31673
+ if (Array.isArray(arr))
31674
+ return arr.map(String).filter(Boolean);
31675
+ } catch {}
31676
+ }
31677
+ const out = [];
31678
+ let field = "";
31679
+ let inQuotes = false;
31680
+ let quoted = false;
31681
+ const push = () => {
31682
+ const v2 = quoted ? field : field.trim();
31683
+ if (v2)
31684
+ out.push(v2);
31685
+ field = "";
31686
+ quoted = false;
31687
+ };
31688
+ for (let i2 = 0;i2 < t2.length; i2++) {
31689
+ const c3 = t2[i2];
31690
+ if (inQuotes) {
31691
+ if (c3 === '"') {
31692
+ if (t2[i2 + 1] === '"') {
31693
+ field += '"';
31694
+ i2++;
31695
+ } else {
31696
+ inQuotes = false;
31697
+ }
31698
+ } else {
31699
+ field += c3;
31700
+ }
31701
+ } else if (c3 === '"' && field.trim() === "") {
31702
+ inQuotes = true;
31703
+ quoted = true;
31704
+ field = "";
31705
+ } else if (c3 === ",") {
31706
+ push();
31707
+ } else {
31708
+ field += c3;
31709
+ }
31710
+ }
31711
+ push();
31712
+ return out;
31713
+ }
31714
+
31535
31715
  // src/core/sync/files.ts
31536
31716
  init_errors();
31537
31717
  function tryResolve(db, ref) {
@@ -31572,8 +31752,19 @@ async function exportDoc(db, id, path) {
31572
31752
  async function exportDb(db, id, path) {
31573
31753
  const props = listProperties(db, id);
31574
31754
  const recs = listRecords(db, id, {});
31755
+ const relTitles = new Map;
31756
+ for (const p of props) {
31757
+ const target = p.type === "relation" ? p.config?.database : undefined;
31758
+ if (target && !relTitles.has(target))
31759
+ relTitles.set(target, recordTitleMap(db, target));
31760
+ }
31761
+ const docTitles = props.some((p) => p.type === "doc") ? documentTitleMap(db) : new Map;
31762
+ const titlesFor = (p) => p.type === "doc" ? docTitles : relTitles.get(p.config?.database ?? "") ?? new Map;
31575
31763
  const header = ["id", ...props.map((p) => p.name)];
31576
- const rows = recs.map((r3) => [r3.id, ...props.map((p) => cellToString(r3.values[p.name]))]);
31764
+ const rows = recs.map((r3) => [
31765
+ r3.id,
31766
+ ...props.map((p) => p.type === "relation" || p.type === "doc" ? encodeRelationCell(r3.cells[p.id], titlesFor(p)) : cellToString(r3.values[p.name]))
31767
+ ]);
31577
31768
  const csv = toCsv([header, ...rows]);
31578
31769
  await Bun.write(path, csv);
31579
31770
  return { direction: "export", kind: "db", id, path, rows: recs.length };
@@ -31589,6 +31780,10 @@ async function importDb(db, id, path) {
31589
31780
  return { direction: "import", kind: "db", id, path, rows: 0 };
31590
31781
  const header = grid[0];
31591
31782
  const idCol = header.indexOf("id");
31783
+ const propByName = new Map;
31784
+ for (const p of listProperties(db, id))
31785
+ if (!propByName.has(p.name))
31786
+ propByName.set(p.name, p);
31592
31787
  let count = 0;
31593
31788
  for (let i2 = 1;i2 < grid.length; i2++) {
31594
31789
  const cells = grid[i2];
@@ -31599,7 +31794,8 @@ async function importDb(db, id, path) {
31599
31794
  const raw = cells[c3];
31600
31795
  if (raw == null || raw === "")
31601
31796
  continue;
31602
- data[header[c3]] = parseCell(raw);
31797
+ const colType = propByName.get(header[c3])?.type;
31798
+ data[header[c3]] = colType === "relation" || colType === "doc" ? decodeRelationCell(raw) : parseCell(raw);
31603
31799
  }
31604
31800
  const rowId = idCol >= 0 ? cells[idCol]?.trim() : undefined;
31605
31801
  if (rowId && getRecord(db, rowId))
@@ -31829,6 +32025,52 @@ function repairOrphanCells(db) {
31829
32025
  emit(db, "records", row.rec, row.prop, undefined);
31830
32026
  return rows.length;
31831
32027
  }
32028
+ function deadCellRefRows(db) {
32029
+ const props = db.query("SELECT id, type FROM properties WHERE __deleted = 0 AND type IN ('relation', 'doc') ORDER BY id").all();
32030
+ const out = [];
32031
+ for (const p of props) {
32032
+ const tgtTable = p.type === "relation" ? "records" : "documents";
32033
+ const pid = p.id.replace(/'/g, "''");
32034
+ const rows = db.query(`SELECT r.id AS rec, j.value AS dead
32035
+ FROM records r, json_each(r.data -> '${pid}') j
32036
+ JOIN ${tgtTable} t ON t.id = j.value AND t.__deleted = 1
32037
+ WHERE r.__deleted = 0 AND json_type(r.data -> '${pid}') = 'array'
32038
+ ORDER BY r.id, j.value`).all();
32039
+ let cur = null;
32040
+ for (const row of rows) {
32041
+ if (!cur || cur.rec !== row.rec) {
32042
+ cur = { rec: row.rec, prop: p.id, tgtTable, dead: [] };
32043
+ out.push(cur);
32044
+ }
32045
+ cur.dead.push(row.dead);
32046
+ }
32047
+ }
32048
+ return out;
32049
+ }
32050
+ function detectDeadCellRefs(db) {
32051
+ return deadCellRefRows(db).map((g3) => ({
32052
+ category: "dead_cell_ref",
32053
+ entity: "records",
32054
+ id: g3.rec,
32055
+ detail: `cell ${g3.prop} references deleted ${g3.tgtTable === "records" ? "record" : "document"}: ${g3.dead.join(", ")}`,
32056
+ fixable: true
32057
+ }));
32058
+ }
32059
+ function repairDeadCellRefs(db) {
32060
+ const groups = deadCellRefRows(db);
32061
+ for (const g3 of groups) {
32062
+ const row = db.query("SELECT data FROM records WHERE id = ?").get(g3.rec);
32063
+ if (!row)
32064
+ continue;
32065
+ const data = JSON.parse(row.data || "{}");
32066
+ const arr = data[g3.prop];
32067
+ if (!Array.isArray(arr))
32068
+ continue;
32069
+ const deadSet = new Set(g3.dead);
32070
+ emit(db, "records", g3.rec, g3.prop, arr.filter((v2) => !deadSet.has(String(v2))));
32071
+ }
32072
+ return groups.length;
32073
+ }
31832
32074
  function dupPathLosers(db) {
31833
32075
  const rows = db.query(`SELECT id, site_id, path FROM site_files
31834
32076
  WHERE __deleted = 0 AND site_id IS NOT NULL AND path IS NOT NULL
@@ -31975,6 +32217,7 @@ function validateHub(db) {
31975
32217
  const issues = [
31976
32218
  ...detectBrokenRefs(db),
31977
32219
  ...detectOrphanCells(db),
32220
+ ...detectDeadCellRefs(db),
31978
32221
  ...detectDupPaths(db),
31979
32222
  ...detectCycleIssues(db),
31980
32223
  ...detectDupNames(db),
@@ -31993,6 +32236,7 @@ function repairPass(db) {
31993
32236
  };
31994
32237
  bump("broken_ref", repairBrokenRefs(db));
31995
32238
  bump("orphan_cell", repairOrphanCells(db));
32239
+ bump("dead_cell_ref", repairDeadCellRefs(db));
31996
32240
  bump("dup_path", repairDupPaths(db));
31997
32241
  bump("parent_cycle", repairParentCycles(db));
31998
32242
  const applied = Object.values(fixed).reduce((a2, b2) => a2 + b2, 0);
@@ -32089,7 +32333,7 @@ function rebuildDeclaredIndexes(db) {
32089
32333
  if (!p.database_id)
32090
32334
  continue;
32091
32335
  const indexed = p.config ? JSON.parse(p.config).indexed : false;
32092
- if (p.type === "relation" || indexed)
32336
+ if (p.type === "relation" || p.type === "doc" || indexed)
32093
32337
  ensurePropIndex(db, p.database_id, p.id);
32094
32338
  }
32095
32339
  }
@@ -32782,25 +33026,6 @@ function f3(r3, t2, s2) {
32782
33026
  const e2 = r3 + t2, i2 = Math.max(s2.length - 1, 0), n2 = e2 < 0 ? i2 : e2 > i2 ? 0 : e2;
32783
33027
  return s2[n2].disabled ? f3(n2, t2 < 0 ? -1 : 1, s2) : n2;
32784
33028
  }
32785
- function I3(r3, t2, s2, e2) {
32786
- const i2 = e2.split(`
32787
- `);
32788
- let n2 = 0, o3 = r3;
32789
- for (const a2 of i2) {
32790
- if (o3 <= a2.length)
32791
- break;
32792
- o3 -= a2.length + 1, n2++;
32793
- }
32794
- for (n2 = Math.max(0, Math.min(i2.length - 1, n2 + s2)), o3 = Math.min(o3, i2[n2].length) + t2;o3 < 0 && n2 > 0; )
32795
- n2--, o3 += i2[n2].length + 1;
32796
- for (;o3 > i2[n2].length && n2 < i2.length - 1; )
32797
- o3 -= i2[n2].length + 1, n2++;
32798
- o3 = Math.max(0, Math.min(i2[n2].length, o3));
32799
- let u3 = 0;
32800
- for (let a2 = 0;a2 < n2; a2++)
32801
- u3 += i2[a2].length + 1;
32802
- return u3 + o3;
32803
- }
32804
33029
  var K = ["up", "down", "left", "right", "space", "enter", "cancel"];
32805
33030
  var j = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
32806
33031
  var h2 = { actions: new Set(K), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...j], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r3, t2) => `There are only ${r3} days in ${t2}`, afterMin: (r3) => `Date must be on or after ${r3.toISOString().slice(0, 10)}`, beforeMax: (r3) => `Date must be on or before ${r3.toISOString().slice(0, 10)}` } } };
@@ -33004,86 +33229,6 @@ class m2 {
33004
33229
  }
33005
33230
  }
33006
33231
  }
33007
- function J2(r3, t2) {
33008
- if (r3 === undefined || t2.length === 0)
33009
- return 0;
33010
- const s2 = t2.findIndex((e2) => e2.value === r3);
33011
- return s2 !== -1 ? s2 : 0;
33012
- }
33013
- function H(r3, t2) {
33014
- return (t2.label ?? String(t2.value)).toLowerCase().includes(r3.toLowerCase());
33015
- }
33016
- function Q2(r3, t2) {
33017
- if (t2)
33018
- return r3 ? t2 : t2[0];
33019
- }
33020
- var X2 = class extends m2 {
33021
- filteredOptions;
33022
- multiple;
33023
- isNavigating = false;
33024
- selectedValues = [];
33025
- focusedValue;
33026
- #s = 0;
33027
- #r = "";
33028
- #t;
33029
- #n;
33030
- #u;
33031
- get cursor() {
33032
- return this.#s;
33033
- }
33034
- get userInputWithCursor() {
33035
- if (!this.userInput)
33036
- return v2(["inverse", "hidden"], "_");
33037
- if (this._cursor >= this.userInput.length)
33038
- return `${this.userInput}\u2588`;
33039
- const t2 = this.userInput.slice(0, this._cursor), [s2, ...e2] = this.userInput.slice(this._cursor);
33040
- return `${t2}${v2("inverse", s2)}${e2.join("")}`;
33041
- }
33042
- get options() {
33043
- return typeof this.#n == "function" ? this.#n() : this.#n;
33044
- }
33045
- constructor(t2) {
33046
- super(t2), this.#n = t2.options, this.#u = t2.placeholder;
33047
- const s2 = this.options;
33048
- this.filteredOptions = [...s2], this.multiple = t2.multiple === true, this.#t = typeof t2.options == "function" ? t2.filter : t2.filter ?? H;
33049
- let e2;
33050
- if (t2.initialValue && Array.isArray(t2.initialValue) ? this.multiple ? e2 = t2.initialValue : e2 = t2.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e2 = [this.options[0].value]), e2)
33051
- for (const i2 of e2) {
33052
- const n2 = s2.findIndex((o3) => o3.value === i2);
33053
- n2 !== -1 && (this.toggleSelected(i2), this.#s = n2);
33054
- }
33055
- this.focusedValue = this.options[this.#s]?.value, this.on("key", (i2, n2) => this.#e(i2, n2)), this.on("userInput", (i2) => this.#i(i2));
33056
- }
33057
- _isActionKey(t2, s2) {
33058
- return t2 === "\t" || this.multiple && this.isNavigating && s2.name === "space" && t2 !== undefined && t2 !== "";
33059
- }
33060
- #e(t2, s2) {
33061
- const e2 = s2.name === "up", i2 = s2.name === "down", n2 = s2.name === "return", o3 = this.userInput === "" || this.userInput === "\t", u3 = this.#u, a2 = this.options, l2 = u3 !== undefined && u3 !== "" && a2.some((c3) => !c3.disabled && (this.#t ? this.#t(u3, c3) : true));
33062
- if (s2.name === "tab" && o3 && l2) {
33063
- this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u3, true), this.isNavigating = false;
33064
- return;
33065
- }
33066
- e2 || i2 ? (this.#s = f3(this.#s, e2 ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n2 ? this.value = Q2(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s2.name === "tab" || this.isNavigating && s2.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
33067
- }
33068
- deselectAll() {
33069
- this.selectedValues = [];
33070
- }
33071
- toggleSelected(t2) {
33072
- this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t2) ? this.selectedValues = this.selectedValues.filter((s2) => s2 !== t2) : this.selectedValues = [...this.selectedValues, t2] : this.selectedValues = [t2]);
33073
- }
33074
- #i(t2) {
33075
- if (t2 !== this.#r) {
33076
- this.#r = t2;
33077
- const s2 = this.options;
33078
- t2 && this.#t ? this.filteredOptions = s2.filter((n2) => this.#t?.(t2, n2)) : this.filteredOptions = [...s2];
33079
- const e2 = J2(this.focusedValue, this.filteredOptions);
33080
- this.#s = f3(e2, 0, this.filteredOptions);
33081
- const i2 = this.filteredOptions[this.#s];
33082
- i2 && !i2.disabled ? this.focusedValue = i2.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
33083
- }
33084
- }
33085
- };
33086
-
33087
33232
  class Z extends m2 {
33088
33233
  get cursor() {
33089
33234
  return this.value ? 0 : 1;
@@ -33101,316 +33246,7 @@ class Z extends m2 {
33101
33246
  });
33102
33247
  }
33103
33248
  }
33104
- var tt = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
33105
- function F3(r3) {
33106
- return [...r3].map((t2) => tt[t2]);
33107
- }
33108
- function st(r3) {
33109
- const t2 = new Intl.DateTimeFormat(r3, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), s2 = [];
33110
- let e2 = "/";
33111
- for (const i2 of t2)
33112
- i2.type === "literal" ? e2 = i2.value.trim() || i2.value : (i2.type === "year" || i2.type === "month" || i2.type === "day") && s2.push({ type: i2.type, len: i2.type === "year" ? 4 : 2 });
33113
- return { segments: s2, separator: e2 };
33114
- }
33115
- function $(r3) {
33116
- return Number.parseInt((r3 || "0").replace(/_/g, "0"), 10) || 0;
33117
- }
33118
- function S3(r3) {
33119
- return { year: $(r3.year), month: $(r3.month), day: $(r3.day) };
33120
- }
33121
- function U(r3, t2) {
33122
- return new Date(r3 || 2001, t2 || 1, 0).getDate();
33123
- }
33124
- function N3(r3) {
33125
- const { year: t2, month: s2, day: e2 } = S3(r3);
33126
- if (!t2 || t2 < 0 || t2 > 9999 || !s2 || s2 < 1 || s2 > 12 || !e2 || e2 < 1)
33127
- return;
33128
- const i2 = new Date(Date.UTC(t2, s2 - 1, e2));
33129
- if (!(i2.getUTCFullYear() !== t2 || i2.getUTCMonth() !== s2 - 1 || i2.getUTCDate() !== e2))
33130
- return { year: t2, month: s2, day: e2 };
33131
- }
33132
- function E(r3) {
33133
- const t2 = N3(r3);
33134
- return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : undefined;
33135
- }
33136
- function et(r3, t2, s2, e2) {
33137
- const i2 = s2 ? { year: s2.getUTCFullYear(), month: s2.getUTCMonth() + 1, day: s2.getUTCDate() } : null, n2 = e2 ? { year: e2.getUTCFullYear(), month: e2.getUTCMonth() + 1, day: e2.getUTCDate() } : null;
33138
- return r3 === "year" ? { min: i2?.year ?? 1, max: n2?.year ?? 9999 } : r3 === "month" ? { min: i2 && t2.year === i2.year ? i2.month : 1, max: n2 && t2.year === n2.year ? n2.month : 12 } : { min: i2 && t2.year === i2.year && t2.month === i2.month ? i2.day : 1, max: n2 && t2.year === n2.year && t2.month === n2.month ? n2.day : U(t2.year, t2.month) };
33139
- }
33140
-
33141
- class it extends m2 {
33142
- #s;
33143
- #r;
33144
- #t;
33145
- #n;
33146
- #u;
33147
- #e = { segmentIndex: 0, positionInSegment: 0 };
33148
- #i = true;
33149
- #o = null;
33150
- inlineError = "";
33151
- get segmentCursor() {
33152
- return { ...this.#e };
33153
- }
33154
- get segmentValues() {
33155
- return { ...this.#t };
33156
- }
33157
- get segments() {
33158
- return this.#s;
33159
- }
33160
- get separator() {
33161
- return this.#r;
33162
- }
33163
- get formattedValue() {
33164
- return this.#c(this.#t);
33165
- }
33166
- #c(t2) {
33167
- return this.#s.map((s2) => t2[s2.type]).join(this.#r);
33168
- }
33169
- #a() {
33170
- this._setUserInput(this.#c(this.#t)), this._setValue(E(this.#t) ?? undefined);
33171
- }
33172
- constructor(t2) {
33173
- const s2 = t2.format ? { segments: F3(t2.format), separator: t2.separator ?? "/" } : st(t2.locale), e2 = t2.separator ?? s2.separator, i2 = t2.format ? F3(t2.format) : s2.segments, n2 = t2.initialValue ?? t2.defaultValue, o3 = n2 ? { year: String(n2.getUTCFullYear()).padStart(4, "0"), month: String(n2.getUTCMonth() + 1).padStart(2, "0"), day: String(n2.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u3 = i2.map((a2) => o3[a2.type]).join(e2);
33174
- super({ ...t2, initialUserInput: u3 }, false), this.#s = i2, this.#r = e2, this.#t = o3, this.#n = t2.minDate, this.#u = t2.maxDate, this.#a(), this.on("cursor", (a2) => this.#d(a2)), this.on("key", (a2, l2) => this.#f(a2, l2)), this.on("finalize", () => this.#g(t2));
33175
- }
33176
- #h() {
33177
- const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s2 = this.#s[t2];
33178
- if (s2)
33179
- return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s2.len - 1)), { segment: s2, index: t2 };
33180
- }
33181
- #l(t2) {
33182
- this.inlineError = "", this.#o = null;
33183
- const s2 = this.#h();
33184
- s2 && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s2.index + t2)), this.#e.positionInSegment = 0, this.#i = true);
33185
- }
33186
- #p(t2) {
33187
- const s2 = this.#h();
33188
- if (!s2)
33189
- return;
33190
- const { segment: e2 } = s2, i2 = this.#t[e2.type], n2 = !i2 || i2.replace(/_/g, "") === "", o3 = Number.parseInt((i2 || "0").replace(/_/g, "0"), 10) || 0, u3 = et(e2.type, S3(this.#t), this.#n, this.#u);
33191
- let a2;
33192
- n2 ? a2 = t2 === 1 ? u3.min : u3.max : a2 = Math.max(Math.min(u3.max, o3 + t2), u3.min), this.#t = { ...this.#t, [e2.type]: a2.toString().padStart(e2.len, "0") }, this.#i = true, this.#o = null, this.#a();
33193
- }
33194
- #d(t2) {
33195
- if (t2)
33196
- switch (t2) {
33197
- case "right":
33198
- return this.#l(1);
33199
- case "left":
33200
- return this.#l(-1);
33201
- case "up":
33202
- return this.#p(1);
33203
- case "down":
33204
- return this.#p(-1);
33205
- }
33206
- }
33207
- #f(t2, s2) {
33208
- if (s2?.name === "backspace" || s2?.sequence === "\x7F" || s2?.sequence === "\b" || t2 === "\x7F" || t2 === "\b") {
33209
- this.inlineError = "";
33210
- const e2 = this.#h();
33211
- if (!e2)
33212
- return;
33213
- if (!this.#t[e2.segment.type].replace(/_/g, "")) {
33214
- this.#l(-1);
33215
- return;
33216
- }
33217
- this.#t[e2.segment.type] = "_".repeat(e2.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
33218
- return;
33219
- }
33220
- if (s2?.name === "tab") {
33221
- this.inlineError = "";
33222
- const e2 = this.#h();
33223
- if (!e2)
33224
- return;
33225
- const i2 = s2.shift ? -1 : 1, n2 = e2.index + i2;
33226
- n2 >= 0 && n2 < this.#s.length && (this.#e.segmentIndex = n2, this.#e.positionInSegment = 0, this.#i = true);
33227
- return;
33228
- }
33229
- if (t2 && /^[0-9]$/.test(t2)) {
33230
- const e2 = this.#h();
33231
- if (!e2)
33232
- return;
33233
- const { segment: i2 } = e2, n2 = !this.#t[i2.type].replace(/_/g, "");
33234
- if (this.#i && this.#o !== null && !n2) {
33235
- const d2 = this.#o + t2, g3 = { ...this.#t, [i2.type]: d2 }, _3 = this.#m(g3, i2);
33236
- if (_3) {
33237
- this.inlineError = _3, this.#o = null, this.#i = false;
33238
- return;
33239
- }
33240
- this.inlineError = "", this.#t[i2.type] = d2, this.#o = null, this.#i = false, this.#a(), e2.index < this.#s.length - 1 && (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true);
33241
- return;
33242
- }
33243
- this.#i && !n2 && (this.#t[i2.type] = "_".repeat(i2.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
33244
- const o3 = this.#t[i2.type], u3 = o3.indexOf("_"), a2 = u3 >= 0 ? u3 : Math.min(this.#e.positionInSegment, i2.len - 1);
33245
- if (a2 < 0 || a2 >= i2.len)
33246
- return;
33247
- let l2 = o3.slice(0, a2) + t2 + o3.slice(a2 + 1), c3 = false;
33248
- if (a2 === 0 && o3 === "__" && (i2.type === "month" || i2.type === "day")) {
33249
- const d2 = Number.parseInt(t2, 10);
33250
- l2 = `0${t2}`, c3 = d2 <= (i2.type === "month" ? 1 : 2);
33251
- }
33252
- if (i2.type === "year" && (l2 = (o3.replace(/_/g, "") + t2).padStart(i2.len, "_")), !l2.includes("_")) {
33253
- const d2 = { ...this.#t, [i2.type]: l2 }, g3 = this.#m(d2, i2);
33254
- if (g3) {
33255
- this.inlineError = g3;
33256
- return;
33257
- }
33258
- }
33259
- this.inlineError = "", this.#t[i2.type] = l2;
33260
- const y3 = l2.includes("_") ? undefined : N3(this.#t);
33261
- if (y3) {
33262
- const { year: d2, month: g3 } = y3, _3 = U(d2, g3);
33263
- this.#t = { year: String(Math.max(0, Math.min(9999, d2))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g3))).padStart(2, "0"), day: String(Math.max(1, Math.min(_3, y3.day))).padStart(2, "0") };
33264
- }
33265
- this.#a();
33266
- const T3 = l2.indexOf("_");
33267
- c3 ? (this.#i = true, this.#o = t2) : T3 >= 0 ? this.#e.positionInSegment = T3 : u3 >= 0 && e2.index < this.#s.length - 1 ? (this.#e.segmentIndex = e2.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a2 + 1, i2.len - 1);
33268
- }
33269
- }
33270
- #m(t2, s2) {
33271
- const { month: e2, day: i2 } = S3(t2);
33272
- if (s2.type === "month" && (e2 < 0 || e2 > 12))
33273
- return h2.date.messages.invalidMonth;
33274
- if (s2.type === "day" && (i2 < 0 || i2 > 31))
33275
- return h2.date.messages.invalidDay(31, "any month");
33276
- }
33277
- #g(t2) {
33278
- const { year: s2, month: e2, day: i2 } = S3(this.#t);
33279
- if (s2 && e2 && i2) {
33280
- const n2 = U(s2, e2);
33281
- this.#t = { ...this.#t, day: String(Math.min(i2, n2)).padStart(2, "0") };
33282
- }
33283
- this.value = E(this.#t) ?? t2.defaultValue ?? undefined;
33284
- }
33285
- }
33286
- var rt = class extends m2 {
33287
- options;
33288
- cursor = 0;
33289
- #s;
33290
- getGroupItems(t2) {
33291
- return this.options.filter((s2) => s2.group === t2);
33292
- }
33293
- isGroupSelected(t2) {
33294
- const s2 = this.getGroupItems(t2), e2 = this.value;
33295
- return e2 === undefined ? false : s2.every((i2) => e2.includes(i2.value));
33296
- }
33297
- toggleValue() {
33298
- const t2 = this.options[this.cursor];
33299
- if (this.value === undefined && (this.value = []), t2.group === true) {
33300
- const s2 = t2.value, e2 = this.getGroupItems(s2);
33301
- this.isGroupSelected(s2) ? this.value = this.value.filter((i2) => e2.findIndex((n2) => n2.value === i2) === -1) : this.value = [...this.value, ...e2.map((i2) => i2.value)], this.value = Array.from(new Set(this.value));
33302
- } else {
33303
- const s2 = this.value.includes(t2.value);
33304
- this.value = s2 ? this.value.filter((e2) => e2 !== t2.value) : [...this.value, t2.value];
33305
- }
33306
- }
33307
- constructor(t2) {
33308
- super(t2, false);
33309
- const { options: s2 } = t2;
33310
- this.#s = t2.selectableGroups !== false, this.options = Object.entries(s2).flatMap(([e2, i2]) => [{ value: e2, group: true, label: e2 }, ...i2.map((n2) => ({ ...n2, group: e2 }))]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e2 }) => e2 === t2.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e2) => {
33311
- switch (e2) {
33312
- case "left":
33313
- case "up": {
33314
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
33315
- const i2 = this.options[this.cursor]?.group === true;
33316
- !this.#s && i2 && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
33317
- break;
33318
- }
33319
- case "down":
33320
- case "right": {
33321
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
33322
- const i2 = this.options[this.cursor]?.group === true;
33323
- !this.#s && i2 && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
33324
- break;
33325
- }
33326
- case "space":
33327
- this.toggleValue();
33328
- break;
33329
- }
33330
- });
33331
- }
33332
- };
33333
33249
  var nt = new Set(["up", "down", "left", "right"]);
33334
-
33335
- class ot extends m2 {
33336
- #s = false;
33337
- #r;
33338
- focused = "editor";
33339
- get userInputWithCursor() {
33340
- if (this.state === "submit")
33341
- return this.userInput;
33342
- const t2 = this.userInput;
33343
- if (this.cursor >= t2.length)
33344
- return `${t2}\u2588`;
33345
- const s2 = t2.slice(0, this.cursor), e2 = t2[this.cursor], i2 = t2.slice(this.cursor + 1);
33346
- return e2 === `
33347
- ` ? `${s2}\u2588
33348
- ${i2}` : `${s2}${v2("inverse", e2)}${i2}`;
33349
- }
33350
- get cursor() {
33351
- return this._cursor;
33352
- }
33353
- #t(t2) {
33354
- if (this.userInput.length === 0) {
33355
- this._setUserInput(t2);
33356
- return;
33357
- }
33358
- this._setUserInput(this.userInput.slice(0, this.cursor) + t2 + this.userInput.slice(this.cursor));
33359
- }
33360
- #n(t2) {
33361
- const s2 = this.value ?? "";
33362
- switch (t2) {
33363
- case "up":
33364
- this._cursor = I3(this._cursor, 0, -1, s2);
33365
- return;
33366
- case "down":
33367
- this._cursor = I3(this._cursor, 0, 1, s2);
33368
- return;
33369
- case "left":
33370
- this._cursor = I3(this._cursor, -1, 0, s2);
33371
- return;
33372
- case "right":
33373
- this._cursor = I3(this._cursor, 1, 0, s2);
33374
- return;
33375
- }
33376
- }
33377
- _shouldSubmit(t2, s2) {
33378
- if (this.#r)
33379
- return this.focused === "submit" ? true : (this.#t(`
33380
- `), this._cursor++, false);
33381
- const e2 = this.#s;
33382
- return this.#s = true, e2 ? (this.userInput[this.cursor - 1] === `
33383
- ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
33384
- `), this._cursor++, false);
33385
- }
33386
- constructor(t2) {
33387
- super(t2, false), this.#r = t2.showSubmit ?? false, this.on("key", (s2, e2) => {
33388
- if (e2?.name && nt.has(e2.name)) {
33389
- this.#n(e2.name);
33390
- return;
33391
- }
33392
- if (s2 === "\t" && this.#r) {
33393
- this.focused = this.focused === "editor" ? "submit" : "editor";
33394
- return;
33395
- }
33396
- if (e2?.name !== "return") {
33397
- if (this.#s = false, e2?.name === "backspace" && this.cursor > 0) {
33398
- this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
33399
- return;
33400
- }
33401
- if (e2?.name === "delete" && this.cursor < this.userInput.length) {
33402
- this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
33403
- return;
33404
- }
33405
- s2 && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s2 ?? ""), this._cursor++);
33406
- }
33407
- }), this.on("userInput", (s2) => {
33408
- this._setValue(s2);
33409
- }), this.on("finalize", () => {
33410
- this.value || (this.value = t2.defaultValue), this.value === undefined && (this.value = "");
33411
- });
33412
- }
33413
- }
33414
33250
  class at extends m2 {
33415
33251
  _mask = "\u2022";
33416
33252
  get cursor() {
@@ -33494,25 +33330,25 @@ var import_sisteransi2 = __toESM(require_src(), 1);
33494
33330
  function se() {
33495
33331
  return V3.platform !== "win32" ? V3.env.TERM !== "linux" : !!V3.env.CI || !!V3.env.WT_SESSION || !!V3.env.TERMINUS_SUBLIME || V3.env.ConEmuTask === "{cmd::Cmder}" || V3.env.TERM_PROGRAM === "Terminus-Sublime" || V3.env.TERM_PROGRAM === "vscode" || V3.env.TERM === "xterm-256color" || V3.env.TERM === "alacritty" || V3.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
33496
33332
  }
33497
- var tt2 = se();
33333
+ var tt = se();
33498
33334
  var at2 = () => process.env.CI === "true";
33499
- var w3 = (t2, i2) => tt2 ? t2 : i2;
33335
+ var w3 = (t2, i2) => tt ? t2 : i2;
33500
33336
  var _t = w3("\u25C6", "*");
33501
33337
  var ut2 = w3("\u25A0", "x");
33502
33338
  var lt2 = w3("\u25B2", "x");
33503
- var H2 = w3("\u25C7", "o");
33339
+ var H = w3("\u25C7", "o");
33504
33340
  var ct2 = w3("\u250C", "T");
33505
- var $2 = w3("\u2502", "|");
33341
+ var $ = w3("\u2502", "|");
33506
33342
  var x3 = w3("\u2514", "\u2014");
33507
33343
  var xt = w3("\u2510", "T");
33508
33344
  var Et = w3("\u2518", "\u2014");
33509
33345
  var z4 = w3("\u25CF", ">");
33510
- var U2 = w3("\u25CB", " ");
33511
- var et2 = w3("\u25FB", "[\u2022]");
33346
+ var U = w3("\u25CB", " ");
33347
+ var et = w3("\u25FB", "[\u2022]");
33512
33348
  var K2 = w3("\u25FC", "[+]");
33513
33349
  var Y3 = w3("\u25FB", "[ ]");
33514
33350
  var Gt = w3("\u25AA", "\u2022");
33515
- var st2 = w3("\u2500", "-");
33351
+ var st = w3("\u2500", "-");
33516
33352
  var $t = w3("\u256E", "+");
33517
33353
  var Mt = w3("\u251C", "+");
33518
33354
  var dt = w3("\u256F", "+");
@@ -33532,20 +33368,20 @@ var P4 = (t2) => {
33532
33368
  case "error":
33533
33369
  return e2("yellow", lt2);
33534
33370
  case "submit":
33535
- return e2("green", H2);
33371
+ return e2("green", H);
33536
33372
  }
33537
33373
  };
33538
33374
  var ft = (t2) => {
33539
33375
  switch (t2) {
33540
33376
  case "initial":
33541
33377
  case "active":
33542
- return e2("cyan", $2);
33378
+ return e2("cyan", $);
33543
33379
  case "cancel":
33544
- return e2("red", $2);
33380
+ return e2("red", $);
33545
33381
  case "error":
33546
- return e2("yellow", $2);
33382
+ return e2("yellow", $);
33547
33383
  case "submit":
33548
- return e2("green", $2);
33384
+ return e2("green", $);
33549
33385
  }
33550
33386
  };
33551
33387
  var Pt = (t2, i2, s2, r3, u3, n2 = false) => {
@@ -33558,15 +33394,15 @@ var Pt = (t2, i2, s2, r3, u3, n2 = false) => {
33558
33394
  ;
33559
33395
  return { lineCount: a2, removals: c3 };
33560
33396
  };
33561
- var F4 = ({ cursor: t2, options: i2, style: s2, output: r3 = process.stdout, maxItems: u3 = Number.POSITIVE_INFINITY, columnPadding: n2 = 0, rowPadding: a2 = 4 }) => {
33397
+ var F3 = ({ cursor: t2, options: i2, style: s2, output: r3 = process.stdout, maxItems: u3 = Number.POSITIVE_INFINITY, columnPadding: n2 = 0, rowPadding: a2 = 4 }) => {
33562
33398
  const c3 = A3(r3) - n2, o3 = L3(r3), l2 = e2("dim", "..."), d2 = Math.max(o3 - a2, 0), g3 = Math.max(Math.min(u3, d2), 5);
33563
33399
  let p2 = 0;
33564
33400
  t2 >= g3 - 3 && (p2 = Math.max(Math.min(t2 - g3 + 3, i2.length - g3), 0));
33565
33401
  let f4 = g3 < i2.length && p2 > 0, h3 = g3 < i2.length && p2 + g3 < i2.length;
33566
- const I4 = Math.min(p2 + g3, i2.length), m3 = [];
33402
+ const I3 = Math.min(p2 + g3, i2.length), m3 = [];
33567
33403
  let y3 = 0;
33568
33404
  f4 && y3++, h3 && y3++;
33569
- const v3 = p2 + (f4 ? 1 : 0), C4 = I4 - (h3 ? 1 : 0);
33405
+ const v3 = p2 + (f4 ? 1 : 0), C4 = I3 - (h3 ? 1 : 0);
33570
33406
  for (let b3 = v3;b3 < C4; b3++) {
33571
33407
  const G4 = wrapAnsi(s2(i2[b3], b3 === t2), c3, { hard: true, trim: false }).split(`
33572
33408
  `);
@@ -33574,39 +33410,39 @@ var F4 = ({ cursor: t2, options: i2, style: s2, output: r3 = process.stdout, max
33574
33410
  }
33575
33411
  if (y3 > d2) {
33576
33412
  let b3 = 0, G4 = 0, M = y3;
33577
- const N4 = t2 - v3;
33413
+ const N3 = t2 - v3;
33578
33414
  let O4 = d2;
33579
- const j2 = () => Pt(m3, M, 0, N4, O4), k3 = () => Pt(m3, M, N4 + 1, m3.length, O4, true);
33415
+ const j2 = () => Pt(m3, M, 0, N3, O4), k3 = () => Pt(m3, M, N3 + 1, m3.length, O4, true);
33580
33416
  f4 ? ({ lineCount: M, removals: b3 } = j2(), M > O4 && (h3 || (O4 -= 1), { lineCount: M, removals: G4 } = k3())) : (h3 || (O4 -= 1), { lineCount: M, removals: G4 } = k3(), M > O4 && (O4 -= 1, { lineCount: M, removals: b3 } = j2())), b3 > 0 && (f4 = true, m3.splice(0, b3)), G4 > 0 && (h3 = true, m3.splice(m3.length - G4, G4));
33581
33417
  }
33582
- const S4 = [];
33583
- f4 && S4.push(l2);
33418
+ const S3 = [];
33419
+ f4 && S3.push(l2);
33584
33420
  for (const b3 of m3)
33585
33421
  for (const G4 of b3)
33586
- S4.push(G4);
33587
- return h3 && S4.push(l2), S4;
33422
+ S3.push(G4);
33423
+ return h3 && S3.push(l2), S3;
33588
33424
  };
33589
33425
  var le2 = (t2) => {
33590
33426
  const i2 = t2.active ?? "Yes", s2 = t2.inactive ?? "No";
33591
33427
  return new Z({ active: i2, inactive: s2, signal: t2.signal, input: t2.input, output: t2.output, initialValue: t2.initialValue ?? true, render() {
33592
- const r3 = t2.withGuide ?? h2.withGuide, u3 = `${P4(this.state)} `, n2 = r3 ? `${e2("gray", $2)} ` : "", a2 = B2(t2.output, t2.message, n2, u3), c3 = `${r3 ? `${e2("gray", $2)}
33428
+ const r3 = t2.withGuide ?? h2.withGuide, u3 = `${P4(this.state)} `, n2 = r3 ? `${e2("gray", $)} ` : "", a2 = B2(t2.output, t2.message, n2, u3), c3 = `${r3 ? `${e2("gray", $)}
33593
33429
  ` : ""}${a2}
33594
33430
  `, o3 = this.value ? i2 : s2;
33595
33431
  switch (this.state) {
33596
33432
  case "submit": {
33597
- const l2 = r3 ? `${e2("gray", $2)} ` : "";
33433
+ const l2 = r3 ? `${e2("gray", $)} ` : "";
33598
33434
  return `${c3}${l2}${e2("dim", o3)}`;
33599
33435
  }
33600
33436
  case "cancel": {
33601
- const l2 = r3 ? `${e2("gray", $2)} ` : "";
33437
+ const l2 = r3 ? `${e2("gray", $)} ` : "";
33602
33438
  return `${c3}${l2}${e2(["strikethrough", "dim"], o3)}${r3 ? `
33603
- ${e2("gray", $2)}` : ""}`;
33439
+ ${e2("gray", $)}` : ""}`;
33604
33440
  }
33605
33441
  default: {
33606
- const l2 = r3 ? `${e2("cyan", $2)} ` : "", d2 = r3 ? e2("cyan", x3) : "";
33607
- return `${c3}${l2}${this.value ? `${e2("green", z4)} ${i2}` : `${e2("dim", U2)} ${e2("dim", i2)}`}${t2.vertical ? r3 ? `
33608
- ${e2("cyan", $2)} ` : `
33609
- ` : ` ${e2("dim", "/")} `}${this.value ? `${e2("dim", U2)} ${e2("dim", s2)}` : `${e2("green", z4)} ${s2}`}
33442
+ const l2 = r3 ? `${e2("cyan", $)} ` : "", d2 = r3 ? e2("cyan", x3) : "";
33443
+ return `${c3}${l2}${this.value ? `${e2("green", z4)} ${i2}` : `${e2("dim", U)} ${e2("dim", i2)}`}${t2.vertical ? r3 ? `
33444
+ ${e2("cyan", $)} ` : `
33445
+ ` : ` ${e2("dim", "/")} `}${this.value ? `${e2("dim", U)} ${e2("dim", s2)}` : `${e2("green", z4)} ${s2}`}
33610
33446
  ${d2}
33611
33447
  `;
33612
33448
  }
@@ -33625,7 +33461,7 @@ var ye2 = (t2 = "", i2) => {
33625
33461
  `);
33626
33462
  };
33627
33463
  var fe2 = (t2 = "", i2) => {
33628
- const s2 = i2?.output ?? process.stdout, r3 = i2?.withGuide ?? h2.withGuide ? `${e2("gray", $2)}
33464
+ const s2 = i2?.output ?? process.stdout, r3 = i2?.withGuide ?? h2.withGuide ? `${e2("gray", $)}
33629
33465
  ${e2("gray", x3)} ` : "";
33630
33466
  s2.write(`${r3}${t2}
33631
33467
 
@@ -33642,37 +33478,37 @@ var Ce = (t2 = "", i2 = "", s2) => {
33642
33478
  `).map(n2), ""], c3 = dist_default2(i2), o3 = Math.max(a2.reduce((p2, f4) => {
33643
33479
  const h3 = dist_default2(f4);
33644
33480
  return h3 > p2 ? h3 : p2;
33645
- }, 0), c3) + 2, l2 = a2.map((p2) => `${e2("gray", $2)} ${p2}${" ".repeat(o3 - dist_default2(p2))}${e2("gray", $2)}`).join(`
33646
- `), d2 = u3 ? `${e2("gray", $2)}
33481
+ }, 0), c3) + 2, l2 = a2.map((p2) => `${e2("gray", $)} ${p2}${" ".repeat(o3 - dist_default2(p2))}${e2("gray", $)}`).join(`
33482
+ `), d2 = u3 ? `${e2("gray", $)}
33647
33483
  ` : "", g3 = u3 ? Mt : ht2;
33648
- r3.write(`${d2}${e2("green", H2)} ${e2("reset", i2)} ${e2("gray", st2.repeat(Math.max(o3 - c3 - 1, 1)) + $t)}
33484
+ r3.write(`${d2}${e2("green", H)} ${e2("reset", i2)} ${e2("gray", st.repeat(Math.max(o3 - c3 - 1, 1)) + $t)}
33649
33485
  ${l2}
33650
- ${e2("gray", g3 + st2.repeat(o3 + 2) + dt)}
33486
+ ${e2("gray", g3 + st.repeat(o3 + 2) + dt)}
33651
33487
  `);
33652
33488
  };
33653
33489
  var Ie = (t2) => new at({ validate: t2.validate, mask: t2.mask ?? Gt, signal: t2.signal, input: t2.input, output: t2.output, render() {
33654
- const i2 = t2.withGuide ?? h2.withGuide, s2 = `${i2 ? `${e2("gray", $2)}
33490
+ const i2 = t2.withGuide ?? h2.withGuide, s2 = `${i2 ? `${e2("gray", $)}
33655
33491
  ` : ""}${P4(this.state)} ${t2.message}
33656
33492
  `, r3 = this.userInputWithCursor, u3 = this.masked;
33657
33493
  switch (this.state) {
33658
33494
  case "error": {
33659
- const n2 = i2 ? `${e2("yellow", $2)} ` : "", a2 = i2 ? `${e2("yellow", x3)} ` : "", c3 = u3 ?? "";
33495
+ const n2 = i2 ? `${e2("yellow", $)} ` : "", a2 = i2 ? `${e2("yellow", x3)} ` : "", c3 = u3 ?? "";
33660
33496
  return t2.clearOnError && this.clear(), `${s2.trim()}
33661
33497
  ${n2}${c3}
33662
33498
  ${a2}${e2("yellow", this.error)}
33663
33499
  `;
33664
33500
  }
33665
33501
  case "submit": {
33666
- const n2 = i2 ? `${e2("gray", $2)} ` : "", a2 = u3 ? e2("dim", u3) : "";
33502
+ const n2 = i2 ? `${e2("gray", $)} ` : "", a2 = u3 ? e2("dim", u3) : "";
33667
33503
  return `${s2}${n2}${a2}`;
33668
33504
  }
33669
33505
  case "cancel": {
33670
- const n2 = i2 ? `${e2("gray", $2)} ` : "", a2 = u3 ? e2(["strikethrough", "dim"], u3) : "";
33506
+ const n2 = i2 ? `${e2("gray", $)} ` : "", a2 = u3 ? e2(["strikethrough", "dim"], u3) : "";
33671
33507
  return `${s2}${n2}${a2}${u3 && i2 ? `
33672
- ${e2("gray", $2)}` : ""}`;
33508
+ ${e2("gray", $)}` : ""}`;
33673
33509
  }
33674
33510
  default: {
33675
- const n2 = i2 ? `${e2("cyan", $2)} ` : "", a2 = i2 ? e2("cyan", x3) : "";
33511
+ const n2 = i2 ? `${e2("cyan", $)} ` : "", a2 = i2 ? e2("cyan", x3) : "";
33676
33512
  return `${s2}${n2}${r3}
33677
33513
  ${a2}
33678
33514
  `;
@@ -33680,35 +33516,35 @@ ${a2}
33680
33516
  }
33681
33517
  } }).prompt();
33682
33518
  var _e = (t2) => e2("magenta", t2);
33683
- var vt = ({ indicator: t2 = "dots", onCancel: i2, output: s2 = process.stdout, cancelMessage: r3, errorMessage: u3, frames: n2 = tt2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: a2 = tt2 ? 80 : 120, signal: c3, ...o3 } = {}) => {
33519
+ var vt = ({ indicator: t2 = "dots", onCancel: i2, output: s2 = process.stdout, cancelMessage: r3, errorMessage: u3, frames: n2 = tt ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: a2 = tt ? 80 : 120, signal: c3, ...o3 } = {}) => {
33684
33520
  const l2 = at2();
33685
- let d2, g3, p2 = false, f4 = false, h3 = "", I4, m3 = performance.now();
33521
+ let d2, g3, p2 = false, f4 = false, h3 = "", I3, m3 = performance.now();
33686
33522
  const y3 = A3(s2), v3 = o3?.styleFrame ?? _e, C4 = (_3) => {
33687
33523
  const A4 = _3 > 1 ? u3 ?? h2.messages.error : r3 ?? h2.messages.cancel;
33688
33524
  f4 = _3 === 1, p2 && (W3(A4, _3), f4 && typeof i2 == "function" && i2());
33689
- }, S4 = () => C4(2), b3 = () => C4(1), G4 = () => {
33690
- process.on("uncaughtExceptionMonitor", S4), process.on("unhandledRejection", S4), process.on("SIGINT", b3), process.on("SIGTERM", b3), process.on("exit", C4), c3 && c3.addEventListener("abort", b3);
33525
+ }, S3 = () => C4(2), b3 = () => C4(1), G4 = () => {
33526
+ process.on("uncaughtExceptionMonitor", S3), process.on("unhandledRejection", S3), process.on("SIGINT", b3), process.on("SIGTERM", b3), process.on("exit", C4), c3 && c3.addEventListener("abort", b3);
33691
33527
  }, M = () => {
33692
- process.removeListener("uncaughtExceptionMonitor", S4), process.removeListener("unhandledRejection", S4), process.removeListener("SIGINT", b3), process.removeListener("SIGTERM", b3), process.removeListener("exit", C4), c3 && c3.removeEventListener("abort", b3);
33693
- }, N4 = () => {
33694
- if (I4 === undefined)
33528
+ process.removeListener("uncaughtExceptionMonitor", S3), process.removeListener("unhandledRejection", S3), process.removeListener("SIGINT", b3), process.removeListener("SIGTERM", b3), process.removeListener("exit", C4), c3 && c3.removeEventListener("abort", b3);
33529
+ }, N3 = () => {
33530
+ if (I3 === undefined)
33695
33531
  return;
33696
33532
  l2 && s2.write(`
33697
33533
  `);
33698
- const _3 = wrapAnsi(I4, y3, { hard: true, trim: false }).split(`
33534
+ const _3 = wrapAnsi(I3, y3, { hard: true, trim: false }).split(`
33699
33535
  `);
33700
33536
  _3.length > 1 && s2.write(import_sisteransi2.cursor.up(_3.length - 1)), s2.write(import_sisteransi2.cursor.to(0)), s2.write(import_sisteransi2.erase.down());
33701
33537
  }, O4 = (_3) => _3.replace(/\.+$/, ""), j2 = (_3) => {
33702
33538
  const A4 = (performance.now() - _3) / 1000, L4 = Math.floor(A4 / 60), D3 = Math.floor(A4 % 60);
33703
33539
  return L4 > 0 ? `[${L4}m ${D3}s]` : `[${D3}s]`;
33704
33540
  }, k3 = o3.withGuide ?? h2.withGuide, rt2 = (_3 = "") => {
33705
- p2 = true, d2 = W2({ output: s2 }), h3 = O4(_3), m3 = performance.now(), k3 && s2.write(`${e2("gray", $2)}
33541
+ p2 = true, d2 = W2({ output: s2 }), h3 = O4(_3), m3 = performance.now(), k3 && s2.write(`${e2("gray", $)}
33706
33542
  `);
33707
33543
  let A4 = 0, L4 = 0;
33708
33544
  G4(), g3 = setInterval(() => {
33709
- if (l2 && h3 === I4)
33545
+ if (l2 && h3 === I3)
33710
33546
  return;
33711
- N4(), I4 = h3;
33547
+ N3(), I3 = h3;
33712
33548
  const D3 = v3(n2[A4]);
33713
33549
  let Z2;
33714
33550
  if (l2)
@@ -33725,8 +33561,8 @@ var vt = ({ indicator: t2 = "dots", onCancel: i2, output: s2 = process.stdout, c
33725
33561
  }, W3 = (_3 = "", A4 = 0, L4 = false) => {
33726
33562
  if (!p2)
33727
33563
  return;
33728
- p2 = false, clearInterval(g3), N4();
33729
- const D3 = A4 === 0 ? e2("green", H2) : A4 === 1 ? e2("red", ut2) : e2("red", lt2);
33564
+ p2 = false, clearInterval(g3), N3();
33565
+ const D3 = A4 === 0 ? e2("green", H) : A4 === 1 ? e2("red", ut2) : e2("red", lt2);
33730
33566
  h3 = _3 ?? h3, L4 || (t2 === "timer" ? s2.write(`${D3} ${h3} ${j2(m3)}
33731
33567
  `) : s2.write(`${D3} ${h3}
33732
33568
  `)), M(), d2();
@@ -33747,7 +33583,7 @@ var Ee = (t2) => {
33747
33583
  const u3 = s2.label ?? String(s2.value);
33748
33584
  switch (r3) {
33749
33585
  case "disabled":
33750
- return `${e2("gray", U2)} ${it2(u3, (n2) => e2("gray", n2))}${s2.hint ? ` ${e2("dim", `(${s2.hint ?? "disabled"})`)}` : ""}`;
33586
+ return `${e2("gray", U)} ${it2(u3, (n2) => e2("gray", n2))}${s2.hint ? ` ${e2("dim", `(${s2.hint ?? "disabled"})`)}` : ""}`;
33751
33587
  case "selected":
33752
33588
  return `${it2(u3, (n2) => e2("dim", n2))}`;
33753
33589
  case "active":
@@ -33755,27 +33591,27 @@ var Ee = (t2) => {
33755
33591
  case "cancelled":
33756
33592
  return `${it2(u3, (n2) => e2(["strikethrough", "dim"], n2))}`;
33757
33593
  default:
33758
- return `${e2("dim", U2)} ${it2(u3, (n2) => e2("dim", n2))}`;
33594
+ return `${e2("dim", U)} ${it2(u3, (n2) => e2("dim", n2))}`;
33759
33595
  }
33760
33596
  };
33761
33597
  return new ht({ options: t2.options, signal: t2.signal, input: t2.input, output: t2.output, initialValue: t2.initialValue, render() {
33762
- const s2 = t2.withGuide ?? h2.withGuide, r3 = `${P4(this.state)} `, u3 = `${ft(this.state)} `, n2 = B2(t2.output, t2.message, u3, r3), a2 = `${s2 ? `${e2("gray", $2)}
33598
+ const s2 = t2.withGuide ?? h2.withGuide, r3 = `${P4(this.state)} `, u3 = `${ft(this.state)} `, n2 = B2(t2.output, t2.message, u3, r3), a2 = `${s2 ? `${e2("gray", $)}
33763
33599
  ` : ""}${n2}
33764
33600
  `;
33765
33601
  switch (this.state) {
33766
33602
  case "submit": {
33767
- const c3 = s2 ? `${e2("gray", $2)} ` : "", o3 = B2(t2.output, i2(this.options[this.cursor], "selected"), c3);
33603
+ const c3 = s2 ? `${e2("gray", $)} ` : "", o3 = B2(t2.output, i2(this.options[this.cursor], "selected"), c3);
33768
33604
  return `${a2}${o3}`;
33769
33605
  }
33770
33606
  case "cancel": {
33771
- const c3 = s2 ? `${e2("gray", $2)} ` : "", o3 = B2(t2.output, i2(this.options[this.cursor], "cancelled"), c3);
33607
+ const c3 = s2 ? `${e2("gray", $)} ` : "", o3 = B2(t2.output, i2(this.options[this.cursor], "cancelled"), c3);
33772
33608
  return `${a2}${o3}${s2 ? `
33773
- ${e2("gray", $2)}` : ""}`;
33609
+ ${e2("gray", $)}` : ""}`;
33774
33610
  }
33775
33611
  default: {
33776
- const c3 = s2 ? `${e2("cyan", $2)} ` : "", o3 = s2 ? e2("cyan", x3) : "", l2 = a2.split(`
33612
+ const c3 = s2 ? `${e2("cyan", $)} ` : "", o3 = s2 ? e2("cyan", x3) : "", l2 = a2.split(`
33777
33613
  `).length, d2 = s2 ? 2 : 1;
33778
- return `${a2}${c3}${F4({ output: t2.output, cursor: this.cursor, options: this.options, maxItems: t2.maxItems, columnPadding: c3.length, rowPadding: l2 + d2, style: (g3, p2) => i2(g3, g3.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
33614
+ return `${a2}${c3}${F3({ output: t2.output, cursor: this.cursor, options: this.options, maxItems: t2.maxItems, columnPadding: c3.length, rowPadding: l2 + d2, style: (g3, p2) => i2(g3, g3.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
33779
33615
  ${c3}`)}
33780
33616
  ${o3}
33781
33617
  `;
@@ -33783,30 +33619,30 @@ ${o3}
33783
33619
  }
33784
33620
  } }).prompt();
33785
33621
  };
33786
- var Bt = `${e2("gray", $2)} `;
33622
+ var Bt = `${e2("gray", $)} `;
33787
33623
  var Re = (t2) => new ct({ validate: t2.validate, placeholder: t2.placeholder, defaultValue: t2.defaultValue, initialValue: t2.initialValue, output: t2.output, signal: t2.signal, input: t2.input, render() {
33788
- const i2 = t2?.withGuide ?? h2.withGuide, s2 = `${`${i2 ? `${e2("gray", $2)}
33624
+ const i2 = t2?.withGuide ?? h2.withGuide, s2 = `${`${i2 ? `${e2("gray", $)}
33789
33625
  ` : ""}${P4(this.state)} `}${t2.message}
33790
33626
  `, r3 = t2.placeholder ? e2("inverse", t2.placeholder[0]) + e2("dim", t2.placeholder.slice(1)) : e2(["inverse", "hidden"], "_"), u3 = this.userInput ? this.userInputWithCursor : r3, n2 = this.value ?? "";
33791
33627
  switch (this.state) {
33792
33628
  case "error": {
33793
- const a2 = this.error ? ` ${e2("yellow", this.error)}` : "", c3 = i2 ? `${e2("yellow", $2)} ` : "", o3 = i2 ? e2("yellow", x3) : "";
33629
+ const a2 = this.error ? ` ${e2("yellow", this.error)}` : "", c3 = i2 ? `${e2("yellow", $)} ` : "", o3 = i2 ? e2("yellow", x3) : "";
33794
33630
  return `${s2.trim()}
33795
33631
  ${c3}${u3}
33796
33632
  ${o3}${a2}
33797
33633
  `;
33798
33634
  }
33799
33635
  case "submit": {
33800
- const a2 = n2 ? ` ${e2("dim", n2)}` : "", c3 = i2 ? e2("gray", $2) : "";
33636
+ const a2 = n2 ? ` ${e2("dim", n2)}` : "", c3 = i2 ? e2("gray", $) : "";
33801
33637
  return `${s2}${c3}${a2}`;
33802
33638
  }
33803
33639
  case "cancel": {
33804
- const a2 = n2 ? ` ${e2(["strikethrough", "dim"], n2)}` : "", c3 = i2 ? e2("gray", $2) : "";
33640
+ const a2 = n2 ? ` ${e2(["strikethrough", "dim"], n2)}` : "", c3 = i2 ? e2("gray", $) : "";
33805
33641
  return `${s2}${c3}${a2}${n2.trim() ? `
33806
33642
  ${c3}` : ""}`;
33807
33643
  }
33808
33644
  default: {
33809
- const a2 = i2 ? `${e2("cyan", $2)} ` : "", c3 = i2 ? e2("cyan", x3) : "";
33645
+ const a2 = i2 ? `${e2("cyan", $)} ` : "", c3 = i2 ? e2("cyan", x3) : "";
33810
33646
  return `${s2}${a2}${u3}
33811
33647
  ${c3}
33812
33648
  `;
@@ -36229,7 +36065,399 @@ var config_default = defineCommand({
36229
36065
  })
36230
36066
  });
36231
36067
 
36068
+ // src/core/audit.ts
36069
+ init_crdt();
36070
+ init_errors();
36071
+ function isMetaCol(dataset, col) {
36072
+ if (dataset === "records")
36073
+ return RECORD_META.has(col);
36074
+ return col === "created_hlc" || col === "__deleted";
36075
+ }
36076
+ function oplogExclude() {
36077
+ return {
36078
+ sql: [...OPLOG_ONLY_DATASETS].map(() => "dataset != ?"),
36079
+ params: [...OPLOG_ONLY_DATASETS]
36080
+ };
36081
+ }
36082
+ function changesOfTxn(db, txn, beforeHlc) {
36083
+ const ex = oplogExclude();
36084
+ const wheres = ["txn = ?", ...ex.sql];
36085
+ const params = [txn, ...ex.params];
36086
+ if (beforeHlc) {
36087
+ wheres.push("hlc < ?");
36088
+ params.push(beforeHlc);
36089
+ }
36090
+ return db.query(`SELECT ${CHANGE_SELECT} FROM crdt_changes WHERE ${wheres.join(" AND ")} ORDER BY hlc`).all(...params);
36091
+ }
36092
+ function databaseName(db, id, c3) {
36093
+ if (!id)
36094
+ return null;
36095
+ if (!c3.dbNames.has(id)) {
36096
+ const row = db.query("SELECT name FROM databases WHERE id = ?").get(id);
36097
+ c3.dbNames.set(id, row?.name ?? null);
36098
+ }
36099
+ return c3.dbNames.get(id);
36100
+ }
36101
+ function titlePropOf(db, databaseId, c3) {
36102
+ if (!c3.titleProps.has(databaseId)) {
36103
+ const row = db.query("SELECT id FROM properties WHERE database_id = ? AND type = 'text' AND __deleted = 0 ORDER BY position LIMIT 1").get(databaseId);
36104
+ c3.titleProps.set(databaseId, row?.id ?? null);
36105
+ }
36106
+ return c3.titleProps.get(databaseId) ?? null;
36107
+ }
36108
+ function resolveEntity2(db, dataset, id, c3) {
36109
+ if (dataset === "records") {
36110
+ const row = db.query("SELECT database_id, data FROM records WHERE id = ?").get(id);
36111
+ if (!row)
36112
+ return { label: null, database_id: null };
36113
+ const titleProp = row.database_id ? titlePropOf(db, row.database_id, c3) : null;
36114
+ const data = JSON.parse(row.data || "{}");
36115
+ const label = titleProp && data[titleProp] != null ? String(data[titleProp]) : null;
36116
+ return { label, database_id: row.database_id };
36117
+ }
36118
+ if (dataset === "documents") {
36119
+ const row = db.query("SELECT title, database_id FROM documents WHERE id = ?").get(id);
36120
+ return { label: row?.title ?? null, database_id: row?.database_id ?? null };
36121
+ }
36122
+ if (dataset === "properties") {
36123
+ const row = db.query("SELECT name, database_id FROM properties WHERE id = ?").get(id);
36124
+ return { label: row?.name ?? null, database_id: row?.database_id ?? null };
36125
+ }
36126
+ if (dataset === "databases") {
36127
+ return { label: databaseName(db, id, c3), database_id: id };
36128
+ }
36129
+ if (dataset === "sites") {
36130
+ const row = db.query("SELECT title, name FROM sites WHERE id = ?").get(id);
36131
+ return { label: row?.title ?? row?.name ?? null, database_id: null };
36132
+ }
36133
+ return { label: null, database_id: null };
36134
+ }
36135
+ function blockDocId(db, group, blockId) {
36136
+ for (const ch of group) {
36137
+ if (ch.dataset === "doc_blocks" && ch.row_id === blockId && ch.col === "doc_id" && ch.value)
36138
+ return JSON.parse(ch.value);
36139
+ }
36140
+ const head = db.query("SELECT doc_id FROM doc_blocks WHERE id = ?").get(blockId);
36141
+ if (head?.doc_id)
36142
+ return head.doc_id;
36143
+ const past = db.query("SELECT value FROM crdt_changes WHERE dataset = 'doc_blocks' AND row_id = ? AND col = 'doc_id' AND value IS NOT NULL ORDER BY hlc DESC LIMIT 1").get(blockId);
36144
+ return past ? JSON.parse(past.value) : null;
36145
+ }
36146
+ function entryOf(db, group, c3) {
36147
+ const accs = new Map;
36148
+ const acc = (dataset, id) => {
36149
+ const key = dataset + "\x00" + id;
36150
+ let a2 = accs.get(key);
36151
+ if (!a2) {
36152
+ a2 = {
36153
+ dataset,
36154
+ id,
36155
+ created: false,
36156
+ deleted: false,
36157
+ fields: new Set,
36158
+ blocksChanged: new Set,
36159
+ blocksDeleted: new Set
36160
+ };
36161
+ accs.set(key, a2);
36162
+ }
36163
+ return a2;
36164
+ };
36165
+ for (const ch of group) {
36166
+ if (ch.dataset === "doc_blocks") {
36167
+ const docId2 = blockDocId(db, group, ch.row_id);
36168
+ const a3 = docId2 ? acc("documents", docId2) : acc("doc_blocks", ch.row_id);
36169
+ if (ch.col === "__deleted" && flagSet(ch.value))
36170
+ a3.blocksDeleted.add(ch.row_id);
36171
+ else
36172
+ a3.blocksChanged.add(ch.row_id);
36173
+ continue;
36174
+ }
36175
+ const a2 = acc(ch.dataset, ch.row_id);
36176
+ if (ch.col === "created_hlc" || ch.dataset === "properties" && ch.col === "database_id")
36177
+ a2.created = true;
36178
+ else if (ch.col === "__deleted")
36179
+ a2.deleted = flagSet(ch.value);
36180
+ if (!isMetaCol(ch.dataset, ch.col))
36181
+ a2.fields.add(ch.col);
36182
+ }
36183
+ const entities = [...accs.values()].map((a2) => {
36184
+ const { label, database_id } = resolveEntity2(db, a2.dataset, a2.id, c3);
36185
+ return {
36186
+ dataset: a2.dataset,
36187
+ id: a2.id,
36188
+ label,
36189
+ database_id,
36190
+ database_label: a2.dataset === "databases" ? null : databaseName(db, database_id, c3),
36191
+ created: a2.created,
36192
+ deleted: a2.deleted,
36193
+ fields: a2.fields.size,
36194
+ blocks_changed: [...a2.blocksChanged].filter((b3) => !a2.blocksDeleted.has(b3)).length,
36195
+ blocks_deleted: a2.blocksDeleted.size
36196
+ };
36197
+ });
36198
+ const last = group[group.length - 1];
36199
+ const { actor, kind } = parseTxn(last.txn);
36200
+ return {
36201
+ version: last.hlc,
36202
+ at: hlcIso(last.hlc),
36203
+ node_id: last.node_id,
36204
+ kind,
36205
+ actor,
36206
+ txn: last.txn,
36207
+ changes: group.length,
36208
+ entities
36209
+ };
36210
+ }
36211
+ function listAuditEntries(db, opts = {}) {
36212
+ const limit = Math.max(1, Math.min(opts.limit ?? 50, 200));
36213
+ if (opts.actor !== undefined && !ACTOR_TAG_RE.test(opts.actor))
36214
+ throw new MhError("invalid_input", `invalid actor tag: ${opts.actor}`);
36215
+ const chunk = Math.min(Math.max(limit * 40, 800), 8000);
36216
+ const ex = oplogExclude();
36217
+ const wheres = [...ex.sql];
36218
+ const params = [...ex.params];
36219
+ if (opts.before) {
36220
+ wheres.push("hlc < ?");
36221
+ params.push(opts.before);
36222
+ }
36223
+ if (opts.actor !== undefined) {
36224
+ wheres.push("txn >= ?", "txn < ?");
36225
+ params.push(opts.actor + "/", opts.actor + "0");
36226
+ }
36227
+ const rows = db.query(`SELECT ${CHANGE_SELECT} FROM crdt_changes
36228
+ ${wheres.length ? "WHERE " + wheres.join(" AND ") : ""}
36229
+ ORDER BY hlc DESC LIMIT ?`).all(...params, chunk);
36230
+ const exhausted = rows.length < chunk;
36231
+ rows.reverse();
36232
+ let groups = clusterRevisions(rows);
36233
+ if (!exhausted && groups.length > 0) {
36234
+ const txn = groups[0][0].txn;
36235
+ if (txn !== null)
36236
+ groups[0] = changesOfTxn(db, txn, opts.before);
36237
+ else if (groups.length > 1)
36238
+ groups = groups.slice(1);
36239
+ }
36240
+ const caches = { dbNames: new Map, titleProps: new Map };
36241
+ const newestFirst = groups.reverse();
36242
+ const kept = newestFirst.slice(0, limit);
36243
+ const entries = kept.map((g3) => entryOf(db, g3, caches));
36244
+ const more = !exhausted || newestFirst.length > limit;
36245
+ const next = more && kept.length ? kept[kept.length - 1][0].hlc : null;
36246
+ return { entries, next };
36247
+ }
36248
+ function valueBefore(db, dataset, rowId, col, hlc) {
36249
+ return db.query("SELECT value FROM crdt_changes WHERE dataset = ? AND row_id = ? AND col = ? AND hlc < ? ORDER BY hlc DESC LIMIT 1").get(dataset, rowId, col, hlc) ?? undefined;
36250
+ }
36251
+ function colLabel(db, dataset, col) {
36252
+ if (dataset !== "records")
36253
+ return col;
36254
+ const row = db.query("SELECT name FROM properties WHERE id = ?").get(col);
36255
+ return row?.name ?? col;
36256
+ }
36257
+ function auditEntryDetail(db, txn) {
36258
+ const group = changesOfTxn(db, txn);
36259
+ if (!group.length)
36260
+ throw new MhError("not_found", `no change group: ${txn}`);
36261
+ const caches = { dbNames: new Map, titleProps: new Map };
36262
+ const entry = entryOf(db, group, caches);
36263
+ const first = new Map;
36264
+ const lastWrite = new Map;
36265
+ for (const ch of group) {
36266
+ const key = ch.dataset + "\x00" + ch.row_id + "\x00" + ch.col;
36267
+ if (!first.has(key))
36268
+ first.set(key, ch);
36269
+ lastWrite.set(key, ch);
36270
+ }
36271
+ const entities = entry.entities.map((e3) => ({
36272
+ ...e3,
36273
+ diffs: [],
36274
+ block_diffs: []
36275
+ }));
36276
+ const byKey = new Map(entities.map((e3) => [e3.dataset + "\x00" + e3.id, e3]));
36277
+ for (const [key, ch] of lastWrite) {
36278
+ const f4 = first.get(key);
36279
+ const diff = (label) => {
36280
+ const out = { col: ch.dataset === "doc_blocks" ? ch.row_id : ch.col, label };
36281
+ const prev = valueBefore(db, ch.dataset, ch.row_id, ch.col, f4.hlc);
36282
+ if (prev && prev.value !== null)
36283
+ out.before = JSON.parse(prev.value);
36284
+ if (ch.value !== null)
36285
+ out.after = JSON.parse(ch.value);
36286
+ return out;
36287
+ };
36288
+ if (ch.dataset === "doc_blocks") {
36289
+ if (ch.col !== "text")
36290
+ continue;
36291
+ const docId2 = blockDocId(db, group, ch.row_id);
36292
+ const ent = byKey.get(docId2 ? "documents\x00" + docId2 : "doc_blocks\x00" + ch.row_id);
36293
+ ent?.block_diffs.push(diff("block"));
36294
+ continue;
36295
+ }
36296
+ if (isMetaCol(ch.dataset, ch.col))
36297
+ continue;
36298
+ byKey.get(ch.dataset + "\x00" + ch.row_id)?.diffs.push(diff(colLabel(db, ch.dataset, ch.col)));
36299
+ }
36300
+ return { ...entry, entities };
36301
+ }
36302
+ var revertChangeGroup = grouped(function revertChangeGroup2(db, txn) {
36303
+ const group = changesOfTxn(db, txn);
36304
+ if (!group.length)
36305
+ throw new MhError("not_found", `no change group: ${txn}`);
36306
+ const byRow = new Map;
36307
+ for (const ch of group) {
36308
+ const key = ch.dataset + "\x00" + ch.row_id;
36309
+ let list7 = byRow.get(key);
36310
+ if (!list7)
36311
+ byRow.set(key, list7 = []);
36312
+ list7.push(ch);
36313
+ }
36314
+ let restored = 0;
36315
+ let skippedRegisters = 0;
36316
+ let removedRows = 0;
36317
+ let skippedRows = 0;
36318
+ for (const rowChanges2 of byRow.values()) {
36319
+ const { dataset, row_id } = rowChanges2[0];
36320
+ const earliest = rowChanges2[0].hlc;
36321
+ const preexisting = db.query("SELECT 1 AS x FROM crdt_changes WHERE dataset = ? AND row_id = ? AND hlc < ? LIMIT 1").get(dataset, row_id, earliest);
36322
+ if (!preexisting) {
36323
+ const foreign = db.query("SELECT 1 AS x FROM crdt_changes WHERE dataset = ? AND row_id = ? AND txn IS NOT ? LIMIT 1").get(dataset, row_id, txn);
36324
+ if (foreign) {
36325
+ skippedRows++;
36326
+ continue;
36327
+ }
36328
+ const lastDeleted = [...rowChanges2].reverse().find((c3) => c3.col === "__deleted");
36329
+ if (lastDeleted && flagSet(lastDeleted.value))
36330
+ continue;
36331
+ emit(db, dataset, row_id, "__deleted", 1);
36332
+ removedRows++;
36333
+ continue;
36334
+ }
36335
+ const firstWrite = new Map;
36336
+ for (const ch of rowChanges2)
36337
+ if (!firstWrite.has(ch.col))
36338
+ firstWrite.set(ch.col, ch);
36339
+ for (const [col, f4] of firstWrite) {
36340
+ const winner = db.query("SELECT value, txn FROM crdt_changes WHERE dataset = ? AND row_id = ? AND col = ? ORDER BY hlc DESC LIMIT 1").get(dataset, row_id, col);
36341
+ if (winner.txn !== txn) {
36342
+ skippedRegisters++;
36343
+ continue;
36344
+ }
36345
+ const prev = valueBefore(db, dataset, row_id, col, f4.hlc);
36346
+ const target = prev === undefined ? col === "__deleted" ? 0 : undefined : prev.value === null ? undefined : JSON.parse(prev.value);
36347
+ const targetJson = target === undefined ? null : JSON.stringify(target);
36348
+ if (targetJson === winner.value)
36349
+ continue;
36350
+ emit(db, dataset, row_id, col, target);
36351
+ restored++;
36352
+ }
36353
+ }
36354
+ return {
36355
+ txn,
36356
+ changed: restored > 0 || removedRows > 0,
36357
+ restored_registers: restored,
36358
+ skipped_registers: skippedRegisters,
36359
+ removed_rows: removedRows,
36360
+ skipped_rows: skippedRows
36361
+ };
36362
+ }, "revert");
36363
+
36364
+ // src/cli/commands/audit.ts
36365
+ function summarize(e3) {
36366
+ const parts = e3.entities.map((ent) => {
36367
+ const what = ent.dataset === "records" ? "record" : ent.dataset === "documents" ? "doc" : ent.dataset === "properties" ? "prop" : ent.dataset === "databases" ? "db" : ent.dataset;
36368
+ const verb = ent.created ? "+" : ent.deleted ? "-" : "~";
36369
+ return `${verb}${what} ${ent.label ?? ent.id}`;
36370
+ });
36371
+ return parts.slice(0, 3).join(", ") + (parts.length > 3 ? ` (+${parts.length - 3} more)` : "");
36372
+ }
36373
+ var show = defineCommand({
36374
+ meta: {
36375
+ name: "show",
36376
+ description: "Expand one audit entry: per-field before/after values"
36377
+ },
36378
+ args: {
36379
+ txn: { type: "positional", description: "Change-group id (from `mh audit`)", required: true }
36380
+ },
36381
+ run: guard((args) => {
36382
+ const db = openMetahub();
36383
+ const d2 = auditEntryDetail(db, args.txn);
36384
+ print(d2, () => {
36385
+ const lines = [`${d2.at} ${d2.actor ?? d2.node_id} ${d2.kind} txn=${d2.txn}`];
36386
+ for (const ent of d2.entities) {
36387
+ lines.push(` ${ent.dataset} ${ent.label ?? ent.id}${ent.created ? " (created)" : ent.deleted ? " (deleted)" : ""}`);
36388
+ for (const f4 of ent.diffs)
36389
+ lines.push(` ${f4.label}: ${JSON.stringify(f4.before)} -> ${JSON.stringify(f4.after)}`);
36390
+ for (const b3 of ent.block_diffs)
36391
+ lines.push(` block: ${JSON.stringify(b3.before)} -> ${JSON.stringify(b3.after)}`);
36392
+ }
36393
+ return lines.join(`
36394
+ `);
36395
+ });
36396
+ })
36397
+ });
36398
+ var revert4 = defineCommand({
36399
+ meta: {
36400
+ name: "revert",
36401
+ description: "Undo one change group as a new forward revision. Registers overwritten " + "since are kept (reported as skipped); the revert itself is revertible."
36402
+ },
36403
+ args: {
36404
+ txn: { type: "positional", description: "Change-group id (from `mh audit`)", required: true }
36405
+ },
36406
+ run: guard((args) => {
36407
+ const db = openMetahub();
36408
+ const r3 = revertChangeGroup(db, args.txn);
36409
+ print(r3, () => [
36410
+ `restored ${r3.restored_registers} register(s), removed ${r3.removed_rows} created row(s)`,
36411
+ r3.skipped_registers || r3.skipped_rows ? `kept ${r3.skipped_registers} register(s) / ${r3.skipped_rows} row(s) with later edits` : null,
36412
+ r3.changed ? null : "nothing to revert (already converged)"
36413
+ ].filter(Boolean).join(`
36414
+ `));
36415
+ })
36416
+ });
36417
+ var runList = guard((args) => {
36418
+ const db = openMetahub();
36419
+ const page = listAuditEntries(db, {
36420
+ limit: args.limit != null ? Number(args.limit) : undefined,
36421
+ actor: args.actor,
36422
+ before: args.before
36423
+ });
36424
+ print(page, () => {
36425
+ const rows = page.entries.map((e3) => ({
36426
+ at: e3.at.replace("T", " ").slice(0, 19),
36427
+ actor: e3.actor ?? "-",
36428
+ kind: e3.kind,
36429
+ summary: summarize(e3),
36430
+ txn: e3.txn ?? "(legacy)"
36431
+ }));
36432
+ const out = table(rows);
36433
+ return page.next ? out + `
36434
+ more: mh audit list --before ${page.next}` : out;
36435
+ });
36436
+ });
36437
+ var LIST_ARGS = {
36438
+ limit: { type: "string", description: "Max entries (default 50)" },
36439
+ actor: { type: "string", description: "Only entries by this actor tag (e.g. ai)" },
36440
+ before: { type: "string", description: "Page older entries (the `next` cursor)" }
36441
+ };
36442
+ var list7 = defineCommand({
36443
+ meta: { name: "list", description: "List audit entries (the default subcommand)" },
36444
+ args: LIST_ARGS,
36445
+ run: (ctx) => runList(ctx)
36446
+ });
36447
+ var audit_default = defineCommand({
36448
+ meta: {
36449
+ name: "audit",
36450
+ description: "The global change feed: every edit across the whole hub, newest first, " + "grouped into logical changes with their actor (e.g. agent-driven CLI " + "writes are tagged 'ai'). Depth is bounded by the compaction window."
36451
+ },
36452
+ subCommands: { list: list7, show, revert: revert4 },
36453
+ run: (ctx) => {
36454
+ if (Object.keys(ctx.args).filter((k3) => k3 !== "_").length === 0 && ctx.args._.length === 0)
36455
+ return runList(ctx);
36456
+ }
36457
+ });
36458
+
36232
36459
  // src/cli/index.ts
36460
+ init_crdt();
36233
36461
  init_token();
36234
36462
 
36235
36463
  // src/core/sync/server.ts
@@ -36312,7 +36540,9 @@ function scalarHtml(specUrl) {
36312
36540
  }
36313
36541
  function startServer(opts = {}) {
36314
36542
  registerRoomBlobResolver(resolveBlob);
36543
+ const tDb = Date.now();
36315
36544
  const db = openMetahub();
36545
+ const dbMs = Date.now() - tDb;
36316
36546
  const node = getNodeId(db);
36317
36547
  const ctx = {
36318
36548
  db,
@@ -36338,6 +36568,7 @@ function startServer(opts = {}) {
36338
36568
  graceMs: DEFAULT_GRACE_MS
36339
36569
  };
36340
36570
  let server;
36571
+ const tServe = Date.now();
36341
36572
  try {
36342
36573
  server = Bun.serve({
36343
36574
  port,
@@ -36419,17 +36650,20 @@ function startServer(opts = {}) {
36419
36650
  }
36420
36651
  throw e3;
36421
36652
  }
36653
+ if (opts.debug) {
36654
+ console.log(`[perf] openMetahub ${dbMs}ms, Bun.serve ${Date.now() - tServe}ms`);
36655
+ }
36422
36656
  let timer = null;
36423
36657
  if (autoSync && syncIntervalMs > 0) {
36424
36658
  const IDLE_BACKOFF_MAX_MS = 150000;
36425
36659
  const idleNext = new Map;
36426
36660
  const dueNow = (key, advanced, now) => {
36427
- const st3 = idleNext.get(key);
36428
- return advanced || !st3 || now >= st3.due;
36661
+ const st2 = idleNext.get(key);
36662
+ return advanced || !st2 || now >= st2.due;
36429
36663
  };
36430
36664
  const recordRound = (key, busy, baseMs) => {
36431
- const st3 = idleNext.get(key);
36432
- const delay = busy ? baseMs : Math.min((st3?.delay ?? baseMs) * 2, IDLE_BACKOFF_MAX_MS);
36665
+ const st2 = idleNext.get(key);
36666
+ const delay = busy ? baseMs : Math.min((st2?.delay ?? baseMs) * 2, IDLE_BACKOFF_MAX_MS);
36433
36667
  idleNext.set(key, { delay, due: Date.now() + delay });
36434
36668
  };
36435
36669
  let lastMaxSeq = -1;
@@ -36837,6 +37071,43 @@ var styles_default = ` :root {
36837
37071
  color:var(--danger); margin:0 0 4px 2px; }
36838
37072
  .set-callout { padding:9px 11px; border-radius:var(--radius-sm); background:var(--surface);
36839
37073
  border:1px solid var(--line); color:var(--fg-soft); font-size:var(--fs-xs); line-height:1.55; }
37074
+ /* ---- \u64CD\u4F5C\u5BA1\u8BA1 (settings/audit-page.tsx): the global change feed ---- */
37075
+ .audit-filters { display:flex; gap:6px; margin:2px 0 14px; flex-wrap:wrap; }
37076
+ .audit-chip { display:inline-flex; align-items:center; gap:6px; padding:4px 12px; border-radius:999px;
37077
+ border:1px solid var(--line); background:none; color:var(--fg-soft); font-size:var(--fs-sm); cursor:pointer; }
37078
+ .audit-chip:hover { background:var(--hover); }
37079
+ .audit-chip.on { background:var(--accent-soft); border-color:transparent; color:var(--accent); font-weight:600; }
37080
+ .audit-chip-dot { width:7px; height:7px; border-radius:50%; background:var(--accent); flex:none; }
37081
+ .audit-group-label { font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.07em;
37082
+ color:var(--muted); margin:18px 0 4px 2px; }
37083
+ .audit-group:first-child .audit-group-label { margin-top:0; }
37084
+ .audit-item { border-bottom:1px solid var(--line); border-radius:var(--radius-sm); }
37085
+ .audit-item:last-child { border-bottom:none; }
37086
+ /* the "AI just did this" cue \u2014 same pulse as the quickboard card flash */
37087
+ .audit-item.flash { animation:audit-flash 1.5s ease-out; }
37088
+ @keyframes audit-flash { 0% { background:var(--accent-soft); } 100% { background:none; } }
37089
+ .audit-item-line { display:flex; align-items:center; gap:8px; padding:9px 4px; cursor:pointer; min-width:0; }
37090
+ .audit-item-line:hover { background:var(--hover); }
37091
+ .audit-when { font-size:var(--fs-sm); color:var(--muted); flex:none; width:74px; }
37092
+ .audit-actor { flex:none; font-size:11px; font-weight:600; padding:1px 7px; border-radius:999px;
37093
+ background:var(--surface); border:1px solid var(--line); color:var(--fg-soft); max-width:110px;
37094
+ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
37095
+ .audit-actor.ai { background:color-mix(in srgb, #8b5cf6 14%, transparent);
37096
+ border-color:color-mix(in srgb, #8b5cf6 35%, transparent); color:#8b5cf6; }
37097
+ .audit-summary { font-size:var(--fs-ui); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
37098
+ .audit-ent { color:inherit; font-weight:600; text-decoration:none; margin-left:2px; }
37099
+ .audit-ent[href]:hover { color:var(--accent); text-decoration:underline; }
37100
+ .audit-dbname { color:var(--muted); font-weight:400; }
37101
+ .audit-spacer { flex:1; }
37102
+ .audit-revert { flex:none; gap:4px; font-size:var(--fs-sm); opacity:0; }
37103
+ .audit-item-line:hover .audit-revert, .audit-revert:disabled { opacity:1; }
37104
+ .audit-caret { flex:none; color:var(--muted); }
37105
+ .audit-detail { padding:0 4px 10px 86px; }
37106
+ .audit-detail-ent-name { font-size:var(--fs-sm); font-weight:600; margin-top:6px; }
37107
+ .audit-blocks { font-size:var(--fs-sm); margin-top:2px; }
37108
+ .audit-more { display:block; margin:14px auto 0; }
37109
+ .audit-foot { font-size:var(--fs-xs); margin-top:18px; line-height:1.6; }
37110
+ @media (hover:none) { .audit-revert { opacity:1; } }
36840
37111
  .set-callout.warn { border-color:color-mix(in srgb,var(--warning,#9a6700) 32%,var(--line)); }
36841
37112
  /* two-fact meta line under a block title (who publishes \xB7 where creds live) \u2014
36842
37113
  answers the questions hiding under "is this bucket for server or browser?" */
@@ -37027,6 +37298,10 @@ var styles_default = ` :root {
37027
37298
  .crumb-sep { flex:none; color:var(--muted); font-weight:400; }
37028
37299
  .iconbtn { width:30px; height:30px; display:grid; place-items:center; border-radius:var(--radius-sm); color:var(--fg-soft); transition:background .12s; }
37029
37300
  .iconbtn:hover { background:var(--hover-2); color:var(--fg); }
37301
+ /* Dead end of the history (topbar back/forward). pointer-events:none also
37302
+ kills the hover background and, on desktop-mac, lets the button revert to
37303
+ the topbar's drag region. */
37304
+ .iconbtn:disabled { opacity:.35; pointer-events:none; }
37030
37305
  /* Reserve the classic-scrollbar gutter up front: view width never changes
37031
37306
  when content grows past one screen \u2014 no jump / rewrap flicker. stable
37032
37307
  ONLY (never both-edges): a left-edge gutter desyncs Chromium's composited
@@ -37106,6 +37381,11 @@ var styles_default = ` :root {
37106
37381
  /* wide mode (\u22EF menu): lift the column cap; the 60px side padding stays as the
37107
37382
  reading gutter and keeps the fixed .doc-toc ticks off the text. */
37108
37383
  .doc.wide-mode { max-width:none; }
37384
+ /* embedded in the record peek drawer: full width, compact padding, a small
37385
+ tail instead of the main view's 36vh, and a smaller title (the row's
37386
+ properties above it are the primary content). Same idiom as .qn-body .doc. */
37387
+ .doc.doc-embed { max-width:none; margin:0; padding:4px 2px 12vh; }
37388
+ .doc.doc-embed .doc-title { font-size:22px; }
37109
37389
  /* floating table of contents: a column of indented tick marks in the right
37110
37390
  gutter that expands to a labelled list on hover (Notion / Vercel-docs style).
37111
37391
  Fixed to the viewport so it never disturbs the centred .doc column. */
@@ -37582,6 +37862,21 @@ var styles_default = ` :root {
37582
37862
  border-bottom:2px solid transparent; margin-bottom:-1px; transition:color .12s; }
37583
37863
  .view-tab.active { color:var(--fg); border-bottom-color:var(--accent); }
37584
37864
  .view-tab:hover { color:var(--fg); } .view-tab svg { width:14px; height:14px; }
37865
+ /* \u6D6E\u7A97\u770B\u677F (right end of the toolbar / board bar, desktop only): a quiet
37866
+ Notion-style secondary pill \u2014 visible as a feature entry, never louder
37867
+ than \u65B0\u5EFA. Hover lifts the pill and nudges the icon's top kanban card up
37868
+ (.i-card, SVG user units). */
37869
+ .popout-btn { display:inline-flex; align-items:center; justify-content:center;
37870
+ width:28px; height:28px;
37871
+ background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-sm);
37872
+ box-shadow:var(--shadow-sm); color:var(--fg-soft); transition:all .15s ease; }
37873
+ .popout-btn .ico { color:var(--muted); transition:color .15s; }
37874
+ .popout-btn:hover { border-color:var(--line-strong); box-shadow:var(--shadow-md);
37875
+ transform:translateY(-1px); color:var(--fg); }
37876
+ .popout-btn:hover .ico { color:var(--fg); }
37877
+ .popout-btn:active { transform:translateY(0); box-shadow:var(--shadow-sm); }
37878
+ .popout-btn .i-card { transition:transform .18s ease; }
37879
+ .popout-btn:hover .i-card { transform:translateY(-2px); }
37585
37880
  .toolbar { display:flex; align-items:center; gap:2px; padding:10px 0; }
37586
37881
  .toolbar .spacer { flex:1; }
37587
37882
  .tbtn { display:flex; align-items:center; gap:6px; padding:5px 9px; border-radius:var(--radius-sm); color:var(--fg-soft); font-size:13px; font-weight:500; }
@@ -37676,6 +37971,12 @@ var styles_default = ` :root {
37676
37971
  background:color-mix(in srgb,var(--c) 15%,transparent); color:var(--c); }
37677
37972
  /* data-resolved (not prefers-color-scheme): tracks a manual dark choice too. */
37678
37973
  :root[data-resolved="dark"] .chip { background:color-mix(in srgb,var(--c) 22%,transparent); color:color-mix(in srgb,var(--c) 75%,#fff); }
37974
+ /* relation chip: an <a> that jumps to the target record */
37975
+ a.chip.rel { text-decoration:none; cursor:pointer; }
37976
+ a.chip.rel:hover { background:color-mix(in srgb,var(--c) 26%,transparent); text-decoration:underline; text-decoration-style:dashed; text-underline-offset:2px; }
37977
+ /* doc chip whose target is deleted/unsynced: muted + dashed, same cue as the
37978
+ editor's .cm-doclink-missing pill */
37979
+ a.chip.rel.doc-missing { background:transparent; color:var(--muted); outline:1px dashed var(--line-strong); outline-offset:-1px; }
37679
37980
  .addrow { display:flex; align-items:center; gap:7px; padding:9px 12px; color:var(--muted); font-size:13px; cursor:pointer; border-top:1px solid var(--line); }
37680
37981
  .addrow:hover { background:var(--hover); color:var(--fg-soft); }
37681
37982
  .gridfoot { display:flex; gap:18px; color:var(--muted); font-size:12px; padding:8px 2px; }
@@ -37887,6 +38188,14 @@ var styles_default = ` :root {
37887
38188
  .proprow .v { flex:1; padding:7px 8px; border-radius:var(--radius-sm); cursor:text; min-height:33px; display:flex; flex-wrap:wrap; gap:3px; align-items:center; }
37888
38189
  .proprow .v:hover { background:var(--hover); }
37889
38190
  .peek-divider { height:1px; background:var(--line); margin:22px 0 18px; }
38191
+ /* linked-document tabs + embedded editor below the peek's property list */
38192
+ .peekdocs-tabs { display:flex; align-items:center; gap:4px; flex-wrap:wrap; margin-bottom:6px; }
38193
+ .peekdocs-tab { border:0; background:none; font:inherit; font-size:var(--fs-sm); font-weight:500; color:var(--muted);
38194
+ padding:5px 10px; border-radius:var(--radius-sm); cursor:pointer; max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
38195
+ .peekdocs-tab:hover { background:var(--hover); color:var(--fg-soft); }
38196
+ .peekdocs-tab.active { background:var(--surface-2); color:var(--fg); }
38197
+ .peekdocs-tab.missing { color:var(--muted); text-decoration:line-through; }
38198
+ .peekdocs-open { flex:none; }
37890
38199
 
37891
38200
  /* version history (doc drawer + record peek view) */
37892
38201
  .hist-peek { width:760px; }
@@ -38047,11 +38356,19 @@ var styles_default = ` :root {
38047
38356
  .pop input.field:focus { border-color:var(--accent); }
38048
38357
  /* select-cell picker: search/create input at the top of the popover */
38049
38358
  .pop .selsearch { display:flex; align-items:center; gap:7px; margin:2px 2px 6px; padding:6px 9px;
38050
- border:1px solid var(--line-strong); border-radius:var(--radius-sm); background:var(--surface); color:var(--muted); }
38051
- .pop .selsearch:focus-within { border-color:var(--accent); }
38359
+ border:1px solid var(--line-strong); border-radius:var(--radius-sm); background:var(--surface); color:var(--muted);
38360
+ transition:border-color .12s ease, box-shadow .12s ease, color .12s ease; }
38361
+ .pop .selsearch:focus-within { border-color:var(--accent); color:var(--accent);
38362
+ box-shadow:0 0 0 2.5px color-mix(in srgb, var(--accent) 16%, transparent); }
38052
38363
  .pop .selsearch input { flex:1; width:0; min-width:0; border:0; background:transparent; outline:none;
38053
38364
  font:inherit; font-size:var(--fs-ui); color:var(--fg); }
38054
38365
  .pop .selsearch input::placeholder { color:var(--muted); }
38366
+ .pop .selsearch .clear { display:grid; place-items:center; width:18px; height:18px; margin:-2px -3px -2px 0;
38367
+ border-radius:50%; color:var(--muted); flex:none; }
38368
+ .pop .selsearch .clear:hover { background:var(--hover-2); color:var(--fg); }
38369
+ /* relation record picker: fixed-height list \u2014 the popover is positioned once
38370
+ on open, so async-loaded rows must scroll instead of growing off-screen */
38371
+ .pop .rellist { max-height:264px; overflow-y:auto; }
38055
38372
  .optrow { display:flex; align-items:center; gap:6px; padding:3px 4px; }
38056
38373
  .optrow .chip { flex:1; }
38057
38374
  .optrow .grip { width:18px; height:22px; display:grid; place-items:center; color:var(--muted); cursor:grab; touch-action:none; flex:none; }
@@ -38260,9 +38577,17 @@ var styles_default = ` :root {
38260
38577
  .board-count { color:var(--muted); font-size:12px; font-weight:600; }
38261
38578
  .board-col-head .iconbtn.sm { width:24px; height:24px; }
38262
38579
  .board-col-body { display:flex; flex-direction:column; gap:7px; padding:0 8px 8px; overflow-y:auto; }
38263
- .kcard { background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-sm); padding:9px 10px; box-shadow:var(--shadow-sm);
38580
+ .kcard { position:relative; background:var(--bg); border:1px solid var(--line); border-radius:var(--radius-sm); padding:9px 10px; box-shadow:var(--shadow-sm);
38264
38581
  cursor:grab; display:flex; flex-direction:column; gap:5px; touch-action:none; transition:border-color .1s,box-shadow .1s; }
38265
38582
  .kcard:hover { border-color:var(--line-strong); }
38583
+ /* hover-only open button, top-right \u2014 same pattern as the grid's .rowactions */
38584
+ .kcard-actions { position:absolute; top:6px; right:6px; opacity:0; pointer-events:none; transition:opacity .1s; }
38585
+ .kcard:hover .kcard-actions { opacity:1; pointer-events:auto; }
38586
+ /* inline title editing: the same .kcard-title div made contentEditable, so a
38587
+ wrapped title keeps its line count; negative margin swallows the padding so
38588
+ the text doesn't shift on entering edit */
38589
+ .kcard-title[contenteditable] { outline:1.5px solid var(--accent); border-radius:4px;
38590
+ padding:2px 5px; margin:-2px -5px; background:var(--bg); cursor:text; }
38266
38591
  .kcard.drag-source { opacity:.4; }
38267
38592
  .kcard.dragging-ghost { position:fixed; left:0; top:0; z-index:120; pointer-events:none; cursor:grabbing;
38268
38593
  box-shadow:var(--shadow-lg); opacity:.95; transform:translate3d(-9999px,0,0); }
@@ -38497,6 +38822,7 @@ var styles_default = ` :root {
38497
38822
  @media (hover: none) {
38498
38823
  .code-tools { opacity:1; transform:none; pointer-events:auto; }
38499
38824
  .rowactions { opacity:1; pointer-events:auto; }
38825
+ .kcard-actions { opacity:1; pointer-events:auto; }
38500
38826
  .cal-add, .filerow .facts,
38501
38827
  .navitem .acts { opacity:1; }
38502
38828
  /* the pill handles survive on touch (focus-driven, not hover-driven), but
@@ -38571,25 +38897,137 @@ var styles_default = ` :root {
38571
38897
  border-color:var(--accent);
38572
38898
  background:var(--accent) center/10px no-repeat
38573
38899
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); }
38574
- /* Compact menus inside the quick-note window only (dropdown + slash command
38575
- share .pop/.item/.lico with the main app; scope under body.quicknote so the
38576
- main app keeps its roomier density). */
38577
- body.quicknote .pop { padding:5px; border-radius:9px; }
38578
- body.quicknote .pop .lbl { padding:4px 8px 2px; font-size:10px; }
38579
- body.quicknote .pop .item { padding:5px 9px; gap:8px; font-size:var(--fs-sm); }
38580
- body.quicknote .pop .item .t { font-size:var(--fs-sm); }
38581
- body.quicknote .pop .item .d { font-size:10.5px; }
38582
- body.quicknote .pop .item .lico { width:22px; height:22px; }
38583
- body.quicknote .pop .item .lico.plain { width:20px; height:20px; }
38584
- body.quicknote .pop .sep { margin:4px 4px; }
38585
-
38586
- /* Quick Notes shortcut capture (desktop only). */
38900
+ /* Compact menus inside the quick windows only (dropdown + slash command
38901
+ share .pop/.item/.lico with the main app; scope under the quick window
38902
+ body classes so the main app keeps its roomier density). */
38903
+ body.quicknote .pop, body.quickboard .pop { padding:5px; border-radius:9px; }
38904
+ body.quicknote .pop .lbl, body.quickboard .pop .lbl { padding:4px 8px 2px; font-size:10px; }
38905
+ body.quicknote .pop .item, body.quickboard .pop .item { padding:5px 9px; gap:8px; font-size:var(--fs-sm); }
38906
+ body.quicknote .pop .item .t, body.quickboard .pop .item .t { font-size:var(--fs-sm); }
38907
+ body.quicknote .pop .item .d, body.quickboard .pop .item .d { font-size:10.5px; }
38908
+ body.quicknote .pop .item .lico, body.quickboard .pop .item .lico { width:22px; height:22px; }
38909
+ body.quicknote .pop .item .lico.plain, body.quickboard .pop .item .lico.plain { width:20px; height:20px; }
38910
+ body.quicknote .pop .sep, body.quickboard .pop .sep { margin:4px 4px; }
38911
+ /* Search box inside quick-window popovers: compact glass field \u2014 translucent
38912
+ fill over the vibrancy pane instead of the app's opaque surface. */
38913
+ body.quicknote .pop .selsearch, body.quickboard .pop .selsearch { margin:1px 1px 5px; padding:5px 8px;
38914
+ border-radius:7px; background:color-mix(in srgb, var(--surface) 60%, transparent); }
38915
+ body.quicknote .pop .selsearch input, body.quickboard .pop .selsearch input { font-size:var(--fs-sm); }
38916
+
38917
+ /* Quick Board window (desktop, loaded at #board). Same shell idiom as the
38918
+ quick-note window above: transparent body so the macOS vibrancy shows,
38919
+ top bar = drag region with opted-out buttons, popups clamped below the
38920
+ bar. Design: a "desktop glass widget" \u2014 one pane of glass (no bar
38921
+ divider), option-colored column washes, and the live feed made visible
38922
+ (breathing dot; poke-touched cards pulse once). All scoped under
38923
+ body.quickboard; the main app's board is untouched. */
38924
+ body.quickboard { background:transparent; --pop-top-inset:44px; }
38925
+ html:has(body.quickboard) { background:transparent; }
38926
+ body.quickboard #app { display:block; width:100vw; height:100vh; height:100dvh; }
38927
+ .qb { display:flex; flex-direction:column; width:100%; height:100vh; height:100dvh; overflow:hidden;
38928
+ background:color-mix(in srgb, var(--bg) 20%, transparent); }
38929
+ .qb-bar { display:flex; align-items:center; gap:6px; padding:6px 10px;
38930
+ user-select:none; -webkit-app-region:drag; }
38931
+ body.desktop-mac .qb-bar { padding-left:76px; }
38932
+ /* The brand doubles as the database switcher \u2014 a Notion-style page-switcher
38933
+ chip (emoji + name + chevron); opts out of the drag region. */
38934
+ .qb-brand { display:inline-flex; align-items:center; gap:5px; min-width:0; max-width:60%;
38935
+ font-size:13px; font-weight:600; color:var(--fg);
38936
+ padding:3px 8px; border-radius:var(--radius-sm); -webkit-app-region:no-drag;
38937
+ transition:background .12s; }
38938
+ .qb-brand:hover { background:var(--hover-2); }
38939
+ .qb-brand .qb-emoji { font-size:14px; line-height:1; flex:none; }
38940
+ .qb-brand .qb-name { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
38941
+ .qb-brand svg { flex:none; color:var(--muted); }
38942
+ .qb-actions { display:flex; align-items:center; gap:2px; margin-left:auto; -webkit-app-region:no-drag; }
38943
+ .qb-actions .iconbtn { width:26px; height:26px; }
38944
+ .qb-actions .iconbtn.active { color:var(--accent); background:var(--hover-2); }
38945
+ /* Live-feed dot: green + breathing halo while the SSE stream is up, muted
38946
+ and still while reconnecting \u2014 the one honest signal that AI edits will
38947
+ appear by themselves. */
38948
+ .qb-live { width:6px; height:6px; border-radius:50%; margin:0 8px 0 4px; flex:none;
38949
+ background:var(--muted); }
38950
+ .qb-live.on { background:var(--success); animation:qb-breathe 2s ease-out infinite; }
38951
+ @keyframes qb-breathe {
38952
+ 0% { box-shadow:0 0 0 0 color-mix(in srgb, var(--success) 40%, transparent); }
38953
+ 70% { box-shadow:0 0 0 5px transparent; }
38954
+ 100% { box-shadow:0 0 0 0 transparent; }
38955
+ }
38956
+ .qb-body { flex:1; min-height:0; overflow:auto; scrollbar-width:thin;
38957
+ -webkit-app-region:no-drag; padding:0 10px; }
38958
+ /* Product-grade empty state (no databases yet / booting). */
38959
+ .qb-empty { display:flex; flex-direction:column; align-items:center; justify-content:center;
38960
+ height:100%; gap:4px; text-align:center; padding:0 32px; }
38961
+ .qb-empty > svg { width:32px; height:32px; stroke-width:1.25; color:var(--muted); opacity:.55; margin-bottom:6px; }
38962
+ .qb-empty-title { font-size:14px; font-weight:600; color:var(--fg-soft); }
38963
+ .qb-empty-sub { font-size:var(--fs-sm); color:var(--muted); line-height:1.6; max-width:280px; }
38964
+ body.quickboard .view-placeholder { display:flex; align-items:center; justify-content:center;
38965
+ height:70%; text-align:center; color:var(--muted); border:0; background:none; }
38966
+ /* Board at widget density: borderless columns washed with 6% of their
38967
+ option color (--col-tint, set inline by board.tsx), stretched to the
38968
+ window rather than the main app's topbar-based calc; vibrancy reads
38969
+ through the gutters between the washes. */
38970
+ body.quickboard .board-wrap { margin-top:0; }
38971
+ body.quickboard .board-bar { padding:6px 0 8px; }
38972
+ body.quickboard .board { min-height:0; padding-bottom:10px; gap:10px; }
38973
+ body.quickboard .board-col { flex:0 0 232px; width:232px;
38974
+ max-height:calc(100vh - 112px); max-height:calc(100dvh - 112px);
38975
+ border:0; border-radius:var(--radius-lg);
38976
+ background:color-mix(in srgb, var(--col-tint) 6%, transparent); }
38977
+ body.quickboard .board-count { color:var(--col-tint); }
38978
+ /* Cards: a lighter pane of the same glass (not opaque white \u2014 the column
38979
+ wash and vibrancy read through), a 3px option-color edge, gentle hover
38980
+ lift that also firms the pane up for reading. */
38981
+ body.quickboard .kcard { background:color-mix(in srgb, var(--bg) 52%, transparent);
38982
+ border-color:color-mix(in srgb, var(--line) 55%, transparent);
38983
+ border-left:3px solid var(--col-tint);
38984
+ padding-left:9px; transition:border-color .1s, box-shadow .12s, transform .12s, background .12s; }
38985
+ body.quickboard .kcard:hover { transform:translateY(-1px); box-shadow:var(--shadow-md);
38986
+ background:color-mix(in srgb, var(--bg) 78%, transparent); }
38987
+ body.quickboard .kcard-title { font-size:var(--fs-sm); }
38988
+ body.quickboard .kcard-field { font-size:var(--fs-xs); }
38989
+ /* The drag ghost is cloned onto <body> \u2014 outside any column, so --col-tint
38990
+ is gone and a see-through pane over arbitrary content reads badly. Firm
38991
+ it up and drop the edge tint while in flight. */
38992
+ body.quickboard .kcard.dragging-ghost { background:color-mix(in srgb, var(--bg) 88%, transparent);
38993
+ border-left-color:var(--line-strong); }
38994
+ /* One-shot pulse on cards a live-feed poke just changed ("AI moved this"). */
38995
+ body.quickboard .kcard.flash { animation:qb-card-flash 1.2s ease-out; }
38996
+ @keyframes qb-card-flash {
38997
+ 0% { background:var(--accent-soft); box-shadow:0 0 0 1.5px var(--accent); }
38998
+ 100% { background:color-mix(in srgb, var(--bg) 52%, transparent); box-shadow:var(--shadow-sm); }
38999
+ }
39000
+ /* The record peek drawer shares its width preference with the main app
39001
+ (mh.peekW) \u2014 cap it so it never swallows the whole small window. */
39002
+ body.quickboard .peek { max-width:92vw; }
39003
+
39004
+ /* Quick-window shortcut capture (desktop only; shared by note + board). */
38587
39005
  .qn-shortcut { min-width:140px; justify-content:center; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif; }
38588
39006
  .qn-shortcut.capturing { outline:2px solid var(--accent); color:var(--accent); }
38589
39007
  .qn-keys { display:inline-flex; align-items:center; gap:6px; }
38590
39008
  .qn-key { line-height:1; }
38591
39009
  .qn-key.sym { font-size:1.15em; line-height:1; } /* \u2318 \u21E7 glyphs render smaller \u2014 bump to match letters */
38592
39010
 
39011
+ /* File-editor window (desktop, loaded at #file?path=\u2026 \u2014 the .txt/.md "open
39012
+ with" surface). Same shell idiom as quicknote: top bar = drag region with
39013
+ opted-out buttons, single full-bleed column, popups clamped below the bar. */
39014
+ body.file-window { --pop-top-inset:46px; }
39015
+ body.file-window #app { display:block; width:100vw; height:100vh; height:100dvh; }
39016
+ .fw { display:flex; flex-direction:column; width:100%; height:100vh; height:100dvh; overflow:hidden; background:var(--bg); }
39017
+ .fw-bar { display:flex; align-items:center; gap:8px; padding:7px 12px;
39018
+ user-select:none; -webkit-app-region:drag;
39019
+ background:var(--surface); border-bottom:1px solid var(--line); }
39020
+ /* macOS only: clear the inset traffic lights (frame is native elsewhere). */
39021
+ body.desktop-mac .fw-bar { padding-left:84px; }
39022
+ .fw-name { flex:1; min-width:0; font-size:13px; font-weight:600; color:var(--fg-soft);
39023
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
39024
+ .fw-dirty { color:var(--accent); font-size:15px; }
39025
+ .fw-actions { display:flex; align-items:center; gap:6px; -webkit-app-region:no-drag; }
39026
+ .fw-actions .btn { padding:4px 10px; font-size:12px; }
39027
+ .fw-body { flex:1; overflow:auto; scrollbar-gutter:stable; scrollbar-width:thin; -webkit-app-region:no-drag; }
39028
+ /* Bar is ~45px, not the main ~50px topbar the find bar assumes. */
39029
+ body.file-window .find-bar { top:52px; }
39030
+
38593
39031
  /* No-origin bootstrap: enroll screen + hydration splash (data-blind shell). */
38594
39032
  .enroll-splash { min-height:100dvh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; padding:24px; }
38595
39033
  .enroll-spinner { width:26px; height:26px; border-radius:50%; border:2.5px solid var(--line-strong); border-top-color:var(--accent); animation:enroll-spin .8s linear infinite; }
@@ -38908,7 +39346,11 @@ var injected2 = {
38908
39346
  sdk: null
38909
39347
  };
38910
39348
  var injectedWasm = null;
39349
+ var injectedWasmLoader = null;
38911
39350
  var injectedFmtWasm = {};
39351
+ function toArrayBuffer(w4) {
39352
+ return w4.byteOffset === 0 && w4.byteLength === w4.buffer.byteLength ? w4.buffer : w4.slice().buffer;
39353
+ }
38912
39354
  function newestSourceMtime(dir) {
38913
39355
  let newest = 0;
38914
39356
  for (const e3 of readdirSync4(dir, { withFileTypes: true })) {
@@ -38925,6 +39367,7 @@ function newestSourceMtime(dir) {
38925
39367
  function bundleGetter(opts) {
38926
39368
  let cached2 = null;
38927
39369
  let cachedMtime = 0;
39370
+ let building = null;
38928
39371
  return async () => {
38929
39372
  const fromBinary = injected2[opts.key];
38930
39373
  if (fromBinary != null)
@@ -38935,15 +39378,24 @@ function bundleGetter(opts) {
38935
39378
  for (const extra of opts.extraDirs ?? []) {
38936
39379
  newest = Math.max(newest, newestSourceMtime(fileURLToPath2(new URL(extra, import.meta.url))));
38937
39380
  }
38938
- if (cached2 == null || newest > cachedMtime) {
38939
- const entry = fileURLToPath2(new URL(opts.entry, import.meta.url));
38940
- const res = await Bun.build({ entrypoints: [entry], target: "browser" });
38941
- if (!res.success)
38942
- throw new AggregateError(res.logs, `${opts.dist} build failed`);
38943
- cached2 = await res.outputs[0].text();
38944
- cachedMtime = newest;
39381
+ if (cached2 != null && newest <= cachedMtime)
39382
+ return cached2;
39383
+ if (!building) {
39384
+ building = (async () => {
39385
+ const t2 = Date.now();
39386
+ const entry = fileURLToPath2(new URL(opts.entry, import.meta.url));
39387
+ const res = await Bun.build({ entrypoints: [entry], target: "browser" });
39388
+ if (!res.success)
39389
+ throw new AggregateError(res.logs, `${opts.dist} build failed`);
39390
+ cached2 = await res.outputs[0].text();
39391
+ cachedMtime = newest;
39392
+ console.log(`[perf] ${opts.dist} dev build ${Date.now() - t2}ms`);
39393
+ return cached2;
39394
+ })().finally(() => {
39395
+ building = null;
39396
+ });
38945
39397
  }
38946
- return cached2;
39398
+ return building;
38947
39399
  }
38948
39400
  if (cached2 == null) {
38949
39401
  const prebuilt = Bun.file(fileURLToPath2(new URL(`./${opts.dist}`, import.meta.url)));
@@ -38995,6 +39447,10 @@ async function getSw() {
38995
39447
  async function getWasm() {
38996
39448
  if (injectedWasm != null)
38997
39449
  return injectedWasm;
39450
+ if (injectedWasmLoader != null) {
39451
+ injectedWasm = toArrayBuffer(await injectedWasmLoader());
39452
+ return injectedWasm;
39453
+ }
38998
39454
  const path = RUNNING_FROM_SOURCE2 ? join11(dirname2(Bun.resolveSync("@sqlite.org/sqlite-wasm", fileURLToPath2(new URL(".", import.meta.url)))), "sqlite3.wasm") : fileURLToPath2(new URL("./sqlite3.wasm", import.meta.url));
38999
39455
  const f4 = Bun.file(path);
39000
39456
  if (!await f4.exists()) {
@@ -39025,21 +39481,34 @@ async function warmWebui() {
39025
39481
  await getJs();
39026
39482
  } catch {}
39027
39483
  }
39028
- function asset(body, contentType) {
39029
- return new Response(body, {
39030
- headers: { "content-type": contentType, "cache-control": "no-store" }
39031
- });
39484
+ var etagCache = new Map;
39485
+ function etagFor(body) {
39486
+ let tag = etagCache.get(body);
39487
+ if (!tag) {
39488
+ if (etagCache.size > 64)
39489
+ etagCache.clear();
39490
+ tag = `"${new Bun.CryptoHasher("sha256").update(body).digest("hex").slice(0, 16)}"`;
39491
+ etagCache.set(body, tag);
39492
+ }
39493
+ return tag;
39494
+ }
39495
+ function asset(req, body, contentType) {
39496
+ const tag = etagFor(body);
39497
+ const headers = { "content-type": contentType, "cache-control": "no-cache", etag: tag };
39498
+ if (req.headers.get("if-none-match") === tag)
39499
+ return new Response(null, { status: 304, headers });
39500
+ return new Response(body, { headers });
39032
39501
  }
39033
39502
  async function serveWebui(req) {
39034
39503
  if (req.method !== "GET")
39035
39504
  return null;
39036
39505
  const { pathname } = new URL(req.url);
39037
39506
  if (pathname === "/")
39038
- return asset(HTML2, "text/html; charset=utf-8");
39507
+ return asset(req, HTML2, "text/html; charset=utf-8");
39039
39508
  if (pathname === "/webui.css")
39040
- return asset(await getCss(), "text/css; charset=utf-8");
39509
+ return asset(req, await getCss(), "text/css; charset=utf-8");
39041
39510
  if (pathname === "/manifest.webmanifest")
39042
- return asset(MANIFEST, "application/manifest+json");
39511
+ return asset(req, MANIFEST, "application/manifest+json");
39043
39512
  const icon = ICONS[pathname];
39044
39513
  if (icon) {
39045
39514
  return new Response(Buffer.from(icon, "base64"), {
@@ -39078,7 +39547,7 @@ async function serveWebui(req) {
39078
39547
  const getter = script[pathname];
39079
39548
  if (getter) {
39080
39549
  try {
39081
- return asset(await getter(), "text/javascript; charset=utf-8");
39550
+ return asset(req, await getter(), "text/javascript; charset=utf-8");
39082
39551
  } catch (e3) {
39083
39552
  console.error(`[webui] failed to serve ${pathname} \u2014`, e3);
39084
39553
  return new Response(`webui build failed: ${e3}`, { status: 500 });
@@ -39357,6 +39826,132 @@ function isPeer(db, url2) {
39357
39826
  return listShareServers(db).some((s2) => s2.url === url2);
39358
39827
  }
39359
39828
 
39829
+ // src/webui/server/changes-route.ts
39830
+ init_zod();
39831
+ init_crdt();
39832
+ var POLL_MS = 1000;
39833
+ var HEARTBEAT_MS = 8000;
39834
+ var BATCH_LIMIT = 1000;
39835
+ var ROW_IDS_CAP = 500;
39836
+ function collectSince(db, since) {
39837
+ const datasets = new Set;
39838
+ const rowIds = new Set;
39839
+ let truncated = false;
39840
+ let cursor = since;
39841
+ for (;; ) {
39842
+ const batch = changesAfterSeq(db, cursor, { limit: BATCH_LIMIT });
39843
+ for (const c3 of batch.changes) {
39844
+ datasets.add(c3.dataset);
39845
+ if (rowIds.size < ROW_IDS_CAP)
39846
+ rowIds.add(c3.row_id);
39847
+ else
39848
+ truncated = true;
39849
+ }
39850
+ cursor = batch.cursor;
39851
+ if (batch.changes.length < BATCH_LIMIT)
39852
+ break;
39853
+ }
39854
+ return { datasets: [...datasets], rowIds: [...rowIds], cursor, truncated };
39855
+ }
39856
+ function highWater(db) {
39857
+ const top = db.query("SELECT MAX(seq) AS m FROM crdt_changes").get();
39858
+ return top.m ?? 0;
39859
+ }
39860
+ var sse = (event, data) => `event: ${event}
39861
+ data: ${JSON.stringify(data)}
39862
+
39863
+ `;
39864
+ var pollers = new WeakMap;
39865
+ function tick(db, poller) {
39866
+ if (highWater(db) <= poller.cursor)
39867
+ return;
39868
+ const payload = collectSince(db, poller.cursor);
39869
+ poller.cursor = payload.cursor;
39870
+ if (!payload.datasets.length)
39871
+ return;
39872
+ const text = sse("changes", payload);
39873
+ for (const send of [...poller.subs])
39874
+ send(text);
39875
+ }
39876
+ function attach(db, send) {
39877
+ let poller = pollers.get(db);
39878
+ if (!poller) {
39879
+ poller = {
39880
+ subs: new Set,
39881
+ cursor: highWater(db),
39882
+ timer: setInterval(() => tick(db, poller), POLL_MS),
39883
+ hb: setInterval(() => {
39884
+ for (const s2 of [...poller.subs])
39885
+ s2(`: hb
39886
+
39887
+ `);
39888
+ }, HEARTBEAT_MS)
39889
+ };
39890
+ pollers.set(db, poller);
39891
+ }
39892
+ poller.subs.add(send);
39893
+ }
39894
+ function detach(db, send) {
39895
+ const poller = pollers.get(db);
39896
+ if (!poller || !poller.subs.delete(send))
39897
+ return;
39898
+ if (poller.subs.size === 0) {
39899
+ clearInterval(poller.timer);
39900
+ clearInterval(poller.hb);
39901
+ pollers.delete(db);
39902
+ }
39903
+ }
39904
+ var changesRoutes = [
39905
+ {
39906
+ method: "GET",
39907
+ path: "/api/changes",
39908
+ summary: "Server-sent event stream of oplog change pokes ({datasets, rowIds, cursor}). " + "Reconnect with ?since=<cursor> to catch up on changes missed while disconnected.",
39909
+ response: exports_external.any().describe("text/event-stream \u2014 `hello` {cursor} on connect, then `changes` {datasets, rowIds, cursor, truncated}"),
39910
+ handler(req, { db }) {
39911
+ const sinceRaw = new URL(req.url).searchParams.get("since");
39912
+ const since = sinceRaw != null && /^\d+$/.test(sinceRaw) ? Number(sinceRaw) : null;
39913
+ const enc = new TextEncoder;
39914
+ let send = () => {};
39915
+ let closed = false;
39916
+ const close = () => {
39917
+ if (closed)
39918
+ return;
39919
+ closed = true;
39920
+ detach(db, send);
39921
+ };
39922
+ const stream = new ReadableStream({
39923
+ start: (controller) => {
39924
+ send = (text) => {
39925
+ if (closed)
39926
+ return;
39927
+ try {
39928
+ controller.enqueue(enc.encode(text));
39929
+ } catch {
39930
+ close();
39931
+ }
39932
+ };
39933
+ attach(db, send);
39934
+ send(sse("hello", { cursor: since ?? highWater(db) }));
39935
+ if (since != null && since < highWater(db)) {
39936
+ const payload = collectSince(db, since);
39937
+ if (payload.datasets.length)
39938
+ send(sse("changes", payload));
39939
+ }
39940
+ },
39941
+ cancel: () => close()
39942
+ });
39943
+ req.signal.addEventListener("abort", close);
39944
+ return new Response(stream, {
39945
+ headers: {
39946
+ "content-type": "text/event-stream; charset=utf-8",
39947
+ "cache-control": "no-store",
39948
+ "x-accel-buffering": "no"
39949
+ }
39950
+ });
39951
+ }
39952
+ }
39953
+ ];
39954
+
39360
39955
  // src/webui/server/site-hosting-routes.ts
39361
39956
  init_zod();
39362
39957
  init_errors();
@@ -40168,10 +40763,56 @@ var RevisionBase = exports_external.object({
40168
40763
  at: exports_external.string().describe("Wall-clock time of the revision (ISO 8601)"),
40169
40764
  node_id: exports_external.string(),
40170
40765
  kind: exports_external.enum(["user", "repair", "revert"]).describe("Source of the revision"),
40766
+ actor: exports_external.string().nullable().describe('Actor tag from the change group ("ai" = agent-driven CLI write)'),
40171
40767
  changes: exports_external.number(),
40172
40768
  created: exports_external.boolean(),
40173
40769
  deleted: exports_external.boolean()
40174
40770
  });
40771
+ var AuditEntitySchema = exports_external.object({
40772
+ dataset: exports_external.string(),
40773
+ id: exports_external.string(),
40774
+ label: exports_external.string().nullable(),
40775
+ database_id: exports_external.string().nullable(),
40776
+ database_label: exports_external.string().nullable(),
40777
+ created: exports_external.boolean(),
40778
+ deleted: exports_external.boolean(),
40779
+ fields: exports_external.number(),
40780
+ blocks_changed: exports_external.number(),
40781
+ blocks_deleted: exports_external.number()
40782
+ });
40783
+ var AuditEntryBase = exports_external.object({
40784
+ version: exports_external.string(),
40785
+ at: exports_external.string(),
40786
+ node_id: exports_external.string(),
40787
+ kind: exports_external.enum(["user", "repair", "revert"]),
40788
+ actor: exports_external.string().nullable(),
40789
+ txn: exports_external.string().nullable().describe("Change-group id; null for legacy display-only entries"),
40790
+ changes: exports_external.number()
40791
+ });
40792
+ var AuditPageSchema = exports_external.object({
40793
+ entries: exports_external.array(AuditEntryBase.extend({ entities: exports_external.array(AuditEntitySchema) })),
40794
+ next: exports_external.string().nullable().describe("Pass as `before` for the next (older) page")
40795
+ });
40796
+ var AuditDiffSchema = exports_external.object({
40797
+ col: exports_external.string(),
40798
+ label: exports_external.string(),
40799
+ before: exports_external.any().optional(),
40800
+ after: exports_external.any().optional()
40801
+ });
40802
+ var AuditEntryDetailSchema = AuditEntryBase.extend({
40803
+ entities: exports_external.array(AuditEntitySchema.extend({
40804
+ diffs: exports_external.array(AuditDiffSchema),
40805
+ block_diffs: exports_external.array(AuditDiffSchema)
40806
+ }))
40807
+ });
40808
+ var RevertGroupResultSchema = exports_external.object({
40809
+ txn: exports_external.string(),
40810
+ changed: exports_external.boolean(),
40811
+ restored_registers: exports_external.number(),
40812
+ skipped_registers: exports_external.number(),
40813
+ removed_rows: exports_external.number(),
40814
+ skipped_rows: exports_external.number()
40815
+ });
40175
40816
  var DocRevisionSchema = RevisionBase.extend({
40176
40817
  title_changed: exports_external.boolean(),
40177
40818
  blocks_changed: exports_external.number(),
@@ -40436,6 +41077,34 @@ var webuiRoutes = [
40436
41077
  });
40437
41078
  })
40438
41079
  },
41080
+ {
41081
+ method: "GET",
41082
+ path: "/api/audit",
41083
+ summary: "The global audit feed: every change group across the whole hub, newest first. " + "Query: ?limit=<n>&before=<cursor>&actor=<tag>",
41084
+ response: AuditPageSchema,
41085
+ handler: handle3((req, { db }) => {
41086
+ const limit = opt(req, "limit");
41087
+ return listAuditEntries(db, {
41088
+ limit: limit ? Number(limit) : undefined,
41089
+ before: opt(req, "before") || undefined,
41090
+ actor: opt(req, "actor") || undefined
41091
+ });
41092
+ })
41093
+ },
41094
+ {
41095
+ method: "GET",
41096
+ path: "/api/audit/entry",
41097
+ summary: "Expand one audit entry with per-register before/after diffs. Query: ?txn=<id>",
41098
+ response: AuditEntryDetailSchema,
41099
+ handler: handle3((req, { db }) => auditEntryDetail(db, need3(req, "txn")))
41100
+ },
41101
+ {
41102
+ method: "POST",
41103
+ path: "/api/audit/revert",
41104
+ summary: "Undo one change group as a new forward revision; registers overwritten since are kept. Query: ?txn=<id>",
41105
+ response: RevertGroupResultSchema,
41106
+ handler: handle3((req, { db }) => revertChangeGroup(db, need3(req, "txn")))
41107
+ },
40439
41108
  {
40440
41109
  method: "GET",
40441
41110
  path: "/api/properties",
@@ -40836,7 +41505,8 @@ var webuiRoutes = [
40836
41505
  },
40837
41506
  ...shareRoutes,
40838
41507
  ...siteHostingRoutes,
40839
- ...edgeRoutes
41508
+ ...edgeRoutes,
41509
+ ...changesRoutes
40840
41510
  ];
40841
41511
 
40842
41512
  // src/cli/banner.ts
@@ -41019,8 +41689,8 @@ function formatUrl(ip, family, port, scheme = "http") {
41019
41689
  function localAddresses(ifaces = os.networkInterfaces()) {
41020
41690
  const groups = Array.isArray(ifaces) ? { _: ifaces } : ifaces;
41021
41691
  const out = [];
41022
- for (const list7 of Object.values(groups)) {
41023
- for (const info of list7 ?? []) {
41692
+ for (const list8 of Object.values(groups)) {
41693
+ for (const info of list8 ?? []) {
41024
41694
  if (info.internal)
41025
41695
  continue;
41026
41696
  const family = normFamily(info.family);
@@ -41372,7 +42042,8 @@ var main = defineCommand({
41372
42042
  cache: cache_default,
41373
42043
  blob: blob_default,
41374
42044
  config: config_default,
41375
- edge: edge_default
42045
+ edge: edge_default,
42046
+ audit: audit_default
41376
42047
  }
41377
42048
  });
41378
42049
  function flagValue(argv2, name) {
@@ -41449,7 +42120,14 @@ if (scopedConfigHelp) {
41449
42120
  syncIntervalMs: s2.syncIntervalMs
41450
42121
  }));
41451
42122
  } else {
42123
+ const actorEnv = process.env.MH_ACTOR;
42124
+ const actor = actorEnv !== undefined ? actorEnv === "" || actorEnv === "human" ? null : actorEnv : process.stdout.isTTY ? null : "ai";
42125
+ try {
42126
+ setActorTag(actor);
42127
+ } catch {
42128
+ fail(`invalid MH_ACTOR value: ${actor}`, "invalid_input");
42129
+ }
41452
42130
  runMain(main, { showUsage: showUsage2 });
41453
42131
  }
41454
42132
 
41455
- //# debugId=0FE630E325CE9F8064756E2164756E21
42133
+ //# debugId=9B73C997087B5E2D64756E2164756E21